0x00444C4E
| 236 | |
| 237 | // 0x00444C4E |
| 238 | static void loadScenarioProgress(ScenarioIndexEntry& entry, Scenario::Options& options) |
| 239 | { |
| 240 | const auto deliveredCargoObjTempLoaded = ObjectManager::loadTemporaryObject(options.objectiveDeliveredCargo); |
| 241 | Scenario::Objective objective = options.objective; |
| 242 | Scenario::ObjectiveProgress progress{}; |
| 243 | progress.timeLimitUntilYear = objective.timeLimitYears + options.scenarioStartYear - 1; |
| 244 | if (deliveredCargoObjTempLoaded) |
| 245 | { |
| 246 | objective.deliveredCargoType = 0xFF; // Used to indicate formatChallengeArguments to use tempObj |
| 247 | } |
| 248 | std::optional<ObjectHeader> previousCurrency; |
| 249 | if (ObjectManager::get<CurrencyObject>() != nullptr) |
| 250 | { |
| 251 | previousCurrency = ObjectManager::getHeader(LoadedObjectHandle{ ObjectType::currency, 0 }); |
| 252 | ObjectManager::unload(*previousCurrency); |
| 253 | } |
| 254 | ObjectManager::load(options.currency); |
| 255 | Gfx::loadCurrency(); |
| 256 | |
| 257 | FormatArguments args{}; |
| 258 | Scenario::formatChallengeArguments(objective, progress, args); |
| 259 | |
| 260 | FormatArgumentsView argsView{ args }; |
| 261 | const auto stringId = argsView.pop<StringId>(); |
| 262 | |
| 263 | // TODO: Validate that argsView is copied in the current state. |
| 264 | StringManager::formatString(entry.objective, stringId, argsView); |
| 265 | |
| 266 | ObjectManager::freeTemporaryObject(); |
| 267 | |
| 268 | // Original didn't clean up like this |
| 269 | if (previousCurrency) |
| 270 | { |
| 271 | ObjectManager::unload(options.currency); |
| 272 | ObjectManager::load(*previousCurrency); |
| 273 | Gfx::loadCurrency(); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | static std::optional<uint32_t> findScenario(const fs::path& fileName) |
| 278 | { |
no test coverage detected