From c6d7c08d581e2e1dca44e1ac9eb82b7d7f76f634 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 29 Apr 2013 19:24:12 +0000 Subject: [PATCH] Generalize ZRANGE and ANGRANGE to accept any nonnegative number. Numbers 0 and 1 mean 'no spread', but the latter does one krand() call. Negative numbers are reserved for potential future use. git-svn-id: https://svn.eduke32.com/eduke32@3715 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 2 ++ polymer/eduke32/source/player.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index aa6fe7a07..1a7982b5d 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -3294,6 +3294,8 @@ static void P_FinishWaterChange(int32_t j, DukePlayer_t *ps, int32_t sectlotag, } } +// Check prevention of teleportation *when alive*. For example, commanders and +// octabrains would be transported by SE7 (both water and normal) only if dead. static int32_t A_CheckNonTeleporting(int32_t s) { int32_t pic = sprite[s].picnum; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index f26c9bcda..2294a256c 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -434,9 +434,11 @@ static void Proj_MaybeAddSpread(int32_t not_accurate_p, int32_t *zvel, int16_t * { if (not_accurate_p) { - // NOTE: if {z,ang}Range is 0, there is a huge spread - *zvel += (zRange/2)-(krand()&(zRange-1)); - *sa += (angRange/2)-(krand()&(angRange-1)); + // Ranges <= 1 mean no spread at all. A range of 1 calls krand() though. + if (zRange > 0) + *zvel += zRange/2 - krand()%zRange; + if (angRange > 0) + *sa += angRange/2 - krand()%angRange; } } @@ -693,7 +695,7 @@ static int32_t P_PostFireHitscan(int32_t p, int32_t k, hitdata_t *hit, int32_t i { l = A_Spawn(k, decaltile); - if (!A_CheckSpriteFlags(l , SPRITE_DECAL)) + if (!A_CheckSpriteFlags(l, SPRITE_DECAL)) actor[l].flags |= SPRITE_DECAL; sprite[l].xvel = -1; @@ -971,7 +973,7 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel) { k = A_Spawn(i,proj->decal); - if (!A_CheckSpriteFlags(k , SPRITE_DECAL)) + if (!A_CheckSpriteFlags(k, SPRITE_DECAL)) actor[k].flags |= SPRITE_DECAL; sprite[k].xvel = -1;