mirror of https://github.com/OpenRCT2/OpenRCT2.git
Replace C-style functions for checking getting path additions
This commit is contained in:
parent
ee05438953
commit
ecd6247462
|
@ -362,7 +362,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
|
|||
return info->type;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
|
||||
sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
||||
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
|
||||
{
|
||||
|
|
|
@ -1813,9 +1813,9 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_PATH_NAME, &pathNameId, COLOUR_DARK_GREEN, x, y);
|
||||
|
||||
// Path addition
|
||||
if (footpath_element_has_path_scenery(tileElement))
|
||||
if (tileElement->AsPath()->HasAddition())
|
||||
{
|
||||
const uint8_t pathAdditionType = footpath_element_get_path_scenery_index(tileElement);
|
||||
const uint8_t pathAdditionType = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
rct_string_id additionNameId = get_footpath_item_entry(pathAdditionType)->name;
|
||||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_PATH_ADDITIONS, &additionNameId, COLOUR_DARK_GREEN, x, y + 11);
|
||||
}
|
||||
|
|
|
@ -1129,7 +1129,7 @@ static void scenery_eyedropper_tool_down(int16_t x, int16_t y, rct_widgetindex w
|
|||
}
|
||||
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
|
||||
{
|
||||
int32_t entryIndex = footpath_element_get_path_scenery_index(tileElement);
|
||||
int32_t entryIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(entryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ static void cheat_fix_vandalism()
|
|||
if (it.element->GetType() != TILE_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
|
||||
if (!footpath_element_has_path_scenery(it.element))
|
||||
if (!(it.element)->AsPath()->HasAddition())
|
||||
continue;
|
||||
|
||||
it.element->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
|
||||
|
@ -138,10 +138,10 @@ static void cheat_remove_litter()
|
|||
if (it.element->GetType() != TILE_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
|
||||
if (!footpath_element_has_path_scenery(it.element))
|
||||
if (!(it.element)->AsPath()->HasAddition())
|
||||
continue;
|
||||
|
||||
sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(it.element));
|
||||
sceneryEntry = it.element->AsPath()->GetAdditionEntry();
|
||||
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)
|
||||
it.element->properties.path.addition_status = 0xFF;
|
||||
|
||||
|
|
|
@ -136,9 +136,9 @@ void setup_in_use_selection_flags()
|
|||
assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]);
|
||||
Editor::SetSelectedObject(OBJECT_TYPE_PATHS, type, OBJECT_SELECTION_FLAG_SELECTED);
|
||||
|
||||
if (footpath_element_has_path_scenery(iter.element))
|
||||
if (iter.element->AsPath()->HasAddition())
|
||||
{
|
||||
uint8_t path_additions = footpath_element_get_path_scenery_index(iter.element);
|
||||
uint8_t path_additions = iter.element->AsPath()->GetAdditionEntryIndex();
|
||||
Editor::SetSelectedObject(OBJECT_TYPE_PATH_BITS, path_additions, OBJECT_SELECTION_FLAG_SELECTED);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -682,7 +682,7 @@ static void sub_6A3F61(
|
|||
{
|
||||
if (!gTrackDesignSaveMode)
|
||||
{
|
||||
if (footpath_element_has_path_scenery(tile_element))
|
||||
if (tile_element->AsPath()->HasAddition())
|
||||
{
|
||||
session->InteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM;
|
||||
if (sceneryImageFlags != 0)
|
||||
|
@ -691,8 +691,7 @@ static void sub_6A3F61(
|
|||
}
|
||||
|
||||
// Draw additional path bits (bins, benches, lamps, queue screens)
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(
|
||||
footpath_element_get_path_scenery_index(tile_element));
|
||||
rct_scenery_entry* sceneryEntry = tile_element->AsPath()->GetAdditionEntry();
|
||||
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
|
||||
&& !(tile_element->flags & TILE_ELEMENT_FLAG_BROKEN)
|
||||
|
@ -939,9 +938,9 @@ void path_paint(paint_session* session, uint16_t height, const rct_tile_element*
|
|||
#ifdef __ENABLE_LIGHTFX__
|
||||
if (lightfx_is_available())
|
||||
{
|
||||
if (footpath_element_has_path_scenery(tile_element) && !(tile_element->flags & TILE_ELEMENT_FLAG_BROKEN))
|
||||
if (tile_element->AsPath()->HasAddition() && !(tile_element->flags & TILE_ELEMENT_FLAG_BROKEN))
|
||||
{
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tile_element));
|
||||
rct_scenery_entry* sceneryEntry = tile_element->AsPath()->GetAdditionEntry();
|
||||
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_LAMP)
|
||||
{
|
||||
if (!(tile_element->properties.path.edges & EDGE_NE))
|
||||
|
|
|
@ -640,10 +640,10 @@ void rct_peep::Tick128UpdateGuest(int32_t index)
|
|||
continue;
|
||||
|
||||
// Check if the footpath has a queue line TV monitor on it
|
||||
if (footpath_element_has_path_scenery(tileElement)
|
||||
if (tileElement->AsPath()->HasAddition()
|
||||
&& !tileElement->AsPath()->AdditionIsGhost())
|
||||
{
|
||||
uint8_t pathSceneryIndex = footpath_element_get_path_scenery_index(tileElement);
|
||||
uint8_t pathSceneryIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex);
|
||||
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN)
|
||||
{
|
||||
|
@ -2718,10 +2718,10 @@ static uint8_t peep_assess_surroundings(int16_t centre_x, int16_t centre_y, int1
|
|||
switch (tileElement->GetType())
|
||||
{
|
||||
case TILE_ELEMENT_TYPE_PATH:
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
break;
|
||||
|
||||
scenery = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
scenery = tileElement->AsPath()->GetAdditionEntry();
|
||||
if (scenery == nullptr)
|
||||
{
|
||||
return PEEP_THOUGHT_TYPE_NONE;
|
||||
|
@ -5318,11 +5318,11 @@ void rct_peep::UpdateWalking()
|
|||
|
||||
int32_t positions_free = 15;
|
||||
|
||||
if (footpath_element_has_path_scenery(tileElement))
|
||||
if (tileElement->AsPath()->HasAddition())
|
||||
{
|
||||
if (!tileElement->AsPath()->AdditionIsGhost())
|
||||
{
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
|
@ -5753,13 +5753,13 @@ void rct_peep::UpdateUsingBin()
|
|||
}
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
{
|
||||
StateReset();
|
||||
return;
|
||||
}
|
||||
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
||||
{
|
||||
StateReset();
|
||||
|
@ -5920,9 +5920,9 @@ bool rct_peep::UpdateWalkingFindBench()
|
|||
}
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
return false;
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
|
||||
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
||||
return false;
|
||||
|
@ -6015,9 +6015,9 @@ bool rct_peep::UpdateWalkingFindBin()
|
|||
}
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
return false;
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
return false;
|
||||
|
@ -6116,9 +6116,9 @@ static void peep_update_walking_break_scenery(rct_peep* peep)
|
|||
}
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
return;
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BREAKABLE))
|
||||
return;
|
||||
|
|
|
@ -2878,7 +2878,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, rct_ti
|
|||
{
|
||||
// 0x00F1AEE2
|
||||
bool vandalism_present = false;
|
||||
if (footpath_element_has_path_scenery(tile_element) && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN)
|
||||
if (tile_element->AsPath()->HasAddition() && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN)
|
||||
&& (tile_element->properties.path.edges & 0xF) != 0xF)
|
||||
{
|
||||
vandalism_present = true;
|
||||
|
|
|
@ -1810,13 +1810,13 @@ void rct_peep::UpdateEmptyingBin()
|
|||
}
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tile_element))
|
||||
if (!tile_element->AsPath()->HasAddition())
|
||||
{
|
||||
StateReset();
|
||||
return;
|
||||
}
|
||||
|
||||
rct_scenery_entry* scenery_entry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tile_element));
|
||||
rct_scenery_entry* scenery_entry = tile_element->AsPath()->GetAdditionEntry();
|
||||
if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->flags & (1 << 5)
|
||||
|| tile_element->AsPath()->AdditionIsGhost())
|
||||
{
|
||||
|
@ -2210,9 +2210,9 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
return 0;
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
||||
return 0;
|
||||
|
|
|
@ -2514,7 +2514,7 @@ private:
|
|||
tileElement->AsPath()->SetAdditionIsGhost(false);
|
||||
|
||||
// Additions
|
||||
uint8_t additionType = footpath_element_get_path_scenery(tileElement);
|
||||
uint8_t additionType = tileElement->AsPath()->GetAddition();
|
||||
if (additionType != RCT1_PATH_ADDITION_NONE)
|
||||
{
|
||||
uint8_t normalisedType = RCT1::NormalisePathAddition(additionType);
|
||||
|
@ -2523,7 +2523,7 @@ private:
|
|||
{
|
||||
tileElement->flags |= TILE_ELEMENT_FLAG_BROKEN;
|
||||
}
|
||||
footpath_element_set_path_scenery(tileElement, entryIndex + 1);
|
||||
tileElement->AsPath()->SetAddition(entryIndex + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ static money32 footpath_element_update(
|
|||
}
|
||||
else if (pathItemType != 0)
|
||||
{
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST) && footpath_element_get_path_scenery(tileElement) == pathItemType
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST) && tileElement->AsPath()->GetAddition() == pathItemType
|
||||
&& !(tileElement->flags & TILE_ELEMENT_FLAG_BROKEN))
|
||||
{
|
||||
if (flags & GAME_COMMAND_FLAG_4)
|
||||
|
@ -357,7 +357,7 @@ static money32 footpath_element_update(
|
|||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
// Check if there is something on the path already
|
||||
if (footpath_element_has_path_scenery(tileElement))
|
||||
if (tileElement->AsPath()->HasAddition())
|
||||
{
|
||||
gGameCommandErrorText = STR_NONE;
|
||||
return MONEY32_UNDEFINED;
|
||||
|
@ -377,7 +377,7 @@ static money32 footpath_element_update(
|
|||
tileElement->AsPath()->SetAdditionIsGhost(false);
|
||||
}
|
||||
|
||||
footpath_element_set_path_scenery(tileElement, pathItemType);
|
||||
tileElement->AsPath()->SetAddition(pathItemType);
|
||||
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
|
||||
if (pathItemType != 0)
|
||||
{
|
||||
|
@ -404,7 +404,7 @@ static money32 footpath_element_update(
|
|||
footpath_element_set_type(tileElement, type);
|
||||
|
||||
tileElement->type = (tileElement->type & 0xFE) | (type >> 7);
|
||||
footpath_element_set_path_scenery(tileElement, pathItemType);
|
||||
tileElement->AsPath()->SetAddition(pathItemType);
|
||||
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
|
||||
|
||||
loc_6A6620(flags, x, y, tileElement);
|
||||
|
@ -2004,25 +2004,30 @@ void PathElement::SetWide(bool isWide)
|
|||
type |= FOOTPATH_ELEMENT_TYPE_FLAG_IS_WIDE;
|
||||
}
|
||||
|
||||
bool footpath_element_has_path_scenery(const rct_tile_element* tileElement)
|
||||
bool PathElement::HasAddition() const
|
||||
{
|
||||
return footpath_element_get_path_scenery(tileElement) != 0;
|
||||
return (additions & FOOTPATH_PROPERTIES_ADDITIONS_TYPE_MASK) != 0;
|
||||
}
|
||||
|
||||
uint8_t footpath_element_get_path_scenery(const rct_tile_element* tileElement)
|
||||
uint8_t PathElement::GetAddition() const
|
||||
{
|
||||
return tileElement->properties.path.additions & FOOTPATH_PROPERTIES_ADDITIONS_TYPE_MASK;
|
||||
return additions & FOOTPATH_PROPERTIES_ADDITIONS_TYPE_MASK;
|
||||
}
|
||||
|
||||
void footpath_element_set_path_scenery(rct_tile_element* tileElement, uint8_t pathSceneryType)
|
||||
uint8_t PathElement::GetAdditionEntryIndex() const
|
||||
{
|
||||
tileElement->properties.path.additions &= ~FOOTPATH_PROPERTIES_ADDITIONS_TYPE_MASK;
|
||||
tileElement->properties.path.additions |= pathSceneryType;
|
||||
return GetAddition() - 1;
|
||||
}
|
||||
|
||||
uint8_t footpath_element_get_path_scenery_index(const rct_tile_element* tileElement)
|
||||
rct_scenery_entry* PathElement::GetAdditionEntry() const
|
||||
{
|
||||
return footpath_element_get_path_scenery(tileElement) - 1;
|
||||
return get_footpath_item_entry(GetAdditionEntryIndex());
|
||||
}
|
||||
|
||||
void PathElement::SetAddition(uint8_t newAddition)
|
||||
{
|
||||
additions &= ~FOOTPATH_PROPERTIES_ADDITIONS_TYPE_MASK;
|
||||
additions |= newAddition;
|
||||
}
|
||||
|
||||
bool PathElement::AdditionIsGhost() const
|
||||
|
|
|
@ -159,10 +159,6 @@ uint8_t footpath_element_get_type(const rct_tile_element* tileElement);
|
|||
void footpath_element_set_type(rct_tile_element* tileElement, uint8_t type);
|
||||
uint8_t footpath_element_get_direction(const rct_tile_element* tileElement);
|
||||
void footpath_element_set_direction(rct_tile_element* tileElement, uint8_t direction);
|
||||
bool footpath_element_has_path_scenery(const rct_tile_element* tileElement);
|
||||
uint8_t footpath_element_get_path_scenery(const rct_tile_element* tileElement);
|
||||
void footpath_element_set_path_scenery(rct_tile_element* tileElement, uint8_t pathSceneryType);
|
||||
uint8_t footpath_element_get_path_scenery_index(const rct_tile_element* tileElement);
|
||||
void footpath_remove_edges_at(int32_t x, int32_t y, rct_tile_element* tileElement);
|
||||
int32_t entrance_get_directions(const rct_tile_element* tileElement);
|
||||
|
||||
|
|
|
@ -261,10 +261,10 @@ static bool is_jumping_fountain(int32_t type, int32_t x, int32_t y, int32_t z)
|
|||
continue;
|
||||
if (tileElement->AsPath()->AdditionIsGhost())
|
||||
continue;
|
||||
if (!footpath_element_has_path_scenery(tileElement))
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
continue;
|
||||
|
||||
uint8_t additionIndex = footpath_element_get_path_scenery_index(tileElement);
|
||||
uint8_t additionIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(additionIndex);
|
||||
if (sceneryEntry != reinterpret_cast<void*>(-1) && sceneryEntry->path_bit.flags & pathBitFlagMask)
|
||||
{
|
||||
|
|
|
@ -88,9 +88,9 @@ void scenery_update_tile(int32_t x, int32_t y)
|
|||
}
|
||||
else if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (footpath_element_has_path_scenery(tileElement) && !tileElement->AsPath()->AdditionIsGhost())
|
||||
if (tileElement->AsPath()->HasAddition() && !tileElement->AsPath()->AdditionIsGhost())
|
||||
{
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement));
|
||||
rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER)
|
||||
|
|
|
@ -202,11 +202,17 @@ public:
|
|||
|
||||
bool IsWide() const;
|
||||
void SetWide(bool isWide);
|
||||
|
||||
|
||||
bool IsQueue() const;
|
||||
void SetIsQueue(bool isQueue);
|
||||
bool HasQueueBanner() const;
|
||||
|
||||
bool HasAddition() const;
|
||||
uint8_t GetAddition() const;
|
||||
uint8_t GetAdditionEntryIndex() const;
|
||||
rct_scenery_entry* GetAdditionEntry() const;
|
||||
void SetAddition(uint8_t newAddition);
|
||||
|
||||
bool AdditionIsGhost() const;
|
||||
void SetAdditionIsGhost(bool isGhost);
|
||||
|
||||
|
|
Loading…
Reference in New Issue