From b542189ab68ec97bdf6ae38615e6949ba9c3eaac Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Mon, 19 Mar 2012 14:09:26 +0800 Subject: [PATCH] Remove all remaining uses of Function_mode, checking for the existence of EditorWindow where necessary instead --- CHANGELOG.txt | 1 + editor/med.c | 9 ++++----- main/endlevel.c | 6 +++++- main/gamecntl.c | 3 --- main/gamesave.c | 6 +++--- main/inferno.c | 1 - main/inferno.h | 11 +---------- main/menu.c | 2 -- main/powerup.c | 2 +- main/render.c | 6 +++--- main/slew.c | 6 +++++- 11 files changed, 23 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 34ded7d3a..0e4864e10 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D2X-Rebirth Changelog 20120319 -------- editor/med.c, include/editor/editor.h, include/ui.h, main/gamecntl.c, main/gameseq.c, main/inferno.c, main/menu.c: The editor now falls back to the main event loop in inferno.c, File->Exit now works as intended and get closer to making the editor and game work together +editor/med.c, main/endlevel.c, main/gamecntl.c, main/gamesave.c, main/inferno.c, main/inferno.h, main/menu.c, main/powerup.c, main/render.c, main/slew.c: Remove all remaining uses of Function_mode, checking for the existence of EditorWindow where necessary instead 20120318 -------- diff --git a/editor/med.c b/editor/med.c index 2f5e1eb88..0f4d3c592 100644 --- a/editor/med.c +++ b/editor/med.c @@ -107,7 +107,7 @@ vms_vector Ed_view_target={0,0,0}; int gamestate_not_restored = 0; -UI_DIALOG * EditorWindow; +UI_DIALOG * EditorWindow = NULL; int Large_view_index = -1; @@ -417,8 +417,8 @@ void init_editor() restore_effect_bitmap_icons(); if (!set_screen_mode(SCREEN_EDITOR)) { - set_screen_mode(SCREEN_GAME); - Function_mode=FMODE_GAME; //force back into game + set_screen_mode(SCREEN_MENU); + show_menus(); //force back into menu return; } @@ -921,6 +921,7 @@ void close_editor_screen() window_close(Pad_info); ui_close_dialog(EditorWindow); + EditorWindow = NULL; close_all_windows(); @@ -1000,13 +1001,11 @@ void close_editor() { case 2: if (Game_wind) window_close(Game_wind); - Function_mode = FMODE_MENU; set_screen_mode(SCREEN_MENU); //put up menu screen show_menus(); break; case 3: - Function_mode=FMODE_GAME; //force back into game set_screen_mode(SCREEN_GAME); //put up game screen Game_mode = GM_EDITOR; editor_reset_stuff_on_level(); diff --git a/main/endlevel.c b/main/endlevel.c index fd09e537f..bd100d0e7 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -66,6 +66,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "ogl_init.h" #endif +#ifdef EDITOR +#include "editor/editor.h" +#endif + typedef struct flythrough_data { object *obj; vms_angvec angles; //orientation in angles @@ -1120,7 +1124,7 @@ void endlevel_render_mine(fix eye_offset) vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.rvec,eye_offset); #ifdef EDITOR - if (Function_mode==FMODE_EDITOR) + if (EditorWindow) Viewer_eye = Viewer->pos; #endif diff --git a/main/gamecntl.c b/main/gamecntl.c index 0601fc9a3..206133ef7 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -417,7 +417,6 @@ int pause_handler(window *wind, d_event *event, char *msg) case 0: break; case KEY_ESC: - //Function_mode = FMODE_MENU; // Don't like this, just press escape twice (kreatordxx) window_close(wind); return 1; case KEY_F1: @@ -1451,8 +1450,6 @@ int HandleTestKey(int key) #ifdef NETWORK multi_leave_game(); #endif - Function_mode = FMODE_EDITOR; - init_editor(); break; case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED: diff --git a/main/gamesave.c b/main/gamesave.c index 558590bf3..6ee251a3c 100644 --- a/main/gamesave.c +++ b/main/gamesave.c @@ -1389,7 +1389,7 @@ int load_level(char * filename_passed) #ifdef EDITOR //If a Descent 1 level and the Descent 1 pig isn't present, pretend it's a Descent 2 level. - if ((Function_mode == FMODE_EDITOR) && (Gamesave_current_version <= 3) && !d1_pig_present) + if (EditorWindow && (Gamesave_current_version <= 3) && !d1_pig_present) { if (!no_old_level_file_error) Warning("A Descent 1 level was loaded,\n" @@ -1402,7 +1402,7 @@ int load_level(char * filename_passed) #endif #ifdef EDITOR - if (Function_mode == FMODE_EDITOR) + if (EditorWindow) editor_status("Loaded NEW mine %s, \"%s\"",filename,Current_level_name); #endif @@ -1722,7 +1722,7 @@ int save_level_sub(char * filename, int compiled_version) // if ( !compiled_version ) { - if (Function_mode == FMODE_EDITOR) + if (EditorWindow) editor_status("Saved mine %s, \"%s\"",filename,Current_level_name); } diff --git a/main/inferno.c b/main/inferno.c index c85db67f3..c0a513c71 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -102,7 +102,6 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR //Current version number char desc_id_exit_num = 0; -int Function_mode=FMODE_MENU; //game or editor? int Screen_mode=-1; //game screen or editor screen? int descent_critical_error = 0; unsigned int descent_critical_deverror = 0; diff --git a/main/inferno.h b/main/inferno.h index 19c58e713..dffe0af82 100644 --- a/main/inferno.h +++ b/main/inferno.h @@ -44,31 +44,22 @@ struct d_event; #define KEY_MAC(x) #endif - /** ** Constants **/ -// How close two points must be in all dimensions to be considered the -// same point. +// How close two points must be in all dimensions to be considered the same point. #define FIX_EPSILON 10 // the maximum length of a filename #define FILENAME_LEN 13 -//for Function_mode variable -#define FMODE_EXIT 0 // leaving the program -#define FMODE_MENU 1 // Using the menu -#define FMODE_GAME 2 // running the game -#define FMODE_EDITOR 3 // running the editor - /** ** Global variables **/ extern jmp_buf LeaveEvents; extern int Quitting; -extern int Function_mode; // in game or editor? extern int Screen_mode; // editor screen or game screen? // Default event handler for everything except the editor diff --git a/main/menu.c b/main/menu.c index 0890b41fb..c683c478d 100644 --- a/main/menu.c +++ b/main/menu.c @@ -575,8 +575,6 @@ int do_option ( int select) break; #ifdef EDITOR case MENU_EDITOR: - Function_mode = FMODE_EDITOR; - create_new_mine(); SetPlayerFromCurseg(); load_palette(NULL,1,0); diff --git a/main/powerup.c b/main/powerup.c index 9c374c2e7..0a1b634fa 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -121,7 +121,7 @@ void draw_powerup(object *obj) draw_object_blob(obj, Vclip[obj->rtype.vclip_info.vclip_num].frames[obj->rtype.vclip_info.framenum] ); #ifdef EDITOR - if ((Function_mode == FMODE_EDITOR) && (Cur_object_index == obj-Objects)) + if (EditorWindow && (Cur_object_index == obj-Objects)) if (blob_vertices[0] != 0x80000) draw_blob_outline(); #endif diff --git a/main/render.c b/main/render.c index aa358323e..d09700fad 100644 --- a/main/render.c +++ b/main/render.c @@ -643,7 +643,7 @@ void do_render_object(int objnum, int window_num) //check for editor object #ifdef EDITOR - if (Function_mode==FMODE_EDITOR && objnum==Cur_object_index) { + if (EditorWindow && objnum==Cur_object_index) { save_3d_outline = g3d_interp_outline; g3d_interp_outline=1; } @@ -668,7 +668,7 @@ void do_render_object(int objnum, int window_num) #ifdef EDITOR - if (Function_mode==FMODE_EDITOR && objnum==Cur_object_index) + if (EditorWindow && objnum==Cur_object_index) g3d_interp_outline = save_3d_outline; #endif @@ -1619,7 +1619,7 @@ void render_frame(fix eye_offset, int window_num) } #ifdef EDITOR - if (Function_mode==FMODE_EDITOR) + if (EditorWindow) Viewer_eye = Viewer->pos; #endif diff --git a/main/slew.c b/main/slew.c index 5bce01e21..2088117e1 100644 --- a/main/slew.c +++ b/main/slew.c @@ -19,6 +19,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ +#ifdef EDITOR +#include "editor/editor.h" +#endif + #ifdef RCS static char rcsid[] = "$Id: slew.c,v 1.1.1.1 2006/03/17 19:56:35 zicodxx Exp $"; #endif @@ -92,7 +96,7 @@ int do_slew_movement(object *obj, int check_keys ) if (!slew_obj || slew_obj->control_type!=CT_SLEW) return 0; if (check_keys) { - if (Function_mode == FMODE_EDITOR) { + if (EditorWindow) { obj->mtype.phys_info.velocity.x += VEL_SPEED * keyd_pressed[KEY_PAD9] * FrameTime; obj->mtype.phys_info.velocity.x -= VEL_SPEED * keyd_pressed[KEY_PAD7] * FrameTime; obj->mtype.phys_info.velocity.y += VEL_SPEED * keyd_pressed[KEY_PADMINUS] * FrameTime;