File diff r27147:5d938ed2c7b5 → r27148:4e041ae27b9d
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -12,24 +12,25 @@
 
#include "../industry.h"
 
#include "../company_func.h"
 
#include "../aircraft.h"
 
#include "../roadveh.h"
 
#include "../ship.h"
 
#include "../train.h"
 
#include "../signs_base.h"
 
#include "../station_base.h"
 
#include "../subsidy_base.h"
 
#include "../debug.h"
 
#include "../depot_base.h"
 
#include "../date_func.h"
 
#include "../timer/timer_game_calendar.h"
 
#include "../vehicle_func.h"
 
#include "../effectvehicle_base.h"
 
#include "../engine_func.h"
 
#include "../company_base.h"
 
#include "../disaster_vehicle.h"
 
#include "../core/smallvec_type.hpp"
 
#include "../timer/timer.h"
 
#include "../timer/timer_game_tick.h"
 
#include "saveload_internal.h"
 
#include "oldloader.h"
 
#include <array>
 

	
 
@@ -389,43 +390,43 @@ static bool FixTTOEngines()
 
		v->engine_type = tto_to_ttd[v->engine_type];
 
	}
 

	
 
	/* Load the default engine set. Many of them will be overridden later */
 
	{
 
		uint j = 0;
 
		for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i);
 
		for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i);
 
		for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i);
 
		for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i);
 
	}
 

	
 
	Date aging_date = std::min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1));
 
	Date aging_date = std::min(TimerGameCalendar::date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1));
 

	
 
	for (EngineID i = 0; i < 256; i++) {
 
		int oi = ttd_to_tto[i];
 
		Engine *e = GetTempDataEngine(i);
 

	
 
		if (oi == 255) {
 
			/* Default engine is used */
 
			_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			TimerGameCalendar::date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			StartupOneEngine(e, aging_date, 0);
 
			CalcEngineReliability(e, false);
 
			e->intro_date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			_date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			TimerGameCalendar::date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 

	
 
			/* Make sure for example monorail and maglev are available when they should be */
 
			if (_date >= e->intro_date && HasBit(e->info.climates, 0)) {
 
			if (TimerGameCalendar::date >= e->intro_date && HasBit(e->info.climates, 0)) {
 
				e->flags |= ENGINE_AVAILABLE;
 
				e->company_avail = MAX_UVALUE(CompanyMask);
 
				e->age = _date > e->intro_date ? (_date - e->intro_date) / 30 : 0;
 
				e->age = TimerGameCalendar::date > e->intro_date ? (TimerGameCalendar::date - e->intro_date) / 30 : 0;
 
			}
 
		} else {
 
			/* Using data from TTO savegame */
 
			Engine *oe = &_old_engines[oi];
 

	
 
			e->intro_date          = oe->intro_date;
 
			e->age                 = oe->age;
 
			e->reliability         = oe->reliability;
 
			e->reliability_spd_dec = oe->reliability_spd_dec;
 
			e->reliability_start   = oe->reliability_start;
 
			e->reliability_max     = oe->reliability_max;
 
			e->reliability_final   = oe->reliability_final;
 
@@ -837,25 +838,25 @@ static bool LoadOldIndustry(LoadgameStat
 
{
 
	Industry *i = new (num) Industry();
 
	if (!LoadChunk(ls, i, industry_chunk)) return false;
 

	
 
	if (i->location.tile != 0) {
 
		i->town = Town::Get(RemapTownIndex(_old_town_index));
 

	
 
		if (_savegame_type == SGT_TTO) {
 
			if (i->type > 0x06) i->type++; // Printing Works were added
 
			if (i->type == 0x0A) i->type = 0x12; // Iron Ore Mine has different ID
 

	
 
			YearMonthDay ymd;
 
			ConvertDateToYMD(_date, &ymd);
 
			ConvertDateToYMD(TimerGameCalendar::date, &ymd);
 
			i->last_prod_year = ymd.year;
 

	
 
			i->random_colour = RemapTTOColour(i->random_colour);
 
		}
 

	
 
		Industry::IncIndustryTypeCount(i->type);
 
	} else {
 
		delete i;
 
	}
 

	
 
	return true;
 
}
 
@@ -1571,26 +1572,26 @@ static bool LoadTTDPatchExtraChunks(Load
 
	return true;
 
}
 

	
 
extern TileIndex _cur_tileloop_tile;
 
extern uint16 _disaster_delay;
 
extern byte _trees_tick_ctr;
 
extern byte _age_cargo_skip_counter; // From misc_sl.cpp
 
extern uint8 _old_diff_level;
 
extern uint8 _old_units;
 
static const OldChunks main_chunk[] = {
 
	OCL_ASSERT( OC_TTD, 0 ),
 
	OCL_ASSERT( OC_TTO, 0 ),
 
	OCL_VAR ( OC_FILE_U16 | OC_VAR_U32, 1, &_date ),
 
	OCL_VAR ( OC_UINT16,   1, &_date_fract ),
 
	OCL_VAR ( OC_FILE_U16 | OC_VAR_U32, 1, &TimerGameCalendar::date ),
 
	OCL_VAR ( OC_UINT16,   1, &TimerGameCalendar::date_fract ),
 
	OCL_NULL( 600 ),            ///< TextEffects
 
	OCL_VAR ( OC_UINT32,   2, &_random.state ),
 

	
 
	OCL_ASSERT( OC_TTD, 0x264 ),
 
	OCL_ASSERT( OC_TTO, 0x264 ),
 

	
 
	OCL_CCHUNK( OC_TTD, 70, LoadOldTown ),
 
	OCL_CCHUNK( OC_TTO, 80, LoadOldTown ),
 

	
 
	OCL_ASSERT( OC_TTD, 0x1C18 ),
 
	OCL_ASSERT( OC_TTO, 0x1AC4 ),