Fix #4511: Crash, invalid scrolling mode for banner

Do not attempt to draw banners with an invalid scrolling mode. Some custom objects use 255 for scrolling mode as they don't actually have scrolling text.
This commit is contained in:
Ted John 2016-10-01 17:33:30 +01:00
parent ee896a481e
commit b18d053a18
3 changed files with 9 additions and 1 deletions

View File

@ -122,6 +122,8 @@ typedef struct rct_palette {
#define PALETTE_TO_G1_OFFSET_COUNT 144
#define MAX_SCROLLING_TEXT_MODES 38
extern sint16 gCurrentFontSpriteBase;
extern uint16 gCurrentFontFlags;

View File

@ -1365,7 +1365,7 @@ static const sint16 _scrollpos37[] = {
-1,
};
static const sint16* _scrollPositions[38] = {
static const sint16* _scrollPositions[MAX_SCROLLING_TEXT_MODES] = {
_scrollpos0,
_scrollpos1,
_scrollpos2,
@ -1416,6 +1416,8 @@ static const sint16* _scrollPositions[38] = {
*/
int scrolling_text_setup(rct_string_id stringId, uint16 scroll, uint16 scrollingMode)
{
assert(scrollingMode < MAX_SCROLLING_TEXT_MODES);
rct_drawpixelinfo* dpi = unk_140E9A8;
if (dpi->zoom_level != 0) return SPR_SCROLLING_TEXT_DEFAULT;

View File

@ -83,6 +83,10 @@ void banner_paint(uint8 direction, int height, rct_map_element* map_element)
if (direction >= 2 || (map_element->flags & MAP_ELEMENT_FLAG_GHOST)) return;
uint16 scrollingMode = banner_scenery->banner.scrolling_mode;
if (scrollingMode >= MAX_SCROLLING_TEXT_MODES) {
return;
}
scrollingMode += direction;
set_format_arg(0, uint32, 0);