Put LeaveGame longjmp back, but in response to new EVENT_WINDOW_CLOSED, fixing demo issues; fix compiler error in last commit

This commit is contained in:
kreatordxx 2010-02-02 07:52:03 +00:00
parent 5de468326f
commit 999a1b2949
6 changed files with 25 additions and 3 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
arch/include/event.h, arch/sdl/window.c, main/automap.c, main/dumpmine.c, main/game.c, main/gamecntl.c, main/gamesave.c, main/gameseq.c, main/kconfig.c, main/net_ipx.c, main/net_udp.c, main/newmenu.c: Add EVENT_WINDOW_DEACTIVATED; move many game_flush_inputs, start_time and stop_time calls to game_handler as well as digi_pause_digi_sounds and digi_resume_digi_sounds
main/inferno.c: Hide all other windows before showing error dialog, hopefully so errors don't happen while the error dialog is there
arch/include/event.h, arch/sdl/window.c, main/game.c, main/inferno.c, main/newmenu.c: Put LeaveGame longjmp back, but in response to new EVENT_WINDOW_CLOSED, fixing demo issues; fix compiler error in last commit
20100201
--------

View file

@ -11,6 +11,7 @@ typedef enum event_type
EVENT_WINDOW_DEACTIVATED,
EVENT_WINDOW_DRAW,
EVENT_WINDOW_CLOSE,
EVENT_WINDOW_CLOSED,
EVENT_USER // spare for use by modules that use windows (e.g. newmenu)
} event_type;

View file

@ -65,6 +65,7 @@ int window_close(window *wind)
{
window *prev;
d_event event;
int (*w_callback)(window *wind, d_event *event, void *data) = wind->w_callback;
event.type = EVENT_WINDOW_DEACTIVATED; // Deactivate first
window_send_event(wind, &event);
@ -92,6 +93,10 @@ int window_close(window *wind)
}
d_free(wind);
event.type = EVENT_WINDOW_CLOSED;
w_callback(wind, &event, NULL); // callback needs to recognise this is a NULL pointer!
return 1;
}

View file

@ -22,6 +22,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include <string.h>
#include <stdarg.h>
#include <SDL/SDL.h>
#include <setjmp.h>
#ifdef OGL
#include "ogl_init.h"
@ -975,6 +976,7 @@ window *game_setup(void)
void game_render_frame();
window *Game_wind = NULL;
jmp_buf LeaveGame;
// Event handler for the game
int game_handler(window *wind, d_event *event, void *data)
@ -1078,6 +1080,10 @@ int game_handler(window *wind, d_event *event, void *data)
return 0; // continue closing
break;
case EVENT_WINDOW_CLOSED:
longjmp(LeaveGame, 0);
break;
default:
return 0;
break;
@ -1093,8 +1099,11 @@ void game()
{
Game_wind = game_setup();
while (Game_wind)
event_process();
if (setjmp(LeaveGame) == 0)
{
while (Game_wind)
event_process();
}
}
//called at the end of the program

View file

@ -188,7 +188,7 @@ void error_messagebox(char *s)
// Hide all windows so they don't interfere
// Don't care about unfreed pointers on exit; trying to close the windows may cause problems
for (wind = window_get_front(), wind != NULL; wind = window_get_front())
for (wind = window_get_front(); wind != NULL; wind = window_get_front())
window_set_visible(wind, 0);
nm_messagebox( TXT_SORRY, 1, TXT_OK, s );

View file

@ -1238,6 +1238,9 @@ int newmenu_draw(window *wind, newmenu *menu)
int newmenu_handler(window *wind, d_event *event, newmenu *menu)
{
if (event->type == EVENT_WINDOW_CLOSED)
return 0;
if (menu->subfunction)
{
int rval = (*menu->subfunction)(menu, event, menu->userdata);
@ -1918,6 +1921,9 @@ int listbox_draw(window *wind, listbox *lb)
int listbox_handler(window *wind, d_event *event, listbox *lb)
{
if (event->type == EVENT_WINDOW_CLOSED)
return 0;
if (lb->listbox_callback)
{
int rval = (*lb->listbox_callback)(lb, event, lb->userdata);