Changeset - r15326:d5a6f99c5425
[Not reviewed]
master
0 3 0
frosch - 14 years ago 2010-06-13 14:14:20
frosch@openttd.org
(svn r19977) -Add: Read current date during SL_LOAD_CHECK.
3 files changed with 39 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/fios.h
Show inline comments
 
@@ -16,6 +16,7 @@
 
#include "core/smallvec_type.hpp"
 
#include "core/enum_type.hpp"
 
#include "gfx_type.h"
 
#include "date_type.h"
 

	
 

	
 
/**
 
@@ -27,6 +28,7 @@ struct LoadCheckData {
 
	char *error_data;   ///< Data to pass to SetDParamStr when displaying #error.
 

	
 
	uint32 map_size_x, map_size_y;
 
	Date current_date;
 

	
 
	LoadCheckData() : error_data(NULL)
 
	{
src/fios_gui.cpp
Show inline comments
 
@@ -46,6 +46,7 @@ void LoadCheckData::Clear()
 
	this->error_data = NULL;
 

	
 
	this->map_size_x = this->map_size_y = 256; // Default for old savegames which do not store mapsize.
 
	this->current_date = 0;
 
}
 

	
 

	
src/saveload/misc_sl.cpp
Show inline comments
 
@@ -21,6 +21,7 @@
 
#include "../gfx_func.h"
 
#include "../company_base.h"
 
#include "../core/random_func.hpp"
 
#include "../fios.h"
 

	
 
#include "saveload.h"
 

	
 
@@ -86,6 +87,31 @@ static const SaveLoadGlobVarList _date_d
 
	    SLEG_END()
 
};
 

	
 
static const SaveLoadGlobVarList _date_check_desc[] = {
 
	SLEG_CONDVAR(_load_check_data.current_date,  SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
 
	SLEG_CONDVAR(_load_check_data.current_date,  SLE_INT32,                  31, SL_MAX_VERSION),
 
	    SLE_NULL(2),                       // _date_fract
 
	    SLE_NULL(2),                       // _tick_counter
 
	    SLE_NULL(2),                       // _vehicle_id_ctr_day
 
	    SLE_NULL(1),                       // _age_cargo_skip_counter
 
	SLE_CONDNULL(1, 0, 45),
 
	SLE_CONDNULL(2, 0, 5),                 // _cur_tileloop_tile
 
	SLE_CONDNULL(4, 6, SL_MAX_VERSION),    // _cur_tileloop_tile
 
	    SLE_NULL(2),                       // _disaster_delay
 
	SLE_CONDNULL(2, 0, 119),
 
	    SLE_NULL(4),                       // _random.state[0]
 
	    SLE_NULL(4),                       // _random.state[1]
 
	SLE_CONDNULL(1,  0,   9),
 
	SLE_CONDNULL(4, 10, 119),
 
	    SLE_NULL(1),                       // _cur_company_tick_index
 
	SLE_CONDNULL(2, 0, 108),               // _next_competitor_start
 
	SLE_CONDNULL(4, 109, SL_MAX_VERSION),  // _next_competitor_start
 
	    SLE_NULL(1),                       // _trees_tick_ctr
 
	SLE_CONDNULL(1, 4, SL_MAX_VERSION),    // _pause_mode
 
	SLE_CONDNULL(4, 11, 119),
 
	    SLEG_END()
 
};
 

	
 
/* Save load date related variables as well as persistent tick counters
 
 * XXX: currently some unrelated stuff is just put here */
 
static void SaveLoad_DATE()
 
@@ -93,6 +119,14 @@ static void SaveLoad_DATE()
 
	SlGlobList(_date_desc);
 
}
 

	
 
static void Check_DATE()
 
{
 
	SlGlobList(_date_check_desc);
 
	if (CheckSavegameVersion(31)) {
 
		_load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
	}
 
}
 

	
 

	
 
static const SaveLoadGlobVarList _view_desc[] = {
 
	SLEG_CONDVAR(_saved_scrollpos_x,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
@@ -109,6 +143,6 @@ static void SaveLoad_VIEW()
 
}
 

	
 
extern const ChunkHandler _misc_chunk_handlers[] = {
 
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, NULL, NULL, CH_RIFF},
 
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, NULL, NULL, CH_RIFF | CH_LAST},
 
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, NULL, Check_DATE, CH_RIFF},
 
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, NULL, NULL,       CH_RIFF | CH_LAST},
 
};
0 comments (0 inline, 0 general)