src/oldloader.cpp
changeset 9413 7042a8ec3fa8
parent 9359 3a8554ac1cb8
child 9466 5a1d4eb2ae07
equal deleted inserted replaced
9412:163c465bf250 9413:7042a8ec3fa8
   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 + _settings.game_creation.town_name;
   322 			town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings_game.game_creation.town_name;
   323 			town->townnameparts = GetOldTownName(town->townnameparts, _settings.game_creation.town_name);
   323 			town->townnameparts = GetOldTownName(town->townnameparts, _settings_game.game_creation.town_name);
   324 		}
   324 		}
   325 	}
   325 	}
   326 }
   326 }
   327 
   327 
   328 static void FixOldStations()
   328 static void FixOldStations()
  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 	bool ret = LoadChunk(ls, &_settings.difficulty, game_difficulty_chunk);
  1395 	bool ret = LoadChunk(ls, &_settings_game.difficulty, game_difficulty_chunk);
  1396 	_settings.difficulty.max_loan *= 1000;
  1396 	_settings_game.difficulty.max_loan *= 1000;
  1397 	return ret;
  1397 	return ret;
  1398 }
  1398 }
  1399 
  1399 
  1400 
  1400 
  1401 static bool LoadOldMapPart1(LoadgameState *ls, int num)
  1401 static bool LoadOldMapPart1(LoadgameState *ls, int num)
  1570 	OCL_NULL( 144 ),             ///< AI cargo-stuff, calculated in InitializeLandscapeVariables
  1570 	OCL_NULL( 144 ),             ///< AI cargo-stuff, calculated in InitializeLandscapeVariables
  1571 	OCL_NULL( 2 ),               ///< Company indexes of players, no longer in use
  1571 	OCL_NULL( 2 ),               ///< Company indexes of players, no longer in use
  1572 
  1572 
  1573 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U16,    1, &_station_tick_ctr ),
  1573 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U16,    1, &_station_tick_ctr ),
  1574 
  1574 
  1575 	OCL_VAR (  OC_UINT8,    1, &_settings.gui.currency ),
  1575 	OCL_VAR (  OC_UINT8,    1, &_settings_client.gui.currency ),
  1576 	OCL_VAR (  OC_UINT8,    1, &_settings.gui.units ),
  1576 	OCL_VAR (  OC_UINT8,    1, &_settings_client.gui.units ),
  1577 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U32,    1, &_cur_player_tick_index ),
  1577 	OCL_VAR ( OC_FILE_U8 | OC_VAR_U32,    1, &_cur_player_tick_index ),
  1578 
  1578 
  1579 	OCL_NULL( 2 ),               ///< Date stuff, calculated automatically
  1579 	OCL_NULL( 2 ),               ///< Date stuff, calculated automatically
  1580 	OCL_NULL( 8 ),               ///< Player colors, calculated automatically
  1580 	OCL_NULL( 8 ),               ///< Player colors, calculated automatically
  1581 
  1581 
  1582 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount ),
  1582 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount ),
  1583 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount_pr ),
  1583 	OCL_VAR (  OC_UINT8,    1, &_economy.infl_amount_pr ),
  1584 	OCL_VAR (  OC_UINT8,    1, &_economy.interest_rate ),
  1584 	OCL_VAR (  OC_UINT8,    1, &_economy.interest_rate ),
  1585 	OCL_NULL( 1 ), // available airports
  1585 	OCL_NULL( 1 ), // available airports
  1586 	OCL_VAR (  OC_UINT8,    1, &_settings.vehicle.road_side ),
  1586 	OCL_VAR (  OC_UINT8,    1, &_settings_game.vehicle.road_side ),
  1587 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.town_name ),
  1587 	OCL_VAR (  OC_UINT8,    1, &_settings_game.game_creation.town_name ),
  1588 
  1588 
  1589 	OCL_CHUNK( 1, LoadOldGameDifficulty ),
  1589 	OCL_CHUNK( 1, LoadOldGameDifficulty ),
  1590 
  1590 
  1591 	OCL_ASSERT( 0x77130 ),
  1591 	OCL_ASSERT( 0x77130 ),
  1592 
  1592 
  1593 	OCL_VAR (  OC_UINT8,    1, &_settings.difficulty.diff_level ),
  1593 	OCL_VAR (  OC_UINT8,    1, &_settings_game.difficulty.diff_level ),
  1594 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.landscape ),
  1594 	OCL_VAR (  OC_UINT8,    1, &_settings_game.game_creation.landscape ),
  1595 	OCL_VAR (  OC_UINT8,    1, &_trees_tick_ctr ),
  1595 	OCL_VAR (  OC_UINT8,    1, &_trees_tick_ctr ),
  1596 
  1596 
  1597 	OCL_NULL( 1 ),               ///< Custom vehicle types yes/no, no longer used
  1597 	OCL_NULL( 1 ),               ///< Custom vehicle types yes/no, no longer used
  1598 	OCL_VAR (  OC_UINT8,    1, &_settings.game_creation.snow_line ),
  1598 	OCL_VAR (  OC_UINT8,    1, &_settings_game.game_creation.snow_line ),
  1599 
  1599 
  1600 	OCL_NULL( 32 ),              ///< new_industry_randtable, no longer used (because of new design)
  1600 	OCL_NULL( 32 ),              ///< new_industry_randtable, no longer used (because of new design)
  1601 	OCL_NULL( 36 ),              ///< cargo-stuff, calculated in InitializeLandscapeVariables
  1601 	OCL_NULL( 36 ),              ///< cargo-stuff, calculated in InitializeLandscapeVariables
  1602 
  1602 
  1603 	OCL_ASSERT( 0x77179 ),
  1603 	OCL_ASSERT( 0x77179 ),
  1628 		return false;
  1628 		return false;
  1629 	}
  1629 	}
  1630 	DEBUG(oldloader, 3, "Done, converting game data...");
  1630 	DEBUG(oldloader, 3, "Done, converting game data...");
  1631 
  1631 
  1632 	/* Fix some general stuff */
  1632 	/* Fix some general stuff */
  1633 	_settings.game_creation.landscape = _settings.game_creation.landscape & 0xF;
  1633 	_settings_game.game_creation.landscape = _settings_game.game_creation.landscape & 0xF;
  1634 
  1634 
  1635 	/* Remap some pointers */
  1635 	/* Remap some pointers */
  1636 	_cur_town_ctr      = REMAP_TOWN_IDX(_old_cur_town_ctr);
  1636 	_cur_town_ctr      = REMAP_TOWN_IDX(_old_cur_town_ctr);
  1637 
  1637 
  1638 	/* _old_map3 is changed in _map3_lo and _map3_hi */
  1638 	/* _old_map3 is changed in _map3_lo and _map3_hi */
  1690 	FixOldTowns();
  1690 	FixOldTowns();
  1691 	FixOldStations();
  1691 	FixOldStations();
  1692 	FixOldVehicles();
  1692 	FixOldVehicles();
  1693 
  1693 
  1694 	/* We have a new difficulty setting */
  1694 	/* We have a new difficulty setting */
  1695 	_settings.difficulty.town_council_tolerance = Clamp(_settings.difficulty.diff_level, 0, 2);
  1695 	_settings_game.difficulty.town_council_tolerance = Clamp(_settings_game.difficulty.diff_level, 0, 2);
  1696 
  1696 
  1697 	DEBUG(oldloader, 3, "Finished converting game data");
  1697 	DEBUG(oldloader, 3, "Finished converting game data");
  1698 	DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
  1698 	DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
  1699 
  1699 
  1700 	free(_old_map3);
  1700 	free(_old_map3);