(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
--- a/src/economy.cpp Wed Mar 21 15:12:30 2007 +0000
+++ b/src/economy.cpp Thu Mar 22 11:11:36 2007 +0000
@@ -1806,9 +1806,16 @@
SlObject(&_economy, _economy_desc);
}
+/** Economy variables */
+static void SaveLoad_ECO2()
+{
+ SlObject(_eco, CEconomy::eco_desc);
+}
+
extern const ChunkHandler _economy_chunk_handlers[] = {
{ 'PRIC', SaveLoad_PRIC, SaveLoad_PRIC, CH_RIFF | CH_AUTO_LENGTH},
{ 'CAPR', SaveLoad_CAPR, SaveLoad_CAPR, CH_RIFF | CH_AUTO_LENGTH},
{ 'SUBS', Save_SUBS, Load_SUBS, CH_ARRAY},
+ { 'ECO2', SaveLoad_ECO2, SaveLoad_ECO2, CH_RIFF},
{ 'ECMY', SaveLoad_ECMY, SaveLoad_ECMY, CH_RIFF | CH_LAST},
};
--- a/src/economy_new.cpp Wed Mar 21 15:12:30 2007 +0000
+++ b/src/economy_new.cpp Thu Mar 22 11:11:36 2007 +0000
@@ -35,6 +35,20 @@
}
/**
+ * Descriptor for the new economy within the savegame
+ */
+/* static */
+const SaveLoad CEconomy::eco_desc[] = {
+ SLE_VAR(CEconomy, m_activity_level, SLE_INT64),
+ SLE_VAR(CEconomy, m_basic_growth, SLE_INT32),
+ SLE_VAR(CEconomy, m_long_term_cycle, SLE_INT8),
+ SLE_VAR(CEconomy, m_short_term_cycle, SLE_INT8),
+ SLE_VAR(CEconomy, m_long_term_ampl, SLE_INT32),
+ SLE_VAR(CEconomy, m_short_term_ampl, SLE_INT32),
+ SLE_END()
+};
+
+/**
* Starts a new economy. As there can always be only one economy in place,
* deletes the one that is currently active
*/
@@ -44,3 +58,4 @@
_eco = new CEconomy;
assert(_eco != NULL);
}
+
--- a/src/economy_new.h Wed Mar 21 15:12:30 2007 +0000
+++ b/src/economy_new.h Thu Mar 22 11:11:36 2007 +0000
@@ -13,9 +13,10 @@
#include "date.h" // current year / date
#include "variables.h" // difficulty
#include "functions.h" // RandomRange
+#include "saveload.h" // Saveload stuff
/**
- * A Base Class used for economic entities in the game that use an activity level
+ * A Base Class used for economic entities in the game that use an activity level.
*/
class EconomicObject {
protected:
@@ -125,6 +126,8 @@
void AdjustActivityByTowns();
+ static const SaveLoad eco_desc[];
+
private:
/**
* Computes the modification of economic growth by cyclic events
--- a/src/openttd.cpp Wed Mar 21 15:12:30 2007 +0000
+++ b/src/openttd.cpp Thu Mar 22 11:11:36 2007 +0000
@@ -1908,6 +1908,11 @@
}
}
+ if (CheckSavegameVersion(54)) {
+ Town *t;
+ FOR_ALL_TOWNS(t) t->SetActivity(1);
+ }
+
return true;
}
--- a/src/saveload.cpp Wed Mar 21 15:12:30 2007 +0000
+++ b/src/saveload.cpp Thu Mar 22 11:11:36 2007 +0000
@@ -28,7 +28,7 @@
#include "variables.h"
#include <setjmp.h>
-extern const uint16 SAVEGAME_VERSION = 53;
+extern const uint16 SAVEGAME_VERSION = 54;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
--- a/src/town.h Wed Mar 21 15:12:30 2007 +0000
+++ b/src/town.h Thu Mar 22 11:11:36 2007 +0000
@@ -6,6 +6,7 @@
#include "oldpool.h"
#include "player.h"
#include "economy_new.h"
+#include "saveload.h"
#include "functions.h"
#include "helpers.hpp"
@@ -199,6 +200,11 @@
* @return The town to which 'group' belongs
*/
static const Town *GetRadiusGroupForTile(TileIndex tile, uint &group);
+
+ /**
+ * Descriptor for the "town" part of the savegame
+ */
+ static const SaveLoad town_desc[];
};
struct HouseSpec {
--- a/src/town_cmd.cpp Wed Mar 21 15:12:30 2007 +0000
+++ b/src/town_cmd.cpp Thu Mar 22 11:11:36 2007 +0000
@@ -1893,9 +1893,8 @@
GetSlopeTileh_Town, /* get_slope_tileh_proc */
};
-
-// Save and load of towns.
-static const SaveLoad _town_desc[] = {
+/* static */
+const SaveLoad Town::town_desc[] = {
SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Town, xy, SLE_UINT32, 6, SL_MAX_VERSION),
@@ -1935,6 +1934,7 @@
SLE_CONDVAR(Town, act_mail, SLE_UINT32, 9, SL_MAX_VERSION),
SLE_CONDVAR(Town, new_act_pass, SLE_UINT32, 9, SL_MAX_VERSION),
SLE_CONDVAR(Town, new_act_mail, SLE_UINT32, 9, SL_MAX_VERSION),
+ SLE_CONDVAR(Town, m_activity_level, SLE_INT64, 54, SL_MAX_VERSION),
SLE_VAR(Town, pct_pass_transported, SLE_UINT8),
SLE_VAR(Town, pct_mail_transported, SLE_UINT8),
@@ -1995,7 +1995,7 @@
FOR_ALL_TOWNS(t) {
SlSetArrayIndex(t->index);
- SlObject(t, _town_desc);
+ SlObject(t, Town::town_desc);
}
}
@@ -2012,7 +2012,7 @@
error("Towns: failed loading savegame: too many towns");
t = GetTown(index);
- SlObject(t, _town_desc);
+ SlObject(t, Town::town_desc);
_total_towns++;
}