mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 04:23:20 +01:00
Check for banner index correctly
At some places, BANNER_NULL and BANNER_INDEX_NULL were mixed, and at one point even MAX_BANNERS, causing the 250th banner to not be initialized properly. This commit makes the uses of those defines correct, and changes all relevant functions to return uint8 instead of sint32.
This commit is contained in:
@@ -693,7 +693,7 @@ void scenario_fix_ghosts(rct_s6_data *s6)
|
||||
rct_tile_element *originalElement = map_get_first_element_at(x, y);
|
||||
do {
|
||||
if (originalElement->flags & TILE_ELEMENT_FLAG_GHOST) {
|
||||
sint32 bannerIndex = tile_element_get_banner_index(originalElement);
|
||||
uint8 bannerIndex = tile_element_get_banner_index(originalElement);
|
||||
if (bannerIndex != BANNER_INDEX_NULL) {
|
||||
rct_banner *banner = &s6->banners[bannerIndex];
|
||||
if (banner->type != BANNER_NULL)
|
||||
|
||||
@@ -356,7 +356,7 @@ static uint8 BannerGetNewIndex() {
|
||||
return bannerIndex;
|
||||
}
|
||||
}
|
||||
return BANNER_NULL;
|
||||
return BANNER_INDEX_NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,10 +382,10 @@ sint32 create_new_banner(uint8 flags)
|
||||
{
|
||||
uint8 bannerIndex = BannerGetNewIndex();
|
||||
|
||||
if (bannerIndex == BANNER_NULL)
|
||||
if (bannerIndex == BANNER_INDEX_NULL)
|
||||
{
|
||||
gGameCommandErrorText = STR_TOO_MANY_BANNERS_IN_GAME;
|
||||
return BANNER_NULL;
|
||||
return bannerIndex;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
@@ -401,7 +401,7 @@ sint32 create_new_banner(uint8 flags)
|
||||
return bannerIndex;
|
||||
}
|
||||
|
||||
rct_tile_element *banner_get_tile_element(sint32 bannerIndex)
|
||||
rct_tile_element* banner_get_tile_element(uint8 bannerIndex)
|
||||
{
|
||||
rct_banner *banner = &gBanners[bannerIndex];
|
||||
rct_tile_element *tileElement = map_get_first_element_at(banner->x, banner->y);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#define BANNER_NULL 255
|
||||
#define MAX_BANNERS 250
|
||||
#define BANNER_INDEX_NULL -1
|
||||
#define BANNER_INDEX_NULL ((uint8)-1)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct rct_banner
|
||||
@@ -54,7 +54,7 @@ extern rct_banner gBanners[MAX_BANNERS];
|
||||
|
||||
void banner_init();
|
||||
sint32 create_new_banner(uint8 flags);
|
||||
rct_tile_element *banner_get_tile_element(sint32 bannerIndex);
|
||||
rct_tile_element* banner_get_tile_element(uint8 bannerIndex);
|
||||
uint8 banner_get_closest_ride_index(sint32 x, sint32 y, sint32 z);
|
||||
void banner_reset_broken_index();
|
||||
void fix_duplicated_banners();
|
||||
|
||||
@@ -42,7 +42,7 @@ void scenery_large_set_secondary_colour(rct_tile_element * tileElement, colour_t
|
||||
tileElement->properties.scenerymultiple.colour[1] |= colour;
|
||||
}
|
||||
|
||||
sint32 scenery_large_get_banner_id(const rct_tile_element * tileElement)
|
||||
uint8 scenery_large_get_banner_id(const rct_tile_element * tileElement)
|
||||
{
|
||||
return (tileElement->type & 0xC0) |
|
||||
(((tileElement->properties.scenerymultiple.colour[0]) &~ TILE_ELEMENT_COLOUR_MASK) >> 2) |
|
||||
|
||||
@@ -24,7 +24,7 @@ colour_t scenery_large_get_primary_colour(const rct_tile_element * tileElement);
|
||||
colour_t scenery_large_get_secondary_colour(const rct_tile_element * tileElement);
|
||||
void scenery_large_set_primary_colour(rct_tile_element * tileElement, colour_t colour);
|
||||
void scenery_large_set_secondary_colour(rct_tile_element * tileElement, colour_t colour);
|
||||
sint32 scenery_large_get_banner_id(const rct_tile_element * tileElement);
|
||||
uint8 scenery_large_get_banner_id(const rct_tile_element* tileElement);
|
||||
void scenery_large_set_banner_id(rct_tile_element * tileElement, uint8 bannerIndex);
|
||||
sint32 scenery_large_get_type(const rct_tile_element * tileElement);
|
||||
sint32 scenery_large_get_sequence(const rct_tile_element * tileElement);
|
||||
|
||||
@@ -2793,7 +2793,7 @@ void game_command_place_large_scenery(
|
||||
gCommandPosition.y = y + 16;
|
||||
gCommandPosition.z = base_height;
|
||||
gSceneryGroundFlags = 0;
|
||||
uint8 banner_id = (uint8)BANNER_INDEX_NULL;
|
||||
uint8 banner_id = BANNER_INDEX_NULL;
|
||||
money32 supportsCost = 0;
|
||||
|
||||
if (game_is_paused() && !gCheatsBuildInPauseMode) {
|
||||
@@ -2821,7 +2821,8 @@ void game_command_place_large_scenery(
|
||||
{
|
||||
banner_id = create_new_banner(flags);
|
||||
|
||||
if (banner_id == MAX_BANNERS) {
|
||||
if (banner_id == BANNER_INDEX_NULL)
|
||||
{
|
||||
*ebx = MONEY32_UNDEFINED;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ bool tile_element_is_underground(rct_tile_element * tileElement)
|
||||
return true;
|
||||
}
|
||||
|
||||
sint32 tile_element_get_banner_index(rct_tile_element * tileElement)
|
||||
uint8 tile_element_get_banner_index(rct_tile_element* tileElement)
|
||||
{
|
||||
rct_scenery_entry* sceneryEntry;
|
||||
|
||||
@@ -135,7 +135,7 @@ void tile_element_set_banner_index(rct_tile_element * tileElement, sint32 banner
|
||||
|
||||
void tile_element_remove_banner_entry(rct_tile_element * tileElement)
|
||||
{
|
||||
sint32 bannerIndex = tile_element_get_banner_index(tileElement);
|
||||
uint8 bannerIndex = tile_element_get_banner_index(tileElement);
|
||||
if (bannerIndex == BANNER_INDEX_NULL)
|
||||
return;
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ enum
|
||||
|
||||
sint32 tile_element_get_direction(const rct_tile_element * element);
|
||||
sint32 tile_element_get_direction_with_offset(const rct_tile_element * element, uint8 offset);
|
||||
sint32 tile_element_get_banner_index(rct_tile_element * tileElement);
|
||||
uint8 tile_element_get_banner_index(rct_tile_element* tileElement);
|
||||
bool tile_element_is_ghost(const rct_tile_element * element);
|
||||
bool tile_element_is_underground(rct_tile_element * tileElement);
|
||||
bool tile_element_is_last_for_tile(const rct_tile_element *element);
|
||||
|
||||
@@ -304,7 +304,7 @@ sint32 tile_inspector_paste_element_at(sint32 x, sint32 y, rct_tile_element elem
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
// Check if the element to be pasted refers to a banner index
|
||||
sint32 bannerIndex = tile_element_get_banner_index(&element);
|
||||
uint8 bannerIndex = tile_element_get_banner_index(&element);
|
||||
if (bannerIndex != BANNER_INDEX_NULL)
|
||||
{
|
||||
// The element to be pasted refers to a banner index - make a copy of it
|
||||
|
||||
Reference in New Issue
Block a user