| 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 |
nothing calls this directly
no test coverage detected