From: Holger Schemel Date: Mon, 13 Nov 2017 22:49:36 +0000 (+0100) Subject: fixed repeated creation of differently sized bitmaps between menu and game X-Git-Tag: 4.0.1.1~29 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cba1a8ce5ba37f1e0a826ce63cf491044573681a;p=rocksndiamonds.git fixed repeated creation of differently sized bitmaps between menu and game --- diff --git a/src/libgame/system.c b/src/libgame/system.c index ed51e626..4f90a2d1 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)