summaryrefslogtreecommitdiff
path: root/sys/src/games/doom/m_random.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-06-12 17:28:09 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-06-12 17:28:09 +0200
commite4c3f92c163dec741abeadeca80d6a938561dfb3 (patch)
treee176989ae16f94ac5b87b76588502975964ac59c /sys/src/games/doom/m_random.c
parent34ae4649cc91bf32cd602558a4e953bc3fb8777a (diff)
games/doom: fix desyncing demo (thanks qwx)
the code used P_Random()-P_Random() in some places which has undefined evaluation order resulting in the wrong pseudo random numbers being returned causing demo playback to desync. this change adds P_Random2() function which returns the right delta-random number and uses it in place of P_Random()-P_Random() expression.
Diffstat (limited to 'sys/src/games/doom/m_random.c')
-rw-r--r--sys/src/games/doom/m_random.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/src/games/doom/m_random.c b/sys/src/games/doom/m_random.c
index 09f857d0b..957bee316 100644
--- a/sys/src/games/doom/m_random.c
+++ b/sys/src/games/doom/m_random.c
@@ -60,6 +60,12 @@ int P_Random (void)
return rndtable[prndindex];
}
+int P_Random2 (void)
+{
+ int tmp = P_Random();
+ return tmp - P_Random();
+}
+
int M_Random (void)
{
rndindex = (rndindex+1)&0xff;