X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=a87ecc837f15206351dd228e89bedcf25512a925;hb=88a1829af8ca41b6e581f209002022b2483b86df;hp=ed51e626a8f473747e4b9644c532f95e76b9b490;hpb=499ad3bb12d513266ddcebe41a84eee8237a7fb5;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index ed51e626..a87ecc83 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -525,6 +525,18 @@ Bitmap *CreateBitmap(int width, int height, int depth) void ReCreateBitmap(Bitmap **bitmap, int width, int height) { + if (*bitmap != NULL) + { + /* if new bitmap size fits into old one, no need to re-create it */ + if (width <= (*bitmap)->width && + height <= (*bitmap)->height) + return; + + /* else adjust size so that old and new bitmap size fit into it */ + width = MAX(width, (*bitmap)->width); + height = MAX(height, (*bitmap)->height); + } + Bitmap *new_bitmap = CreateBitmap(width, height, DEFAULT_DEPTH); if (*bitmap == NULL) @@ -1481,9 +1493,9 @@ boolean PendingEvent(void) return (SDL_PollEvent(NULL) ? TRUE : FALSE); } -void NextEvent(Event *event) +void WaitEvent(Event *event) { - SDLNextEvent(event); + SDLWaitEvent(event); } void PeekEvent(Event *event) @@ -1495,6 +1507,12 @@ void PeekEvent(Event *event) #endif } +void CheckQuitEvent(void) +{ + if (SDL_QuitRequested()) + program.exit_function(0); +} + Key GetEventKey(KeyEvent *event, boolean with_modifiers) { #if defined(TARGET_SDL2)