1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Use mutex to protect scrolling banner cache from data race

This commit is contained in:
Matt
2019-03-31 16:52:16 +02:00
parent 1153b97ace
commit 4e264bd45d

View File

@@ -17,6 +17,7 @@
#include "TTF.h"
#include <algorithm>
#include <mutex>
#pragma pack(push, 1)
/* size: 0xA12 */
@@ -38,6 +39,7 @@ assert_struct_size(rct_draw_scroll_text, 0xA12);
static rct_draw_scroll_text _drawScrollTextList[MAX_SCROLLING_TEXT_ENTRIES];
static uint8_t _characterBitmaps[FONT_SPRITE_GLYPH_COUNT + SPR_G2_GLYPH_COUNT][8];
static uint32_t _drawSCrollNextIndex = 0;
static std::mutex _scrollingTextMutex;
static void scrolling_text_set_bitmap_for_sprite(
utf8* text, int32_t scroll, uint8_t* bitmap, const int16_t* scrollPositionOffsets);
@@ -1472,6 +1474,8 @@ void scrolling_text_invalidate()
*/
int32_t scrolling_text_setup(paint_session* session, rct_string_id stringId, uint16_t scroll, uint16_t scrollingMode)
{
std::scoped_lock<std::mutex> lock(_scrollingTextMutex);
assert(scrollingMode < MAX_SCROLLING_TEXT_MODES);
rct_drawpixelinfo* dpi = &session->DPI;