(svn r3396) - Autoreplace changes:

- Change fixed array per player to a single pool. This avoids future problems
    with vehicle numbers and decreases savegame size. Engine replacements from
    previous savegames will be lost.
  - Move engine replacement code from players.c to engine.c.
                                      (thanks to blathijs for rewriting this)
This commit is contained in:
peter1138
2006-01-12 15:52:18 +00:00
parent 28ca056d56
commit 90aff7a026
12 changed files with 360 additions and 116 deletions

View File

@@ -29,7 +29,7 @@
#include <setjmp.h>
enum {
SAVEGAME_VERSION = 18,
SAVEGAME_VERSION = 19,
};
@@ -1051,6 +1051,7 @@ static void UninitWriteZlib(void)
// these define the chunks
extern const ChunkHandler _misc_chunk_handlers[];
extern const ChunkHandler _player_chunk_handlers[];
extern const ChunkHandler _engine_chunk_handlers[];
extern const ChunkHandler _veh_chunk_handlers[];
extern const ChunkHandler _waypoint_chunk_handlers[];
extern const ChunkHandler _depot_chunk_handlers[];
@@ -1059,7 +1060,6 @@ extern const ChunkHandler _town_chunk_handlers[];
extern const ChunkHandler _sign_chunk_handlers[];
extern const ChunkHandler _station_chunk_handlers[];
extern const ChunkHandler _industry_chunk_handlers[];
extern const ChunkHandler _engine_chunk_handlers[];
extern const ChunkHandler _economy_chunk_handlers[];
extern const ChunkHandler _animated_tile_chunk_handlers[];
@@ -1107,6 +1107,7 @@ static uint ReferenceToInt(const void *obj, SLRefType rt)
case REF_TOWN: return ((const Town*)obj)->index + 1;
case REF_ORDER: return ((const Order*)obj)->index + 1;
case REF_ROADSTOPS: return ((const RoadStop*)obj)->index + 1;
case REF_ENGINE_RENEWS: return ((const EngineRenew*)obj)->index + 1;
default: NOT_REACHED();
}
@@ -1162,6 +1163,11 @@ static void *IntToReference(uint index, SLRefType rt)
error("RoadStops: failed loading savegame: too many RoadStops");
return GetRoadStop(index);
}
case REF_ENGINE_RENEWS: {
if (!AddBlockIfNeeded(&_engine_renew_pool, index))
error("EngineRenews: failed loading savegame: too many EngineRenews");
return GetEngineRenew(index);
}
case REF_VEHICLE_OLD: {
/* Old vehicles were saved differently: