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

Function setDefaultScenarioOptions

src/OpenLoco/src/EditorController.cpp:170–206  ·  view source on GitHub ↗

0x00440165

Source from the content-addressed store, hash-verified

168
169 // 0x00440165
170 static void setDefaultScenarioOptions()
171 {
172 auto& options = Scenario::getOptions();
173 auto& gameState = getGameState();
174 // Sets the type of the scenario text to an invalid type
175 options.scenarioText.flags = 0xFF | options.scenarioText.flags;
176
177 auto* obj = ObjectManager::get<ScenarioTextObject>();
178 if (obj != nullptr)
179 {
180 char buffer[256]{};
181 StringManager::formatString(buffer, obj->name);
182 strncpy(options.scenarioName, buffer, std::size(options.scenarioName) - 1);
183 options.scenarioName[std::size(options.scenarioName) - 1] = '\0';
184 // Copy the object
185 options.scenarioText = ObjectManager::getHeader(LoadedObjectHandle{ ObjectType::scenarioText, 0 });
186 }
187
188 if (strnlen(options.scenarioName, sizeof(options.scenarioName)) == 0)
189 {
190 StringManager::formatString(options.scenarioName, StringIds::unnamed);
191 }
192
193 options.scenarioFlags &= ~Scenario::ScenarioFlags::landscapeGenerationDone;
194 if (Game::hasFlags(GameStateFlags::tileManagerLoaded))
195 {
196 options.scenarioFlags |= Scenario::ScenarioFlags::landscapeGenerationDone;
197 Scenario::drawScenarioMiniMapImage();
198 }
199
200 options.maxCompetingCompanies = CompanyManager::getMaxCompetingCompanies();
201 options.competitorStartDelay = CompanyManager::getCompetitorStartDelay();
202 gameState.numberOfIndustries = options.numberOfIndustries;
203 options.objective = Scenario::getObjective();
204 options.objectiveDeliveredCargo = ObjectManager::getHeader(LoadedObjectHandle{ ObjectType::cargo, options.objective.deliveredCargoType });
205 options.currency = ObjectManager::getHeader(LoadedObjectHandle{ ObjectType::currency, 0 });
206 }
207
208 // 0x00440297
209 static void resetLandDistributionPatterns()

Callers 1

goToNextStepFunction · 0.85

Calls 5

formatStringFunction · 0.85
drawScenarioMiniMapImageFunction · 0.85
getMaxCompetingCompaniesFunction · 0.85
getCompetitorStartDelayFunction · 0.85
hasFlagsFunction · 0.70

Tested by

no test coverage detected