diff options
author | truelight <truelight@openttd.org> | 2004-09-15 18:36:33 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2004-09-15 18:36:33 +0000 |
commit | a69e422cdda77f59e77c8db7bd1b8af0bf8dafdb (patch) | |
tree | e7f4d150b64cd500924d16fb14705ca8702375d3 /misc.c | |
parent | 0346fec1cad4fa96368e3102c2b42d0a85e288e1 (diff) | |
download | openttd-a69e422cdda77f59e77c8db7bd1b8af0bf8dafdb.tar.xz |
(svn r266) -Fix: hopefully fixed the desync problem nicely (and reverted the
workaround for it)
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -15,15 +15,20 @@ static INLINE uint32 ROR(uint32 x, int n) return (x >> n) + (x << ((sizeof(x)*8)-n)); } -/* Fuck bitch code, most probably one of the loops (tileloop, vehicleloop, etc.) - * doesn't set up/reset _current_player so the normal random below fails #$%@$#! - * The old code below is prune to desyncs because randoms interfere. - * SO FIND THE OFFENDING LOOP AND FIX IT ONCE AND FOR ALL */ -#undef NORMAL_RANDOM // unuseable game, desyncs way too fast +// For multiplayer, we introduced this new way of random-seeds +// It is player-based, so 2 clients can do 2 commands at the same time +// without the game desyncing. +// It is not used for non-multiplayer games +#ifdef ENABLE_NETWORK + #define PLAYER_SEED_RANDOM +#else + #undef PLAYER_SEED_RANDOM +#endif + uint32 Random() { -#ifdef NORMAL_RANDOM - if (_current_player>=MAX_PLAYERS) { +#ifdef PLAYER_SEED_RANDOM + if (_current_player>=MAX_PLAYERS || !_networking) { uint32 s = _random_seeds[0][0]; uint32 t = _random_seeds[0][1]; _random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7); |