1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 14:02:59 +01:00

Fix fallback for missing path objects

This commit is contained in:
ζeh Matt
2021-10-15 01:12:38 +03:00
parent 0ef4ed35e9
commit 7f3dc5c001

View File

@@ -699,6 +699,25 @@ static ObjectEntryIndex TrackDesignGetDefaultRailingIndex()
return OBJECT_ENTRY_INDEX_NULL;
}
static ObjectEntryIndex TrackDesignGetDefaultPathIndex(bool isQueue)
{
for (ObjectEntryIndex i = 0; i < MAX_PATH_OBJECTS; i++)
{
auto legacyPathEntry = GetLegacyFootpathEntry(i);
if (legacyPathEntry != nullptr)
{
const auto& surfaceDescriptor = isQueue ? legacyPathEntry->GetQueueSurfaceDescriptor()
: legacyPathEntry->GetPathSurfaceDescriptor();
if (surfaceDescriptor.IsEditorOnly())
{
continue;
}
return i;
}
}
return OBJECT_ENTRY_INDEX_NULL;
}
static std::optional<TrackSceneryEntry> TrackDesignPlaceSceneryElementGetEntry(const TrackDesignSceneryElement& scenery)
{
TrackSceneryEntry result;
@@ -734,6 +753,13 @@ static std::optional<TrackSceneryEntry> TrackDesignPlaceSceneryElementGetEntry(c
if (result.SecondaryIndex == OBJECT_ENTRY_INDEX_NULL)
result.SecondaryIndex = TrackDesignGetDefaultRailingIndex();
// NOTE: This block can be deleted in the NSF branch.
if (result.Index == OBJECT_ENTRY_INDEX_NULL)
{
result.Type = ObjectType::Paths;
result.Index = TrackDesignGetDefaultPathIndex(scenery.IsQueue());
}
if (result.Index == OBJECT_ENTRY_INDEX_NULL)
{
_trackDesignPlaceStateSceneryUnavailable = true;