From: Holger Schemel Date: Wed, 13 Jun 2018 19:21:49 +0000 (+0200) Subject: fixed bug causing crash when trying to draw undefined optional graphics X-Git-Tag: 4.1.1.0~149 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=400c25c653549b236d701d6b0d9b47a9565ec5be;p=rocksndiamonds.git fixed bug causing crash when trying to draw undefined optional graphics Before, the program crashed (segmentation fault) if optional graphics (like "menu.button_level_number", which are defined to be off-screen by default) are defined to a valid screen position (by setting the corresponding screen position values like "main.button.level_number.x/y" to positions on the screen), but no image was defined to be used for that graphic. This bug was fixed by using fallback graphics when attempting to draw those undefined optional graphics. --- diff --git a/src/tools.c b/src/tools.c index 76b40a29..6d3a0aeb 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1574,6 +1574,10 @@ void getSizedGraphicSourceExt(int graphic, int frame, int tilesize, { struct GraphicInfo *g = &graphic_info[graphic]; + // if no graphics defined at all, use fallback graphics + if (g->bitmaps == NULL) + *g = graphic_info[IMG_CHAR_EXCLAM]; + // if no in-game graphics defined, always use standard graphic size if (g->bitmaps[IMG_BITMAP_GAME] == NULL) tilesize = TILESIZE;