Removed some old event eating code, as randomly discarding events is a bad idea with...
authorIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 02:31:22 +0000 (04:31 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 02:33:35 +0000 (04:33 +0200)
src/supertux/game_session.cpp
src/supertux/main.cpp
src/supertux/main.hpp

index c81b117..393d6e7 100644 (file)
@@ -425,11 +425,6 @@ GameSession::setup()
   }
   currentsector->play_music(LEVEL_MUSIC);
 
-  // Eat unneeded events
-  SDL_Event event;
-  while(SDL_PollEvent(&event))
-  {}
-
   int total_stats_to_be_collected = level->stats.total_coins + level->stats.total_badguys + level->stats.total_secrets;
   if ((!levelintro_shown) && (total_stats_to_be_collected > 0)) {
     levelintro_shown = true;
index 7b80c26..509c60f 100644 (file)
@@ -398,13 +398,6 @@ Main::init_sdl()
   }
   // just to be sure
   atexit(SDL_Quit);
-
-  // wait 100ms and clear SDL event queue because sometimes we have random
-  // joystick events in the queue on startup...
-  SDL_Delay(100);
-  SDL_Event dummy;
-  while(SDL_PollEvent(&dummy))
-    ;
 }
 
 void
@@ -460,47 +453,6 @@ Main::quit_audio()
   }
 }
 
-void
-Main::wait_for_event(float min_delay, float max_delay)
-{
-  assert(min_delay <= max_delay);
-
-  Uint32 min = (Uint32) (min_delay * 1000);
-  Uint32 max = (Uint32) (max_delay * 1000);
-
-  Uint32 ticks = SDL_GetTicks();
-  while(SDL_GetTicks() - ticks < min) {
-    SDL_Delay(10);
-    sound_manager->update();
-  }
-
-  // clear event queue
-  SDL_Event event;
-  while (SDL_PollEvent(&event))
-  {}
-
-  /* Handle events: */
-  bool running = false;
-  ticks = SDL_GetTicks();
-  while(running) {
-    while(SDL_PollEvent(&event)) {
-      switch(event.type) {
-        case SDL_QUIT:
-          g_screen_manager->quit();
-          break;
-        case SDL_KEYDOWN:
-        case SDL_JOYBUTTONDOWN:
-        case SDL_MOUSEBUTTONDOWN:
-          running = false;
-      }
-    }
-    if(SDL_GetTicks() - ticks >= (max - min))
-      running = false;
-    sound_manager->update();
-    SDL_Delay(10);
-  }
-}
-
 static Uint32 last_timelog_ticks = 0;
 static const char* last_timelog_component = 0;
 
index 22e4b13..d36f8ab 100644 (file)
@@ -31,7 +31,6 @@ private:
   void init_video();
   void print_usage(const char* argv0);
   void quit_audio();
-  void wait_for_event(float min_delay, float max_delay);
 
 public:
   /** We call it run() instead of main() as main collides with