MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / HandleSimulate

Function HandleSimulate

src/openrct2/command_line/SimulateCommands.cpp:43–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 // clang-format on
42
43 static ExitCode HandleSimulate(CommandLineArgEnumerator* argEnumerator)
44 {
45 const utf8* inputPath;
46 if (!argEnumerator->TryPopString(&inputPath))
47 {
48 Console::Error::WriteLine("Expected a save file path");
49 return ExitCode::fail;
50 }
51
52 int32_t ticks;
53 if (!argEnumerator->TryPopInteger(&ticks))
54 {
55 Console::Error::WriteLine("Expected a number of ticks to simulate");
56 return ExitCode::fail;
57 }
58
59 gOpenRCT2Headless = true;
60
61#ifndef DISABLE_NETWORK
62 gNetworkStart = Network::Mode::server;
63#endif
64
65 std::unique_ptr<IContext> context(CreateContext());
66 if (context->Initialise())
67 {
68 if (!context->LoadParkFromFile(inputPath))
69 {
70 return ExitCode::fail;
71 }
72
73 Console::WriteLine("Running %d ticks...", ticks);
74 for (int32_t i = 0; i < ticks; i++)
75 {
76 gameStateUpdateLogic();
77 }
78 Console::WriteLine("Completed: %s", getGameState().entities.GetAllEntitiesChecksum().ToString().c_str());
79 }
80 else
81 {
82 Console::Error::WriteLine("Context initialization failed.");
83 return ExitCode::fail;
84 }
85
86 return ExitCode::ok;
87 }
88} // namespace OpenRCT2

Callers

nothing calls this directly

Calls 9

WriteLineFunction · 0.85
CreateContextFunction · 0.85
gameStateUpdateLogicFunction · 0.85
TryPopStringMethod · 0.80
TryPopIntegerMethod · 0.80
InitialiseMethod · 0.45
LoadParkFromFileMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected