mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 08:45:00 +01:00
Prepare footpath handling for surfaces and railings
This commit is contained in:
@@ -22,11 +22,14 @@
|
||||
#include "../world/Wall.h"
|
||||
|
||||
FootpathPlaceFromTrackAction::FootpathPlaceFromTrackAction(
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, uint8_t edges)
|
||||
const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, uint8_t edges,
|
||||
PathConstructFlags constructFlags)
|
||||
: _loc(loc)
|
||||
, _slope(slope)
|
||||
, _type(type)
|
||||
, _railingsType(railingsType)
|
||||
, _edges(edges)
|
||||
, _constructFlags(constructFlags)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -34,7 +37,8 @@ void FootpathPlaceFromTrackAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_edges);
|
||||
stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_railingsType) << DS_TAG(_edges)
|
||||
<< DS_TAG(_constructFlags);
|
||||
}
|
||||
|
||||
uint16_t FootpathPlaceFromTrackAction::GetActionFlags() const
|
||||
@@ -122,16 +126,16 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertQuery(GameAc
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (entranceElement->GetLegacyPathEntryIndex() == (_type & 0xF))
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res->Cost -= MONEY(6, 00);
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped.
|
||||
uint8_t crossingMode = (_type & FOOTPATH_ELEMENT_INSERT_QUEUE) || (_slope != TILE_ELEMENT_SLOPE_FLAT)
|
||||
? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild->Error != GameActions::Status::Ok)
|
||||
@@ -189,16 +193,16 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertExecute(Game
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (entranceElement->GetLegacyPathEntryIndex() == (_type & 0xF))
|
||||
if (IsSameAsEntranceElement(*entranceElement))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
res->Cost -= MONEY(6, 00);
|
||||
}
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped.
|
||||
uint8_t crossingMode = (_type & FOOTPATH_ELEMENT_INSERT_QUEUE) || (_slope != TILE_ELEMENT_SLOPE_FLAT)
|
||||
? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(),
|
||||
crossingMode);
|
||||
@@ -222,8 +226,14 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertExecute(Game
|
||||
{
|
||||
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
{
|
||||
// Set the path type but make sure it's not a queue as that will not show up
|
||||
entranceElement->SetLegacyPathEntryIndex(_type & 0x7F);
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
entranceElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
entranceElement->SetSurfaceEntryIndex(_type);
|
||||
}
|
||||
map_invalidate_tile_full(_loc);
|
||||
}
|
||||
}
|
||||
@@ -233,10 +243,18 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertExecute(Game
|
||||
Guard::Assert(pathElement != nullptr);
|
||||
|
||||
pathElement->SetClearanceZ(zHigh);
|
||||
pathElement->SetLegacyPathEntryIndex(_type & ~FOOTPATH_ELEMENT_INSERT_QUEUE);
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
pathElement->SetLegacyPathEntryIndex(_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
pathElement->SetSurfaceEntryIndex(_type);
|
||||
pathElement->SetRailingsEntryIndex(_railingsType);
|
||||
}
|
||||
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
|
||||
pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED);
|
||||
pathElement->SetIsQueue(_type & FOOTPATH_ELEMENT_INSERT_QUEUE);
|
||||
pathElement->SetIsQueue(isQueue);
|
||||
pathElement->SetAddition(0);
|
||||
pathElement->SetRideIndex(RIDE_ID_NULL);
|
||||
pathElement->SetAdditionStatus(255);
|
||||
@@ -254,3 +272,27 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertExecute(Game
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool FootpathPlaceFromTrackAction::IsSameAsEntranceElement(const EntranceElement& entranceElement) const
|
||||
{
|
||||
if (entranceElement.HasLegacyPathEntry())
|
||||
{
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return entranceElement.GetLegacyPathEntryIndex() == _type;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructFlags & PathConstructFlag::IsLegacyPathObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entranceElement.GetSurfaceEntryIndex() == _type;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user