From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by ur; Sun Aug 16 16:04:39 EDT 2015 Received: by wibhh20 with SMTP id hh20so64583226wib.0 for <9front@9front.org>; Sun, 16 Aug 2015 13:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=NXkFGzrM7VUDjOo6MwQLOwuZBBKtVXOmMrgHLWFR5fY=; b=BlhzF1pi3hjirg5u2LCYPWe7wT3fdwZhxxkBfW1h2E5JzMhd8U5UhGkSYZcWV/wIb+ 0DVy0a3yMlCEMbbBzGqsyV+sEmQu9QEiXDeKmkSrMZoWozimmXohbFEJZJGAxn1XOBy7 mNgTk0LcBblx0iIdK8NWav6eW6Ddx5ok20TgzAjDjArcPa5wGDfOsNi85Zs0+j9/ra/I DT/KNaDVdw4DUU9Fetc8o+I9fsStwdfP3hxIMAfy2TA8vPtDGPheN95JmdhP5ae3WPUd WGK2ZYJ4JbXDcl9FkF5LEYmY8oaANmm+amcK3z4jyXTf240Pw+TYGYJCMFE6LLks5R4g NDjw== MIME-Version: 1.0 X-Received: by 10.180.102.74 with SMTP id fm10mr28056618wib.25.1439755476400; Sun, 16 Aug 2015 13:04:36 -0700 (PDT) Received: by 10.28.229.135 with HTTP; Sun, 16 Aug 2015 13:04:36 -0700 (PDT) Date: Sun, 16 Aug 2015 23:04:36 +0300 Message-ID: List-ID: <9front.9front.org> X-Glyph: ➈ X-Bullshit: object-oriented information event XMPP package general-purpose-aware injection CMS interface Subject: games/doom: fix array offsets for respawn angle From: qux To: 9front@9front.org Content-Type: text/plain; charset=UTF-8 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