src/oldloader.cpp
changeset 9358 2e1e4d2f71dd
parent 9200 ae323616f9ab
child 9359 3a8554ac1cb8
equal deleted inserted replaced
9357:f540f1fb6bd9 9358:2e1e4d2f71dd
   317 	Town *town;
   317 	Town *town;
   318 
   318 
   319 	/* Convert town-names if needed */
   319 	/* Convert town-names if needed */
   320 	FOR_ALL_TOWNS(town) {
   320 	FOR_ALL_TOWNS(town) {
   321 		if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
   321 		if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
   322 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
   322 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings.game_creation.town_name;
   323 			town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
   323 			town->townnameparts = GetOldTownName(town->townnameparts, _settings.game_creation.town_name);
   324 		}
   324 		}
   325 	}
   325 	}
   326 }
   326 }
   327 
   327 
   328 static void FixOldStations()
   328 static void FixOldStations()
  1368 {
  1368 {
  1369 	return LoadChunk(ls, &_subsidies[num], subsidy_chunk);
  1369 	return LoadChunk(ls, &_subsidies[num], subsidy_chunk);
  1370 }
  1370 }
  1371 
  1371 
  1372 static const OldChunks game_difficulty_chunk[] = {
  1372 static const OldChunks game_difficulty_chunk[] = {
  1373 	OCL_SVAR( OC_UINT16, GameDifficulty, max_no_competitors ),
  1373 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, max_no_competitors ),
  1374 	OCL_SVAR( OC_UINT16, GameDifficulty, competitor_start_time ),
  1374 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, competitor_start_time ),
  1375 	OCL_SVAR( OC_UINT16, GameDifficulty, number_towns ),
  1375 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, number_towns ),
  1376 	OCL_SVAR( OC_UINT16, GameDifficulty, number_industries ),
  1376 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, number_industries ),
  1377 	OCL_SVAR( OC_UINT16, GameDifficulty, max_loan ),
  1377 	OCL_SVAR( OC_FILE_U16 | OC_VAR_U16, DifficultySettings, max_loan ),
  1378 	OCL_SVAR( OC_UINT16, GameDifficulty, initial_interest ),
  1378 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, initial_interest ),
  1379 	OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_costs ),
  1379 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, vehicle_costs ),
  1380 	OCL_SVAR( OC_UINT16, GameDifficulty, competitor_speed ),
  1380 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, competitor_speed ),
  1381 	OCL_SVAR( OC_UINT16, GameDifficulty, competitor_intelligence ),
  1381 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, competitor_intelligence ),
  1382 	OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_breakdowns ),
  1382 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, vehicle_breakdowns ),
  1383 	OCL_SVAR( OC_UINT16, GameDifficulty, subsidy_multiplier ),
  1383 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, subsidy_multiplier ),
  1384 	OCL_SVAR( OC_UINT16, GameDifficulty, construction_cost ),
  1384 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, construction_cost ),
  1385 	OCL_SVAR( OC_UINT16, GameDifficulty, terrain_type ),
  1385 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, terrain_type ),
  1386 	OCL_SVAR( OC_UINT16, GameDifficulty, quantity_sea_lakes ),
  1386 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, quantity_sea_lakes ),
  1387 	OCL_SVAR( OC_UINT16, GameDifficulty, economy ),
  1387 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, economy ),
  1388 	OCL_SVAR( OC_UINT16, GameDifficulty, line_reverse_mode ),
  1388 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, line_reverse_mode ),
  1389 	OCL_SVAR( OC_UINT16, GameDifficulty, disasters ),
  1389 	OCL_SVAR( OC_FILE_U16 |  OC_VAR_U8, DifficultySettings, disasters ),
  1390 	OCL_END()
  1390 	OCL_END()
  1391 };
  1391 };
  1392 
  1392 
  1393 static inline bool LoadOldGameDifficulty(LoadgameState *ls, int num)
  1393 static inline bool LoadOldGameDifficulty(LoadgameState *ls, int num)
  1394 {
  1394 {
  1395 	return LoadChunk(ls, &_opt.diff, game_difficulty_chunk);
  1395 	return LoadChunk(ls, &_settings.difficulty, game_difficulty_chunk);
  1396 }
  1396 }
  1397 
  1397 
  1398 
  1398 
  1399 static bool LoadOldMapPart1(LoadgameState *ls, int num)
  1399 static bool LoadOldMapPart1(LoadgameState *ls, int num)
  1400 {
  1400 {
  1568 	OCL_NULL( 144 ),             ///< AI cargo-stuff, calculated in InitializeLandscapeVariables
  1568 	OCL_NULL( 144 ),             ///< AI cargo-stuff, calculated in InitializeLandscapeVariables
  1569 	OCL_NULL( 2 ),               ///< Company indexes of players, no longer in use
  1569 	OCL_NULL( 2 ),               ///< Company indexes of players, no longer in use
  1570 
  1570 
  1571 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U16,    1, &_station_tick_ctr ),
  1571 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U16,    1, &_station_tick_ctr ),
  1572 
  1572 
  1573 	OCL_VAR (  OC_UINT8,    1, &_opt.currency ),
  1573 	OCL_VAR (  OC_UINT8,    1, &_settings.gui.currency ),
  1574 	OCL_VAR (  OC_UINT8,    1, &_opt.units ),
  1574 	OCL_VAR (  OC_UINT8,    1, &_settings.gui.units ),
  1575 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U32,    1, &_cur_player_tick_index ),
  1575 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U32,    1, &_cur_player_tick_index ),
  1576 
  1576 
  1577 	OCL_NULL( 2 ),               ///< Date stuff, calculated automatically
  1577 	OCL_NULL( 2 ),               ///< Date stuff, calculated automatically
  1578 	OCL_NULL( 8 ),               ///< Player colors, calculated automatically
  1578 	OCL_NULL( 8 ),               ///< Player colors, calculated automatically
  1579 
  1579 
  1580 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount ),
  1580 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount ),
  1581 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount_pr ),
  1581 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount_pr ),
  1582 	OCL_VAR (  OC_UINT8,    1, &_economy.interest_rate ),
  1582 	OCL_VAR (  OC_UINT8,    1, &_economy.interest_rate ),
  1583 	OCL_NULL( 1 ), // available airports
  1583 	OCL_NULL( 1 ), // available airports
  1584 	OCL_VAR (  OC_UINT8,    1, &_opt.road_side ),
  1584 	OCL_VAR (  OC_UINT8,    1, &_settings.vehicle.road_side ),
  1585 	OCL_VAR (  OC_UINT8,    1, &_opt.town_name ),
  1585 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.town_name ),
  1586 
  1586 
  1587 	OCL_CHUNK( 1, LoadOldGameDifficulty ),
  1587 	OCL_CHUNK( 1, LoadOldGameDifficulty ),
  1588 
  1588 
  1589 	OCL_ASSERT( 0x77130 ),
  1589 	OCL_ASSERT( 0x77130 ),
  1590 
  1590 
  1591 	OCL_VAR (  OC_UINT8,    1, &_opt.diff_level ),
  1591 	OCL_VAR (  OC_UINT8,    1, &_settings.difficulty.diff_level ),
  1592 	OCL_VAR (  OC_UINT8,    1, &_opt.landscape ),
  1592 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.landscape ),
  1593 	OCL_VAR (  OC_UINT8,    1, &_trees_tick_ctr ),
  1593 	OCL_VAR (  OC_UINT8,    1, &_trees_tick_ctr ),
  1594 
  1594 
  1595 	OCL_NULL( 1 ),               ///< Custom vehicle types yes/no, no longer used
  1595 	OCL_NULL( 1 ),               ///< Custom vehicle types yes/no, no longer used
  1596 	OCL_VAR (  OC_UINT8,    1, &_opt.snow_line ),
  1596 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.snow_line ),
  1597 
  1597 
  1598 	OCL_NULL( 32 ),              ///< new_industry_randtable, no longer used (because of new design)
  1598 	OCL_NULL( 32 ),              ///< new_industry_randtable, no longer used (because of new design)
  1599 	OCL_NULL( 36 ),              ///< cargo-stuff, calculated in InitializeLandscapeVariables
  1599 	OCL_NULL( 36 ),              ///< cargo-stuff, calculated in InitializeLandscapeVariables
  1600 
  1600 
  1601 	OCL_ASSERT( 0x77179 ),
  1601 	OCL_ASSERT( 0x77179 ),
  1626 		return false;
  1626 		return false;
  1627 	}
  1627 	}
  1628 	DEBUG(oldloader, 3, "Done, converting game data...");
  1628 	DEBUG(oldloader, 3, "Done, converting game data...");
  1629 
  1629 
  1630 	/* Fix some general stuff */
  1630 	/* Fix some general stuff */
  1631 	_opt.landscape = _opt.landscape & 0xF;
  1631 	_settings.game_creation.landscape = _settings.game_creation.landscape & 0xF;
  1632 
  1632 
  1633 	/* Remap some pointers */
  1633 	/* Remap some pointers */
  1634 	_cur_town_ctr      = REMAP_TOWN_IDX(_old_cur_town_ctr);
  1634 	_cur_town_ctr      = REMAP_TOWN_IDX(_old_cur_town_ctr);
  1635 
  1635 
  1636 	/* _old_map3 is changed in _map3_lo and _map3_hi */
  1636 	/* _old_map3 is changed in _map3_lo and _map3_hi */
  1688 	FixOldTowns();
  1688 	FixOldTowns();
  1689 	FixOldStations();
  1689 	FixOldStations();
  1690 	FixOldVehicles();
  1690 	FixOldVehicles();
  1691 
  1691 
  1692 	/* We have a new difficulty setting */
  1692 	/* We have a new difficulty setting */
  1693 	_opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);
  1693 	_settings.difficulty.town_council_tolerance = Clamp(_settings.difficulty.diff_level, 0, 2);
  1694 
  1694 
  1695 	DEBUG(oldloader, 3, "Finished converting game data");
  1695 	DEBUG(oldloader, 3, "Finished converting game data");
  1696 	DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
  1696 	DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
  1697 
  1697 
  1698 	free(_old_map3);
  1698 	free(_old_map3);