rocksndiamonds-2.0.1
[rocksndiamonds.git] / src / events.c
index 1e2ca16841661450886d719a2f701e0c8eea49be..79ffdd4ad02613fb5bf65e609be6ed563b87405b 100644 (file)
@@ -1,7 +1,7 @@
 /***********************************************************
 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
 *----------------------------------------------------------*
-* (c) 1995-2000 Artsoft Entertainment                      *
+* (c) 1995-2001 Artsoft Entertainment                      *
 *               Holger Schemel                             *
 *               Detmolder Strasse 189                      *
 *               33604 Bielefeld                            *
@@ -19,6 +19,7 @@
 #include "tools.h"
 #include "game.h"
 #include "editor.h"
+#include "files.h"
 #include "tape.h"
 #include "joystick.h"
 #include "network.h"
@@ -45,6 +46,23 @@ int FilterMouseMotionEvents(const Event *event)
     return 1;
 }
 
+/* this is only really needed for non-SDL targets to filter unwanted events;
+   when using SDL with properly installed event filter, this function can be
+   replaced with a simple "NextEvent()" call, but it doesn't hurt either */
+
+static boolean NextValidEvent(Event *event)
+{
+  while (PendingEvent())
+  {
+    NextEvent(event);
+
+    if (FilterMouseMotionEvents(event))
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
 void EventLoop(void)
 {
   while(1)
@@ -53,9 +71,7 @@ void EventLoop(void)
     {
       Event event;
 
-      NextEvent(&event);
-
-      if (FilterMouseMotionEvents(&event))
+      if (NextValidEvent(&event))
       {
        switch(event.type)
        {
@@ -550,6 +566,12 @@ void HandleKey(Key key, int key_status)
             HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
          break;
 
+#ifdef DEBUG
+        case KSYM_t:
+         DumpTape(&tape);
+         break;
+#endif
+
        default:
          break;
       }