diff options
author | peter1138 <peter1138@openttd.org> | 2005-12-28 22:29:59 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2005-12-28 22:29:59 +0000 |
commit | 1ffc70079787954dda1182de89eca25f36837490 (patch) | |
tree | 36bb1703510989fc2a6344323a6e775738b29355 /vehicle.c | |
parent | a4de62577deffc10b3d9b1c2c3316c3dbd1d5675 (diff) | |
download | openttd-1ffc70079787954dda1182de89eca25f36837490.tar.xz |
(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.
Diffstat (limited to 'vehicle.c')
-rw-r--r-- | vehicle.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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 |