diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index a8f36abd52..fa42ebdfce 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -234,7 +234,7 @@ static void window_install_track_paint(rct_window *w, rct_drawpixelinfo *dpi) g1temp.height = 217; g1temp.flags = G1_FLAG_BMP; gfx_set_g1_element(SPR_TEMP, &g1temp); - gfx_draw_sprite(dpi, 0, x, y, 0); + gfx_draw_sprite(dpi, SPR_TEMP, x, y, 0); x = w->x + (widget->left + widget->right) / 2; y = w->y + widget->bottom - 12; diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index d3adf06440..c7d99d06f0 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -472,7 +472,7 @@ static void window_track_place_paint(rct_window *w, rct_drawpixelinfo *dpi) g1temp.width = TRACK_MINI_PREVIEW_WIDTH; g1temp.height = TRACK_MINI_PREVIEW_HEIGHT; gfx_set_g1_element(SPR_TEMP, &g1temp); - gfx_draw_sprite(&clippedDpi, SPRITE_ID_PALETTE_COLOUR_1(NOT_TRANSLUCENT(w->colours[0])), 0, 0, 0); + gfx_draw_sprite(&clippedDpi, SPR_TEMP | SPRITE_ID_PALETTE_COLOUR_1(NOT_TRANSLUCENT(w->colours[0])), 0, 0, 0); } // Price diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 4613b54307..6fd0d66a84 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -429,7 +429,7 @@ static void window_track_list_paint(rct_window *w, rct_drawpixelinfo *dpi) g1temp.height = 217; g1temp.flags = G1_FLAG_BMP; gfx_set_g1_element(SPR_TEMP, &g1temp); - gfx_draw_sprite(dpi, 0, x, y, 0); + gfx_draw_sprite(dpi, SPR_TEMP, x, y, 0); x = w->x + (widget->left + widget->right) / 2; y = w->y + widget->bottom - 12; diff --git a/src/openrct2/drawing/Sprite.cpp b/src/openrct2/drawing/Sprite.cpp index ceef901fff..f7fd500d32 100644 --- a/src/openrct2/drawing/Sprite.cpp +++ b/src/openrct2/drawing/Sprite.cpp @@ -167,6 +167,7 @@ extern "C" #else static rct_g1_element * _g1Elements = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element); #endif + static rct_g1_element _g1Temp = { 0 }; bool gTinyFontAntiAliased = false; /** @@ -754,7 +755,11 @@ extern "C" return nullptr; } - if (image_id < SPR_G2_BEGIN) + if (image_id == SPR_TEMP) + { + return &_g1Temp; + } + else if (image_id < SPR_G2_BEGIN) { if (image_id >= (sint32)_g1ElementsCount) { @@ -791,11 +796,15 @@ extern "C" { openrct2_assert(!gOpenRCT2NoGraphics, "gfx_set_g1_element called on headless instance"); #ifdef DEBUG - openrct2_assert(imageId >= 0 && imageId < SPR_G2_BEGIN, "gfx_set_g1_element called with unexpected image id"); + openrct2_assert((imageId >= 0 && imageId < SPR_G2_BEGIN) || imageId == SPR_TEMP, "gfx_set_g1_element called with unexpected image id"); openrct2_assert(g1 != nullptr, "g1 was nullptr"); #endif - if (imageId >= 0 || imageId < SPR_G2_BEGIN) + if (imageId == SPR_TEMP) + { + _g1Temp = *g1; + } + else if (imageId >= 0 || imageId < SPR_G2_BEGIN) { if (imageId < (sint32)_g1ElementsCount) { diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index 332a0c8f76..0204e0f6a9 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -19,7 +19,9 @@ enum { SPR_NONE = -1, - SPR_TEMP = 0, + + // Used for on-demand drawing of dynamic memory + SPR_TEMP = 0x70000, SPR_SCROLLING_TEXT_START = 1542, SPR_SCROLLING_TEXT_DEFAULT = 1574,