From: Holger Schemel Date: Thu, 4 Mar 2021 19:58:03 +0000 (+0100) Subject: fixed using custom sized game graphics also for global animations X-Git-Tag: 4.3.0.0~218 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c07e4d51f30c46731bf28c42954dc7726457984e;p=rocksndiamonds.git fixed using custom sized game graphics also for global animations When using image files for game graphics with custom tile size, then configuring the same image files also for global animations, global animations had broken (standard-sized) graphics before. This change (together with the previous commit) fixes this bug. --- diff --git a/src/anim.c b/src/anim.c index 2e6280ce..c2ec75f6 100644 --- a/src/anim.c +++ b/src/anim.c @@ -825,8 +825,8 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) gfx.anim_random_frame = last_anim_random_frame; - getFixedGraphicSource(part->graphic, frame, &src_bitmap, - &src_x, &src_y); + getGlobalAnimGraphicSource(part->graphic, frame, &src_bitmap, + &src_x, &src_y); src_x += cut_x; src_y += cut_y; diff --git a/src/libgame/system.c b/src/libgame/system.c index 225738cc..db9d72b1 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -1493,12 +1493,18 @@ void CreateBitmapWithSmallBitmaps(Bitmap **bitmaps, int zoom_factor, void CreateBitmapTextures(Bitmap **bitmaps) { - SDLCreateBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); + if (bitmaps[IMG_BITMAP_PTR_ORIGINAL] != NULL) + SDLCreateBitmapTextures(bitmaps[IMG_BITMAP_PTR_ORIGINAL]); + else + SDLCreateBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); } void FreeBitmapTextures(Bitmap **bitmaps) { - SDLFreeBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); + if (bitmaps[IMG_BITMAP_PTR_ORIGINAL] != NULL) + SDLFreeBitmapTextures(bitmaps[IMG_BITMAP_PTR_ORIGINAL]); + else + SDLFreeBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); } void ScaleBitmap(Bitmap **bitmaps, int zoom_factor) diff --git a/src/tools.c b/src/tools.c index 38f5dd7b..1e7fef67 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1559,6 +1559,24 @@ void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) getSizedGraphicSource(graphic, 0, MINI_TILESIZE, bitmap, x, y); } +void getGlobalAnimGraphicSource(int graphic, int frame, + Bitmap **bitmap, int *x, int *y) +{ + 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]; + + // use original size graphics, if existing, else use standard size graphics + if (g->bitmaps[IMG_BITMAP_PTR_ORIGINAL]) + *bitmap = g->bitmaps[IMG_BITMAP_PTR_ORIGINAL]; + else + *bitmap = g->bitmaps[IMG_BITMAP_STANDARD]; + + getGraphicSourceXY(graphic, frame, x, y, FALSE); +} + static void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, int *x, int *y, boolean get_backside) { diff --git a/src/tools.h b/src/tools.h index cb8c9343..5a02dd11 100644 --- a/src/tools.h +++ b/src/tools.h @@ -150,6 +150,7 @@ void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean); void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *); void getFixedGraphicSource(int, int, Bitmap **, int *, int *); void getMiniGraphicSource(int, Bitmap **, int *, int *); +void getGlobalAnimGraphicSource(int, int, Bitmap **, int *, int *); void getGraphicSource(int, int, Bitmap **, int *, int *); void DrawGraphic(int, int, int, int);