Empty SDLs event queue when starting cinematic playback.

Sometimes cinematics are skipped after the first frame even if the
player didn't press any key. I'm unable to reliable reproduce that,
so my educated guess is that one or more events are still waiting in
SDLs event queue.

For example, during intermission IN_Update() is not called for 5
seconds, key presses by impatient players are just added to the queue
and not processed. The first event is used to skip leave the
intermission, the second event skips the cinematic...

Fix this by implementing a new function IN_FlushQueue() to flush SDLs
event queue and calling it when starting cinematic playback. Yes, this
is just another layer violation. :(
This commit is contained in:
Yamagi Burmeister 2017-04-22 10:29:25 +02:00
parent c0b768278f
commit 98276aeb91
2 changed files with 21 additions and 0 deletions

View file

@ -49,4 +49,9 @@ void IN_Shutdown(void);
*/
void IN_Update(void);
/*
* Removes all pending events from SDLs queue.
*/
void In_FlushQueue(void);
#endif

View file

@ -464,6 +464,22 @@ IN_Update(void)
*/
GLimp_GrabInput(want_grab);
}
/*
* Removes all pending events from SDLs queue.
*/
void
In_FlushQueue(void)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
#else
SDL_Event event;
while(SDL_PollEvent(&event));
#endif
Key_MarkAllUp();
}
/*
* Move handling