diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-12 17:28:09 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-12 17:28:09 +0200 |
commit | e4c3f92c163dec741abeadeca80d6a938561dfb3 (patch) | |
tree | e176989ae16f94ac5b87b76588502975964ac59c /sys/src/games/doom/p_mobj.c | |
parent | 34ae4649cc91bf32cd602558a4e953bc3fb8777a (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/p_mobj.c')
-rw-r--r-- | sys/src/games/doom/p_mobj.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/games/doom/p_mobj.c b/sys/src/games/doom/p_mobj.c index 8fcb4c1c5..07eb37a35 100644 --- a/sys/src/games/doom/p_mobj.c +++ b/sys/src/games/doom/p_mobj.c @@ -818,7 +818,7 @@ P_SpawnPuff { mobj_t* th; - z += ((P_Random()-P_Random())<<10); + z += P_Random2()<<10; th = P_SpawnMobj (x,y,z, MT_PUFF); th->momz = FRACUNIT; @@ -846,7 +846,7 @@ P_SpawnBlood { mobj_t* th; - z += ((P_Random()-P_Random())<<10); + z += P_Random2()<<10; th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; th->tics -= P_Random()&3; @@ -909,7 +909,7 @@ P_SpawnMissile // fuzzy player if (dest->flags & MF_SHADOW) - an += (P_Random()-P_Random())<<20; + an += P_Random2()<<20; th->angle = an; an >>= ANGLETOFINESHIFT; |