diff options
author | alexey.lysiuk | 2014-05-10 15:50:44 +0300 |
---|---|---|
committer | alexey.lysiuk | 2014-05-10 15:50:44 +0300 |
commit | f388d888518486676931e0fc3bd915fbb8b338e3 (patch) | |
tree | b37aff05be295f943f022ee7ea57f84381d08eda | |
parent | 28c1aa1b1cdd315850b649a065cec61e1846d926 (diff) | |
download | chocolate-doom-f388d888518486676931e0fc3bd915fbb8b338e3.tar.gz chocolate-doom-f388d888518486676931e0fc3bd915fbb8b338e3.tar.bz2 chocolate-doom-f388d888518486676931e0fc3bd915fbb8b338e3.zip |
hexen: Fix desync of demo1 on some platforms/compilers
Official release of Hexen's source code relies on unspecified behavior the in order of function's argument evaluation, see ISO-IEC 9899-1999, [6.5.2.2.10]
P_Random() are called in different parameters of P_SpawnMobj() within A_LeafSpawn()
-rw-r--r-- | src/hexen/a_action.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/hexen/a_action.c b/src/hexen/a_action.c index 3100a074..e25b4f84 100644 --- a/src/hexen/a_action.c +++ b/src/hexen/a_action.c @@ -295,10 +295,15 @@ void A_LeafSpawn(mobj_t * actor) for (i = (P_Random() & 3) + 1; i; i--) { - mo = P_SpawnMobj(actor->x + ((P_Random() - P_Random()) << 14), - actor->y + ((P_Random() - P_Random()) << 14), - actor->z + (P_Random() << 14), - MT_LEAF1 + (P_Random() & 1)); + // Official release of Hexen's source code relies on unspecified behavior + // the in order of function's argument evaluation, + // see ISO-IEC 9899-1999, [6.5.2.2.10] + mobjtype_t type = MT_LEAF1 + (P_Random() & 1); + fixed_t z = actor->z + (P_Random() << 14); + fixed_t y = actor->y + ((P_Random() - P_Random()) << 14); + fixed_t x = actor->x + ((P_Random() - P_Random()) << 14); + + mo = P_SpawnMobj(x, y, z, type); if (mo) { P_ThrustMobj(mo, actor->angle, (P_Random() << 9) + 3 * FRACUNIT); |