diff options
author | smatz <smatz@openttd.org> | 2009-08-08 20:53:36 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-08-08 20:53:36 +0000 |
commit | 13e23141b418214db51e1463bb3696a4e6d87129 (patch) | |
tree | 3b092f293fd5fdc1c1dd17120ba874d919824bf0 /src/saveload | |
parent | 8d809d5f4c21afbed4bbeb0388d42a9c5718a755 (diff) | |
download | openttd-13e23141b418214db51e1463bb3696a4e6d87129.tar.xz |
(svn r17124) -Codechange: store subsidies in a pool (instead of an array)
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 2 | ||||
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 5 | ||||
-rw-r--r-- | src/saveload/subsidy_sl.cpp | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 8427c7d8e..055407a7d 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1902,7 +1902,7 @@ bool AfterLoadGame() } } /* Awarded subsidy or invalid source/destination, invalidate */ - s->cargo_type = CT_INVALID; + delete s; } } diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 14db853bf..8a45d587b 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -1477,7 +1477,10 @@ static const OldChunks subsidy_chunk[] = { static bool LoadOldSubsidy(LoadgameState *ls, int num) { - return LoadChunk(ls, &Subsidy::array[num], subsidy_chunk); + Subsidy *s = new (num) Subsidy(); + bool ret = LoadChunk(ls, s, subsidy_chunk); + if (s->cargo_type == CT_INVALID) delete s; + return ret; } static const OldChunks game_difficulty_chunk[] = { diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp index 163a9ce8c..cf2985a09 100644 --- a/src/saveload/subsidy_sl.cpp +++ b/src/saveload/subsidy_sl.cpp @@ -24,7 +24,7 @@ void Save_SUBS() { Subsidy *s; FOR_ALL_SUBSIDIES(s) { - SlSetArrayIndex(s->Index()); + SlSetArrayIndex(s->index); SlObject(s, _subsidies_desc); } } @@ -33,7 +33,8 @@ void Load_SUBS() { int index; while ((index = SlIterateArray()) != -1) { - SlObject(&Subsidy::array[index], _subsidies_desc); + Subsidy *s = new (index) Subsidy(); + SlObject(s, _subsidies_desc); } } |