MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / goToNextStep

Function goToNextStep

src/OpenLoco/src/EditorController.cpp:312–422  ·  view source on GitHub ↗

0x0043D15D

Source from the content-addressed store, hash-verified

310
311 // 0x0043D15D
312 void goToNextStep()
313 {
314 switch (getCurrentStep())
315 {
316 case Step::null:
317 break;
318
319 case Step::objectSelection:
320 {
321 if (!Windows::ObjectSelectionWindow::tryCloseWindow())
322 {
323 // Try close has failed so do not allow changing step!
324 return;
325 }
326 auto res = validateHeadquarterBuilding();
327 if (res != StringIds::null)
328 {
329 Windows::Error::open(StringIds::invalid_selection_of_objects, res);
330 return;
331 }
332 Scenario::sub_4748D4();
333 Scenario::initialiseSnowLine();
334 Windows::Terraform::resetLastSelections();
335 Scenario::getOptions().editorStep = Step::landscapeEditor;
336 Windows::LandscapeGeneration::open();
337 if ((Scenario::getOptions().scenarioFlags & Scenario::ScenarioFlags::landscapeGenerationDone) != Scenario::ScenarioFlags::none)
338 {
339 if (!Game::hasFlags(GameStateFlags::tileManagerLoaded))
340 {
341 Scenario::generateLandscape();
342 }
343 }
344 break;
345 }
346 case Step::landscapeEditor:
347 {
348 if (!validateStep1())
349 {
350 Windows::Error::open(StringIds::cant_advance_to_next_editor_stage, GameCommands::getErrorText());
351 break;
352 }
353
354 const auto cargoId = Scenario::getOptions().objective.deliveredCargoType;
355 if (ObjectManager::get<CargoObject>(cargoId) == nullptr)
356 {
357 for (size_t i = 0; i < ObjectManager::getMaxObjects(ObjectType::cargo); i++)
358 {
359 if (ObjectManager::get<CargoObject>(i) != nullptr)
360 {
361 Scenario::getOptions().objective.deliveredCargoType = static_cast<uint8_t>(i);
362 break;
363 }
364 }
365 }
366
367 WindowManager::closeAllFloatingWindows();
368 Scenario::initialiseDate(Scenario::getOptions().scenarioStartYear);
369 Scenario::initialiseSnowLine();

Callers 1

onMouseUpFunction · 0.85

Calls 15

getCurrentStepFunction · 0.85
tryCloseWindowFunction · 0.85
sub_4748D4Function · 0.85
initialiseSnowLineFunction · 0.85
resetLastSelectionsFunction · 0.85
generateLandscapeFunction · 0.85
validateStep1Function · 0.85
getErrorTextFunction · 0.85
getMaxObjectsFunction · 0.85
initialiseDateFunction · 0.85

Tested by

no test coverage detected