forked from rosebudai/OpenRCT2-Web
Merge pull request #14472 from Gymnasiast/refactor/integrate-footpath-globals
Clean up some footpath globals
This commit is contained in:
12 files changed
+98
-93
No files matched your search
@@ -48,7 +48,7 @@ rct_window* window_editor_main_open()
|
||||
gShowGridLinesRefCount = 0;
|
||||
gShowLandRightsRefCount = 0;
|
||||
gShowConstuctionRightsRefCount = 0;
|
||||
gFootpathSelectedType = 0;
|
||||
window_footpath_reset_selected_path();
|
||||
|
||||
context_open_window(WC_TOP_TOOLBAR);
|
||||
context_open_window_view(WV_EDITOR_BOTTOM_TOOLBAR);
|
||||
|
||||
@@ -30,6 +30,11 @@ static constexpr const int32_t WH = 381;
|
||||
static constexpr const int32_t WW = 106;
|
||||
static constexpr const uint16_t ARROW_PULSE_DURATION = 200;
|
||||
|
||||
static uint8_t _footpathSelectedType;
|
||||
static uint8_t _footpathConstructDirection;
|
||||
static uint8_t _footpathConstructValidDirections;
|
||||
static uint8_t _footpathConstructionMode;
|
||||
|
||||
// clang-format off
|
||||
enum
|
||||
{
|
||||
@@ -217,7 +222,7 @@ rct_window* window_footpath_open()
|
||||
show_gridlines();
|
||||
|
||||
tool_cancel();
|
||||
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||
tool_set(window, WIDX_CONSTRUCT_ON_LAND, Tool::PathDown);
|
||||
input_set_flag(INPUT_FLAG_6, true);
|
||||
_footpathErrorOccured = false;
|
||||
@@ -258,7 +263,7 @@ static void window_footpath_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
window_footpath_remove();
|
||||
break;
|
||||
case WIDX_CONSTRUCT_ON_LAND:
|
||||
if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
|
||||
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -268,14 +273,14 @@ static void window_footpath_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
footpath_provisional_update();
|
||||
map_invalidate_map_selection_tiles();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||
tool_set(w, WIDX_CONSTRUCT_ON_LAND, Tool::PathDown);
|
||||
input_set_flag(INPUT_FLAG_6, true);
|
||||
_footpathErrorOccured = false;
|
||||
window_footpath_set_enabled_and_pressed_widgets();
|
||||
break;
|
||||
case WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL:
|
||||
if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
|
||||
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -285,7 +290,7 @@ static void window_footpath_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
footpath_provisional_update();
|
||||
map_invalidate_map_selection_tiles();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
|
||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
|
||||
tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::Crosshair);
|
||||
input_set_flag(INPUT_FLAG_6, true);
|
||||
_footpathErrorOccured = false;
|
||||
@@ -340,11 +345,11 @@ static void window_footpath_dropdown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
if (widgetIndex == WIDX_FOOTPATH_TYPE)
|
||||
{
|
||||
gFootpathSelectedType = SELECTED_PATH_TYPE_NORMAL;
|
||||
_footpathSelectedType = SELECTED_PATH_TYPE_NORMAL;
|
||||
}
|
||||
else if (widgetIndex == WIDX_QUEUELINE_TYPE)
|
||||
{
|
||||
gFootpathSelectedType = SELECTED_PATH_TYPE_QUEUE;
|
||||
_footpathSelectedType = SELECTED_PATH_TYPE_QUEUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -454,20 +459,20 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window*
|
||||
{
|
||||
int32_t type, slope;
|
||||
|
||||
if (gFootpathConstructionMode != PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
if (_footpathConstructionMode != PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
@@ -482,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 = gFootpathConstructDirection;
|
||||
if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
|
||||
gMapSelectArrowDirection = _footpathConstructDirection;
|
||||
if (gProvisionalFootpath.Flags & PROVISIONAL_PATH_FLAG_SHOW_ARROW)
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
}
|
||||
@@ -517,7 +522,7 @@ static void window_footpath_update(rct_window* w)
|
||||
}
|
||||
|
||||
// Check tool
|
||||
if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
|
||||
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND)
|
||||
{
|
||||
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
{
|
||||
@@ -532,7 +537,7 @@ static void window_footpath_update(rct_window* w)
|
||||
window_close(w);
|
||||
}
|
||||
}
|
||||
else if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
|
||||
else if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL)
|
||||
{
|
||||
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
{
|
||||
@@ -558,11 +563,11 @@ static void window_footpath_invalidate(rct_window* w)
|
||||
// Press / unpress footpath and queue type buttons
|
||||
w->pressed_widgets &= ~(1 << WIDX_FOOTPATH_TYPE);
|
||||
w->pressed_widgets &= ~(1 << WIDX_QUEUELINE_TYPE);
|
||||
w->pressed_widgets |= gFootpathSelectedType == SELECTED_PATH_TYPE_NORMAL ? (1 << WIDX_FOOTPATH_TYPE)
|
||||
w->pressed_widgets |= _footpathSelectedType == SELECTED_PATH_TYPE_NORMAL ? (1 << WIDX_FOOTPATH_TYPE)
|
||||
: (1 << WIDX_QUEUELINE_TYPE);
|
||||
|
||||
// Enable / disable construct button
|
||||
window_footpath_widgets[WIDX_CONSTRUCT].type = gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL
|
||||
window_footpath_widgets[WIDX_CONSTRUCT].type = _footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL
|
||||
? WindowWidgetType::ImgBtn
|
||||
: WindowWidgetType::Empty;
|
||||
|
||||
@@ -592,7 +597,7 @@ static void window_footpath_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
if (!(w->disabled_widgets & (1 << WIDX_CONSTRUCT)))
|
||||
{
|
||||
// Get construction image
|
||||
uint8_t direction = (gFootpathConstructDirection + get_current_rotation()) % 4;
|
||||
uint8_t direction = (_footpathConstructDirection + get_current_rotation()) % 4;
|
||||
uint8_t slope = 0;
|
||||
if (gFootpathConstructSlope == 2)
|
||||
{
|
||||
@@ -604,7 +609,7 @@ static void window_footpath_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
}
|
||||
int32_t image = ConstructionPreviewImages[slope][direction];
|
||||
|
||||
int32_t selectedPath = gFootpathSelectedId + (MAX_PATH_OBJECTS * gFootpathSelectedType);
|
||||
int32_t selectedPath = gFootpathSelectedId + (MAX_PATH_OBJECTS * _footpathSelectedType);
|
||||
PathSurfaceEntry* pathType = get_path_surface_entry(selectedPath);
|
||||
image += pathType->image;
|
||||
|
||||
@@ -683,7 +688,7 @@ static void window_footpath_show_footpath_types_dialog(rct_window* w, rct_widget
|
||||
static void window_footpath_mousedown_direction(int32_t direction)
|
||||
{
|
||||
footpath_provisional_update();
|
||||
gFootpathConstructDirection = (direction - get_current_rotation()) & 3;
|
||||
_footpathConstructDirection = (direction - get_current_rotation()) & 3;
|
||||
_window_footpath_cost = MONEY32_UNDEFINED;
|
||||
window_footpath_set_enabled_and_pressed_widgets();
|
||||
}
|
||||
@@ -720,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;
|
||||
}
|
||||
@@ -769,7 +774,7 @@ static void window_footpath_set_provisional_path_at_point(const ScreenCoordsXY&
|
||||
slope &= ~RAISE_FOOTPATH_FLAG;
|
||||
z += PATH_HEIGHT_STEP;
|
||||
}
|
||||
int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
int32_t pathType = (_footpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
|
||||
_window_footpath_cost = footpath_provisional_set(pathType, { info.Loc, z }, slope);
|
||||
window_invalidate_by_class(WC_FOOTPATH);
|
||||
@@ -864,7 +869,7 @@ static void window_footpath_place_path_at_point(const ScreenCoordsXY& screenCoor
|
||||
slope &= ~RAISE_FOOTPATH_FLAG;
|
||||
z += PATH_HEIGHT_STEP;
|
||||
}
|
||||
auto selectedType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
auto selectedType = (_footpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
|
||||
// Try and place path
|
||||
gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
@@ -935,11 +940,11 @@ static void window_footpath_start_bridge_at_point(const ScreenCoordsXY& screenCo
|
||||
|
||||
tool_cancel();
|
||||
gFootpathConstructFromPosition = { mapCoords, z };
|
||||
gFootpathConstructDirection = direction;
|
||||
gFootpathProvisionalFlags = 0;
|
||||
_footpathConstructDirection = direction;
|
||||
gProvisionalFootpath.Flags = 0;
|
||||
gFootpathConstructSlope = 0;
|
||||
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
|
||||
gFootpathConstructValidDirections = INVALID_DIRECTION;
|
||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
|
||||
_footpathConstructValidDirections = INVALID_DIRECTION;
|
||||
window_footpath_set_enabled_and_pressed_widgets();
|
||||
}
|
||||
|
||||
@@ -957,7 +962,7 @@ static void window_footpath_construct()
|
||||
footpath_get_next_path_info(&type, footpathLoc, &slope);
|
||||
|
||||
gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type, gFootpathConstructDirection);
|
||||
auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type, _footpathConstructDirection);
|
||||
footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -965,11 +970,11 @@ static void window_footpath_construct()
|
||||
|
||||
if (gFootpathConstructSlope == 0)
|
||||
{
|
||||
gFootpathConstructValidDirections = INVALID_DIRECTION;
|
||||
_footpathConstructValidDirections = INVALID_DIRECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
gFootpathConstructValidDirections = gFootpathConstructDirection;
|
||||
_footpathConstructValidDirections = _footpathConstructDirection;
|
||||
}
|
||||
|
||||
if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND)
|
||||
@@ -1002,14 +1007,14 @@ static void footpath_remove_tile_element(TileElement* tileElement)
|
||||
{
|
||||
uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection();
|
||||
slopeDirection = direction_reverse(slopeDirection);
|
||||
if (slopeDirection == gFootpathConstructDirection)
|
||||
if (slopeDirection == _footpathConstructDirection)
|
||||
{
|
||||
z += PATH_HEIGHT_STEP;
|
||||
}
|
||||
}
|
||||
|
||||
// Find a connected edge
|
||||
int32_t edge = direction_reverse(gFootpathConstructDirection);
|
||||
int32_t edge = direction_reverse(_footpathConstructDirection);
|
||||
if (!(tileElement->AsPath()->GetEdges() & (1 << edge)))
|
||||
{
|
||||
edge = (edge + 1) & 3;
|
||||
@@ -1036,8 +1041,8 @@ static void footpath_remove_tile_element(TileElement* tileElement)
|
||||
gFootpathConstructFromPosition.x -= CoordsDirectionDelta[edge].x;
|
||||
gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y;
|
||||
gFootpathConstructFromPosition.z = z;
|
||||
gFootpathConstructDirection = edge;
|
||||
gFootpathConstructValidDirections = INVALID_DIRECTION;
|
||||
_footpathConstructDirection = edge;
|
||||
_footpathConstructValidDirections = INVALID_DIRECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1068,7 +1073,7 @@ static TileElement* footpath_get_tile_element_to_remove()
|
||||
{
|
||||
if (tileElement->AsPath()->IsSloped())
|
||||
{
|
||||
if (direction_reverse(tileElement->AsPath()->GetSlopeDirection()) != gFootpathConstructDirection)
|
||||
if (direction_reverse(tileElement->AsPath()->GetSlopeDirection()) != _footpathConstructDirection)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1080,7 +1085,7 @@ static TileElement* footpath_get_tile_element_to_remove()
|
||||
{
|
||||
if (!tileElement->AsPath()->IsSloped())
|
||||
{
|
||||
if ((tileElement->AsPath()->GetSlopeDirection()) == gFootpathConstructDirection)
|
||||
if ((tileElement->AsPath()->GetSlopeDirection()) == _footpathConstructDirection)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1126,13 +1131,13 @@ static void window_footpath_set_enabled_and_pressed_widgets()
|
||||
return;
|
||||
}
|
||||
|
||||
if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
{
|
||||
map_invalidate_map_selection_tiles();
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_GREEN;
|
||||
|
||||
int32_t direction = gFootpathConstructDirection;
|
||||
int32_t direction = _footpathConstructDirection;
|
||||
gMapSelectionTiles.clear();
|
||||
gMapSelectionTiles.push_back({ gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x,
|
||||
gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y });
|
||||
@@ -1144,10 +1149,10 @@ static void window_footpath_set_enabled_and_pressed_widgets()
|
||||
| (1LL << WIDX_SLOPEDOWN) | (1LL << WIDX_LEVEL) | (1LL << WIDX_SLOPEUP));
|
||||
uint64_t disabledWidgets = 0;
|
||||
int32_t currentRotation = get_current_rotation();
|
||||
if (gFootpathConstructionMode >= PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
if (_footpathConstructionMode >= PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
{
|
||||
// Set pressed directional widget
|
||||
int32_t direction = (gFootpathConstructDirection + currentRotation) & 3;
|
||||
int32_t direction = (_footpathConstructDirection + currentRotation) & 3;
|
||||
pressedWidgets |= (1LL << (WIDX_DIRECTION_NW + direction));
|
||||
|
||||
// Set pressed slope widget
|
||||
@@ -1166,7 +1171,7 @@ static void window_footpath_set_enabled_and_pressed_widgets()
|
||||
}
|
||||
|
||||
// Enable / disable directional widgets
|
||||
direction = gFootpathConstructValidDirections;
|
||||
direction = _footpathConstructValidDirections;
|
||||
if (direction != INVALID_DIRECTION)
|
||||
{
|
||||
disabledWidgets |= (1 << WIDX_DIRECTION_NW) | (1 << WIDX_DIRECTION_NE) | (1 << WIDX_DIRECTION_SW)
|
||||
@@ -1197,15 +1202,15 @@ static void footpath_get_next_path_info(int32_t* type, CoordsXYZ& footpathLoc, i
|
||||
{
|
||||
int32_t direction;
|
||||
|
||||
direction = gFootpathConstructDirection;
|
||||
direction = _footpathConstructDirection;
|
||||
footpathLoc.x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x;
|
||||
footpathLoc.y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y;
|
||||
footpathLoc.z = gFootpathConstructFromPosition.z;
|
||||
*type = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
*type = (_footpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
*slope = TILE_ELEMENT_SLOPE_FLAT;
|
||||
if (gFootpathConstructSlope != 0)
|
||||
{
|
||||
*slope = gFootpathConstructDirection | TILE_ELEMENT_SLOPE_S_CORNER_UP;
|
||||
*slope = _footpathConstructDirection | TILE_ELEMENT_SLOPE_S_CORNER_UP;
|
||||
if (gFootpathConstructSlope != 2)
|
||||
{
|
||||
footpathLoc.z -= PATH_HEIGHT_STEP;
|
||||
@@ -1247,12 +1252,12 @@ void window_footpath_keyboard_shortcut_turn_left()
|
||||
{
|
||||
rct_window* w = window_find_by_class(WC_FOOTPATH);
|
||||
if (w == nullptr || WidgetIsDisabled(w, WIDX_DIRECTION_NW) || WidgetIsDisabled(w, WIDX_DIRECTION_NE)
|
||||
|| WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || gFootpathConstructionMode != 2)
|
||||
|| WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || _footpathConstructionMode != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int32_t currentRotation = get_current_rotation();
|
||||
int32_t turnedRotation = gFootpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? 1 : -1);
|
||||
int32_t turnedRotation = _footpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? 1 : -1);
|
||||
window_footpath_mousedown_direction(turnedRotation);
|
||||
}
|
||||
|
||||
@@ -1260,12 +1265,12 @@ void window_footpath_keyboard_shortcut_turn_right()
|
||||
{
|
||||
rct_window* w = window_find_by_class(WC_FOOTPATH);
|
||||
if (w == nullptr || WidgetIsDisabled(w, WIDX_DIRECTION_NW) || WidgetIsDisabled(w, WIDX_DIRECTION_NE)
|
||||
|| WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || gFootpathConstructionMode != 2)
|
||||
|| WidgetIsDisabled(w, WIDX_DIRECTION_SW) || WidgetIsDisabled(w, WIDX_DIRECTION_SE) || _footpathConstructionMode != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int32_t currentRotation = get_current_rotation();
|
||||
int32_t turnedRotation = gFootpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? -1 : 1);
|
||||
int32_t turnedRotation = _footpathConstructDirection - currentRotation + (currentRotation % 2 == 1 ? -1 : 1);
|
||||
window_footpath_mousedown_direction(turnedRotation);
|
||||
}
|
||||
|
||||
@@ -1337,3 +1342,8 @@ void window_footpath_keyboard_shortcut_build_current()
|
||||
|
||||
window_event_mouse_up_call(w, WIDX_CONSTRUCT);
|
||||
}
|
||||
|
||||
void window_footpath_reset_selected_path()
|
||||
{
|
||||
_footpathSelectedType = 0;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ rct_window* window_main_open()
|
||||
gShowGridLinesRefCount = 0;
|
||||
gShowLandRightsRefCount = 0;
|
||||
gShowConstuctionRightsRefCount = 0;
|
||||
gFootpathSelectedType = 0;
|
||||
window_footpath_reset_selected_path();
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ static void window_map_place_park_entrance_tool_down(const ScreenCoordsXY& scree
|
||||
CoordsXYZD parkEntrancePosition = place_park_entrance_get_map_position(screenCoords);
|
||||
if (!parkEntrancePosition.isNull())
|
||||
{
|
||||
auto gameAction = PlaceParkEntranceAction(parkEntrancePosition);
|
||||
auto gameAction = PlaceParkEntranceAction(parkEntrancePosition, gFootpathSelectedId);
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
if (result->Error == GameActions::Status::Ok)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -47,6 +47,7 @@ rct_window* window_editor_main_open();
|
||||
rct_window* window_editor_objective_options_open();
|
||||
rct_window* window_editor_scenario_options_open();
|
||||
rct_window* window_footpath_open();
|
||||
void window_footpath_reset_selected_path();
|
||||
rct_window* window_guest_open(Peep* peep);
|
||||
rct_window* window_land_open();
|
||||
rct_window* window_land_rights_open();
|
||||
|
||||
@@ -33,7 +33,7 @@ money32 park_entrance_place_ghost(const CoordsXYZD& entranceLoc)
|
||||
{
|
||||
park_entrance_remove_ghost();
|
||||
|
||||
auto gameAction = PlaceParkEntranceAction(entranceLoc);
|
||||
auto gameAction = PlaceParkEntranceAction(entranceLoc, gFootpathSelectedId);
|
||||
gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST);
|
||||
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
#include "../world/Sprite.h"
|
||||
#include "../world/Surface.h"
|
||||
|
||||
PlaceParkEntranceAction::PlaceParkEntranceAction(const CoordsXYZD& location)
|
||||
PlaceParkEntranceAction::PlaceParkEntranceAction(const CoordsXYZD& location, ObjectEntryIndex pathType)
|
||||
: _loc(location)
|
||||
, _pathType(pathType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@ GameActions::Result::Ptr PlaceParkEntranceAction::Execute() const
|
||||
entranceElement->SetDirection(_loc.direction);
|
||||
entranceElement->SetSequenceIndex(index);
|
||||
entranceElement->SetEntranceType(ENTRANCE_TYPE_PARK_ENTRANCE);
|
||||
entranceElement->SetPathType(gFootpathSelectedId);
|
||||
entranceElement->SetPathType(_pathType);
|
||||
|
||||
if (!entranceElement->IsGhost())
|
||||
{
|
||||
|
||||
@@ -15,10 +15,11 @@ DEFINE_GAME_ACTION(PlaceParkEntranceAction, GameCommand::PlaceParkEntrance, Game
|
||||
{
|
||||
private:
|
||||
CoordsXYZD _loc;
|
||||
ObjectEntryIndex _pathType;
|
||||
|
||||
public:
|
||||
PlaceParkEntranceAction() = default;
|
||||
PlaceParkEntranceAction(const CoordsXYZD& location);
|
||||
PlaceParkEntranceAction(const CoordsXYZD& location, ObjectEntryIndex pathType);
|
||||
|
||||
uint16_t GetActionFlags() const override;
|
||||
|
||||
|
||||
@@ -40,18 +40,10 @@
|
||||
|
||||
void footpath_update_queue_entrance_banner(const CoordsXY& footpathPos, TileElement* tileElement);
|
||||
|
||||
uint8_t gFootpathProvisionalFlags;
|
||||
CoordsXYZ gFootpathProvisionalPosition;
|
||||
uint8_t gFootpathProvisionalType;
|
||||
uint8_t gFootpathProvisionalSlope;
|
||||
uint8_t gFootpathConstructionMode;
|
||||
ProvisionalFootpath gProvisionalFootpath;
|
||||
uint16_t gFootpathSelectedId;
|
||||
uint8_t gFootpathSelectedType;
|
||||
CoordsXYZ gFootpathConstructFromPosition;
|
||||
uint8_t gFootpathConstructDirection;
|
||||
uint8_t gFootpathConstructSlope;
|
||||
uint8_t gFootpathConstructValidDirections;
|
||||
money32 gFootpathPrice;
|
||||
uint8_t gFootpathGroundFlags;
|
||||
|
||||
static ride_id_t* _footpathQueueChainNext;
|
||||
@@ -158,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)
|
||||
{
|
||||
@@ -185,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,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);
|
||||
}
|
||||
@@ -223,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);
|
||||
|
||||
@@ -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,18 +166,10 @@ 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 uint8_t gFootpathConstructionMode;
|
||||
extern ProvisionalFootpath gProvisionalFootpath;
|
||||
extern uint16_t gFootpathSelectedId;
|
||||
extern uint8_t gFootpathSelectedType;
|
||||
extern CoordsXYZ gFootpathConstructFromPosition;
|
||||
extern uint8_t gFootpathConstructDirection;
|
||||
extern uint8_t gFootpathConstructSlope;
|
||||
extern uint8_t gFootpathConstructValidDirections;
|
||||
extern money32 gFootpathPrice;
|
||||
extern uint8_t gFootpathGroundFlags;
|
||||
|
||||
// Given a direction, this will return how to increase/decrease the x and y coordinates.
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user