MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / LoadTTOMain

Function LoadTTOMain

src/saveload/oldloader_sl.cpp:1830–1873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1828}
1829
1830bool LoadTTOMain(LoadgameState &ls)
1831{
1832 Debug(oldloader, 3, "Reading main chunk...");
1833
1834 _read_ttdpatch_flags = false;
1835
1836 std::array<uint8_t, 103 * sizeof(Engine)> engines; // we don't want to call Engine constructor here
1837 _old_engines = (Engine *)engines.data();
1838
1839 /* Load the biggest chunk */
1840 if (!LoadChunk(ls, nullptr, main_chunk)) {
1841 Debug(oldloader, 0, "Loading failed");
1842 return false;
1843 }
1844 Debug(oldloader, 3, "Done, converting game data...");
1845
1846 if (_settings_game.game_creation.town_name != 0) _settings_game.game_creation.town_name++;
1847
1848 _settings_game.game_creation.landscape = LandscapeType::Temperate;
1849 _trees_tick_ctr = 0xFF;
1850
1851 if (!FixTTOMapArray() || !FixTTOEngines()) {
1852 Debug(oldloader, 0, "Conversion failed");
1853 return false;
1854 }
1855
1856 FixOldTowns();
1857 FixOldVehicles(ls);
1858 FixTTOCompanies();
1859
1860 /* We have a new difficulty setting */
1861 _settings_game.difficulty.town_council_tolerance = Clamp(_old_diff_level, 0, 2);
1862
1863 /* SVXConverter about cargo payment rates correction:
1864 * "increase them to compensate for the faster time advance in TTD compared to TTO
1865 * which otherwise would cause much less income while the annual running costs of
1866 * the vehicles stay the same" */
1867 _economy.inflation_payment = std::min(_economy.inflation_payment * 124 / 74, MAX_INFLATION);
1868
1869 Debug(oldloader, 3, "Finished converting game data");
1870 Debug(oldloader, 1, "TTO savegame successfully converted");
1871
1872 return true;
1873}

Callers

nothing calls this directly

Calls 8

LoadChunkFunction · 0.85
FixTTOMapArrayFunction · 0.85
FixTTOEnginesFunction · 0.85
FixOldTownsFunction · 0.85
FixOldVehiclesFunction · 0.85
FixTTOCompaniesFunction · 0.85
ClampFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected