From 689788c65b64b70d91aed65d4cf34f4795898d50 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 10 Aug 2012 19:11:49 +0000 Subject: [PATCH] actors.c: factor out 4 instances of id. code (up to args) into nudge_player(). git-svn-id: https://svn.eduke32.com/eduke32@2874 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index f5b025bad..ac04b5a3c 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -898,16 +898,21 @@ static inline int32_t ifhitsectors(int32_t sectnum) #define IFHITSECT(Sectnum) if (ifhitsectors(Sectnum) >= 0) +static void nudge_player(int32_t p, int32_t sn, int32_t shl) +{ + g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<vel.y += actor[sn].extra*(sintable[actor[sn].ang&2047])<= 0) { if (sprite[sn].extra >= 0) { - npc = &sprite[sn]; + spritetype *const npc = &sprite[sn]; if (npc->picnum == APLAYER) { @@ -948,17 +953,11 @@ int32_t A_IncurDamage(int32_t sn) if (A_CheckSpriteTileFlags(actor[sn].picnum,SPRITE_PROJECTILE) && (SpriteProjectile[sn].workslike & PROJECTILE_RPG)) { - g_player[p].ps->vel.x += - actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<2; - g_player[p].ps->vel.y += - actor[sn].extra*(sintable[actor[sn].ang&2047])<<2; + nudge_player(p, sn, 2); } else if (A_CheckSpriteTileFlags(actor[sn].picnum,SPRITE_PROJECTILE)) { - g_player[p].ps->vel.x += - actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<1; - g_player[p].ps->vel.y += - actor[sn].extra*(sintable[actor[sn].ang&2047])<<1; + nudge_player(p, sn, 1); } switch (DYNAMICTILEMAP(actor[sn].picnum)) @@ -970,16 +969,10 @@ int32_t A_IncurDamage(int32_t sn) case SEENINE__STATIC: case OOZFILTER__STATIC: case EXPLODINGBARREL__STATIC: - g_player[p].ps->vel.x += - actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<2; - g_player[p].ps->vel.y += - actor[sn].extra*(sintable[actor[sn].ang&2047])<<2; + nudge_player(p, sn, 2); break; default: - g_player[p].ps->vel.x += - actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<1; - g_player[p].ps->vel.y += - actor[sn].extra*(sintable[actor[sn].ang&2047])<<1; + nudge_player(p, sn, 1); break; } }