From cd6ab6178c7daf0aa1c00eda66671f57fc1f73fd Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 19 May 2006 10:04:03 +0000 Subject: (svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations --- aircraft_cmd.c | 2 ++ newgrf_engine.c | 2 +- roadveh_cmd.c | 1 + ship_cmd.c | 1 + train_cmd.c | 4 ++++ vehicle.h | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/aircraft_cmd.c b/aircraft_cmd.c index fd7dad834..e52618210 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -236,6 +236,8 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->cargo_type = CT_PASSENGERS; u->cargo_type = CT_MAIL; + v->cargo_subtype = 0; + v->string_id = STR_SV_AIRCRAFT_NAME; // v->next_order_param = v->next_order = 0; diff --git a/newgrf_engine.c b/newgrf_engine.c index 3a7773130..e4c3074c2 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -675,7 +675,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by case 0x5F: return v->value & 0xFF; case 0x60: return v->string_id; case 0x61: return v->string_id & 0xFF; - case 0x72: return 0; // XXX Refit cycle + case 0x72: return v->cargo_subtype; case 0x7A: return v->random_bits; case 0x7B: return v->waiting_triggers; } diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 963f635ec..0c93972de 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -156,6 +156,7 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->spritenum = rvi->image_index; v->cargo_type = rvi->cargo_type; + v->cargo_subtype = 0; v->cargo_cap = rvi->capacity; // v->cargo_count = 0; v->value = cost; diff --git a/ship_cmd.c b/ship_cmd.c index 1d6e1383d..0f9abf178 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -863,6 +863,7 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->spritenum = svi->image_index; v->cargo_type = svi->cargo_type; + v->cargo_subtype = 0; v->cargo_cap = svi->capacity; v->value = value; diff --git a/train_cmd.c b/train_cmd.c index bf6996ccc..1810d5925 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -535,6 +535,7 @@ static void AddArticulatedParts(const RailVehicleInfo *rvi, Vehicle **vl) u->spritenum = rvi_artic->image_index; if (flip_image) u->spritenum++; u->cargo_type = rvi_artic->cargo_type; + u->cargo_subtype = 0; u->cargo_cap = rvi_artic->capacity; u->max_speed = 0; u->max_age = 0; @@ -616,6 +617,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) } v->cargo_type = rvi->cargo_type; + v->cargo_subtype = 0; v->cargo_cap = rvi->capacity; v->value = value; // v->day_counter = 0; @@ -681,6 +683,7 @@ static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool buildin SetMultiheaded(u); u->spritenum = v->spritenum + 1; u->cargo_type = v->cargo_type; + u->cargo_subtype = v->cargo_subtype; u->cargo_cap = v->cargo_cap; u->u.rail.railtype = v->u.rail.railtype; if (building) v->next = u; @@ -763,6 +766,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; v->spritenum = rvi->image_index; v->cargo_type = rvi->cargo_type; + v->cargo_subtype = 0; v->cargo_cap = rvi->capacity; v->max_speed = rvi->max_speed; v->value = value; diff --git a/vehicle.h b/vehicle.h index e6a1f5dbf..a4939c69e 100644 --- a/vehicle.h +++ b/vehicle.h @@ -183,6 +183,7 @@ struct Vehicle { StationID cargo_source;// source of cargo uint16 cargo_cap; // total capacity uint16 cargo_count;// how many pieces are used + byte cargo_subtype; ///< Used for livery refits (NewGRF variations) byte day_counter; // increased by one for each day byte tick_counter;// increased by one for each tick -- cgit v1.2.3-70-g09d2