1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 23:34:37 +01:00

Improve path railing code

This commit is contained in:
Ted John
2021-04-12 22:42:37 +01:00
parent ef6d8a6e69
commit 04e4b160b3
7 changed files with 70 additions and 52 deletions

View File

@@ -945,7 +945,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile
}
PathSurfaceEntry* footpathEntry = tile_element->AsPath()->GetSurfaceEntry();
auto railingEntry = get_path_railings_entry(0);
auto railingEntry = tile_element->AsPath()->GetRailingEntry();
if (footpathEntry != nullptr && railingEntry != nullptr)
{

View File

@@ -122,6 +122,7 @@ private:
EntryList _pathAdditionEntries;
EntryList _sceneryGroupEntries;
EntryList _waterEntry;
EntryList _footpathRailingsEntries;
// Lookup tables for converting from RCT1 hard coded types to the new dynamic object entries
ObjectEntryIndex _rideTypeToRideEntryMap[RCT1_RIDE_TYPE_COUNT]{};
@@ -132,6 +133,7 @@ private:
ObjectEntryIndex _pathTypeToEntryMap[24]{};
ObjectEntryIndex _pathAdditionTypeToEntryMap[16]{};
ObjectEntryIndex _sceneryThemeTypeToEntryMap[24]{};
ObjectEntryIndex _footpathRailingsTypeToEntryMap[4]{};
// Research
std::bitset<MAX_RIDE_OBJECTS> _researchRideEntryUsed{};
@@ -369,6 +371,8 @@ private:
std::fill(std::begin(_pathTypeToEntryMap), std::end(_pathTypeToEntryMap), OBJECT_ENTRY_INDEX_NULL);
std::fill(std::begin(_pathAdditionTypeToEntryMap), std::end(_pathAdditionTypeToEntryMap), OBJECT_ENTRY_INDEX_NULL);
std::fill(std::begin(_sceneryThemeTypeToEntryMap), std::end(_sceneryThemeTypeToEntryMap), OBJECT_ENTRY_INDEX_NULL);
std::fill(
std::begin(_footpathRailingsTypeToEntryMap), std::end(_footpathRailingsTypeToEntryMap), OBJECT_ENTRY_INDEX_NULL);
}
/**
@@ -399,6 +403,9 @@ private:
// Add default footpaths
_pathEntries.AddRange({ "rct1.path.tarmac", "rct1.path.dirt", "rct1.path.crazy", "rct1.path.tile.pink" });
_footpathRailingsEntries.AddRange({ "rct2.railings.wood", "rct2.railings.concrete", "rct2.railings.space",
"rct2.railings.black", "rct2.railings.brown" });
}
void AddAvailableEntriesFromResearchList()
@@ -457,9 +464,15 @@ private:
{
uint8_t pathType = tileElement->AsPath()->GetRCT1PathType();
uint8_t pathAdditionsType = tileElement->AsPath()->GetAddition();
uint8_t footpathRailingsType = RCT1_PATH_SUPPORT_TYPE_TRUSS;
if (_gameVersion == FILE_VERSION_RCT1_LL)
{
footpathRailingsType = tileElement->AsPath()->GetRCT1SupportType();
}
AddEntryForPath(pathType);
AddEntryForPathAddition(pathAdditionsType);
AddEntryForFootpathRailings(footpathRailingsType);
break;
}
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
@@ -685,6 +698,20 @@ private:
}
}
void AddEntryForFootpathRailings(ObjectEntryIndex railingsType)
{
assert(railingsType < std::size(_footpathRailingsTypeToEntryMap));
if (_footpathRailingsTypeToEntryMap[railingsType] == OBJECT_ENTRY_INDEX_NULL)
{
auto identifier = RCT1::GetFootpathRailingsObject(railingsType);
if (!identifier.empty())
{
auto entryIndex = _footpathRailingsEntries.GetOrAddEntry(identifier);
_footpathRailingsTypeToEntryMap[railingsType] = entryIndex;
}
}
}
void ImportRides()
{
for (int32_t i = 0; i < RCT12_MAX_RIDES_IN_PARK; i++)
@@ -1535,6 +1562,7 @@ private:
}));
AppendRequiredObjects(result, ObjectType::ParkEntrance, std::vector<std::string>({ "rct2.pkent1" }));
AppendRequiredObjects(result, ObjectType::Water, _waterEntry);
AppendRequiredObjects(result, ObjectType::FootpathRailings, _footpathRailingsEntries);
RCT12AddDefaultObjects(result);
return result;
}
@@ -1652,30 +1680,14 @@ private:
{
dst2->SetIsQueue(true);
}
if (_gameVersion != FILE_VERSION_RCT1_LL)
uint8_t railingsType = RCT1_PATH_SUPPORT_TYPE_TRUSS;
if (_gameVersion == FILE_VERSION_RCT1_LL)
{
dst2->SetRailingEntryIndex(0);
}
else
{
ObjectEntryIndex railingsEntryIndex;
switch (src2->GetRCT1SupportType())
{
case RCT1_PATH_SUPPORT_TYPE_COATED_WOOD:
railingsEntryIndex = 3;
break;
case RCT1_PATH_SUPPORT_TYPE_SPACE:
railingsEntryIndex = 4;
break;
case RCT1_PATH_SUPPORT_TYPE_BAMBOO:
railingsEntryIndex = 5;
break;
case RCT1_PATH_SUPPORT_TYPE_TRUSS:
default:
railingsEntryIndex = 0;
}
dst2->SetRailingEntryIndex(railingsEntryIndex);
railingsType = src2->GetRCT1SupportType();
}
auto railingsEntryIndex = _footpathRailingsTypeToEntryMap[railingsType];
dst2->SetRailingEntryIndex(railingsEntryIndex);
// Additions
ObjectEntryIndex additionType = dst2->GetAddition();

View File

@@ -1256,35 +1256,35 @@ namespace RCT1
{
static constexpr const char * map[] =
{
"rct1.path.tarmac", // RCT1_FOOTPATH_TYPE_QUEUE_BLUE
"rct1.aa.path.space", // RCT1_FOOTPATH_TYPE_QUEUE_RED
"rct1.path.dirt", // RCT1_FOOTPATH_TYPE_QUEUE_YELLOW
"rct1.aa.tarmac.green", // RCT1_FOOTPATH_TYPE_QUEUE_GREEN
"rct1.path.tarmac", // RCT1_FOOTPATH_TYPE_QUEUE_BLUE
"rct1.aa.path.space", // RCT1_FOOTPATH_TYPE_QUEUE_RED
"rct1.path.dirt", // RCT1_FOOTPATH_TYPE_QUEUE_YELLOW
"rct1.aa.path.tarmac.green", // RCT1_FOOTPATH_TYPE_QUEUE_GREEN
"rct1.path.tarmac", // RCT1_FOOTPATH_TYPE_TARMAC_GRAY
"rct1.aa.path.space", // RCT1_FOOTPATH_TYPE_TARMAC_RED
"rct1.aa.tarmac.brown", // RCT1_FOOTPATH_TYPE_TARMAC_BROWN
"rct1.aa.tarmac.green", // RCT1_FOOTPATH_TYPE_TARMAC_GREEN
"rct1.path.tarmac", // RCT1_FOOTPATH_TYPE_TARMAC_GRAY
"rct1.aa.path.space", // RCT1_FOOTPATH_TYPE_TARMAC_RED
"rct1.aa.path.tarmac.brown", // RCT1_FOOTPATH_TYPE_TARMAC_BROWN
"rct1.aa.path.tarmac.green", // RCT1_FOOTPATH_TYPE_TARMAC_GREEN
"rct1.path.dirt", // RCT1_FOOTPATH_TYPE_DIRT_RED
"rct1.aa.path.ash", // RCT1_FOOTPATH_TYPE_DIRT_BLACK
"rct1.path.dirt", // RCT1_FOOTPATH_TYPE_DIRT_RED
"rct1.aa.path.ash", // RCT1_FOOTPATH_TYPE_DIRT_BLACK
"",
"",
"rct1.path.crazy", // RCT1_FOOTPATH_TYPE_CRAZY_PAVING
"rct1.path.crazy", // RCT1_FOOTPATH_TYPE_CRAZY_PAVING
"",
"",
"",
"rct2.road", // RCT1_FOOTPATH_TYPE_ROADS
"rct2.road", // RCT1_FOOTPATH_TYPE_ROADS
"",
"",
"",
"rct1.path.tile.pink", // RCT1_FOOTPATH_TYPE_TILE_PINK
"rct1.aa.path.tile.grey", // RCT1_FOOTPATH_TYPE_TILE_GRAY
"rct1.ll.path.tile.red", // RCT1_FOOTPATH_TYPE_TILE_RED
"rct1.ll.path.tile.green", // RCT1_FOOTPATH_TYPE_TILE_GREEN
"rct1.path.tile.pink", // RCT1_FOOTPATH_TYPE_TILE_PINK
"rct1.aa.path.tile.grey", // RCT1_FOOTPATH_TYPE_TILE_GRAY
"rct1.ll.path.tile.red", // RCT1_FOOTPATH_TYPE_TILE_RED
"rct1.ll.path.tile.green", // RCT1_FOOTPATH_TYPE_TILE_GREEN
};
return map[pathType];
}
@@ -1312,6 +1312,18 @@ namespace RCT1
return map[pathAdditionType];
}
std::string_view GetFootpathRailingsObject(uint8_t footpathRailingsType)
{
static constexpr const char * map[] =
{
"rct2.railings.wood", // RCT1_PATH_SUPPORT_TYPE_TRUSS
"rct2.railings.concrete", // RCT1_PATH_SUPPORT_TYPE_COATED_WOOD
"rct2.railings.space", // RCT1_PATH_SUPPORT_TYPE_SPACE
"rct2.railings.brown", // RCT1_PATH_SUPPORT_TYPE_BAMBOO
};
return map[footpathRailingsType];
}
std::string_view GetSceneryGroupObject(uint8_t sceneryGroupType)
{
static constexpr const char * map[] =

View File

@@ -40,6 +40,7 @@ namespace RCT1
std::string_view GetWallObject(uint8_t wallType);
std::string_view GetPathObject(uint8_t pathType);
std::string_view GetPathAddtionObject(uint8_t pathAdditionType);
std::string_view GetFootpathRailingsObject(uint8_t footpathRailingsType);
std::string_view GetSceneryGroupObject(uint8_t sceneryGroupType);
std::string_view GetWaterObject(uint8_t waterType);

View File

@@ -1440,11 +1440,4 @@ void RCT12AddDefaultObjects(ObjectList& objectList)
objectList.SetObject(ObjectType::Music, static_cast<ObjectEntryIndex>(i), _musicStyles[i]);
}
}
// Path railings
objectList.SetObject(ObjectType::FootpathRailings, 0, "rct2.railings.wood");
objectList.SetObject(ObjectType::FootpathRailings, 1, "rct2.railings.concrete");
objectList.SetObject(ObjectType::FootpathRailings, 2, "rct2.railings.space");
objectList.SetObject(ObjectType::FootpathRailings, 3, "rct2.railings.black");
objectList.SetObject(ObjectType::FootpathRailings, 4, "rct2.railings.brown");
}

View File

@@ -1656,7 +1656,7 @@ PathSurfaceIndex PathElement::GetSurfaceEntryIndex() const
PathRailingsIndex PathElement::GetRailingEntryIndex() const
{
return GetSurfaceEntryIndex();
return RailingsIndex;
}
PathSurfaceEntry* PathElement::GetSurfaceEntry() const
@@ -1667,10 +1667,9 @@ PathSurfaceEntry* PathElement::GetSurfaceEntry() const
return get_path_surface_entry(GetSurfaceEntryIndex() + MAX_PATH_OBJECTS);
}
PathRailingsEntry* PathElement::GetRailingEntry() const
FootpathRailingsObject* PathElement::GetRailingEntry() const
{
return nullptr;
// return get_path_railings_entry(GetRailingEntryIndex());
return get_path_railings_entry(GetRailingEntryIndex());
}
void PathElement::SetSurfaceEntryIndex(PathSurfaceIndex newIndex)
@@ -1680,7 +1679,7 @@ void PathElement::SetSurfaceEntryIndex(PathSurfaceIndex newIndex)
void PathElement::SetRailingEntryIndex(PathRailingsIndex newEntryIndex)
{
log_verbose("Setting railing entry index to %d", newEntryIndex);
RailingsIndex = newEntryIndex;
}
uint8_t PathElement::GetQueueBannerDirection() const

View File

@@ -22,6 +22,7 @@ struct rct_footpath_entry;
class LargeSceneryObject;
class TerrainSurfaceObject;
class TerrainEdgeObject;
class FootpathRailingsObject;
using track_type_t = uint16_t;
constexpr const uint8_t MAX_ELEMENT_HEIGHT = 255;
@@ -279,7 +280,7 @@ public:
void SetSurfaceEntryIndex(PathSurfaceIndex newIndex);
PathRailingsIndex GetRailingEntryIndex() const;
PathRailingsEntry* GetRailingEntry() const;
FootpathRailingsObject* GetRailingEntry() const;
void SetRailingEntryIndex(PathRailingsIndex newIndex);
uint8_t GetQueueBannerDirection() const;