summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorsignde <signde@openttd.org>2004-09-14 22:51:37 +0000
committersignde <signde@openttd.org>2004-09-14 22:51:37 +0000
commit9dcf10eb6c3bc0e06f003c79269d1c4c99b5ab22 (patch)
tree118d146d5c22439eb93a3b7587fd820f0fe056ce /misc.c
parenteaeca76e5aef9a7aad2bbe57142e5fefe0118ff6 (diff)
downloadopenttd-9dcf10eb6c3bc0e06f003c79269d1c4c99b5ab22.tar.xz
(svn r261) -Workaround: unplayeable network-game on busy maps because of wrong setup of _current_player. This is only a workaround that can cause desyncs too but not that often
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index b353c5e27..f3ccb5953 100644
--- a/misc.c
+++ b/misc.c
@@ -15,9 +15,14 @@ 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
uint32 Random()
{
+#ifdef NORMAL_RANDOM
if (_current_player>=MAX_PLAYERS) {
uint32 s = _random_seeds[0][0];
uint32 t = _random_seeds[0][1];
@@ -29,6 +34,12 @@ uint32 Random()
_player_seeds[_current_player][0] = s + ROR(t ^ 0x1234567F, 7);
return _player_seeds[_current_player][1] = ROR(s, 3);
}
+#else
+ uint32 s = _random_seeds[0][0];
+ uint32 t = _random_seeds[0][1];
+ _random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7);
+ return _random_seeds[0][1] = ROR(s, 3);
+#endif
}
uint RandomRange(uint max)