9front - general discussion about 9front
 help / color / mirror / Atom feed
* games/doom: fix array offsets for respawn angle
@ 2015-08-16 20:04 qux
  2015-08-16 20:19 ` [9front] " cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: qux @ 2015-08-16 20:04 UTC (permalink / raw)
  To: 9front

games/doom: fix array offsets for respawn angle

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

diff -Naur a/sys/src/games/doom/g_game.c b/sys/src/games/doom/g_game.c
--- a/sys/src/games/doom/g_game.c	Wed Jul 29 13:45:35 2015
+++ b/sys/src/games/doom/g_game.c	Sun Aug 16 22:33:07 2015
@@ -860,7 +860,7 @@
 	
     // 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] games/doom: fix array offsets for respawn angle
  2015-08-16 20:04 games/doom: fix array offsets for respawn angle qux
@ 2015-08-16 20:19 ` cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2015-08-16 20:19 UTC (permalink / raw)
  To: 9front

all done. thank you!

--
cinap


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-16 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-16 20:04 games/doom: fix array offsets for respawn angle qux
2015-08-16 20:19 ` [9front] " cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).