From 88373bd89d41abe1a749bf5e55b74719223c353f Mon Sep 17 00:00:00 2001 From: kreatordxx <> Date: Sun, 25 Jul 2010 00:49:33 +0000 Subject: [PATCH] Exit SDL_PollEvent early if window changes, to avoid menu problems when pressing keys fast; fix 'condition is always false' warning --- CHANGELOG.txt | 4 ++++ arch/ogl/gr.c | 2 +- arch/sdl/event.c | 6 +++++- arch/sdl/gr.c | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8c902c340..97a89f9f6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20100725 +-------- +arch/sdl/event.c, arch/ogl/gr.c, arch/sdl/gr.c: Exit SDL_PollEvent early if window changes, to avoid menu problems when pressing keys fast; fix 'condition is always false' warning + 20100721 -------- main/net_udp.c: Fixing crash when joinging game over UDP Netlist: when exiting the menu for any reason, return 0 instead of following the code and possibly lead to drawing text from a newly free'd pointer - D'OH! diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index d11d63774..f8eb2d704 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -219,7 +219,7 @@ int gr_list_modes( u_int32_t gsmodes[] ) { for (i = 0; modes[i]; ++i) { - if (modes[i]->w > 0xFFFF || modes[i]->h > 0xFFFF // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) + if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (changed to 0xFFF0 to fix warning) || modes[i]->w < 320 || modes[i]->h < 200) // also skip everything smaller than 320x200 continue; gsmodes[modesnum] = SM(modes[i]->w,modes[i]->h); diff --git a/arch/sdl/event.c b/arch/sdl/event.c index 1dd8d2cd1..34cd036e1 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -30,8 +30,12 @@ void event_poll() SDL_Event event; int clean_uniframe=1; fix time = timer_get_fixed_seconds(); + window *wind = window_get_front(); - while (SDL_PollEvent(&event)) { + // If the front window changes, exit this loop, otherwise unintended behavior can occur + // like pressing 'Return' really fast at 'Difficulty Level' causing multiple games to be started + while ((wind == window_get_front()) && SDL_PollEvent(&event)) + { switch(event.type) { case SDL_KEYDOWN: case SDL_KEYUP: diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 41f2f5d89..8245c7971 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -65,7 +65,7 @@ int gr_list_modes( u_int32_t gsmodes[] ) { for (i = 0; modes[i]; ++i) { - if (modes[i]->w > 0xFFFF || modes[i]->h > 0xFFFF // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) + if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (kreatordxx - made 0xFFF0 to kill warning) || modes[i]->w < 320 || modes[i]->h < 200) // also skip everything smaller than 320x200 continue; gsmodes[modesnum] = SM(modes[i]->w,modes[i]->h);