diff options
-rw-r--r-- | aircraft_cmd.c | 4 | ||||
-rw-r--r-- | roadveh_cmd.c | 1 | ||||
-rw-r--r-- | ship_cmd.c | 1 | ||||
-rw-r--r-- | train_cmd.c | 4 | ||||
-rw-r--r-- | vehicle.c | 17 | ||||
-rw-r--r-- | vehicle.h | 1 |
6 files changed, 21 insertions, 7 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 4ec0b531f..a6fd64f53 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -265,6 +265,9 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->cur_image = u->cur_image = 0xEA0; + v->random_bits = VehicleRandomBits(); + u->random_bits = VehicleRandomBits(); + VehiclePositionChanged(v); VehiclePositionChanged(u); @@ -286,6 +289,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2) w->vehstatus = VS_HIDDEN | VS_UNCLICKABLE; w->subtype = 6; w->cur_image = SPR_ROTOR_STOPPED; + w->random_bits = VehicleRandomBits(); VehiclePositionChanged(w); } diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 3467f3ae1..a640351ff 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -187,6 +187,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->type = VEH_Road; v->cur_image = 0xC15; + v->random_bits = VehicleRandomBits(); VehiclePositionChanged(v); diff --git a/ship_cmd.c b/ship_cmd.c index 880ef60da..1b117c136 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -888,6 +888,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->build_year = _cur_year; v->cur_image = 0x0E5E; v->type = VEH_Ship; + v->random_bits = VehicleRandomBits(); VehiclePositionChanged(v); diff --git a/train_cmd.c b/train_cmd.c index c3d64385b..f75dff5d7 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -492,6 +492,7 @@ static void AddArticulatedParts(const RailVehicleInfo *rvi, Vehicle **vl) u->subtype = 0; SetArticulatedPart(u); u->cur_image = 0xAC2; + u->random_bits = VehicleRandomBits(); VehiclePositionChanged(u); } @@ -572,6 +573,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) v->build_year = _cur_year; v->type = VEH_Train; v->cur_image = 0xAC2; + v->random_bits = VehicleRandomBits(); AddArticulatedParts(rvi, vl); @@ -652,6 +654,7 @@ void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) u->value = v->value; u->type = VEH_Train; u->cur_image = 0xAC2; + u->random_bits = VehicleRandomBits(); VehiclePositionChanged(u); } @@ -746,6 +749,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->build_year = _cur_year; v->type = VEH_Train; v->cur_image = 0xAC2; + v->random_bits = VehicleRandomBits(); v->subtype = 0; SetFrontEngine(v); @@ -254,16 +254,19 @@ static Vehicle *InitializeVehicle(Vehicle *v) v->next_shared = NULL; v->prev_shared = NULL; v->depot_list = NULL; - /* random_bits is used to pick out a random sprite for vehicles - which are technical the same (newgrf stuff). - Because RandomRange() results in desyncs, and because it does - not really matter that one client has other visual vehicles than - the other, it can be InteractiveRandomRange() without any problem - */ - v->random_bits = InteractiveRandomRange(256); + v->random_bits = 0; return v; } +/** + * Get a value for a vehicle's random_bits. + * @return A random value from 0 to 255. + */ +byte VehicleRandomBits(void) +{ + return GB(Random(), 0, 8); +} + Vehicle *ForceAllocateSpecialVehicle(void) { /* This stays a strange story.. there should always be room for special @@ -271,6 +271,7 @@ void CallVehicleTicks(void); Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z); void InitializeTrains(void); +byte VehicleRandomBits(void); bool CanFillVehicle(Vehicle *v); bool CanRefitTo(EngineID engine_type, CargoID cid_to); |