(svn r17124) -Codechange: store subsidies in a pool (instead of an array)
This commit is contained in:
@@ -1902,7 +1902,7 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
/* Awarded subsidy or invalid source/destination, invalidate */
|
||||
s->cargo_type = CT_INVALID;
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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[] = {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user