From: qux <qu7uux@gmail.com>
To: 9front@9front.org
Subject: games/doom: fix array offsets for respawn angle
Date: Sun, 16 Aug 2015 23:04:36 +0300 [thread overview]
Message-ID: <CAAGZaiL+gsa6JWu=BHz61u9wi9GpU2+VdTCb7peO_iW2S8ByRg@mail.gmail.com> (raw)
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
next reply other threads:[~2015-08-16 20:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-16 20:04 qux [this message]
2015-08-16 20:19 ` [9front] " cinap_lenrek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAGZaiL+gsa6JWu=BHz61u9wi9GpU2+VdTCb7peO_iW2S8ByRg@mail.gmail.com' \
--to=qu7uux@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).