diff --git a/CHANGELOG.txt b/CHANGELOG.txt index dc2124a2d..bc43676b3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D1X-Rebirth Changelog 20100131 -------- main/newmenu.c: Fix memory errors, but still dynamically allocate menu and lb so it doesn't have to stay in newmenu_do4 and newmenu_listbox1 respectively +main/automap.c, main/game.c, main/game.h, main/multi.c, main/multi.h, main/net_ipx.c, main/net_udp.c, main/newmenu.c: Fix crashing when doing menus in multiplayer, don't let player move when in automap 20100130 -------- diff --git a/main/automap.c b/main/automap.c index 0c35c971e..3e1d2cdf1 100644 --- a/main/automap.c +++ b/main/automap.c @@ -95,6 +95,7 @@ typedef struct automap int leave_mode; int pause_game; vms_angvec tangles; + ushort old_wiggle; // keep 4 byte aligned int max_segments_away; int segment_limit; @@ -358,6 +359,11 @@ int automap_idle(window *wind, d_event *event, automap *am) vms_matrix tempm; int c; + if (!am->pause_game) { + ConsoleObject->mtype.phys_info.flags |= am->old_wiggle; // Restore wiggle + Controls = am->saved_control_info; // Restore controls + } + if ( am->leave_mode==0 && Controls.automap_state && (timer_get_fixed_seconds()-am->entry_time)>LEAVE_TIME) am->leave_mode = 1; @@ -367,16 +373,6 @@ int automap_idle(window *wind, d_event *event, automap *am) return 1; } - if (!am->pause_game) { - ushort old_wiggle; - am->saved_control_info = Controls; // Save controls so we can zero them - memset(&Controls,0,sizeof(control_info)); // Clear everything... - old_wiggle = ConsoleObject->mtype.phys_info.flags & PF_WIGGLE; // Save old wiggle - ConsoleObject->mtype.phys_info.flags &= ~PF_WIGGLE; // Turn off wiggle - ConsoleObject->mtype.phys_info.flags |= old_wiggle; // Restore wiggle - Controls = am->saved_control_info; - } - controls_read_all(1); if ( Controls.automap_down_count ) { @@ -502,6 +498,13 @@ int automap_idle(window *wind, d_event *event, automap *am) } am->t1 = am->t2; + if (!am->pause_game) { + am->saved_control_info = Controls; // Save controls so we can zero them + memset(&Controls,0,sizeof(control_info)); // Clear everything... + am->old_wiggle = ConsoleObject->mtype.phys_info.flags & PF_WIGGLE; // Save old wiggle + ConsoleObject->mtype.phys_info.flags &= ~PF_WIGGLE; // Turn off wiggle + } + return 0; } diff --git a/main/game.c b/main/game.c index c0a3982c6..e2e8988ae 100644 --- a/main/game.c +++ b/main/game.c @@ -1106,8 +1106,23 @@ extern void check_create_player_path(void); extern int Do_appearance_effect; +void game_leave_menus(void) +{ + window *wind; + + if (!Game_wind) + return; + + for (wind = window_get_next(Game_wind); wind != NULL; wind = window_get_next(wind)) + window_close(wind); +} + void GameProcessFrame(void) { + fix player_shields = Players[Player_num].shields; + int was_fuelcen_destroyed = Control_center_destroyed; + int player_was_dead = Player_is_dead; + update_player_stats(); diminish_palette_towards_normal(); // Should leave palette effect up for as long as possible by putting right before render. do_cloak_stuff(); @@ -1218,6 +1233,13 @@ void GameProcessFrame(void) create_player_appearance_effect(ConsoleObject); Do_appearance_effect = 0; } + + // Check if we have to close in-game menus for multiplayer + if (Endlevel_sequence || (Player_is_dead != player_was_dead) || (Players[Player_num].shields < player_shields)) + game_leave_menus(); + + if ((Control_center_destroyed && !was_fuelcen_destroyed) || ((Control_center_destroyed) && (Fuelcen_seconds_left < 10))) + game_leave_menus(); } // ----------------------------------------------------------------------------- diff --git a/main/game.h b/main/game.h index 72f36199d..6f980102f 100644 --- a/main/game.h +++ b/main/game.h @@ -200,6 +200,7 @@ extern grs_canvas VR_screen_sub_pages[2]; // Two sub pages of VRAM if paging is void game_init_render_buffers (int render_max_w, int render_max_h, int render_method); void game_do_render_frame(int flip); +void game_leave_menus(void); #endif diff --git a/main/multi.c b/main/multi.c index 12e9ef38c..0cd60a07f 100644 --- a/main/multi.c +++ b/main/multi.c @@ -722,8 +722,6 @@ void multi_do_protocol_frame(int force, int listen) } } -int multi_menu_check(void); - void multi_do_frame(void) { if (!(Game_mode & GM_MULTI) || Newdemo_state == ND_STATE_PLAYBACK) @@ -734,8 +732,6 @@ void multi_do_frame(void) multi_send_message(); // Send any waiting messages - multi_menu_check(); - if (Game_mode & GM_MULTI_ROBOTS) { multi_check_robot_timeout(); @@ -933,43 +929,6 @@ void multi_send_endlevel_packet() // the state of the game in some way. // -void multi_leave_menus(void) -{ - window *wind; - - for (wind = window_get_front(); wind != Game_wind; wind = window_get_front()) - if (!window_close(wind)) // Uh-oh! Close cancelled. - break; -} - -static fix old_shields = 400*F1_0; -static int was_fuelcen_destroyed = 1; -static int player_was_dead; - -int multi_menu_check(void) -{ - // Check if we have to close in-game menus for multiplayer - - if (! ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME)) ) - return(0); - - if (Endlevel_sequence || (Control_center_destroyed && !was_fuelcen_destroyed) || (Player_is_dead != player_was_dead) || (Players[Player_num].shields < old_shields)) - { - multi_leave_menus(); - return(-1); - } - if ((Control_center_destroyed) && (Fuelcen_seconds_left < 10)) - { - multi_leave_menus(); - return(-1); - } - - old_shields = Players[Player_num].shields; - was_fuelcen_destroyed = Control_center_destroyed; - player_was_dead = Player_is_dead; - return(0); -} - void multi_define_macro(int key) { @@ -2724,7 +2683,7 @@ void multi_consistency_error(int reset) Function_mode = FMODE_GAME; count = 0; multi_quit_game = 1; - multi_leave_menus(); + game_leave_menus(); multi_reset_stuff(); Function_mode = FMODE_MENU; } diff --git a/main/multi.h b/main/multi.h index 5a6d42738..246d65917 100644 --- a/main/multi.h +++ b/main/multi.h @@ -221,7 +221,6 @@ int multi_endlevel_poll1(); int multi_endlevel_poll2( newmenu *menu, d_event *event, void *userdata ); void multi_send_endlevel_packet(); void multi_leave_game(void); -void multi_leave_menus(void); void multi_process_data(char *dat, int len); void multi_process_bigdata(char *buf, int len); void multi_do_death(int objnum); diff --git a/main/net_ipx.c b/main/net_ipx.c index 291698d33..ac83d4ced 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -1880,7 +1880,7 @@ void net_ipx_process_dump(IPX_sequence_packet *their) nm_messagebox(NULL, 1, TXT_OK, "%s has kicked you out!",their->player.callsign); Function_mode = FMODE_GAME; multi_quit_game = 1; - multi_leave_menus(); + game_leave_menus(); multi_reset_stuff(); Function_mode = FMODE_MENU; } diff --git a/main/net_udp.c b/main/net_udp.c index a52f6b7ae..00efc2901 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -686,7 +686,7 @@ net_udp_disconnect_player(int playernum) nm_messagebox(NULL, 1, TXT_OK, "Game was closed by host!"); Function_mode = FMODE_GAME; multi_quit_game = 1; - multi_leave_menus(); + game_leave_menus(); multi_reset_stuff(); Function_mode = FMODE_MENU; } @@ -1888,7 +1888,7 @@ void net_udp_process_dump(ubyte *data, int len, struct _sockaddr sender_addr) nm_messagebox(NULL, 1, TXT_OK, "%s has kicked you out!",Players[0].callsign); Function_mode = FMODE_GAME; multi_quit_game = 1; - multi_leave_menus(); + game_leave_menus(); multi_reset_stuff(); Function_mode = FMODE_MENU; } diff --git a/main/newmenu.c b/main/newmenu.c index 38d2db490..59eef7d23 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1232,6 +1232,13 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu) break; case EVENT_WINDOW_CLOSE: + if (!menu->done) + { + menu->citem = -1; + menu->done = 1; + return 1; // cancel close and do it in newmenu_do4 instead + } + newmenu_hide_cursor(); game_flush_inputs(); @@ -1934,6 +1941,13 @@ int listbox_handler(window *wind, d_event *event, listbox *lb) break; case EVENT_WINDOW_CLOSE: + if (!lb->done) + { + lb->citem = -1; + lb->done = 1; + return 1; // cancel close and do it in newmenu_listbox1 instead + } + newmenu_hide_cursor(); d_free(lb); break;