Fix: Unable to change colours of scrolling wall banner sign via sign dialog (#9303)

1. Check in SignSetStlyeAction query was accidentally inverting value of
   wallFound boolean
2. Code in action execution was not looping through the tile elements to find
   the correct wall piece like the query did (which meant just fixing 1. would
   cause a segfault)

Moved code to find relevant wall tile element into new helper function
banner_get_scrolling_wall_tile_element() in Banner; use in both query and action
to avoid any duplication of search logic.
This commit is contained in:
James Warwood 2019-05-30 09:33:13 +01:00 committed by Michael Steenbeek
parent 4d7c78fa3a
commit 67f1359936
4 changed files with 35 additions and 21 deletions

View File

@ -77,23 +77,9 @@ public:
}
else
{
TileElement* tileElement = map_get_first_element_at(coords.x / 32, coords.y / 32);
bool wallFound = false;
do
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
WallElement* wallElement = banner_get_scrolling_wall_tile_element(static_cast<BannerIndex>(_bannerIndex));
rct_scenery_entry* scenery_entry = tileElement->AsWall()->GetEntry();
if (scenery_entry->wall.scrolling_mode == SCROLLING_MODE_NONE)
continue;
if (tileElement->AsWall()->GetBannerIndex() != (BannerIndex)_bannerIndex)
continue;
wallFound = true;
break;
} while (!(tileElement++)->IsLastForTile());
if (!wallFound == false)
if (!wallElement)
{
log_warning("Invalid game command for setting sign style, banner id '%d' not found", _bannerIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
@ -121,10 +107,11 @@ public:
}
else
{
TileElement* tileElement = map_get_first_element_at(coords.x / 32, coords.y / 32);
tileElement->AsWall()->SetPrimaryColour(_mainColour);
tileElement->AsWall()->SetSecondaryColour(_textColour);
map_invalidate_tile(coords.x, coords.y, tileElement->base_height * 8, tileElement->clearance_height * 8);
WallElement* wallElement = banner_get_scrolling_wall_tile_element(static_cast<BannerIndex>(_bannerIndex));
wallElement->SetPrimaryColour(_mainColour);
wallElement->SetSecondaryColour(_textColour);
map_invalidate_tile(coords.x, coords.y, wallElement->base_height * 8, wallElement->clearance_height * 8);
}
auto intent = Intent(INTENT_ACTION_UPDATE_BANNER);

View File

@ -33,7 +33,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "35"
#define NETWORK_STREAM_VERSION "36"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -128,6 +128,32 @@ TileElement* banner_get_tile_element(BannerIndex bannerIndex)
return nullptr;
}
WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex)
{
rct_banner* banner = &gBanners[bannerIndex];
TileElement* tileElement = map_get_first_element_at(banner->x, banner->y);
if (tileElement == nullptr)
return nullptr;
do
{
auto wallElement = tileElement->AsWall();
if (wallElement == nullptr)
continue;
rct_scenery_entry* scenery_entry = wallElement->GetEntry();
if (scenery_entry->wall.scrolling_mode == SCROLLING_MODE_NONE)
continue;
if (wallElement->GetBannerIndex() != bannerIndex)
continue;
return wallElement;
} while (!(tileElement++)->IsLastForTile());
return nullptr;
}
/**
*
* rct2: 0x006B7D86

View File

@ -49,6 +49,7 @@ extern rct_banner gBanners[MAX_BANNERS];
void banner_init();
BannerIndex create_new_banner(uint8_t flags);
TileElement* banner_get_tile_element(BannerIndex bannerIndex);
WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex);
uint8_t banner_get_closest_ride_index(int32_t x, int32_t y, int32_t z);
void banner_reset_broken_index();
void fix_duplicated_banners();