Create ProvisionalFootpath struct

This commit is contained in:
Gymnasiast 2021-04-14 14:56:28 +02:00
parent 85157d8604
commit 5e28586a1c
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
5 changed files with 36 additions and 34 deletions

View File

@ -465,14 +465,14 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window*
}
// Recheck area for construction. Set by ride_construction window
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_2)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_2)
{
footpath_provisional_remove();
gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_2;
gProvisionalFootpath.Flags &= ~PROVISIONAL_PATH_FLAG_2;
}
// Update provisional bridge mode path
if (!(gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1))
if (!(gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_1))
{
CoordsXYZ footpathLoc;
footpath_get_next_path_info(&type, footpathLoc, &slope);
@ -487,12 +487,12 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window*
{
_footpathConstructionNextArrowPulse = curTime + ARROW_PULSE_DURATION;
gFootpathProvisionalFlags ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW;
gProvisionalFootpath.Flags ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW;
CoordsXYZ footpathLoc;
footpath_get_next_path_info(&type, footpathLoc, &slope);
gMapSelectArrowPosition = footpathLoc;
gMapSelectArrowDirection = _footpathConstructDirection;
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
{
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
}
@ -725,8 +725,8 @@ static void window_footpath_set_provisional_path_at_point(const ScreenCoordsXY&
else
{
// Check for change
if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1)
&& gFootpathProvisionalPosition == CoordsXYZ{ info.Loc, info.Element->GetBaseZ() })
if ((gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_1)
&& gProvisionalFootpath.Position == CoordsXYZ{ info.Loc, info.Element->GetBaseZ() })
{
return;
}
@ -941,7 +941,7 @@ static void window_footpath_start_bridge_at_point(const ScreenCoordsXY& screenCo
tool_cancel();
gFootpathConstructFromPosition = { mapCoords, z };
_footpathConstructDirection = direction;
gFootpathProvisionalFlags = 0;
gProvisionalFootpath.Flags = 0;
gFootpathConstructSlope = 0;
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
_footpathConstructValidDirections = INVALID_DIRECTION;

View File

@ -650,7 +650,7 @@ static void window_ride_construction_mouseup(rct_window* w, rct_widgetindex widg
case WIDX_CONSTRUCT:
window_ride_construction_construct(w);
// Force any footpath construction to recheck the area.
gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_2;
gProvisionalFootpath.Flags |= PROVISIONAL_PATH_FLAG_2;
break;
case WIDX_DEMOLISH:
window_ride_construction_mouseup_demolish(w);

View File

@ -40,10 +40,7 @@
void footpath_update_queue_entrance_banner(const CoordsXY& footpathPos, TileElement* tileElement);
uint8_t gFootpathProvisionalFlags;
CoordsXYZ gFootpathProvisionalPosition;
uint8_t gFootpathProvisionalType;
uint8_t gFootpathProvisionalSlope;
ProvisionalFootpath gProvisionalFootpath;
uint16_t gFootpathSelectedId;
CoordsXYZ gFootpathConstructFromPosition;
uint8_t gFootpathConstructSlope;
@ -153,10 +150,10 @@ money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int
cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED;
if (res->Error == GameActions::Status::Ok)
{
gFootpathProvisionalType = type;
gFootpathProvisionalPosition = footpathLoc;
gFootpathProvisionalSlope = slope;
gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1;
gProvisionalFootpath.Type = type;
gProvisionalFootpath.Position = footpathLoc;
gProvisionalFootpath.Slope = slope;
gProvisionalFootpath.Flags |= PROVISIONAL_PATH_FLAG_1;
if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND)
{
@ -180,15 +177,15 @@ money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int
}
else if (
gFootpathConstructSlope == TILE_ELEMENT_SLOPE_FLAT
|| gFootpathProvisionalPosition.z < gFootpathConstructFromPosition.z)
|| gProvisionalFootpath.Position.z < gFootpathConstructFromPosition.z)
{
// Going either straight on, or down.
virtual_floor_set_height(gFootpathProvisionalPosition.z);
virtual_floor_set_height(gProvisionalFootpath.Position.z);
}
else
{
// Going up in the world!
virtual_floor_set_height(gFootpathProvisionalPosition.z + LAND_HEIGHT_STEP);
virtual_floor_set_height(gProvisionalFootpath.Position.z + LAND_HEIGHT_STEP);
}
}
@ -201,12 +198,12 @@ money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int
*/
void footpath_provisional_remove()
{
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_1)
{
gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_1;
gProvisionalFootpath.Flags &= ~PROVISIONAL_PATH_FLAG_1;
footpath_remove(
gFootpathProvisionalPosition,
gProvisionalFootpath.Position,
GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_GHOST);
}
@ -218,9 +215,9 @@ void footpath_provisional_remove()
*/
void footpath_provisional_update()
{
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
{
gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_SHOW_ARROW;
gProvisionalFootpath.Flags &= ~PROVISIONAL_PATH_FLAG_SHOW_ARROW;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(gFootpathConstructFromPosition);

View File

@ -72,6 +72,14 @@ struct PathRailingsEntry
uint8_t scrolling_mode;
};
struct ProvisionalFootpath
{
ObjectEntryIndex Type;
CoordsXYZ Position;
uint8_t Slope;
uint8_t Flags;
};
// Masks for values stored in TileElement.type
enum
{
@ -158,10 +166,7 @@ enum
FOOTPATH_CONNECTED_MAP_EDGE_IGNORE_NO_ENTRY = (1 << 7)
};
extern uint8_t gFootpathProvisionalFlags;
extern CoordsXYZ gFootpathProvisionalPosition;
extern uint8_t gFootpathProvisionalType;
extern uint8_t gFootpathProvisionalSlope;
extern ProvisionalFootpath gProvisionalFootpath;
extern uint16_t gFootpathSelectedId;
extern CoordsXYZ gFootpathConstructFromPosition;
extern uint8_t gFootpathConstructSlope;

View File

@ -1515,10 +1515,10 @@ void map_update_tiles()
void map_remove_provisional_elements()
{
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_1)
{
footpath_provisional_remove();
gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1;
gProvisionalFootpath.Flags |= PROVISIONAL_PATH_FLAG_1;
}
if (window_find_by_class(WC_RIDE_CONSTRUCTION) != nullptr)
{
@ -1536,10 +1536,10 @@ void map_remove_provisional_elements()
void map_restore_provisional_elements()
{
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1)
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_1)
{
gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_1;
footpath_provisional_set(gFootpathProvisionalType, gFootpathProvisionalPosition, gFootpathProvisionalSlope);
gProvisionalFootpath.Flags &= ~PROVISIONAL_PATH_FLAG_1;
footpath_provisional_set(gProvisionalFootpath.Type, gProvisionalFootpath.Position, gProvisionalFootpath.Slope);
}
if (window_find_by_class(WC_RIDE_CONSTRUCTION) != nullptr)
{