From fa76bc657e5c28722586bbf973ad803f5843d23b Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Mon, 16 Apr 2012 16:53:32 +0800 Subject: [PATCH] Make a new mission when making a new mine to avoid a crash when testing it straight from the editor and winning, only create a new mine if a mission isn't loaded, if it thinks it needs to use Cursegp to fix the player object make sure Cursegp is initialised, remove key command for ToggleDrawAllSegments since add segment now has ctrl-A --- CHANGELOG.txt | 1 + editor/eglobal.c | 4 ++-- editor/med.c | 2 +- main/game.c | 6 ++++++ main/gamesave.c | 2 ++ main/menu.c | 14 ++++++++++---- main/mission.c | 18 ++++++++++++++++++ main/mission.h | 4 ++++ 8 files changed, 44 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2162fffdc..c6da187cc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ D1X-Rebirth Changelog main/gameseq.c, main/multi.c, main/multi.h: fixed two bugs caused by recent Multiplayer cleanup: Set more player-death-related veriables outside of dead_player_end() when creating new ship as not covered in subfunction is Palyer_is_dead is not true; also init my own inventory properly in multi_prep_level to get our inventory straight after receiving netgame information editor/data/med.mnu, editor/med.c, editor/medmisc.c, main/slew.c, ui/ui.c: Make movement in the editor's game screen use the player controls, make that movement more like the automap and resolve some likely conflicting key commands editor/centers.c, editor/eswitch.c, editor/med.c, editor/medrobot.c, editor/medwall.c, main/game.c, main/gameseq.c: Avoid crashes when clicking on close box with a center, switch, object or wall editing dialog open; also when playing a level, going to the editor, going back to the game then dying +editor/eglobal.c, editor/med.c, main/game.c, main/gamesave.c, main/menu.c, main/mission.c, main/mission.h: Make a new mission when making a new mine to avoid a crash when testing it straight from the editor and winning, only create a new mine if a mission isn't loaded, if it thinks it needs to use Cursegp to fix the player object make sure Cursegp is initialised, remove key command for ToggleDrawAllSegments since add segment now has ctrl-A 20120415 -------- diff --git a/editor/eglobal.c b/editor/eglobal.c index ccb9c27f4..613ffa6eb 100644 --- a/editor/eglobal.c +++ b/editor/eglobal.c @@ -29,12 +29,12 @@ static char rcsid[] = "$Id: eglobal.c,v 1.1.1.1 2006/03/17 19:45:24 zicodxx Exp // Global pointer to current vertices, right now always Vertices. Set in create_new_mine. segment New_segment; // The segment which can be added to the mine. -segment *Cursegp; // Pointer to current segment in mine. +segment *Cursegp = NULL; // Pointer to current segment in mine. int Curside; // Side index in 0..MAX_SIDES_PER_SEGMENT of active side. int Curedge; // Current edge on current side, in 0..3 int Curvert; // Current vertex on current side, in 0..3 int AttachSide = WFRONT; // Side on segment to attach. -segment *Markedsegp; // Marked segment, used in conjunction with *Cursegp to form joints. +segment *Markedsegp = NULL; // Marked segment, used in conjunction with *Cursegp to form joints. int Markedside; // Marked side on Markedsegp. int Draw_all_segments; // Set to 1 means draw_world draws all segments in Segments, else draw only connected segments diff --git a/editor/med.c b/editor/med.c index baf7cd952..849cfc3bd 100644 --- a/editor/med.c +++ b/editor/med.c @@ -843,7 +843,7 @@ void init_editor_screen() // ui_gadget_calc_keys(EditorWindow); //make tab work for all windows ViewIcon = ui_add_gadget_icon( EditorWindow, "Lock\nview", 455,25+530, 40, 22, KEY_V+KEY_CTRLED, ToggleLockViewToCursegp ); - AllIcon = ui_add_gadget_icon( EditorWindow, "Draw\nall", 500,25+530, 40, 22, KEY_A+KEY_CTRLED, ToggleDrawAllSegments ); + AllIcon = ui_add_gadget_icon( EditorWindow, "Draw\nall", 500,25+530, 40, 22, -1, ToggleDrawAllSegments ); AxesIcon = ui_add_gadget_icon( EditorWindow, "Coord\naxes",545,25+530, 40, 22, KEY_D+KEY_CTRLED, ToggleCoordAxes ); //-NOLIGHTICON- LightIcon = ui_add_gadget_icon( EditorWindow, "Light\ning", 590,25+530, 40, 22, KEY_L+KEY_SHIFTED,ToggleLighting ); ChaseIcon = ui_add_gadget_icon( EditorWindow, "Chase\nmode",635,25+530, 40, 22, -1, ToggleChaseMode ); diff --git a/main/game.c b/main/game.c index 2a958e656..3a0cbb38e 100644 --- a/main/game.c +++ b/main/game.c @@ -938,6 +938,12 @@ window *game_setup(void) netplayerinfo_on = 0; #ifdef EDITOR + if (!Cursegp) + { + Cursegp = &Segments[0]; + Curside = 0; + } + if (Segments[ConsoleObject->segnum].segnum == -1) //segment no longer exists obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) ); diff --git a/main/gamesave.c b/main/gamesave.c index e86053563..5d4526ef2 100644 --- a/main/gamesave.c +++ b/main/gamesave.c @@ -1327,6 +1327,8 @@ int create_new_mine(void) ControlCenterTriggers.num_links = 0; + create_new_mission(); + //editor_status("New mine created."); return 0; // say no error } diff --git a/main/menu.c b/main/menu.c index d1a3ebadd..35ca94781 100644 --- a/main/menu.c +++ b/main/menu.c @@ -547,8 +547,11 @@ int do_option ( int select) break; #ifdef EDITOR case MENU_EDITOR: - create_new_mine(); - SetPlayerFromCurseg(); + if (!Current_mission) + { + create_new_mine(); + SetPlayerFromCurseg(); + } hide_menus(); init_editor(); @@ -1765,8 +1768,11 @@ void do_sound_menu() #endif m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = ""; - +#ifdef USE_SDLMIXER + m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "cd music / jukebox options:"; +#else m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "cd music options:"; +#endif opt_sm_redbook_playorder = nitems; m[nitems].type = NM_TYPE_CHECK; m[nitems].text = "force mac cd track order"; m[nitems++].value = GameCfg.OrigTrackOrder; @@ -2162,4 +2168,4 @@ void do_sandbox_menu() newmenu_do3( NULL, "Coder's sandbox", 2, m, sandbox_menuset, NULL, 0, NULL ); } -#endif \ No newline at end of file +#endif diff --git a/main/mission.c b/main/mission.c index 75e2f0cb7..c8503627d 100644 --- a/main/mission.c +++ b/main/mission.c @@ -746,3 +746,21 @@ int select_mission(int anarchy_mode, char *message, int (*when_selected)(void)) return 1; // presume success } + +#ifdef EDITOR +void create_new_mission(void) +{ + if (Current_mission) + free_mission(); + + Current_mission = d_malloc(sizeof(Mission)); + if (!Current_mission) + return; + memset(Current_mission, 0, sizeof(Mission)); + + Current_mission->path = d_strdup("new_mission"); + Current_mission->filename = Current_mission->path; + + strcpy(Level_names[0], "GAMESAVE.LVL"); +} +#endif diff --git a/main/mission.h b/main/mission.h index 7418ecf98..22435d444 100644 --- a/main/mission.h +++ b/main/mission.h @@ -96,5 +96,9 @@ int select_mission (int anarchy_mode, char *message, int (*when_selected)(void)) void free_mission(void); +#ifdef EDITOR +void create_new_mission(void); +#endif + #endif