summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-08-16 22:12:11 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-08-16 22:12:11 +0200
commitdd4c85cf3ad0dcc5a435552fbc265a091a454089 (patch)
tree6d4a0ea15ad2e41f7ed78c9c6e943fdfd69f4041
parentf369fa9d46d67019efd2ebff2556d5092e791613 (diff)
downloadplan9front-dd4c85cf3ad0dcc5a435552fbc265a091a454089.tar.xz
games/doom: fix array offsets for respawn angle (thanks qu7uux)
mthing->angle is a signed short, and if ANG45 * mthing->angle/45 < 0, the result of the right shift is sign extended. afaik, an being 16bit in the dos version of doom, you'd endup with a negative array offset, which would just access values from adjacent arrays (finetangent[] for finecosine[], and finecosine[] for finesine[]), and it would result in a misplaced teleport fog in some circumstances (fog is not in front of the player on respawn, hence "silent teleport"). so, this fix is bug incompatible, but this only affects live multiplay. to test: % hget http://doomedsda.us/dm/ahfx7_2.zip | unzip -sv extracting AHFX7_2.TXT extracting AHFX7_2.LMP % mv AHFX7_2.LMP ahfx7_2.lmp % games/doom -playdemo ahfx7_2 [...] doom 10553: suicide: sys: trap: fault read addr=0x400429e10 pc=0x205b45
-rw-r--r--sys/src/games/doom/g_game.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/games/doom/g_game.c b/sys/src/games/doom/g_game.c
index a653fd2a4..6741498c0 100644
--- a/sys/src/games/doom/g_game.c
+++ b/sys/src/games/doom/g_game.c
@@ -860,7 +860,7 @@ G_CheckSpot
// spawn a teleport fog
ss = R_PointInSubsector (x,y);
- an = ( ANG45 * (mthing->angle/45) ) >> ANGLETOFINESHIFT;
+ an = ( ANG45 * ((unsigned)mthing->angle/45) ) >> ANGLETOFINESHIFT;
mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an]
, ss->sector->floorheight