changeset 15336:3e790f032a7c draft

(svn r19977) -Add: Read current date during SL_LOAD_CHECK.
author frosch <frosch@openttd.org>
date Sun, 13 Jun 2010 14:14:20 +0000
parents 3d75c6abc840
children c37904846c25
files src/fios.h src/fios_gui.cpp src/saveload/misc_sl.cpp
diffstat 3 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/fios.h
+++ b/src/fios.h
@@ -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 @@
 	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)
 	{
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -46,6 +46,7 @@
 	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;
 }
 
 
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -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 @@
 	    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 @@
 	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 @@
 }
 
 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},
 };