shithub: choc

Download patch

ref: 840e87ce39fe2319cbcfc4ff97c2781ce36e5549
parent: cea768a93430b1823cc3d2e683282833b70b75f1
author: Simon Howard <fraggle@gmail.com>
date: Thu Mar 27 18:44:19 EDT 2014

hexen: Allow abort on startup by pressing escape.

Vanilla Hexen allows the game startup to be aborted by pressing the
escape key. This can also be used to abort netgame startup. Add back
this functionality by polling the SDL event loop; this feature only
works if the graphical startup is enabled, but that's good enough.

--- a/src/hexen/d_net.c
+++ b/src/hexen/d_net.c
@@ -33,6 +33,7 @@
 #include "i_system.h"
 #include "i_timer.h"
 #include "i_video.h"
+#include "i_videohr.h"
 #include "h2def.h"
 #include "p_local.h"
 #include "s_sound.h"
@@ -239,7 +240,8 @@
 
     ready = now_ready;
 
-    return true;
+    // Allow the user to hit escape during netgame startup to abort.
+    return !I_CheckAbortHR();
 }
 
 //
--- a/src/hexen/st_start.c
+++ b/src/hexen/st_start.c
@@ -204,11 +204,11 @@
 
 void ST_Progress(void)
 {
-    // haleyjd FIXME: any way to get input here? SDL event loop?
-#ifdef __WATCOMC__
     // Check for ESC press -- during startup all events eaten here
-    I_StartupReadKeys();
-#endif
+    if (I_CheckAbortHR())
+    {
+        I_Quit();
+    }
 
     if (using_graphical_startup)
     {
--- a/src/i_videohr.c
+++ b/src/i_videohr.c
@@ -220,3 +220,26 @@
     I_SetPaletteHR(blackpal);
 }
 
+// Check if the user has hit the escape key to abort startup.
+boolean I_CheckAbortHR(void)
+{
+    SDL_Event ev;
+    boolean result = false;
+
+    // Not initialized?
+    if (hr_surface == NULL)
+    {
+        return false;
+    }
+
+    while (SDL_PollEvent(&ev))
+    {
+        if (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_ESCAPE)
+        {
+            result = true;
+        }
+    }
+
+    return result;
+}
+
--- a/src/i_videohr.h
+++ b/src/i_videohr.h
@@ -37,6 +37,7 @@
 void I_SetPaletteHR(const byte *palette);
 void I_FadeToPaletteHR(const byte *palette);
 void I_BlackPaletteHR(void);
+boolean I_CheckAbortHR(void);
 
 #endif /* #ifndef I_VIDEOHR_H */