From 13e23141b418214db51e1463bb3696a4e6d87129 Mon Sep 17 00:00:00 2001 From: smatz Date: Sat, 8 Aug 2009 20:53:36 +0000 Subject: (svn r17124) -Codechange: store subsidies in a pool (instead of an array) --- src/saveload/afterload.cpp | 2 +- src/saveload/oldloader_sl.cpp | 5 ++++- src/saveload/subsidy_sl.cpp | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/saveload') 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); } } -- cgit v1.2.3-70-g09d2