(svn r3352) - NewGRF: Move initialization of vehicle random_bits to DC_EXEC blocks to allow use of Random() instead of InteractiveRandom(), which will alleviate some possible network desyncs.

This commit is contained in:
peter1138
2005-12-28 22:29:59 +00:00
parent 139d1ed1eb
commit 901068fd6e
6 changed files with 21 additions and 7 deletions

View File

@@ -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