Remove all uses of LeaveGame jmpbuf to allow more changing of main loop
This commit is contained in:
parent
422c745cfa
commit
3a116769be
|
@ -1,5 +1,9 @@
|
|||
D2X-Rebirth Changelog
|
||||
|
||||
20100127
|
||||
--------
|
||||
main/game.c, main/game.h, main/gamecntl.c, main/gameseq.c, main/kmatrix.c, main/multi.c, main/net_ipx.c, main/net_udp.c, main/newdemo.c, main/render.c: Remove all uses of LeaveGame jmpbuf to allow more changing of main loop
|
||||
|
||||
20100126
|
||||
--------
|
||||
main/newdemo.c: Once again improving Demo Interpolation code, regarding changes from rev993, reducing Viewport flicker and jitter
|
||||
|
|
38
main/game.c
38
main/game.c
|
@ -1083,7 +1083,6 @@ void reset_rear_view(void)
|
|||
}
|
||||
|
||||
int Config_menu_flag;
|
||||
jmp_buf LeaveGame;
|
||||
|
||||
int Cheats_enabled=0;
|
||||
|
||||
|
@ -1201,7 +1200,7 @@ int game_handler(window *wind, d_event *event, void *data)
|
|||
|
||||
ReadControls(); // will have its own event(s) eventually
|
||||
if (window_get_front() != wind)
|
||||
return 1;
|
||||
break;
|
||||
|
||||
GameProcessFrame();
|
||||
|
||||
|
@ -1218,25 +1217,8 @@ int game_handler(window *wind, d_event *event, void *data)
|
|||
if (!(Game_mode&GM_MULTI)) palette_restore();
|
||||
}
|
||||
|
||||
if ( (Function_mode != FMODE_GAME) && GameArg.SysAutoDemo && (Newdemo_state != ND_STATE_NORMAL) ) {
|
||||
int choice, fmode;
|
||||
fmode = Function_mode;
|
||||
Function_mode = FMODE_GAME;
|
||||
palette_save();
|
||||
apply_modified_palette();
|
||||
reset_palette_add();
|
||||
gr_palette_load( gr_palette );
|
||||
choice=nm_messagebox( NULL, 2, TXT_YES, TXT_NO, TXT_ABORT_AUTODEMO );
|
||||
palette_restore();
|
||||
Function_mode = fmode;
|
||||
if (choice==0) {
|
||||
GameArg.SysAutoDemo = 0;
|
||||
newdemo_stop_playback();
|
||||
Function_mode = FMODE_MENU;
|
||||
} else {
|
||||
Function_mode = FMODE_GAME;
|
||||
}
|
||||
}
|
||||
if (!Game_wind)
|
||||
break;
|
||||
|
||||
if ( (Function_mode != FMODE_GAME ) && (Newdemo_state != ND_STATE_PLAYBACK ) && (Function_mode!=FMODE_EDITOR))
|
||||
{
|
||||
|
@ -1255,7 +1237,7 @@ int game_handler(window *wind, d_event *event, void *data)
|
|||
}
|
||||
|
||||
if (Function_mode != FMODE_GAME)
|
||||
longjmp(LeaveGame,0);
|
||||
window_close(wind);
|
||||
|
||||
return 0;
|
||||
break;
|
||||
|
@ -1269,6 +1251,9 @@ int game_handler(window *wind, d_event *event, void *data)
|
|||
break;
|
||||
|
||||
case EVENT_WINDOW_CLOSE:
|
||||
if (Function_mode == FMODE_GAME)
|
||||
Function_mode = FMODE_MENU;
|
||||
|
||||
digi_stop_all();
|
||||
|
||||
if ( (Newdemo_state == ND_STATE_RECORDING) || (Newdemo_state == ND_STATE_PAUSED) )
|
||||
|
@ -1303,13 +1288,8 @@ void game()
|
|||
{
|
||||
Game_wind = game_setup();
|
||||
|
||||
if ( setjmp(LeaveGame)==0 ) {
|
||||
|
||||
while (Game_wind)
|
||||
event_process();
|
||||
}
|
||||
|
||||
window_close(Game_wind);
|
||||
}
|
||||
|
||||
//called at the end of the program
|
||||
|
@ -1481,7 +1461,9 @@ void GameProcessFrame(void)
|
|||
if ( Newdemo_state == ND_STATE_PLAYBACK ) {
|
||||
newdemo_playback_one_frame();
|
||||
if ( Newdemo_state != ND_STATE_PLAYBACK ) {
|
||||
longjmp( LeaveGame, 0 ); // Go back to menu
|
||||
if (Game_wind)
|
||||
window_close(Game_wind); // Go back to menu
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -20,9 +20,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#ifndef _GAME_H
|
||||
#define _GAME_H
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "pstypes.h"
|
||||
#include "window.h"
|
||||
#include "vecmat.h"
|
||||
#include "object.h"
|
||||
|
||||
|
@ -126,7 +125,6 @@ void calc_frame_time(void);
|
|||
void FixedStepCalc();
|
||||
int do_flythrough(object *obj,int first_time);
|
||||
|
||||
extern jmp_buf LeaveGame; // Do a long jump to this when game is over.
|
||||
extern int Difficulty_level; // Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest
|
||||
extern int Global_laser_firing_count;
|
||||
extern int Global_missile_firing_count;
|
||||
|
|
|
@ -591,7 +591,21 @@ void HandleDemoKey(int key)
|
|||
#endif
|
||||
break;
|
||||
case KEY_ESC:
|
||||
Function_mode = FMODE_MENU;
|
||||
if (GameArg.SysAutoDemo)
|
||||
{
|
||||
int choice;
|
||||
palette_save();
|
||||
apply_modified_palette();
|
||||
reset_palette_add();
|
||||
gr_palette_load( gr_palette );
|
||||
choice=nm_messagebox( NULL, 2, TXT_YES, TXT_NO, TXT_ABORT_AUTODEMO );
|
||||
palette_restore();
|
||||
if (choice==0)
|
||||
GameArg.SysAutoDemo = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
newdemo_stop_playback();
|
||||
break;
|
||||
case KEY_UP:
|
||||
Newdemo_vcr_state = ND_STATE_PLAYBACK;
|
||||
|
|
|
@ -515,10 +515,9 @@ void DoGameOver()
|
|||
if (PLAYING_BUILTIN_MISSION)
|
||||
scores_maybe_add_player(0);
|
||||
|
||||
Function_mode = FMODE_MENU;
|
||||
Game_mode = GM_GAME_OVER;
|
||||
longjmp( LeaveGame, 0 ); // Exit out of game loop
|
||||
|
||||
if (Game_wind)
|
||||
window_close(Game_wind); // Exit out of game loop
|
||||
}
|
||||
|
||||
//update various information about the player
|
||||
|
@ -1426,12 +1425,11 @@ void DoEndGame(void)
|
|||
scores_maybe_add_player(0);
|
||||
}
|
||||
|
||||
Function_mode = FMODE_MENU;
|
||||
|
||||
Game_mode = GM_GAME_OVER;
|
||||
|
||||
|
||||
longjmp( LeaveGame, 0 ); // Exit out of game loop
|
||||
if (Game_wind)
|
||||
window_close(Game_wind); // Exit out of game loop
|
||||
}
|
||||
|
||||
//called to go to the next level (if there is one)
|
||||
|
@ -1468,8 +1466,8 @@ void AdvanceLevel(int secret_flag)
|
|||
if (result) // failed to sync
|
||||
{
|
||||
if (Current_level_num == Last_level) //player has finished the game!
|
||||
longjmp( LeaveGame, 0 ); // Exit out of game loop
|
||||
else
|
||||
if (Game_wind)
|
||||
window_close(Game_wind); // Exit out of game loop
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "key.h"
|
||||
#include "palette.h"
|
||||
#include "game.h"
|
||||
#include "window.h"
|
||||
#include "gamefont.h"
|
||||
#include "u_mem.h"
|
||||
#include "newmenu.h"
|
||||
|
@ -395,7 +396,8 @@ void kmatrix_ipx_view(int network)
|
|||
if (network)
|
||||
multi_send_endlevel_packet();
|
||||
multi_leave_game();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +421,8 @@ void kmatrix_ipx_view(int network)
|
|||
if (network)
|
||||
multi_send_endlevel_packet();
|
||||
multi_leave_game();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -446,7 +449,8 @@ void kmatrix_ipx_view(int network)
|
|||
if (network)
|
||||
multi_send_endlevel_packet();
|
||||
multi_leave_game();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -787,7 +791,8 @@ void kmatrix_view(int network)
|
|||
multi_send_endlevel_packet();
|
||||
|
||||
multi_leave_game();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -819,7 +824,8 @@ void kmatrix_view(int network)
|
|||
multi_send_endlevel_packet();
|
||||
|
||||
multi_leave_game();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -924,7 +924,8 @@ multi_do_frame(void)
|
|||
if (multi_quit_game && !multi_in_menu)
|
||||
{
|
||||
multi_quit_game = 0;
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3974,7 +3974,8 @@ menu:
|
|||
net_ipx_dump_player(Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, DUMP_ABORTED);
|
||||
}
|
||||
}
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
}
|
||||
else if (choice != -2)
|
||||
goto menu;
|
||||
|
@ -4007,7 +4008,8 @@ net_ipx_level_sync(void)
|
|||
{
|
||||
Players[Player_num].connected = CONNECT_DISCONNECTED;
|
||||
net_ipx_send_endlevel_packet();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -4126,7 +4128,8 @@ void net_ipx_join_game()
|
|||
|
||||
N_players = 0;
|
||||
|
||||
setjmp(LeaveGame);
|
||||
// FIXME: Keep browsing window to go back to
|
||||
//setjmp(LeaveGame);
|
||||
|
||||
Network_send_objects = 0;
|
||||
Network_sending_extras=0;
|
||||
|
|
|
@ -428,7 +428,8 @@ void net_udp_manual_join_game()
|
|||
char addrbuf[128]="";
|
||||
char portbuf[6]="";
|
||||
|
||||
setjmp(LeaveGame);
|
||||
// FIXME: Keep IP window to go back to
|
||||
//setjmp(LeaveGame);
|
||||
|
||||
net_udp_init();
|
||||
|
||||
|
@ -3068,7 +3069,9 @@ void net_udp_send_sync(void)
|
|||
Netgame.numplayers = 0;
|
||||
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO); // Tell everyone we're bailing
|
||||
}
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
return;
|
||||
}
|
||||
|
||||
// Randomize their starting locations...
|
||||
|
@ -3313,11 +3316,12 @@ net_udp_start_game()
|
|||
{
|
||||
int i;
|
||||
|
||||
if (setjmp(LeaveGame))
|
||||
{
|
||||
Game_mode = GM_GAME_OVER;
|
||||
return;
|
||||
}
|
||||
// FIXME: Keep multiplayer menu to go back to
|
||||
//if (setjmp(LeaveGame))
|
||||
//{
|
||||
// Game_mode = GM_GAME_OVER;
|
||||
// return;
|
||||
//}
|
||||
|
||||
net_udp_init();
|
||||
change_playernum_to(0);
|
||||
|
@ -3472,7 +3476,8 @@ menu:
|
|||
net_udp_dump_player(Netgame.players[i].protocol.udp.addr, DUMP_ABORTED);
|
||||
}
|
||||
}
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
}
|
||||
else if (choice != -2)
|
||||
goto menu;
|
||||
|
@ -3506,7 +3511,8 @@ net_udp_level_sync(void)
|
|||
{
|
||||
Players[Player_num].connected = CONNECT_DISCONNECTED;
|
||||
net_udp_send_endlevel_packet();
|
||||
longjmp(LeaveGame, 0);
|
||||
if (Game_wind)
|
||||
window_close(Game_wind);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
|
|
@ -3576,8 +3576,8 @@ void newdemo_stop_playback()
|
|||
PlayerCfg.CockpitMode = Newdemo_old_cockpit;
|
||||
Rear_view=0;
|
||||
Newdemo_game_mode = Game_mode = GM_GAME_OVER;
|
||||
Function_mode = FMODE_MENU;
|
||||
longjmp(LeaveGame,0); // Exit game loop
|
||||
if (Game_wind)
|
||||
window_close(Game_wind); // Exit game loop
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -877,11 +877,11 @@ int reset_perspective_depth(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
typedef struct window {
|
||||
typedef struct rect {
|
||||
short left,top,right,bot;
|
||||
} window;
|
||||
} rect;
|
||||
|
||||
ubyte code_window_point(fix x,fix y,window *w)
|
||||
ubyte code_window_point(fix x,fix y,rect *w)
|
||||
{
|
||||
ubyte code=0;
|
||||
|
||||
|
@ -933,7 +933,7 @@ int lcnt_save,scnt_save;
|
|||
//@@short *persp_ptr;
|
||||
short render_pos[MAX_SEGMENTS]; //where in render_list does this segment appear?
|
||||
//ubyte no_render_flag[MAX_RENDER_SEGS];
|
||||
window render_windows[MAX_RENDER_SEGS];
|
||||
rect render_windows[MAX_RENDER_SEGS];
|
||||
|
||||
short render_obj_list[MAX_RENDER_SEGS+N_EXTRA_OBJ_LISTS][OBJS_PER_SEG];
|
||||
|
||||
|
@ -1700,7 +1700,7 @@ void build_segment_list(int start_seg_num, int window_num)
|
|||
//while (scnt < ecnt) {
|
||||
for (scnt=0;scnt < ecnt;scnt++) {
|
||||
int rotated,segnum;
|
||||
window *check_w;
|
||||
rect *check_w;
|
||||
short child_list[MAX_SIDES_PER_SEGMENT]; //list of ordered sides to process
|
||||
int n_children; //how many sides in child_list
|
||||
segment *seg;
|
||||
|
@ -1816,7 +1816,7 @@ void build_segment_list(int start_seg_num, int window_num)
|
|||
|
||||
if (no_proj_flag || (!codes_and_3d && !codes_and_2d)) { //maybe add this segment
|
||||
int rp = render_pos[ch];
|
||||
window *new_w = &render_windows[lcnt];
|
||||
rect *new_w = &render_windows[lcnt];
|
||||
|
||||
if (no_proj_flag) *new_w = *check_w;
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue