summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-09-15 18:36:33 +0000
committertruelight <truelight@openttd.org>2004-09-15 18:36:33 +0000
commita69e422cdda77f59e77c8db7bd1b8af0bf8dafdb (patch)
treee7f4d150b64cd500924d16fb14705ca8702375d3 /misc.c
parent0346fec1cad4fa96368e3102c2b42d0a85e288e1 (diff)
downloadopenttd-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.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/misc.c b/misc.c
index f3ccb5953..f9a0593b0 100644
--- a/misc.c
+++ b/misc.c
@@ -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);