forked from rosebudai/OpenRCT2-Web
Merge pull request #27239 from Gymnasiast/refactor/park-info-objects
Fix "openrct2 parkinfo objects" crashing every time
This commit is contained in:
2 files changed
+21
-8
No files matched your search
@@ -39,6 +39,7 @@
|
||||
- Fix: [#27136] Guests keep waiting at a level crossing after the train has passed, due to faulty iteration over the track the train has vacated.
|
||||
- Fix: [#27212] Chain lifts are blue in screenshots taken from the command line.
|
||||
- Fix: [#27218] Tile inspector coordinate spinners are too short for coordinate 1000.
|
||||
- Fix: [#27233] `openrct2 parkinfo objects` crashes when called with a scenario instead of save.
|
||||
- Fix: [#27234] [Plugin] Setting `TrackElement.seatRotation` fails on every ride except mazes, where it does not apply.
|
||||
|
||||
0.5.5 (2026-09-06)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../FileClassifier.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../ParkImporter.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/FileStream.h"
|
||||
@@ -55,6 +56,8 @@ namespace OpenRCT2
|
||||
auto sourcePath = Path::GetAbsolute(rawSourcePath);
|
||||
|
||||
auto context = CreateContext();
|
||||
// Needed for Context::Initialise(), because it will try and load the game proper otherwise, and crash.
|
||||
gOpenRCT2Headless = true;
|
||||
context->Initialise();
|
||||
|
||||
auto stream = FileStream(sourcePath, FileMode::open);
|
||||
@@ -87,16 +90,19 @@ namespace OpenRCT2
|
||||
// Save is an S6 (RCT2 format)
|
||||
parkImporter = ParkImporter::CreateS6(objectRepository);
|
||||
}
|
||||
auto loadResult = parkImporter->LoadSavedGame(sourcePath.c_str());
|
||||
auto loadResult = parkImporter->Load(sourcePath.c_str(), false);
|
||||
|
||||
Console::WriteLine("File contains the following objects: ");
|
||||
Console::WriteLine();
|
||||
|
||||
constexpr std::array typeToName = {
|
||||
"Ride", "SmallScenery", "LargeScenery", "Walls", "Banners", "Paths",
|
||||
"PathAdditions", "SceneryGroup", "ParkEntrance", "Water", "ScenarioMeta", "TerrainSurface",
|
||||
"TerrainEdge", "Station", "Music", "FootpathSurface", "FootpathRailings",
|
||||
constexpr std::array kTypeToName = {
|
||||
"Ride", "SmallScenery", "LargeScenery", "Walls", "Banners", "Paths",
|
||||
"PathAdditions", "SceneryGroup", "ParkEntrance", "Water", "ScenarioMeta", "TerrainSurface",
|
||||
"TerrainEdge", "Station", "Music", "FootpathSurface", "FootpathRailings", "Audio",
|
||||
"PeepNames", "PeepAnimations", "Climate",
|
||||
};
|
||||
static_assert(kTypeToName.size() == static_cast<size_t>(ObjectType::count));
|
||||
|
||||
constexpr std::array sourceGameToName = {
|
||||
"Custom", "WackyWorlds", "TimeTwister", "OpenRCT2Official", "RCT1", "AddedAttractions", "LoopyLandscapes",
|
||||
"", "RCT2",
|
||||
@@ -120,19 +126,25 @@ namespace OpenRCT2
|
||||
ObjectType::music,
|
||||
ObjectType::footpathSurface,
|
||||
ObjectType::footpathRailings,
|
||||
ObjectType::peepNames,
|
||||
ObjectType::peepAnimations,
|
||||
ObjectType::climate,
|
||||
})
|
||||
{
|
||||
auto& list = loadResult.RequiredObjects.GetList(objType);
|
||||
Console::WriteLine("ObjectType: %s, Number of Objects: %d", typeToName[EnumValue(objType)], list.size());
|
||||
Console::WriteLine("ObjectType: %s, Number of Objects: %d", kTypeToName[EnumValue(objType)], list.size());
|
||||
for (auto& obj : list)
|
||||
{
|
||||
if (obj.Generation == ObjectGeneration::json && obj.Identifier.empty())
|
||||
{
|
||||
// Empty object slot don't output anything
|
||||
// Empty object slot, don't output anything
|
||||
continue;
|
||||
}
|
||||
auto* ori = GetContext()->GetObjectRepository().FindObject(obj);
|
||||
Console::WriteFormat("%s Object: ", sourceGameToName[EnumValue(ori->GetFirstSourceGame())]);
|
||||
auto sourceGame = ObjectSourceGame::custom;
|
||||
if (ori != nullptr)
|
||||
sourceGame = ori->GetFirstSourceGame();
|
||||
Console::WriteFormat("%s Object: ", sourceGameToName[EnumValue(sourceGame)]);
|
||||
|
||||
std::string name{ obj.GetName() };
|
||||
if (obj.Generation == ObjectGeneration::dat)
|
||||
|
||||
Reference in new issue
Block a user