Use IsGhost() to access ghost state

Added set and clear ghost to further prevent direct access to flags
This commit is contained in:
duncanspumpkin 2019-02-25 15:08:49 +00:00
parent f769779f0d
commit 737c308e4e
29 changed files with 61 additions and 45 deletions

View File

@ -2185,7 +2185,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo*
const int32_t baseHeight = tileElement->base_height;
const int32_t clearanceHeight = tileElement->clearance_height;
const bool ghost = (tileElement->flags & TILE_ELEMENT_FLAG_GHOST) != 0;
const bool ghost = (tileElement->IsGhost()) != 0;
const bool broken = (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) != 0;
const bool last = (tileElement->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0;

View File

@ -237,7 +237,7 @@ public:
if (flags & GAME_COMMAND_FLAG_GHOST)
{
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
tileElement->SetGhost();
}
map_invalidate_tile_full(flooredX, flooredY);

View File

@ -170,7 +170,7 @@ public:
if (flags & GAME_COMMAND_FLAG_GHOST)
{
newElement->flags |= TILE_ELEMENT_FLAG_GHOST;
newElement->SetGhost();
}
entranceElement->SetDirection(_direction);

View File

@ -616,7 +616,7 @@ public:
tileElement->AsTrack()->SetTrackType(_trackType);
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
{
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
tileElement->SetGhost();
}
switch (_trackType)

View File

@ -442,7 +442,7 @@ public:
invalidate_test_results(ride);
footpath_queue_chain_reset();
if (!gCheatsDisableClearanceChecks || !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if (!gCheatsDisableClearanceChecks || !(tileElement->IsGhost()))
{
footpath_remove_edges_at(mapLoc.x, mapLoc.y, tileElement);
}

View File

@ -277,7 +277,7 @@ static void virtual_floor_get_tile_properties(
continue;
}
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
{
*outLit = true;
continue;

View File

@ -60,7 +60,7 @@ void banner_paint(paint_session* session, uint8_t direction, int32_t height, con
uint32_t base_id = (direction << 1) + banner_scenery->image;
uint32_t image_id = base_id;
if (tile_element->flags & TILE_ELEMENT_FLAG_GHOST) // if being placed
if (tile_element->IsGhost()) // if being placed
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
image_id |= CONSTRUCTION_MARKER;
@ -81,7 +81,7 @@ void banner_paint(paint_session* session, uint8_t direction, int32_t height, con
direction = direction_reverse(direction);
direction--;
// If text not showing / ghost
if (direction >= 2 || (tile_element->flags & TILE_ELEMENT_FLAG_GHOST))
if (direction >= 2 || (tile_element->IsGhost()))
return;
uint16_t scrollingMode = banner_scenery->banner.scrolling_mode;

View File

@ -91,7 +91,7 @@ static void ride_entrance_exit_paint(paint_session* session, uint8_t direction,
session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
_unk9E32BC = 0;
if (tile_element->flags & TILE_ELEMENT_FLAG_GHOST)
if (tile_element->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
image_id = CONSTRUCTION_MARKER;
@ -157,7 +157,7 @@ static void ride_entrance_exit_paint(paint_session* session, uint8_t direction,
paint_util_push_tunnel_left(session, height, TUNNEL_6);
}
if (!is_exit && !(tile_element->flags & TILE_ELEMENT_FLAG_GHOST) && tile_element->AsEntrance()->GetRideIndex() != 0xFF
if (!is_exit && !(tile_element->IsGhost()) && tile_element->AsEntrance()->GetRideIndex() != 0xFF
&& stationObj->ScrollingMode != 0xFF)
{
set_format_arg(0, uint32_t, 0);
@ -225,7 +225,7 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32
session->InteractionType = VIEWPORT_INTERACTION_ITEM_PARK;
_unk9E32BC = 0;
uint32_t image_id, ghost_id = 0;
if (tile_element->flags & TILE_ELEMENT_FLAG_GHOST)
if (tile_element->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
ghost_id = CONSTRUCTION_MARKER;

View File

@ -248,7 +248,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei
image_id |= dword_F4387C;
}
}
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
sequenceNum = CONSTRUCTION_MARKER;

View File

@ -829,7 +829,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile
sceneryImageFlags = CONSTRUCTION_MARKER;
}
if (tile_element->flags & TILE_ELEMENT_FLAG_GHOST)
if (tile_element->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
imageFlags = CONSTRUCTION_MARKER;

View File

@ -53,7 +53,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co
baseImageid = SPRITE_ID_PALETTE_COLOUR_1(PALETTE_46);
}
}
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
baseImageid = CONSTRUCTION_MARKER;

View File

@ -198,7 +198,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
}
}
if (tile_element->flags & TILE_ELEMENT_FLAG_GHOST)
if (tile_element->IsGhost())
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
dword_141F710 = CONSTRUCTION_MARKER;

View File

@ -238,7 +238,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, TileElement
nextTileElement = map_get_first_element_at(loc.x, loc.y);
do
{
if (nextTileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (nextTileElement->IsGhost())
continue;
if (nextTileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
@ -292,7 +292,7 @@ static uint8_t footpath_element_dest_in_dir(
}
do
{
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
continue;
switch (tileElement->GetType())
@ -643,7 +643,7 @@ static void peep_pathfind_heuristic_search(
/* Look for all map elements that the peep could walk onto while
* navigating to the goal, including the goal tile. */
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
continue;
ride_id_t rideIndex = RIDE_ID_NULL;

View File

@ -3191,7 +3191,7 @@ void rct_peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_res
continue;
if (top_z < tileElement->base_height)
continue;
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
continue;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)

View File

@ -31,6 +31,11 @@ bool RCT12TileElementBase::IsLastForTile() const
return (this->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0;
}
bool RCT12TileElementBase::IsGhost() const
{
return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0;
}
uint8_t RCT12SurfaceElement::GetSlope() const
{
return (slope & TILE_ELEMENT_SURFACE_SLOPE_MASK);

View File

@ -6512,7 +6512,7 @@ bool ride_has_any_track_elements(const Ride* ride)
continue;
if (it.element->AsTrack()->GetRideIndex() != ride->id)
continue;
if (it.element->flags & TILE_ELEMENT_FLAG_GHOST)
if (it.element->IsGhost())
continue;
return true;
@ -6532,7 +6532,7 @@ void ride_all_has_any_track_elements(bool* rideIndexArray)
{
if (it.element->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
if (it.element->flags & TILE_ELEMENT_FLAG_GHOST)
if (it.element->IsGhost())
continue;
rideIndexArray[it.element->AsTrack()->GetRideIndex()] = true;

View File

@ -1170,7 +1170,7 @@ static money32 track_remove(
invalidate_test_results(ride);
footpath_queue_chain_reset();
if (!gCheatsDisableClearanceChecks || !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if (!gCheatsDisableClearanceChecks || !(tileElement->IsGhost()))
{
footpath_remove_edges_at(x, y, tileElement);
}

View File

@ -2129,7 +2129,7 @@ static money32 place_maze_design(uint8_t flags, Ride* ride, uint16_t mazeEntry,
tileElement->AsTrack()->SetMazeEntry(mazeEntry);
if (flags & GAME_COMMAND_FLAG_GHOST)
{
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
tileElement->SetGhost();
}
map_invalidate_element(fx, fy, tileElement);

View File

@ -2199,7 +2199,7 @@ void track_paint(paint_session* session, uint8_t direction, int32_t height, cons
session->TrackColours[SCHEME_MISC] = 0x21600000;
session->TrackColours[SCHEME_3] = 0x21600000;
}
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
{
uint32_t ghost_id = CONSTRUCTION_MARKER;
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;

View File

@ -695,7 +695,7 @@ void scenario_fix_ghosts(rct_s6_data* s6)
RCT12TileElement* originalElement = reinterpret_cast<RCT12TileElement*>(map_get_first_element_at(x, y));
do
{
if (originalElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (originalElement->IsGhost())
{
BannerIndex bannerIndex = tile_element_get_banner_index(reinterpret_cast<TileElement*>(originalElement));
if (bannerIndex != BANNER_INDEX_NULL)

View File

@ -254,7 +254,7 @@ static money32 BannerPlace(
newTileElement->AsBanner()->SetIndex(*bannerIndex);
if (flags & GAME_COMMAND_FLAG_GHOST)
{
newTileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
newTileElement->SetGhost();
}
map_invalidate_tile_full(x, y);
map_animation_create(MAP_ANIMATION_TYPE_BANNER, x, y, newTileElement->base_height);

View File

@ -275,7 +275,7 @@ static money32 RideEntranceExitPlace(
if (flags & GAME_COMMAND_FLAG_GHOST)
{
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
tileElement->SetGhost();
}
if (isExit)
@ -370,7 +370,7 @@ static money32 RideEntranceExitRemove(int16_t x, int16_t y, ride_id_t rideIndex,
if (tileElement->AsEntrance()->GetStationIndex() != stationNum)
continue;
if (flags & GAME_COMMAND_FLAG_5 && !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if (flags & GAME_COMMAND_FLAG_5 && !(tileElement->IsGhost()))
continue;
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)

View File

@ -291,7 +291,7 @@ static money32 footpath_element_insert(
tileElement->AsPath()->SetAdditionStatus(255);
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & GAME_COMMAND_FLAG_GHOST)
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->SetGhost();
footpath_queue_chain_reset();
@ -686,7 +686,7 @@ static money32 footpath_place_from_track(
tileElement->AsPath()->SetCorners(0);
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
if (flags & (1 << 6))
pathElement->flags |= TILE_ELEMENT_FLAG_GHOST;
pathElement->SetGhost();
map_invalidate_tile_full(x, y);
}
@ -1061,7 +1061,7 @@ bool fence_in_the_way(int32_t x, int32_t y, int32_t z0, int32_t z1, int32_t dire
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
continue;
if (z0 >= tileElement->clearance_height)
continue;

View File

@ -283,7 +283,7 @@ TileElement* map_get_path_element_at(int32_t x, int32_t y, int32_t z)
// Find the path element at known z
do
{
if (tileElement->flags & TILE_ELEMENT_FLAG_GHOST)
if (tileElement->IsGhost())
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
@ -413,7 +413,7 @@ void map_strip_ghost_flag_from_elements()
{
for (auto& element : gTileElements)
{
element.flags &= ~TILE_ELEMENT_FLAG_GHOST;
element.ClearGhost();
}
}
@ -821,7 +821,7 @@ void game_command_set_large_scenery_colour(
return;
}
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tile_element->flags & TILE_ELEMENT_FLAG_GHOST))
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tile_element->IsGhost()))
{
*ebx = 0;
return;
@ -2472,7 +2472,7 @@ void game_command_place_large_scenery(
if (flags & GAME_COMMAND_FLAG_GHOST)
{
new_tile_element->flags |= TILE_ELEMENT_FLAG_GHOST;
new_tile_element->SetGhost();
}
if (tile_num == 0)
@ -2884,8 +2884,7 @@ bool map_can_construct_with_clear_at(
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_SURFACE)
{
if (zLow < tileElement->clearance_height && zHigh > tileElement->base_height
&& !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if (zLow < tileElement->clearance_height && zHigh > tileElement->base_height && !(tileElement->IsGhost()))
{
if (tileElement->flags & (bl.GetBaseQuarterOccupied()))
{
@ -3372,7 +3371,7 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
continue;
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if ((ghost == false) && (tileElement->IsGhost()))
continue;
return tileElement->AsEntrance();
@ -3397,7 +3396,7 @@ EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE)
continue;
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if ((ghost == false) && (tileElement->IsGhost()))
continue;
return tileElement->AsEntrance();
@ -3422,7 +3421,7 @@ EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, b
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_EXIT)
continue;
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if ((ghost == false) && (tileElement->IsGhost()))
continue;
return tileElement->AsEntrance();

View File

@ -183,7 +183,7 @@ void update_park_fences(const CoordsXY coords)
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
continue;
if (!(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if (!(tileElement->IsGhost()))
{
fenceRequired = false;
break;

View File

@ -49,7 +49,7 @@ static money32 SmallScenerySetColour(
return 0;
}
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tileElement->IsGhost()))
{
return 0;
}
@ -317,7 +317,7 @@ static money32 SmallSceneryPlace(
if (flags & GAME_COMMAND_FLAG_GHOST)
{
newElement->flags |= TILE_ELEMENT_FLAG_GHOST;
newElement->SetGhost();
}
map_invalidate_tile_full(x, y);

View File

@ -54,6 +54,16 @@ bool TileElementBase::IsGhost() const
return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0;
}
void TileElementBase::SetGhost()
{
this->flags |= TILE_ELEMENT_FLAG_GHOST;
}
void TileElementBase::ClearGhost()
{
this->flags &= ~TILE_ELEMENT_FLAG_GHOST;
}
bool tile_element_is_underground(TileElement* tileElement)
{
do

View File

@ -71,6 +71,8 @@ struct TileElementBase
uint8_t GetDirectionWithOffset(uint8_t offset) const;
bool IsLastForTile() const;
bool IsGhost() const;
void SetGhost();
void ClearGhost();
void Remove();
};

View File

@ -538,7 +538,7 @@ static money32 WallPlace(
if (flags & GAME_COMMAND_FLAG_GHOST)
{
tileElement->flags |= TILE_ELEMENT_FLAG_GHOST;
tileElement->SetGhost();
}
gSceneryTileElement = tileElement;
@ -577,7 +577,7 @@ static money32 WallSetColour(
return 0;
}
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & TILE_ELEMENT_FLAG_GHOST))
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost()))
{
return 0;
}