diff options
author | truelight <truelight@openttd.org> | 2005-02-02 16:16:43 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-02 16:16:43 +0000 |
commit | 0668a6b485fbe99e4fb465cb9efbd5a42f0a1bf9 (patch) | |
tree | 76125ad531fb31d62d879d3f5541edf39532e2d5 | |
parent | c51ed8465d1726d554068ffd9cc278ea50e8e223 (diff) | |
download | openttd-0668a6b485fbe99e4fb465cb9efbd5a42f0a1bf9.tar.xz |
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
(and should be an uint16, not uint8)
-rw-r--r-- | aircraft_cmd.c | 2 | ||||
-rw-r--r-- | economy.c | 8 | ||||
-rw-r--r-- | order_cmd.c | 2 | ||||
-rw-r--r-- | roadveh_cmd.c | 4 | ||||
-rw-r--r-- | saveload.c | 4 | ||||
-rw-r--r-- | ship_cmd.c | 4 | ||||
-rw-r--r-- | station.h | 13 | ||||
-rw-r--r-- | station_cmd.c | 18 | ||||
-rw-r--r-- | station_gui.c | 2 | ||||
-rw-r--r-- | train_cmd.c | 4 | ||||
-rw-r--r-- | vehicle.c | 3 | ||||
-rw-r--r-- | vehicle.h | 2 |
12 files changed, 38 insertions, 28 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 8d8bf19bd..1eefa66f6 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -232,7 +232,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2) // v->load_unload_time_rem = 0; // v->progress = 0; - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; // v->destination_coords = 0; v->max_speed = avi->max_speed; @@ -1208,7 +1208,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type) return false; } -static int32 DeliverGoods(int num_pieces, byte cargo_type, byte source, byte dest, byte days_in_transit) +static int32 DeliverGoods(int num_pieces, byte cargo_type, uint16 source, uint16 dest, byte days_in_transit) { bool subsidised; Station *s_from, *s_to; @@ -1335,7 +1335,7 @@ int LoadUnloadVehicle(Vehicle *v) int unloading_time = 20; Vehicle *u = v; int result = 0; - int last_visited; + uint16 last_visited; Station *st; GoodsEntry *ge; int t; @@ -1358,7 +1358,7 @@ int LoadUnloadVehicle(Vehicle *v) /* unload? */ if (v->cargo_count != 0) { - if (v->cargo_source != (byte)last_visited && ge->waiting_acceptance & 0x8000) { + if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000) { // deliver goods to the station unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */ profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days); @@ -1376,7 +1376,7 @@ int LoadUnloadVehicle(Vehicle *v) // Goods already waiting at station. Set counters to the worst value. if (v->cargo_days >= ge->enroute_time) ge->enroute_time = v->cargo_days; - if ((byte)last_visited != ge->enroute_from) + if (last_visited != ge->enroute_from) ge->enroute_from = v->cargo_source; } // Update amount of waiting cargo diff --git a/order_cmd.c b/order_cmd.c index fe9f22e23..b03305f4b 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -756,7 +756,7 @@ void DeleteDestinationFromVehicleOrder(Order dest) /* Forget about this station if this station is removed */ if (v->last_station_visited == dest.station && dest.type == OT_GOTO_STATION) - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; /* Check the current order */ if (v->current_order.type == dest.type && diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 9ee7d2bf3..63f40e1d1 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -173,7 +173,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->u.road.slotindex = 0; v->u.road.slot_age = 0; - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; v->max_speed = rvi->max_speed; v->engine_type = (byte)p1; @@ -639,7 +639,7 @@ static void ProcessRoadVehOrder(Vehicle *v) if (order->type == OT_GOTO_STATION) { if (order->station == v->last_station_visited) - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; st = GetStation(order->station); { diff --git a/saveload.c b/saveload.c index 7ce00b1ee..8db82bf2c 100644 --- a/saveload.c +++ b/saveload.c @@ -7,8 +7,8 @@ #include "saveload.h" enum { - SAVEGAME_MAJOR_VERSION = 6, - SAVEGAME_MINOR_VERSION = 1, + SAVEGAME_MAJOR_VERSION = 7, + SAVEGAME_MINOR_VERSION = 0, SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION }; diff --git a/ship_cmd.c b/ship_cmd.c index bad598136..42614ed1d 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -254,7 +254,7 @@ static void ProcessShipOrder(Vehicle *v) const Station *st; if (order->station == v->last_station_visited) - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; st = GetStation(order->station); if (st->dock_tile != 0) { @@ -919,7 +919,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->cargo_cap = svi->capacity; v->value = value; - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; v->max_speed = svi->max_speed; v->engine_type = (byte)p1; @@ -9,7 +9,7 @@ typedef struct GoodsEntry { uint16 waiting_acceptance; byte days_since_pickup; byte rating; - byte enroute_from; + uint16 enroute_from; byte enroute_time; byte last_speed; byte last_age; @@ -20,10 +20,13 @@ typedef enum RoadStopType { RS_TRUCK } RoadStopType; -enum { NUM_ROAD_STOPS = 250 }; -enum { ROAD_STOP_LIMIT = 8 }; -enum { NUM_SLOTS = 2 }; -enum { INVALID_SLOT = 0xFFFF }; +enum { + INVALID_STATION = 0xFFFF, + INVALID_SLOT = 0xFFFF, + NUM_SLOTS = 2, + ROAD_STOP_LIMIT = 8, + NUM_ROAD_STOPS = 250, +}; typedef struct RoadStop { TileIndex xy; diff --git a/station_cmd.c b/station_cmd.c index f4a4fc8aa..cbce2014b 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -415,7 +415,7 @@ static void StationInitialize(Station *st, TileIndex tile) for(i=0,ge=st->goods; i!=NUM_CARGO; i++, ge++) { ge->waiting_acceptance = 0; ge->days_since_pickup = 0; - ge->enroute_from = 0xFF; + ge->enroute_from = INVALID_STATION; ge->rating = 175; ge->last_speed = 0; ge->last_age = 0xFF; @@ -2447,7 +2447,7 @@ static void UpdateStationRating(Station *st) ge = st->goods; do { - if (ge->enroute_from != 0xFF) { + if (ge->enroute_from != INVALID_STATION) { byte_inc_sat(&ge->enroute_time); byte_inc_sat(&ge->days_since_pickup); @@ -2589,7 +2589,7 @@ void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radi DistanceManhattan(tile, st->xy) <= radius) { ge = st->goods; for(i=0; i!=NUM_CARGO; i++,ge++) { - if (ge->enroute_from != 0xFF) { + if (ge->enroute_from != INVALID_STATION) { ge->rating = clamp(ge->rating + amount, 0, 255); } } @@ -2808,7 +2808,7 @@ void BuildOilRig(uint tile) for(j=0; j!=NUM_CARGO; j++) { st->goods[j].waiting_acceptance = 0; st->goods[j].days_since_pickup = 0; - st->goods[j].enroute_from = 0xFF; + st->goods[j].enroute_from = INVALID_STATION; st->goods[j].rating = 175; st->goods[j].last_speed = 0; st->goods[j].last_age = 255; @@ -2998,7 +2998,8 @@ static const byte _goods_desc[] = { SLE_VAR(GoodsEntry,waiting_acceptance,SLE_UINT16), SLE_VAR(GoodsEntry,days_since_pickup, SLE_UINT8), SLE_VAR(GoodsEntry,rating, SLE_UINT8), - SLE_VAR(GoodsEntry,enroute_from, SLE_UINT8), + SLE_CONDVAR(GoodsEntry,enroute_from, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), + SLE_CONDVAR(GoodsEntry,enroute_from, SLE_UINT16, 7, 255), SLE_VAR(GoodsEntry,enroute_time, SLE_UINT8), SLE_VAR(GoodsEntry,last_speed, SLE_UINT8), SLE_VAR(GoodsEntry,last_age, SLE_UINT8), @@ -3012,8 +3013,13 @@ static void SaveLoad_STNS(Station *st) int i; SlObject(st, _station_desc); - for (i = 0; i != NUM_CARGO; i++) + for (i = 0; i != NUM_CARGO; i++) { SlObject(&st->goods[i], _goods_desc); + + /* In older versions, enroute_from had 0xFF as INVALID_STATION, is now 0xFFFF */ + if (_sl.full_version < 0x700 && st->goods[i].enroute_from == 0xFF) + st->goods[i].enroute_from = 0xFFFF; + } } static void Save_STNS(void) diff --git a/station_gui.c b/station_gui.c index 0d8fd0b1e..d7316d429 100644 --- a/station_gui.c +++ b/station_gui.c @@ -432,7 +432,7 @@ static void DrawStationViewWindow(Window *w) y = 77; for(i=0; i!=NUM_CARGO; i++) { - if (st->goods[i].enroute_from != 0xFF) { + if (st->goods[i].enroute_from != INVALID_STATION) { SetDParam(0, _cargoc.names_s[i]); SetDParam(2, st->goods[i].rating * 101 >> 8); SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); diff --git a/train_cmd.c b/train_cmd.c index d9473be93..3f56fa801 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -586,7 +586,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->cargo_cap = rvi->capacity; v->max_speed = rvi->max_speed; v->value = value; - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; v->dest_tile = 0; v->engine_type = (byte)p1; @@ -1938,7 +1938,7 @@ static bool ProcessTrainOrder(Vehicle *v) switch (order->type) { case OT_GOTO_STATION: if (order->station == v->last_station_visited) - v->last_station_visited = 0xFFFF; + v->last_station_visited = INVALID_STATION; v->dest_tile = GetStation(order->station)->xy; result = CheckReverseTrain(v); break; @@ -1807,7 +1807,8 @@ const byte _common_veh_desc[] = { SLE_VAR(Vehicle,cargo_type, SLE_UINT8), SLE_VAR(Vehicle,cargo_days, SLE_UINT8), - SLE_VAR(Vehicle,cargo_source, SLE_UINT8), + SLE_CONDVAR(Vehicle,cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), + SLE_CONDVAR(Vehicle,cargo_source, SLE_UINT16, 7, 255), SLE_VAR(Vehicle,cargo_cap, SLE_UINT16), SLE_VAR(Vehicle,cargo_count, SLE_UINT16), @@ -138,7 +138,7 @@ struct Vehicle { byte cargo_type; // type of cargo this vehicle is carrying byte cargo_days; // how many days have the pieces been in transit - byte cargo_source;// source of cargo + uint16 cargo_source;// source of cargo uint16 cargo_cap; // total capacity uint16 cargo_count;// how many pieces are used |