diff options
author | truelight <truelight@openttd.org> | 2005-01-08 12:47:26 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-01-08 12:47:26 +0000 |
commit | 788f543bc3a778895a10480d4b9e65e3a488e41f (patch) | |
tree | eb8091f14551600fb73a27878ecd5163e0e72187 | |
parent | 3be9515d846cdd62bbdac65d2eba2655ca207cda (diff) | |
download | openttd-788f543bc3a778895a10480d4b9e65e3a488e41f.tar.xz |
(svn r1429) Change: bumped savegame to revision 5.
- Now orders are bigger
- Now _map2 is official 16 bits
-rw-r--r-- | saveload.c | 4 | ||||
-rw-r--r-- | vehicle.c | 42 | ||||
-rw-r--r-- | vehicle.h | 30 |
3 files changed, 46 insertions, 30 deletions
diff --git a/saveload.c b/saveload.c index b99796256..328ac91be 100644 --- a/saveload.c +++ b/saveload.c @@ -7,8 +7,8 @@ #include "saveload.h" enum { - SAVEGAME_MAJOR_VERSION = 4, - SAVEGAME_MINOR_VERSION = 4, + SAVEGAME_MAJOR_VERSION = 5, + SAVEGAME_MINOR_VERSION = 0, SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION }; @@ -598,7 +598,7 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v) uint32 full = 0, not_full = 0; //special handling of aircraft - + //if the aircraft carries passengers and is NOT full, then //continue loading, no matter how much mail is in if ((v->type == VEH_Aircraft) && (v->cargo_type == CT_PASSENGERS) && (v->cargo_cap != v->cargo_count)) { @@ -1507,7 +1507,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) if it is a multiheaded engine (rear engine) (rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) is true if the engine is heading the other way, otherwise 0*/ v->spritenum = rvi->image_index + (( rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) ? 1 : 0); - + // turn the last engine in a multiheaded train if needed if ( v->next == NULL && rvi->flags & RVI_MULTIHEAD && v->spritenum == rvi->image_index ) v->spritenum++; @@ -2023,10 +2023,6 @@ static void Save_VEHS() // Write the vehicles FOR_ALL_VEHICLES(v) { if (v->type != 0) { - /* XXX - Here for now, because we did not bump the savegame to version 5 yet */ - if (_sl.version < 5 && v->last_station_visited == 0xFFFF) - v->last_station_visited = 0xFF; - SlSetArrayIndex(v->index); SlObject(v, _veh_descs[v->type - 0x10]); } @@ -2128,7 +2124,7 @@ static void Load_CHKP() static void Save_ORDR() { - uint16 orders[lengthof(_order_array)]; + uint32 orders[lengthof(_order_array)]; uint len = _ptr_to_next_order - _order_array; uint i; @@ -2137,22 +2133,38 @@ static void Save_ORDR() for (i = 0; i < len; ++i) orders[i] = PackOrder(&_order_array[i]); - SlArray(orders, len, SLE_UINT16); + SlArray(orders, len, SLE_UINT32); } static void Load_ORDR() { - uint16 orders[lengthof(_order_array)]; - uint len = SlGetFieldLength() >> 1; + uint len = SlGetFieldLength(); uint i; - assert (len <= lengthof(orders)); + if (_sl.version < 5) { + /* Older version had an other layout for orders.. convert them correctly */ + uint16 orders[lengthof(_order_array)]; - _ptr_to_next_order = _order_array + len; - SlArray(orders, len, SLE_UINT16); + len /= sizeof(uint16); + assert (len <= lengthof(orders)); - for (i = 0; i < len; ++i) - _order_array[i] = UnpackOrder(orders[i]); + SlArray(orders, len, SLE_UINT16); + + for (i = 0; i < len; ++i) + _order_array[i] = UnpackVersion4Order(orders[i]); + } else { + uint32 orders[lengthof(_order_array)]; + + len /= sizeof(uint32); + assert (len <= lengthof(orders)); + + SlArray(orders, len, SLE_UINT32); + + for (i = 0; i < len; ++i) + _order_array[i] = UnpackOrder(orders[i]); + } + + _ptr_to_next_order = _order_array + len; } const ChunkHandler _veh_chunk_handlers[] = { @@ -4,27 +4,31 @@ #include "vehicle_gui.h" typedef struct Order { -#ifdef TTD_LITTLE_ENDIAN /* XXX hack to avoid savegame revision bump */ - uint8 type:4; - uint8 flags:4; -#else - uint8 flags:4; - uint8 type:4; -#endif + uint8 type; + uint8 flags; uint16 station; } Order; -static inline uint16 PackOrder(const Order *order) +static inline uint32 PackOrder(const Order *order) { - return order->station << 8 | order->flags << 4 | order->type; + return order->station << 16 | order->flags << 8 | order->type; } -static inline Order UnpackOrder(uint16 packed) +static inline Order UnpackOrder(uint32 packed) { Order order; - order.type = (packed & 0x000f); - order.flags = (packed & 0x00f0) >> 4, - order.station = (packed & 0xff00) >> 8; + order.type = (packed & 0x000000FF); + order.flags = (packed & 0x0000FF00) >> 8; + order.station = (packed & 0xFFFF0000) >> 16; + return order; +} + +static inline Order UnpackVersion4Order(uint16 packed) +{ + Order order; + order.type = (packed & 0x000F); + order.flags = (packed & 0x00F0) >> 4; + order.station = (packed & 0xFF00) >> 8; return order; } |