From c9628e2034a4a62834a181ad6701a0070454aeb8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Dec 2021 20:20:29 +0100 Subject: [PATCH] - partial cleanup of SW's macro mess. Renamed some functions to give them better names and converted more macros into functions or constants --- source/games/sw/src/actor.cpp | 4 +- source/games/sw/src/ai.cpp | 22 ++--- source/games/sw/src/break.cpp | 2 +- source/games/sw/src/bunny.cpp | 8 +- source/games/sw/src/coolie.cpp | 2 +- source/games/sw/src/draw.cpp | 10 +- source/games/sw/src/eel.cpp | 2 +- source/games/sw/src/game.h | 125 ++++++++++++----------- source/games/sw/src/hornet.cpp | 4 +- source/games/sw/src/jweapon.cpp | 28 +++--- source/games/sw/src/miscactr.cpp | 24 ++--- source/games/sw/src/player.cpp | 24 ++--- source/games/sw/src/ripper.cpp | 4 +- source/games/sw/src/ripper2.cpp | 2 +- source/games/sw/src/sector.cpp | 6 +- source/games/sw/src/serp.cpp | 2 +- source/games/sw/src/skull.cpp | 8 +- source/games/sw/src/sprite.cpp | 42 ++++---- source/games/sw/src/sumo.cpp | 2 +- source/games/sw/src/track.cpp | 12 +-- source/games/sw/src/vator.cpp | 4 +- source/games/sw/src/weapon.cpp | 164 +++++++++++++++---------------- 22 files changed, 253 insertions(+), 248 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 4d57d59bf..f2072fc49 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -337,7 +337,7 @@ int DoActorSectorDamage(DSWActor* actor) } } } - else if (SPRITEp_BOS(&actor->spr) >= sectp->floorz) + else if (GetSpriteZOfBottom(&actor->spr) >= sectp->floorz) { if ((u->DamageTics -= synctics) < 0) { @@ -355,7 +355,7 @@ int DoActorSectorDamage(DSWActor* actor) } // note that most squishing is done in vator.c - if (u->lo_sectp && u->hi_sectp && labs(u->loz - u->hiz) < (SPRITEp_SIZE_Z(actor) >> 1)) + if (u->lo_sectp && u->hi_sectp && labs(u->loz - u->hiz) < (GetSpriteSizeZ(actor) >> 1)) { u->Health = 0; if (SpawnShrap(actor, nullptr, WPN_NM_SECTOR_SQUISH)) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 3989814b5..379b025ea 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -105,9 +105,9 @@ bool ActorFlaming(DSWActor* actor) int size; SPRITEp fp = &u->flameActor->s(); - size = SPRITEp_SIZE_Z(sp) - (SPRITEp_SIZE_Z(sp) >> 2); + size = GetSpriteSizeZ(sp) - (GetSpriteSizeZ(sp) >> 2); - if (SPRITEp_SIZE_Z(fp) > size) + if (GetSpriteSizeZ(fp) > size) return true; } @@ -230,7 +230,7 @@ bool CanSeePlayer(DSWActor* actor) SPRITEp sp = &actor->s(); // if actor can still see the player - int look_height = SPRITEp_TOS(sp); + int look_height = GetSpriteZOfTop(sp); if (u->targetActor && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), u->targetActor->spr.pos.X, u->targetActor->spr.pos.Y, ActorUpper(u->targetActor), u->targetActor->spr.sector())) return true; @@ -248,7 +248,7 @@ int CanHitPlayer(DSWActor* actor) // if actor can still see the player int zhs, zhh; - zhs = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp)); + zhs = sp->pos.Z - DIV2(GetSpriteSizeZ(sp)); auto hp = &u->targetActor->s(); @@ -261,7 +261,7 @@ int CanHitPlayer(DSWActor* actor) yvect = bsin(ang); // get zvect - zhh = hp->pos.Z - DIV2(SPRITEp_SIZE_Z(hp)); + zhh = hp->pos.Z - DIV2(GetSpriteSizeZ(hp)); if (hp->pos.X - sp->pos.X != 0) zvect = xvect * ((zhh - zhs)/(hp->pos.X - sp->pos.X)); else if (hp->pos.Y - sp->pos.Y != 0) @@ -302,7 +302,7 @@ int DoActorPickClosePlayer(DSWActor* actor) int pnum; PLAYERp pp; // if actor can still see the player - int look_height = SPRITEp_TOS(sp); + int look_height = GetSpriteZOfTop(sp); bool found = false; int i; @@ -380,7 +380,7 @@ int DoActorPickClosePlayer(DSWActor* actor) DISTANCE(sp->pos.X, sp->pos.Y, pp->pos.X, pp->pos.Y, dist, a, b, c); auto psp = &pp->Actor()->s(); - if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, SPRITEp_UPPER(psp), psp->sector())) + if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, GetSpriteUpperZ(psp), psp->sector())) { near_dist = dist; u->targetActor = pp->Actor(); @@ -407,7 +407,7 @@ TARGETACTOR: auto itSp = &itActor->s(); DISTANCE(sp->pos.X, sp->pos.Y, itSp->pos.X, itSp->pos.Y, dist, a, b, c); - if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), itSp->pos.X, itSp->pos.Y, SPRITEp_UPPER(itSp), itSp->sector())) + if (dist < near_dist && FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), itSp->pos.X, itSp->pos.Y, GetSpriteUpperZ(itSp), itSp->sector())) { near_dist = dist; u->targetActor = itActor; @@ -464,8 +464,8 @@ int DoActorOperate(DSWActor* actor) if ((u->WaitTics -= ACTORMOVETICS) > 0) return false; - z[0] = sp->pos.Z - SPRITEp_SIZE_Z(sp) + Z(5); - z[1] = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp)); + z[0] = sp->pos.Z - GetSpriteSizeZ(sp) + Z(5); + z[1] = sp->pos.Z - DIV2(GetSpriteSizeZ(sp)); for (i = 0; i < SIZ(z); i++) { @@ -1010,7 +1010,7 @@ int FindTrackToPlayer(DSWActor* actor) BIT(TT_SCAN) }; - zdiff = ActorUpper(u->targetActor) - (sp->pos.Z - SPRITEp_SIZE_Z(sp) + Z(8)); + zdiff = ActorUpper(u->targetActor) - (sp->pos.Z - GetSpriteSizeZ(sp) + Z(8)); if (labs(zdiff) <= Z(20)) { diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 1d3b85aa2..9ee2383cc 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -519,7 +519,7 @@ BREAK_INFOp SetupSpriteForBreak(DSWActor* actor) else SET(sp->extra, SPRX_BREAKABLE); - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SET(sp->cstat, CSTAT_SPRITE_BREAKABLE); } diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 9d3e4eb95..84fa3abfe 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -910,7 +910,7 @@ void DoPickCloseBunny(DSWActor* actor) int dist, near_dist = 1000, a,b,c; // if actor can still see the player - int look_height = SPRITEp_TOS(sp); + int look_height = GetSpriteZOfTop(sp); bool ICanSee = false; SWStatIterator it(STAT_ENEMY); @@ -927,7 +927,7 @@ void DoPickCloseBunny(DSWActor* actor) if (dist > near_dist) continue; - ICanSee = FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), tsp->pos.X, tsp->pos.Y, SPRITEp_UPPER(tsp), tsp->sector()); + ICanSee = FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), tsp->pos.X, tsp->pos.Y, GetSpriteUpperZ(tsp), tsp->sector()); if (ICanSee && dist < near_dist && tu->ID == BUNNY_RUN_R0) { @@ -1032,7 +1032,7 @@ int DoBunnyQuickJump(DSWActor* actor) if (pp == Player+myconnectindex) { choose_snd = STD_RANDOM_RANGE(2<<8)>>8; - if (FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_TOS(sp),sp->sector(),pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector) && Facing(actor, u->targetActor)) + if (FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfTop(sp),sp->sector(),pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector) && Facing(actor, u->targetActor)) PlayerSound(fagsnds[choose_snd], v3df_doppler|v3df_follow|v3df_dontpan,pp); } } @@ -1047,7 +1047,7 @@ int DoBunnyQuickJump(DSWActor* actor) if (pp == Player+myconnectindex) { choose_snd = STD_RANDOM_RANGE(3<<8)>>8; - if (FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_TOS(sp),sp->sector(),pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector) && Facing(actor, u->targetActor)) + if (FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfTop(sp),sp->sector(),pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector) && Facing(actor, u->targetActor)) PlayerSound(straightsnds[choose_snd], v3df_doppler|v3df_follow|v3df_dontpan,pp); } } diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index e434f0007..c6be9e94e 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -413,7 +413,7 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp perso u->lo_step = Z(32); u->floor_dist = u->zclip - u->lo_step; - u->ceiling_dist = SPRITEp_SIZE_Z(sp) - u->zclip; + u->ceiling_dist = GetSpriteSizeZ(sp) - u->zclip; u->Radius = 400; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 1cb052eb3..990485e8b 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -286,7 +286,7 @@ void DoShadows(tspritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int v if ((tsp->yrepeat >> 2) > 4) { - yrepeat = (tsp->yrepeat >> 2) - (SPRITEp_SIZE_Y(tsp) / 64) * 2; + yrepeat = (tsp->yrepeat >> 2) - (GetSpriteSizeY(tsp) / 64) * 2; xrepeat = tSpr->xrepeat; } else @@ -322,7 +322,7 @@ void DoShadows(tspritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int v view_dist = 0; // make shadow smaller depending on height from ground - ground_dist = labs(loz - SPRITEp_BOS(tsp)) >> 12; + ground_dist = labs(loz - GetSpriteZOfBottom(tsp)) >> 12; xrepeat = max(xrepeat - ground_dist - view_dist, 4); yrepeat = max(yrepeat - ground_dist - view_dist, 4); @@ -579,7 +579,7 @@ DSWActor* ConnectCopySprite(sprt const* tsp) if (FAF_ConnectCeiling(tsp->sector())) { newsector = tsp->sector(); - testz = SPRITEp_TOS(tsp) - Z(10); + testz = GetSpriteZOfTop(tsp) - Z(10); if (testz < tsp->sector()->ceilingz) updatesectorz(tsp->pos.X, tsp->pos.Y, testz, &newsector); @@ -593,7 +593,7 @@ DSWActor* ConnectCopySprite(sprt const* tsp) if (FAF_ConnectFloor(tsp->sector())) { newsector = tsp->sector(); - testz = SPRITEp_BOS(tsp) + Z(10); + testz = GetSpriteZOfBottom(tsp) + Z(10); if (testz > tsp->sector()->floorz) updatesectorz(tsp->pos.X, tsp->pos.Y, testz, &newsector); @@ -1153,7 +1153,7 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, sectortype** tsect, binan FAFcansee_test = (FAFcansee(sp->pos.X, sp->pos.Y, sp->pos.Z, sp->sector(), *tx, *ty, *tz, pp->cursector) || - FAFcansee(sp->pos.X, sp->pos.Y, sp->pos.Z, sp->sector(), *tx, *ty, *tz + SPRITEp_SIZE_Z(&pp->Actor()->s()), pp->cursector)); + FAFcansee(sp->pos.X, sp->pos.Y, sp->pos.Z, sp->sector(), *tx, *ty, *tz + GetSpriteSizeZ(&pp->Actor()->s()), pp->cursector)); player_in_camera = ang_test && FAFcansee_test; diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index 49f3d0e32..80a424e1b 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -451,7 +451,7 @@ int DoEelMatchPlayerZ(DSWActor* actor) // actor does a sine wave about u->sz - this is the z mid point - zdiff = (SPRITEp_BOS(tsp) - Z(8)) - u->sz; + zdiff = (GetSpriteZOfBottom(tsp) - Z(8)) - u->sz; // check z diff of the player and the sprite zdist = Z(20 + RandomRange(64)); // put a random amount diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 313ec3f6e..089c0f0ee 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -234,74 +234,87 @@ inline void DISTANCE(int x1, int y1, int x2, int y2, int& dist, int& tx, int& ty dist = tx + ty - (tmin >> 1); } -inline int SPRITEp_SIZE_X(const spritetypebase* sp) +inline int GetSpriteSizeX(const spritetypebase* sp) { return MulScale(tileWidth(sp->picnum), sp->xrepeat, 6); } -inline int SPRITEp_SIZE_Y(const spritetypebase* sp) +inline int GetSpriteSizeY(const spritetypebase* sp) { return MulScale(tileHeight(sp->picnum), sp->yrepeat, 6); } -inline int SPRITEp_SIZE_Z(const spritetypebase* sp) +inline int GetSpriteSizeZ(const spritetypebase* sp) { return (tileHeight(sp->picnum) * sp->yrepeat) << 2; } // Given a z height and sprite return the correct y repeat value -inline int SPRITEp_SIZE_Z_2_YREPEAT(const spritetype* sp, int zh) +inline int GetRepeatFromHeight(const spritetype* sp, int zh) { return zh / (4 * tileHeight(sp->picnum)); } // Z size of top (TOS) and bottom (BOS) part of sprite -inline int SPRITEp_SIZE_TOS(const spritetype* sp) +inline int GetSpriteSizeToTop(const spritetypebase* sp) { - return (DIV2(SPRITEp_SIZE_Z(sp)) + (tileTopOffset(sp->picnum) << 8)); + return (DIV2(GetSpriteSizeZ(sp)) + (tileTopOffset(sp->picnum) << 8)); } -inline int SPRITEp_SIZE_TOS(const tspritetype* sp) +inline int GetSpriteSizeToBottom(const spritetypebase* sp) { - return (DIV2(SPRITEp_SIZE_Z(sp)) + (tileTopOffset(sp->picnum) << 8)); -} - -inline int SPRITEp_SIZE_BOS(const spritetype* sp) -{ - return (DIV2(SPRITEp_SIZE_Z(sp)) - (tileTopOffset(sp->picnum) << 8)); -} - -inline int SPRITEp_SIZE_BOS(const tspritetype* sp) -{ - return (DIV2(SPRITEp_SIZE_Z(sp)) - (tileTopOffset(sp->picnum) << 8)); + return (DIV2(GetSpriteSizeZ(sp)) - (tileTopOffset(sp->picnum) << 8)); } // actual Z for TOS and BOS - handles both WYSIWYG and old style -#define SPRITEp_TOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \ - ((sp)->pos.Z - SPRITEp_SIZE_TOS(sp)) : \ - ((sp)->pos.Z - SPRITEp_SIZE_Z(sp))) +inline int GetSpriteZOfTop(const spritetypebase* sp) +{ + return (TEST(sp->cstat, CSTAT_SPRITE_YCENTER) ? + sp->pos.Z - GetSpriteSizeToTop(sp) : + sp->pos.Z - GetSpriteSizeZ(sp)); +} -#define SPRITEp_BOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \ - ((sp)->pos.Z + SPRITEp_SIZE_BOS(sp)) : \ - (sp)->pos.Z) +inline int GetSpriteZOfBottom(const spritetypebase* sp) +{ + return (TEST(sp->cstat, CSTAT_SPRITE_YCENTER) ? + sp->pos.Z + GetSpriteSizeToBottom(sp) : + sp->pos.Z); +} // mid and upper/lower sprite calculations -#define SPRITEp_MID(sp) (DIV2(SPRITEp_TOS(sp) + SPRITEp_BOS(sp))) -#define SPRITEp_UPPER(sp) (SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2)) -#define SPRITEp_LOWER(sp) (SPRITEp_BOS(sp) - (SPRITEp_SIZE_Z(sp) >> 2)) +inline int GetSpriteZOfMiddle(const spritetypebase* sp) +{ + return (GetSpriteZOfTop(sp) + GetSpriteZOfBottom(sp)) >> 1; +} -#define Z(value) ((int)(value) << 8) -#define PIXZ(value) ((int)(value) >> 8) +inline int GetSpriteUpperZ(const spritetypebase* sp) +{ + return (GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2)); +} -#define SQ(val) ((val) * (val)) +int GetSpriteLowerZ(const spritetypebase* sp) +{ + return (GetSpriteZOfBottom(sp) - (GetSpriteSizeZ(sp) >> 2)); +} + +constexpr int Z(int value) +{ + return value << 8; +} + +constexpr int PIXZ(int value) +{ + return value >> 8; +} + +constexpr int SQ(int val) +{ + return val * val; +} -#define KENFACING_PLAYER(pp,sp) (bcos(sp->ang)*(pp->pos.Y-sp->pos.Y) >= bsin(sp-ang)*(pp->pos.X-sp->pos.X)) -#define FACING_PLAYER(pp,sp) (abs(getincangle(getangle((pp)->pos.X - (sp)->pos.X, (pp)->pos.Y - (sp)->pos.Y), (sp)->ang)) < 512) -#define PLAYER_FACING(pp,sp) (abs(getincangle(getangle((sp)->pos.X - (pp)->pos.X, (sp)->pos.Y - (pp)->pos.Y), (pp)->angle.ang.asbuild())) < 320) -#define FACING_PLAYER_RANGE(pp,sp,range) (abs(getincangle(getangle((pp)->pos.X - (sp)->pos.X, (pp)->pos.Y - (sp)->pos.Y), (sp)->ang)) < (range)) #define PLAYER_FACING_RANGE(pp,sp,range) (abs(getincangle(getangle((sp)->pos.X - (pp)->pos.X, (sp)->pos.Y - (pp)->pos.Y), (pp)->angle.ang.asbuild())) < (range)) #define FACING_RANGE(sp1,sp2,range) (abs(getincangle(getangle((sp1)->pos.X - (sp2)->pos.X, (sp1)->pos.Y - (sp2)->pos.Y), (sp2)->ang)) < (range)) @@ -332,32 +345,24 @@ inline int SPRITEp_SIZE_BOS(const tspritetype* sp) // new define more readable defines // Clip Sprite adjustment -#define CS(sprite_bit) IntToFixed(sprite_bit) +constexpr int CS(int sprite_bit) +{ + return (sprite_bit) << 16; +} -// for players to clip against walls -#define CLIPMASK_PLAYER (CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK) +enum EClip +{ + // for players to clip against walls + CLIPMASK_PLAYER = CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK, -// for actors to clip against walls -#define CLIPMASK_ACTOR \ - ( \ - CS(CSTAT_SPRITE_BLOCK) | \ - CSTAT_WALL_BLOCK | \ - CSTAT_WALL_BLOCK_ACTOR \ - ) + // for actors to clip against walls + CLIPMASK_ACTOR = CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK | CSTAT_WALL_BLOCK_ACTOR, -// for missiles to clip against actors -#define CLIPMASK_MISSILE \ - ( \ - CS(CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE) | \ - CSTAT_WALL_BLOCK_HITSCAN \ - ) + // for missiles to clip against actors + CLIPMASK_MISSILE = CS(CSTAT_SPRITE_BLOCK_HITSCAN | CSTAT_SPRITE_BLOCK_MISSILE) | CSTAT_WALL_BLOCK_HITSCAN, -#define CLIPMASK_WARP_HITSCAN \ - ( \ - CS(CSTAT_SPRITE_BLOCK_HITSCAN) | \ - CSTAT_WALL_BLOCK_HITSCAN | \ - CSTAT_WALL_WARP_HITSCAN \ - ) + CLIPMASK_WARP_HITSCAN = CS(CSTAT_SPRITE_BLOCK_HITSCAN) | CSTAT_WALL_BLOCK_HITSCAN | CSTAT_WALL_WARP_HITSCAN, +}; #define SIZ countof @@ -2126,20 +2131,20 @@ BEGIN_SW_NS inline int ActorUpper(DSWActor* actor) { - return SPRITEp_UPPER(&actor->s()); + return GetSpriteUpperZ(&actor->s()); } inline int ActorLower(DSWActor* actor) { - return SPRITEp_LOWER(&actor->s()); + return GetSpriteLowerZ(&actor->s()); } inline int ActorMid(DSWActor* actor) { - return SPRITEp_MID(&actor->s()); + return GetSpriteZOfMiddle(&actor->s()); } -inline int SPRITEp_SIZE_Z(DSWActor* sp) +inline int GetSpriteSizeZ(DSWActor* sp) { return (tileHeight(sp->spr.picnum) * sp->spr.yrepeat) << 2; } diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index a2b10cafe..24b6f48d7 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -357,8 +357,8 @@ int DoHornetMatchPlayerZ(DSWActor* actor) // actor does a sine wave about u->sz - this is the z mid point - //zdiff = (SPRITEp_LOWER(tsp) - Z(8)) - u->sz; - zdiff = (SPRITEp_MID(tsp)) - u->sz; + //zdiff = (GetSpriteLowerZ(tsp) - Z(8)) - u->sz; + zdiff = (GetSpriteZOfMiddle(tsp)) - u->sz; // check z diff of the player and the sprite zdist = Z(20 + RandomRange(200)); // put a random amount diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 566a443b7..51f679fcc 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -303,7 +303,7 @@ void SpawnMidSplash(DSWActor* actor) USERp nu; auto actorNew = SpawnActor(STAT_MISSILE, GOREDrip, s_GoreSplash, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->ang, 0); + sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->ang, 0); np = &actorNew->s(); nu = actorNew->u(); @@ -1533,7 +1533,7 @@ int PlayerInitFlashBomb(PLAYERp pp) if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK)) continue; - if (!FAFcansee(hp->pos.X, hp->pos.Y, hp->pos.Z, hp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z - SPRITEp_SIZE_Z(sp), sp->sector())) + if (!FAFcansee(hp->pos.X, hp->pos.Y, hp->pos.Z, hp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z - GetSpriteSizeZ(sp), sp->sector())) continue; damage = GetDamage(itActor, pp->Actor(), DMG_FLASHBOMB); @@ -1598,7 +1598,7 @@ int InitFlashBomb(DSWActor* actor) if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK)) continue; - if (!FAFcansee(hp->pos.X, hp->pos.Y, hp->pos.Z, hp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z - SPRITEp_SIZE_Z(sp), sp->sector())) + if (!FAFcansee(hp->pos.X, hp->pos.Y, hp->pos.Z, hp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z - GetSpriteSizeZ(sp), sp->sector())) continue; damage = GetDamage(itActor, actor, DMG_FLASHBOMB); @@ -1650,21 +1650,21 @@ void SpawnFlashBombOnActor(DSWActor* actor) { if (u->flameActor != nullptr) { - int sizez = (SPRITEp_SIZE_Z(sp) * 5) >> 2; + int sizez = (GetSpriteSizeZ(sp) * 5) >> 2; auto np = &u->flameActor->s(); auto nu = u->flameActor->u(); - if (nu->Counter >= SPRITEp_SIZE_Z_2_YREPEAT(np, sizez)) + if (nu->Counter >= GetRepeatFromHeight(np, sizez)) { // keep flame only slightly bigger than the enemy itself - nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, sizez) * 2; + nu->Counter = GetRepeatFromHeight(np, sizez) * 2; } else { // increase max size - nu->Counter += SPRITEp_SIZE_Z_2_YREPEAT(np, 8 << 8) * 2; + nu->Counter += GetRepeatFromHeight(np, 8 << 8) * 2; } // Counter is max size @@ -1694,7 +1694,7 @@ void SpawnFlashBombOnActor(DSWActor* actor) if (u->flameActor != nullptr) { - nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, SPRITEp_SIZE_Z(sp) >> 1) * 4; + nu->Counter = GetRepeatFromHeight(np, GetSpriteSizeZ(sp) >> 1) * 4; } else nu->Counter = 0; // max flame size @@ -1941,7 +1941,7 @@ int InitBloodSpray(DSWActor* actor, bool dogib, short velocity) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_TOS(sp)-20; + nz = GetSpriteZOfTop(sp)-20; // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, GOREDrip, s_BloodSprayChunk, sp->sector(), @@ -2079,7 +2079,7 @@ int DoCarryFlag(DSWActor* actor) { SPRITEp ap = &u->attachActor->s(); - vec3_t pos = { ap->pos.X, ap->pos.Y, SPRITEp_MID(ap) }; + vec3_t pos = { ap->pos.X, ap->pos.Y, GetSpriteZOfMiddle(ap) }; SetActorZ(actor, &pos); sp->ang = NORM_ANGLE(ap->ang + 1536); } @@ -2239,10 +2239,10 @@ int DoCarryFlagNoDet(DSWActor* actor) { SPRITEp ap = &u->attachActor->s(); - vec3_t pos = { ap->pos.X, ap->pos.Y, SPRITEp_MID(ap) }; + vec3_t pos = { ap->pos.X, ap->pos.Y, GetSpriteZOfMiddle(ap) }; SetActorZ(actor, &pos); sp->ang = NORM_ANGLE(ap->ang + 1536); - sp->pos.Z = ap->pos.Z - DIV2(SPRITEp_SIZE_Z(ap)); + sp->pos.Z = ap->pos.Z - DIV2(GetSpriteSizeZ(ap)); } @@ -2325,7 +2325,7 @@ int DoFlag(DSWActor* actor) // attach weapon to sprite RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); SetAttach(hitActor, actor); - u->sz = hsp->pos.Z - DIV2(SPRITEp_SIZE_Z(hsp)); + u->sz = hsp->pos.Z - DIV2(GetSpriteSizeZ(hsp)); } } @@ -2346,7 +2346,7 @@ int SpawnShell(DSWActor* actor, int ShellNum) nx = sp->pos.X; ny = sp->pos.Y; - nz = DIV2(SPRITEp_TOS(sp)+ SPRITEp_BOS(sp)); + nz = DIV2(GetSpriteZOfTop(sp)+ GetSpriteZOfBottom(sp)); switch (ShellNum) { diff --git a/source/games/sw/src/miscactr.cpp b/source/games/sw/src/miscactr.cpp index 288679740..bad5241bc 100644 --- a/source/games/sw/src/miscactr.cpp +++ b/source/games/sw/src/miscactr.cpp @@ -155,7 +155,7 @@ int DoToiletGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (u->FlagOwner != 1) { @@ -210,7 +210,7 @@ int NullToiletGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -390,7 +390,7 @@ int DoWashGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (RandomRange(1000) > 980 && u->ShellNum <= 0) { @@ -454,7 +454,7 @@ int NullWashGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1253,7 +1253,7 @@ int DoCarGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (u->FlagOwner == 1) { @@ -1299,7 +1299,7 @@ int NullCarGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1467,7 +1467,7 @@ int DoMechanicGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (u->FlagOwner == 1) { @@ -1513,7 +1513,7 @@ int NullMechanicGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1683,7 +1683,7 @@ int DoSailorGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (u->FlagOwner == 1) { @@ -1734,7 +1734,7 @@ int NullSailorGirl(DSWActor* actor) static short alreadythrew = 0; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1890,7 +1890,7 @@ int DoPruneGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,ActorMid(u->targetActor),u->targetActor->spr.sector()); if (u->FlagOwner == 1) { @@ -1952,7 +1952,7 @@ int NullPruneGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); + ICanSee = FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),u->targetActor->spr.pos.X,u->targetActor->spr.pos.Y,u->targetActor->spr.pos.Z,u->targetActor->spr.sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 265a571a6..377c10744 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1197,11 +1197,11 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets if (u && u->PlayerP) zh = u->PlayerP->pos.Z; else - zh = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); + zh = GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2); - ezh = SPRITEp_TOS(ep) + (SPRITEp_SIZE_Z(ep) >> 2); - ezhm = SPRITEp_TOS(ep) + DIV2(SPRITEp_SIZE_Z(ep)); - ezhl = SPRITEp_BOS(ep) - (SPRITEp_SIZE_Z(ep) >> 2); + ezh = GetSpriteZOfTop(ep) + (GetSpriteSizeZ(ep) >> 2); + ezhm = GetSpriteZOfTop(ep) + DIV2(GetSpriteSizeZ(ep)); + ezhl = GetSpriteZOfBottom(ep) - (GetSpriteSizeZ(ep) >> 2); // If you can't see 'em you can't shoot 'em if (!FAFcansee(sp->pos.X, sp->pos.Y, zh, sp->sector(), ep->pos.X, ep->pos.Y, ezh, ep->sector()) && @@ -1315,7 +1315,7 @@ void DoSpawnTeleporterEffect(DSWActor* actor) ny += sp->pos.Y; auto effectActor = SpawnActor(STAT_MISSILE, 0, s_TeleportEffect, sp->sector(), - nx, ny, SPRITEp_TOS(sp) + Z(16), + nx, ny, GetSpriteZOfTop(sp) + Z(16), sp->ang, 0); ep = &effectActor->s(); @@ -1337,7 +1337,7 @@ void DoSpawnTeleporterEffectPlace(DSWActor* actor) SPRITEp ep; auto effectActor = SpawnActor(STAT_MISSILE, 0, s_TeleportEffect, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp) + Z(16), + sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp) + Z(16), sp->ang, 0); ep = &effectActor->s(); @@ -1715,7 +1715,7 @@ void UpdatePlayerUnderSprite(PLAYERp pp) water_level_z = over_sp->sector()->floorz; // - Z(pp->WadeDepth); // if not below water - above_water = (SPRITEp_BOS(over_sp) <= water_level_z); + above_water = (GetSpriteZOfBottom(over_sp) <= water_level_z); in_dive_area = SpriteInDiveArea(over_sp); // if not in dive area OR (in dive area AND above the water) - Kill it @@ -1751,7 +1751,7 @@ void UpdatePlayerUnderSprite(PLAYERp pp) // find z water level of the top sector // diff between the bottom of the upper sprite and the water level - zdiff = SPRITEp_BOS(over_sp) - water_level_z; + zdiff = GetSpriteZOfBottom(over_sp) - water_level_z; // add diff to ceiling sp->pos.Z = sp->sector()->ceilingz + zdiff; @@ -3001,7 +3001,7 @@ void StackedWaterSplash(PLAYERp pp) auto sect = pp->cursector; auto psp = &pp->Actor()->s(); - updatesectorz(pp->pos.X, pp->pos.Y, SPRITEp_BOS(psp), §); + updatesectorz(pp->pos.X, pp->pos.Y, GetSpriteZOfBottom(psp), §); if (SectorIsUnderwaterArea(sect)) { @@ -3870,7 +3870,7 @@ int PlayerCanDiveNoWarp(PLAYERp pp) { auto sect = pp->cursector; - updatesectorz(pp->pos.X, pp->pos.Y, SPRITEp_BOS(&pp->Actor()->s()), §); + updatesectorz(pp->pos.X, pp->pos.Y, GetSpriteZOfBottom(&pp->Actor()->s()), §); if (SectorIsUnderwaterArea(sect)) { @@ -5797,7 +5797,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) { SPRITEp kp = &pp->KillerActor->s(); - if (FAFcansee(kp->pos.X, kp->pos.Y, SPRITEp_TOS(kp), kp->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector)) + if (FAFcansee(kp->pos.X, kp->pos.Y, GetSpriteZOfTop(kp), kp->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector)) { pp->angle.addadjustment(getincanglebam(pp->angle.ang, bvectangbam(kp->pos.X - pp->pos.X, kp->pos.Y - pp->pos.Y)) >> 4); } @@ -5947,7 +5947,7 @@ SPRITEp DoPlayerDeathCheckKick(PLAYERp pp) DoPlayerZrange(pp); // sector stomper kick - if (labs(pp->loz - pp->hiz) < SPRITEp_SIZE_Z(sp) - Z(8)) + if (labs(pp->loz - pp->hiz) < GetSpriteSizeZ(sp) - Z(8)) { u->slide_ang = RANDOM_P2(2048); u->slide_vel = 1000; diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 96e121117..7facf58f4 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -908,7 +908,7 @@ int PickJumpMaxSpeed(DSWActor* actor, short max_speed) u->jump_speed = max_speed; u->jump_grav = 8; - zh = SPRITEp_TOS(sp); + zh = GetSpriteZOfTop(sp); while (true) { @@ -944,7 +944,7 @@ int InitRipperHang(DSWActor* actor) { tang = NORM_ANGLE(sp->ang + dang); - FAFhitscan(sp->pos.X, sp->pos.Y, sp->pos.Z - SPRITEp_SIZE_Z(sp), sp->sector(), // Start position + FAFhitscan(sp->pos.X, sp->pos.Y, sp->pos.Z - GetSpriteSizeZ(sp), sp->sector(), // Start position bcos(tang), // X vector of 3D ang bsin(tang), // Y vector of 3D ang 0, // Z vector of 3D ang diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 00b373623..102f450de 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -947,7 +947,7 @@ int InitRipper2Hang(DSWActor* actor) { tang = NORM_ANGLE(sp->ang + dang); - FAFhitscan(sp->pos.X, sp->pos.Y, sp->pos.Z - SPRITEp_SIZE_Z(sp), sp->sector(), // Start position + FAFhitscan(sp->pos.X, sp->pos.Y, sp->pos.Z - GetSpriteSizeZ(sp), sp->sector(), // Start position bcos(tang), // X vector of 3D ang bsin(tang), // Y vector of 3D ang 0, // Z vector of 3D ang diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 6d88b03e5..c811c76a0 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -1451,7 +1451,7 @@ int OperateSprite(DSWActor* actor, short player_is_operating) { pp = GlobPlayerP; - if (!FAFcansee(pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector, sp->pos.X, sp->pos.Y, sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp)), sp->sector())) + if (!FAFcansee(pp->pos.X, pp->pos.Y, pp->pos.Z, pp->cursector, sp->pos.X, sp->pos.Y, sp->pos.Z - DIV2(GetSpriteSizeZ(sp)), sp->sector())) return false; } @@ -2301,7 +2301,7 @@ void PlayerOperateEnv(PLAYERp pp) short nt_ndx; auto psp = &pp->Actor()->s(); - z[0] = psp->pos.Z - SPRITEp_SIZE_Z(psp) - Z(10); + z[0] = psp->pos.Z - GetSpriteSizeZ(psp) - Z(10); z[1] = psp->pos.Z; z[2] = DIV2(z[0] + z[1]); @@ -2382,7 +2382,7 @@ void PlayerOperateEnv(PLAYERp pp) { PlayerTakeSectorDamage(pp); } - else if ((SPRITEp_BOS(&pp->Actor()->s()) >= sectp->floorz) && !TEST(pp->Flags, PF_DIVING)) + else if ((GetSpriteZOfBottom(&pp->Actor()->s()) >= sectp->floorz) && !TEST(pp->Flags, PF_DIVING)) { PlayerTakeSectorDamage(pp); } diff --git a/source/games/sw/src/serp.cpp b/source/games/sw/src/serp.cpp index 37b049d41..de6ad99f0 100644 --- a/source/games/sw/src/serp.cpp +++ b/source/games/sw/src/serp.cpp @@ -745,7 +745,7 @@ int SetupSerp(DSWActor* actor) u->lo_step = Z(40); u->floor_dist = u->zclip - u->lo_step; - u->ceiling_dist = SPRITEp_SIZE_Z(sp) - u->zclip; + u->ceiling_dist = GetSpriteSizeZ(sp) - u->zclip; return 0; } diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index f7e2df1ea..92ae2004d 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -239,13 +239,13 @@ int SetupSkull(DSWActor* actor) u->Radius = 400; - if (SPRITEp_BOS(sp) > u->loz - Z(16)) + if (GetSpriteZOfBottom(sp) > u->loz - Z(16)) { sp->pos.Z = u->loz + Z(tileTopOffset(sp->picnum)); u->loz = sp->pos.Z; // leave 8 pixels above the ground - sp->pos.Z += SPRITEp_SIZE_TOS(sp) - Z(3);; + sp->pos.Z += GetSpriteSizeToTop(sp) - Z(3);; } else { @@ -643,13 +643,13 @@ int SetupBetty(DSWActor* actor) u->Radius = 400; - if (SPRITEp_BOS(sp) > u->loz - Z(16)) + if (GetSpriteZOfBottom(sp) > u->loz - Z(16)) { sp->pos.Z = u->loz + Z(tileTopOffset(sp->picnum)); u->loz = sp->pos.Z; // leave 8 pixels above the ground - sp->pos.Z += SPRITEp_SIZE_TOS(sp) - Z(3);; + sp->pos.Z += GetSpriteSizeToTop(sp) - Z(3);; } else { diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 55df5f609..7a427d6f7 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1667,7 +1667,7 @@ void SpriteSetup(void) case BREAKABLE: // need something that tells missiles to hit them // but allows actors to move through them - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SET(sp->extra, SPRX_BREAKABLE); SET(sp->cstat, CSTAT_SPRITE_BREAKABLE); break; @@ -3488,7 +3488,7 @@ NUKE_REPLACEMENT: u = SpawnUser(actor, sp->picnum, nullptr); - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SET(sp->cstat, CSTAT_SPRITE_BREAKABLE); SET(sp->extra, SPRX_BREAKABLE); break; @@ -3610,7 +3610,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_MID(sp); + np->pos.Z = GetSpriteZOfMiddle(sp); np->ang = 0; np->extra = 0; @@ -3652,7 +3652,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_MID(sp); + np->pos.Z = GetSpriteZOfMiddle(sp); np->ang = 0; np->extra = 0; @@ -3681,7 +3681,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_MID(sp); + np->pos.Z = GetSpriteZOfMiddle(sp); np->ang = 0; np->extra = 0; @@ -3713,7 +3713,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_MID(sp); + np->pos.Z = GetSpriteZOfMiddle(sp); np->ang = 0; np->extra = 0; @@ -3776,7 +3776,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_MID(sp); + np->pos.Z = GetSpriteZOfMiddle(sp); np->ang = 0; np->extra = 0; @@ -3835,7 +3835,7 @@ int ActorCoughItem(DSWActor* actor) np->extra = 0; np->pos.X = sp->pos.X; np->pos.Y = sp->pos.Y; - np->pos.Z = SPRITEp_LOWER(sp)+Z(10); + np->pos.Z = GetSpriteLowerZ(sp)+Z(10); np->ang = sp->ang; // vel @@ -4397,11 +4397,11 @@ bool SpriteOverlap(DSWActor* actor_a, DSWActor* actor_b) return false; } - spa_tos = SPRITEp_TOS(spa); - spa_bos = SPRITEp_BOS(spa); + spa_tos = GetSpriteZOfTop(spa); + spa_bos = GetSpriteZOfBottom(spa); - spb_tos = SPRITEp_TOS(spb); - spb_bos = SPRITEp_BOS(spb); + spb_tos = GetSpriteZOfTop(spb); + spb_bos = GetSpriteZOfBottom(spb); overlap_z = ua->OverlapZ + ub->OverlapZ; @@ -4428,11 +4428,11 @@ bool SpriteOverlapZ(DSWActor* actor_a, DSWActor* actor_b, int z_overlap) int spa_tos, spa_bos, spb_tos, spb_bos; - spa_tos = SPRITEp_TOS(spa); - spa_bos = SPRITEp_BOS(spa); + spa_tos = GetSpriteZOfTop(spa); + spa_bos = GetSpriteZOfBottom(spa); - spb_tos = SPRITEp_TOS(spb); - spb_bos = SPRITEp_BOS(spb); + spb_tos = GetSpriteZOfTop(spb); + spb_bos = GetSpriteZOfBottom(spb); // if the top of sprite a is below the bottom of b @@ -4585,7 +4585,7 @@ void DoActorZrange(DSWActor* actor) auto save_cstat = sp->cstat & CSTAT_SPRITE_BLOCK; RESET(sp->cstat, CSTAT_SPRITE_BLOCK); vec3_t pos = sp->pos; - pos.Z -= DIV2(SPRITEp_SIZE_Z(sp)); + pos.Z -= DIV2(GetSpriteSizeZ(sp)); FAFgetzrange(pos, sp->sector(), &u->hiz, &ceilhit, &u->loz, &florhit, (((int) sp->clipdist) << 2) - GETZRANGE_CLIP_ADJ, CLIPMASK_ACTOR); sp->cstat |= save_cstat; @@ -4667,7 +4667,7 @@ bool ActorDrop(DSWActor* actor, int x, int y, int z, sectortype* new_sector, sho // look only at the center point for a floor sprite auto save_cstat = TEST(sp->cstat, CSTAT_SPRITE_BLOCK); RESET(sp->cstat, CSTAT_SPRITE_BLOCK); - FAFgetzrangepoint(x, y, z - DIV2(SPRITEp_SIZE_Z(sp)), new_sector, &hiz, &ceilhit, &loz, &florhit); + FAFgetzrangepoint(x, y, z - DIV2(GetSpriteSizeZ(sp)), new_sector, &hiz, &ceilhit, &loz, &florhit); SET(sp->cstat, save_cstat); if (florhit.type < 0 || ceilhit.type < 0) @@ -6031,7 +6031,7 @@ KeyMain: RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); SET(np->cstat, CSTAT_SPRITE_ALIGNMENT_WALL); SetAttach(pp->Actor(), actorNew); - nu->sz = SPRITEp_MID(&pp->Actor()->s()); // Set mid way up who it hit + nu->sz = GetSpriteZOfMiddle(&pp->Actor()->s()); // Set mid way up who it hit nu->spal = np->pal = sp->pal; // Set the palette of the flag SetOwner(pp->Actor(), actorNew); // Player now owns the flag @@ -6098,8 +6098,8 @@ void AdjustActiveRange(PLAYERp pp, DSWActor* actor, int dist) // // if actor can still see the player - look_height = SPRITEp_TOS(sp); - if (FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, SPRITEp_UPPER(psp), psp->sector())) + look_height = GetSpriteZOfTop(sp); + if (FAFcansee(sp->pos.X, sp->pos.Y, look_height, sp->sector(), psp->pos.X, psp->pos.Y, GetSpriteUpperZ(psp), psp->sector())) { // Player is visible // adjust update range of this sprite diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index 623ca692c..9296e1d0e 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -838,7 +838,7 @@ void BossHealthMeter(void) sp = &BossSpriteNum[i]->s(); u = BossSpriteNum[i]->u(); - if (cansee(sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp), sp->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z - Z(40), pp->cursector)) + if (cansee(sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp), sp->sector(), pp->pos.X, pp->pos.Y, pp->pos.Z - Z(40), pp->cursector)) { if (i == 0 && !bosswasseen[0]) { diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index f23c1a0dc..2a76b900c 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -2220,7 +2220,7 @@ void CallbackSOsink(ANIMp ap, void *data) continue; // move sprite WAY down in water - ndx = AnimSet(ANIM_Userz, 0, actor, -u->sz - SPRITEp_SIZE_Z(sp) - Z(100), ap->vel>>8); + ndx = AnimSet(ANIM_Userz, 0, actor, -u->sz - GetSpriteSizeZ(sp) - Z(100), ap->vel>>8); AnimSetVelAdj(ndx, ap->vel_adj); } @@ -3228,8 +3228,8 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) sp->ang = tpoint->ang; - z[0] = sp->pos.Z - SPRITEp_SIZE_Z(sp) + Z(5); - z[1] = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp)); + z[0] = sp->pos.Z - GetSpriteSizeZ(sp) + Z(5); + z[1] = sp->pos.Z - DIV2(GetSpriteSizeZ(sp)); for (i = 0; i < (int)SIZ(z); i++) { @@ -3452,7 +3452,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) // Get the z height to climb // - neartag({ sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp) - DIV2(SPRITEp_SIZE_Z(sp)) }, sp->sector(), sp->ang, near, 600, NTAG_SEARCH_LO_HI); + neartag({ sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp) - DIV2(GetSpriteSizeZ(sp)) }, sp->sector(), sp->ang, near, 600, NTAG_SEARCH_LO_HI); if (near.hitWall == nullptr) { @@ -3481,7 +3481,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) // SET(sp->cstat, CSTAT_SPRITE_YCENTER); - bos_z = SPRITEp_BOS(sp); + bos_z = GetSpriteZOfBottom(sp); if (bos_z > u->loz) { u->sy = (bos_z - sp->pos.Z); @@ -3638,7 +3638,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics) if (TEST(u->Flags, SPR_CLIMBING)) { - if (SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2) < u->sz) + if (GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2) < u->sz) { RESET(u->Flags, SPR_CLIMBING); diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index d04e94055..6f56e23f8 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -493,7 +493,7 @@ int DoVator(DSWActor* actor) if (bsp->statnum == STAT_ENEMY) { - if (labs(sectp->ceilingz - sectp->floorz) < SPRITEp_SIZE_Z(bsp)) + if (labs(sectp->ceilingz - sectp->floorz) < GetSpriteSizeZ(bsp)) { InitBloodSpray(itActor, true, -1); UpdateSinglePlayKills(itActor); @@ -543,7 +543,7 @@ int DoVator(DSWActor* actor) if (bsp->statnum == STAT_ENEMY) { - if (labs(sectp->ceilingz - sectp->floorz) < SPRITEp_SIZE_Z(bsp)) + if (labs(sectp->ceilingz - sectp->floorz) < GetSpriteSizeZ(bsp)) { InitBloodSpray(itActor, true, -1); UpdateSinglePlayKills(itActor); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 837fb9067..2aba9dc32 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3662,8 +3662,8 @@ AutoShrap: } } - hz[Z_TOP] = SPRITEp_TOS(parent); // top - hz[Z_BOT] = SPRITEp_BOS(parent); // bottom + hz[Z_TOP] = GetSpriteZOfTop(parent); // top + hz[Z_BOT] = GetSpriteZOfBottom(parent); // bottom hz[Z_MID] = DIV2(hz[0] + hz[2]); // mid for (; p->id; p++) @@ -4057,7 +4057,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = sp->ang; hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = SPRITEp_TOS(wp) + (SPRITEp_SIZE_Z(wp) >> 4); + hit_z = GetSpriteZOfTop(wp) + (GetSpriteSizeZ(wp) >> 4); } else { @@ -4065,7 +4065,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = SPRITEp_TOS(wp) + (SPRITEp_SIZE_Z(wp) >> 2); + hit_z = GetSpriteZOfTop(wp) + (GetSpriteSizeZ(wp) >> 2); //ASSERT(wu->PlayerP); } @@ -4075,7 +4075,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); + hit_z = GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2); break; case BLADE1: case BLADE2: @@ -4085,7 +4085,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = NORM_ANGLE(ANG2SPRITE(sp, wp) + 1024); hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = wp->pos.Z - DIV2(SPRITEp_SIZE_Z(wp)); + hit_z = wp->pos.Z - DIV2(GetSpriteSizeZ(wp)); break; case STAR1: case CROSSBOLT: @@ -4100,14 +4100,14 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = wp->ang; hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); + hit_z = GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2); break; default: p = SomeBlood; hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->pos.X; hit_y = sp->pos.Y; - hit_z = SPRITEp_TOS(wp) + (SPRITEp_SIZE_Z(wp) >> 2); + hit_z = GetSpriteZOfTop(wp) + (GetSpriteSizeZ(wp) >> 2); break; } } @@ -4363,7 +4363,7 @@ bool WeaponMoveHit(DSWActor* actor) if (TEST(sectp->ceilingstat, CSTAT_SECTOR_SKY) && sectp->ceilingpicnum != FAF_MIRROR_PIC) { - if (labs(sp->pos.Z - sectp->ceilingz) < SPRITEp_SIZE_Z(sp)) + if (labs(sp->pos.Z - sectp->ceilingz) < GetSpriteSizeZ(sp)) { SetSuicide(actor); return true; @@ -4554,7 +4554,7 @@ int DoFireballFlames(DSWActor* actor) sp->pos.X = ap->pos.X; sp->pos.Y = ap->pos.Y; - sp->pos.Z = DIV2(SPRITEp_TOS(ap) + SPRITEp_BOS(ap)); + sp->pos.Z = DIV2(GetSpriteZOfTop(ap) + GetSpriteZOfBottom(ap)); if (TEST(ap->extra, SPRX_BURNABLE)) { @@ -7173,7 +7173,7 @@ int DoDamageTest(DSWActor* actor) // For speed's sake, try limiting check only to radius weapons! if (wu->Radius > 200) { - if (!FAFcansee(sp->pos.X,sp->pos.Y, SPRITEp_UPPER(sp), sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector())) + if (!FAFcansee(sp->pos.X,sp->pos.Y, GetSpriteUpperZ(sp), sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector())) continue; } @@ -7254,7 +7254,7 @@ int DoFlamesDamageTest(DSWActor* actor) if (wu->Radius > 200) // Note: No weaps have bigger radius than 200 cept explosion stuff { - if (FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),wp->pos.X,wp->pos.Y,SPRITEp_MID(wp),wp->sector())) + if (FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),wp->pos.X,wp->pos.Y,GetSpriteZOfMiddle(wp),wp->sector())) { DoDamage(itActor, actor); } @@ -7406,8 +7406,8 @@ int DoExpDamageTest(DSWActor* actor) // Second parameter MUST have blocking bits set or cansee won't work // added second check for FAF water - hitscans were hitting ceiling - if (!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, SPRITEp_UPPER(sp), sp->sector()) && - !FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, SPRITEp_LOWER(sp), sp->sector())) + if (!FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, GetSpriteUpperZ(sp), sp->sector()) && + !FAFcansee(wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector(), sp->pos.X, sp->pos.Y, GetSpriteLowerZ(sp), sp->sector())) continue; DoDamage(itActor, actor); @@ -7435,11 +7435,11 @@ int DoExpDamageTest(DSWActor* actor) if ((unsigned)dist > wu->Radius) continue; - dist = FindDistance3D(sp->pos.X - wp->pos.X, sp->pos.Y - wp->pos.Y, SPRITEp_MID(sp) - wp->pos.Z); + dist = FindDistance3D(sp->pos.X - wp->pos.X, sp->pos.Y - wp->pos.Y, GetSpriteZOfMiddle(sp) - wp->pos.Z); if ((unsigned)dist > wu->Radius) continue; - if (!FAFcansee(sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->sector(), wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector())) + if (!FAFcansee(sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->sector(), wp->pos.X, wp->pos.Y, wp->pos.Z, wp->sector())) continue; if (TEST(sp->extra, SPRX_BREAKABLE)) @@ -7879,7 +7879,7 @@ int MissileSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range/*, int1 sp->ang -= delta_ang; - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); delta_ang = (zh - sp->pos.Z)>>1; @@ -7955,7 +7955,7 @@ int ComboMissileSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range/*, u->xchange = MOVEx(sp->xvel, sp->ang); u->ychange = MOVEy(sp->xvel, sp->ang); - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); dist = ksqrt(SQ(sp->pos.X - hp->pos.X) + SQ(sp->pos.Y - hp->pos.Y) + (SQ(sp->pos.Z - zh)>>8)); @@ -8035,7 +8035,7 @@ int VectorMissileSeek(DSWActor* actor, int16_t delay_tics, int16_t turn_speed, i if (!hp) return 0; - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); dist = ksqrt(SQ(sp->pos.X - hp->pos.X) + SQ(sp->pos.Y - hp->pos.Y) + (SQ(sp->pos.Z - zh)>>8)); @@ -8100,7 +8100,7 @@ int VectorWormSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range1, in int ox,oy,oz; hp = &u->WpnGoalActor->s(); - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); dist = ksqrt(SQ(sp->pos.X - hp->pos.X) + SQ(sp->pos.Y - hp->pos.Y) + (SQ(sp->pos.Z - zh)>>8)); @@ -8150,7 +8150,7 @@ int InitPlasmaFountain(DSWActor* wActor, DSWActor* sActor) USERp nu; auto actorNew = SpawnActor(STAT_MISSILE, PLASMA_FOUNTAIN, s_PlasmaFountain, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_BOS(sp), sp->ang, 0); + sp->pos.X, sp->pos.Y, GetSpriteZOfBottom(sp), sp->ang, 0); np = &actorNew->s(); nu = actorNew->u(); @@ -8870,7 +8870,7 @@ int DoMineRangeTest(DSWActor* actor, int range) if (dist > range) continue; - if (!FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_UPPER(sp),sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector())) + if (!FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteUpperZ(sp),sp->sector(),wp->pos.X,wp->pos.Y,wp->pos.Z,wp->sector())) continue; return true; @@ -8905,7 +8905,7 @@ int DoMineStuck(DSWActor* actor) vec3_t pos = { ap->pos.X, ap->pos.Y, ap->pos.Z - u->sz }; SetActorZ(actor, &pos); - sp->pos.Z = ap->pos.Z - DIV2(SPRITEp_SIZE_Z(ap)); + sp->pos.Z = ap->pos.Z - DIV2(GetSpriteSizeZ(ap)); } // not activated yet @@ -9098,7 +9098,7 @@ int DoMine(DSWActor* actor) SetMineStuck(actor); // Set the Z position - sp->pos.Z = hsp->pos.Z - DIV2(SPRITEp_SIZE_Z(hsp)); + sp->pos.Z = hsp->pos.Z - DIV2(GetSpriteSizeZ(hsp)); // If it's not alive, don't stick it if (hu && hu->Health <= 0) return false; // JBF: added null check @@ -10056,7 +10056,7 @@ int SpawnCoolieExp(DSWActor* actor) u->Counter = RandomRange(120); // This is the wait til birth time! - zh = sp->pos.Z - SPRITEp_SIZE_Z(sp) + (SPRITEp_SIZE_Z(sp) >> 2); + zh = sp->pos.Z - GetSpriteSizeZ(sp) + (GetSpriteSizeZ(sp) >> 2); nx = sp->pos.X + MOVEx(64, sp->ang+1024); ny = sp->pos.Y + MOVEy(64, sp->ang+1024); @@ -10105,22 +10105,22 @@ void SpawnFireballFlames(DSWActor* actor, DSWActor* enemyActor) if (eu->flameActor != nullptr) { - int sizez = SPRITEp_SIZE_Z(ep) + (SPRITEp_SIZE_Z(ep) >> 2); + int sizez = GetSpriteSizeZ(ep) + (GetSpriteSizeZ(ep) >> 2); auto np = &eu->flameActor->s(); auto nu = eu->flameActor->u(); if (TEST(ep->extra, SPRX_BURNABLE)) return; - if (nu->Counter >= SPRITEp_SIZE_Z_2_YREPEAT(np, sizez)) + if (nu->Counter >= GetRepeatFromHeight(np, sizez)) { // keep flame only slightly bigger than the enemy itself - nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, sizez); + nu->Counter = GetRepeatFromHeight(np, sizez); } else { //increase max size - nu->Counter += SPRITEp_SIZE_Z_2_YREPEAT(np, 8<<8); + nu->Counter += GetRepeatFromHeight(np, 8<<8); } // Counter is max size @@ -10154,12 +10154,12 @@ void SpawnFireballFlames(DSWActor* actor, DSWActor* enemyActor) // large flame for trees and such if (TEST(ep->extra, SPRX_BURNABLE)) { - int sizez = SPRITEp_SIZE_Z(ep) + (SPRITEp_SIZE_Z(ep) >> 2); - nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, sizez); + int sizez = GetSpriteSizeZ(ep) + (GetSpriteSizeZ(ep) >> 2); + nu->Counter = GetRepeatFromHeight(np, sizez); } else { - nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, SPRITEp_SIZE_Z(ep)>>1); + nu->Counter = GetRepeatFromHeight(np, GetSpriteSizeZ(ep)>>1); } } else @@ -10833,7 +10833,7 @@ void SpawnGrenadeExp(DSWActor* actor) { dx += RandomRange(1000)-RandomRange(1000); dy += RandomRange(1000)-RandomRange(1000); - dz = SPRITEp_MID(sp) + RandomRange(1000)-RandomRange(1000); + dz = GetSpriteZOfMiddle(sp) + RandomRange(1000)-RandomRange(1000); } auto expActor = SpawnActor(STAT_MISSILE, GRENADE_EXP, s_GrenadeExp, sp->sector(), @@ -11744,7 +11744,7 @@ int DoRing(DSWActor* actor) if (pp) sp->pos.Z = pp->pos.Z + Z(20); else - sp->pos.Z = SPRITEp_MID(so) + Z(30); + sp->pos.Z = GetSpriteZOfMiddle(so) + Z(30); // go out until its time to come back in if (u->Counter2 == false) @@ -11790,9 +11790,9 @@ int DoRing(DSWActor* actor) sp->pos.Z = fz; } - if (sp->pos.Z < cz + SPRITEp_SIZE_Z(sp)) + if (sp->pos.Z < cz + GetSpriteSizeZ(sp)) { - sp->pos.Z = cz + SPRITEp_SIZE_Z(sp); + sp->pos.Z = cz + GetSpriteSizeZ(sp); } // Done last - check for damage @@ -11929,9 +11929,9 @@ int DoSerpRing(DSWActor* actor) sp->pos.Z = fz; } - if (sp->pos.Z < cz + SPRITEp_SIZE_Z(sp)) + if (sp->pos.Z < cz + GetSpriteSizeZ(sp)) { - sp->pos.Z = cz + SPRITEp_SIZE_Z(sp); + sp->pos.Z = cz + GetSpriteSizeZ(sp); } if (u->Counter2 > 0) @@ -11990,7 +11990,7 @@ int InitLavaThrow(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); + nz = GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, LAVA_BOULDER, s_LavaBoulder, sp->sector(), @@ -12077,7 +12077,7 @@ void InitVulcanBoulder(DSWActor* actor) wp->ang = nang; wu->Counter = 0; - zsize = SPRITEp_SIZE_Z(wp); + zsize = GetSpriteSizeZ(wp); wu->Radius = 200; SET(wp->cstat, CSTAT_SPRITE_YCENTER); @@ -12144,7 +12144,7 @@ int InitSerpRing(DSWActor* actor) np->zvel = Z(3); np->pal = 0; - np->pos.Z = SPRITEp_TOS(sp) - Z(20); + np->pos.Z = GetSpriteZOfTop(sp) - Z(20); nu->sz = Z(50); // ang around the serp is now slide_ang @@ -12296,7 +12296,7 @@ int InitEnemyNapalm(DSWActor* actor) for (i = 0; i < SIZ(mp); i++) { auto actorNew = SpawnActor(STAT_MISSILE, FIREBALL1, s_Napalm, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2), sp->ang, NAPALM_VELOCITY); + sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2), sp->ang, NAPALM_VELOCITY); wp = &actorNew->s(); wu = actorNew->u(); @@ -12410,7 +12410,7 @@ int InitEnemyMirv(DSWActor* actor) PlaySound(DIGI_MIRVFIRE, actor, v3df_none); auto actorNew = SpawnActor(STAT_MISSILE, MIRV_METEOR, s_Mirv, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2), sp->ang, MIRV_VELOCITY); + sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp) + (GetSpriteSizeZ(sp) >> 2), sp->ang, MIRV_VELOCITY); wp = &actorNew->s(); wu = actorNew->u(); @@ -12514,7 +12514,7 @@ int InitSwordAttack(PLAYERp pp) { if (SpriteOverlapZ(pp->Actor(), itActor, Z(20))) { - if (FAFcansee(sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->sector(), psp->pos.X, psp->pos.Y, SPRITEp_MID(psp), psp->sector())) + if (FAFcansee(sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->sector(), psp->pos.X, psp->pos.Y, GetSpriteZOfMiddle(psp), psp->sector())) DoDamage(itActor, pp->Actor()); } } @@ -12699,7 +12699,7 @@ int InitFistAttack(PLAYERp pp) { if (SpriteOverlapZ(pp->Actor(), itActor, Z(20)) || face == 190) { - if (FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),psp->pos.X,psp->pos.Y,SPRITEp_MID(psp),psp->sector())) + if (FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),psp->pos.X,psp->pos.Y,GetSpriteZOfMiddle(psp),psp->sector())) DoDamage(itActor, pp->Actor()); if (face == 190) { @@ -12861,7 +12861,7 @@ int InitSumoNapalm(DSWActor* actor) for (i = 0; i < (int)SIZ(mp); i++) { auto wActor = SpawnActor(STAT_MISSILE, FIREBALL1, s_Napalm, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_TOS(sp), ang, NAPALM_VELOCITY); + sp->pos.X, sp->pos.Y, GetSpriteZOfTop(sp), ang, NAPALM_VELOCITY); wp = &wActor->s(); wu = wActor->u(); @@ -12930,7 +12930,7 @@ int InitSumoSkull(DSWActor* actor) PlaySound(DIGI_SERPSUMMONHEADS, actor, v3df_none); - auto actorNew = SpawnActor(STAT_ENEMY, SKULL_R0, &s_SkullWait[0][0], sp->sector(), sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->ang, 0); + auto actorNew = SpawnActor(STAT_ENEMY, SKULL_R0, &s_SkullWait[0][0], sp->sector(), sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->ang, 0); np = &actorNew->s(); nu = actorNew->u(); @@ -13000,7 +13000,7 @@ int InitSumoStompAttack(DSWActor* actor) if (dist < CLOSE_RANGE_DIST_FUDGE(tsp, sp, reach)) { - if (FAFcansee(tsp->pos.X,tsp->pos.Y,SPRITEp_MID(tsp),tsp->sector(),sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector())) + if (FAFcansee(tsp->pos.X,tsp->pos.Y,GetSpriteZOfMiddle(tsp),tsp->sector(),sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector())) DoDamage(itActor, actor); } } @@ -13029,7 +13029,7 @@ int InitMiniSumoClap(DSWActor* actor) { if (SpriteOverlapZ(actor, u->targetActor, Z(20))) { - if (FAFcansee(tsp->pos.X, tsp->pos.Y, ActorMid(u->targetActor), tsp->sector(), sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->sector())) + if (FAFcansee(tsp->pos.X, tsp->pos.Y, ActorMid(u->targetActor), tsp->sector(), sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->sector())) { PlaySound(DIGI_CGTHIGHBONE, actor, v3df_follow | v3df_dontpan); DoDamage(u->targetActor, actor); @@ -13038,7 +13038,7 @@ int InitMiniSumoClap(DSWActor* actor) } else if (dist < CLOSE_RANGE_DIST_FUDGE(tsp, sp, reach)) { - if (FAFcansee(tsp->pos.X, tsp->pos.Y, ActorMid(u->targetActor), tsp->sector(), sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->sector())) + if (FAFcansee(tsp->pos.X, tsp->pos.Y, ActorMid(u->targetActor), tsp->sector(), sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->sector())) { PlaySound(DIGI_30MMEXPLODE, actor, v3df_none); SpawnFireballFlames(actor, u->targetActor); @@ -13081,9 +13081,9 @@ int WeaponAutoAim(DSWActor* actor, DSWActor* mislActor, short ang, bool test) { int tos, diff, siz; - tos = SPRITEp_TOS(hp); + tos = GetSpriteZOfTop(hp); diff = wp->pos.Z - tos; - siz = SPRITEp_SIZE_Z(hp); + siz = GetSpriteSizeZ(hp); // hit_sprite is below if (diff < -Z(50)) @@ -13148,9 +13148,9 @@ int WeaponAutoAimZvel(DSWActor* actor, DSWActor* missileActor, int *zvel, short { int tos, diff, siz; - tos = SPRITEp_TOS(hp); + tos = GetSpriteZOfTop(hp); diff = wp->pos.Z - tos; - siz = SPRITEp_SIZE_Z(hp); + siz = GetSpriteSizeZ(hp); // hit_sprite is below if (diff < -Z(50)) @@ -13199,7 +13199,7 @@ DSWActor* AimHitscanToTarget(DSWActor* actor, int *z, short *ang, int z_ratio) if (dist != 0) { - zh = SPRITEp_UPPER(hp); + zh = GetSpriteUpperZ(hp); xvect = bcos(*ang); yvect = bsin(*ang); @@ -13257,7 +13257,7 @@ DSWActor* WeaponAutoAimHitscan(DSWActor* actor, int *z, short *ang, bool test) if (dist != 0) { - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); xvect = bcos(*ang); yvect = bsin(*ang); @@ -13292,7 +13292,7 @@ void WeaponHitscanShootFeet(DSWActor* actor, DSWActor* hitActor, int *zvect) if (dist != 0) { - zh = SPRITEp_BOS(hp) + Z(20); + zh = GetSpriteZOfBottom(hp) + Z(20); z = sp->pos.Z; xvect = bcos(ang); @@ -13948,7 +13948,7 @@ int InitZillaRail(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_TOS(sp); + nz = GetSpriteZOfTop(sp); // Spawn a shot // Inserting and setting up variables @@ -14533,7 +14533,7 @@ int InitMicro(PLAYERp pp) if (dist != 0) { int zh; - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); wp->zvel = (wp->xvel * (zh - wp->pos.Z)) / dist; } @@ -14772,7 +14772,7 @@ int DoStaticFlamesDamage(DSWActor* actor) DoDamage(itActor, actor); else if (u->Radius > 200) { - if (FAFcansee(sp->pos.X,sp->pos.Y,SPRITEp_MID(sp),sp->sector(),hp->pos.X,hp->pos.Y,SPRITEp_MID(hp),hp->sector())) + if (FAFcansee(sp->pos.X,sp->pos.Y,GetSpriteZOfMiddle(sp),sp->sector(),hp->pos.X,hp->pos.Y,GetSpriteZOfMiddle(hp),hp->sector())) DoDamage(itActor, actor); } } @@ -14920,7 +14920,7 @@ int InitSerpSpell(DSWActor* actor) np = &actorNew->s(); nu = actorNew->u(); - np->pos.Z = SPRITEp_TOS(sp); + np->pos.Z = GetSpriteZOfTop(sp); nu->RotNum = 5; NewStateGroup(actorNew, &sg_SerpMeteor[0]); @@ -14979,7 +14979,7 @@ int SpawnDemonFist(DSWActor* actor) return -1; auto expActor = SpawnActor(STAT_MISSILE, 0, s_TeleportEffect, sp->sector(), - sp->pos.X, sp->pos.Y, SPRITEp_MID(sp), sp->ang, 0); + sp->pos.X, sp->pos.Y, GetSpriteZOfMiddle(sp), sp->ang, 0); exp = &expActor->s(); eu = expActor->u(); @@ -15033,7 +15033,7 @@ int InitSerpMonstSpell(DSWActor* actor) nu = actorNew->u(); nu->spal = np->pal = 25; // Bright Red - np->pos.Z = SPRITEp_TOS(sp); + np->pos.Z = GetSpriteZOfTop(sp); nu->RotNum = 5; NewStateGroup(actorNew, &sg_SerpMeteor[0]); @@ -15103,7 +15103,7 @@ int InitEnemyRocket(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp))-Z(8); + nz = sp->pos.Z - DIV2(GetSpriteSizeZ(sp))-Z(8); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, BOLT_THINMAN_R2, &s_Rocket[0][0], sp->sector(), @@ -15189,7 +15189,7 @@ int InitEnemyRail(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp))-Z(8); + nz = sp->pos.Z - DIV2(GetSpriteSizeZ(sp))-Z(8); // Spawn a shot // Inserting and setting up variables @@ -15276,7 +15276,7 @@ int InitZillaRocket(DSWActor* actor) { nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp))-Z(8); + nz = sp->pos.Z - DIV2(GetSpriteSizeZ(sp))-Z(8); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, BOLT_THINMAN_R2, &s_Rocket[0][0], sp->sector(), @@ -15341,7 +15341,7 @@ int InitEnemyStar(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_MID(sp); + nz = GetSpriteZOfMiddle(sp); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, STAR1, s_Star, sp->sector(), @@ -15386,7 +15386,7 @@ int InitEnemyCrossbow(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_MID(sp)-Z(14); + nz = GetSpriteZOfMiddle(sp)-Z(14); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, CROSSBOLT, &s_CrossBolt[0][0], sp->sector(), @@ -15440,7 +15440,7 @@ int InitSkelSpell(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - DIV2(SPRITEp_SIZE_Z(sp)); + nz = sp->pos.Z - DIV2(GetSpriteSizeZ(sp)); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, ELECTRO_ENEMY, s_Electro, sp->sector(), @@ -15687,7 +15687,7 @@ void InitFireballTrap(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - SPRITEp_SIZE_Z(sp); + nz = sp->pos.Z - GetSpriteSizeZ(sp); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, FIREBALL, s_Fireball, sp->sector(), nx, ny, nz, @@ -15722,7 +15722,7 @@ void InitBoltTrap(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = sp->pos.Z - SPRITEp_SIZE_Z(sp); + nz = sp->pos.Z - GetSpriteSizeZ(sp); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], sp->sector(), nx, ny, nz, @@ -15755,7 +15755,7 @@ void InitSpearTrap(DSWActor* actor) nx = sp->pos.X; ny = sp->pos.Y; - nz = SPRITEp_MID(sp); + nz = GetSpriteZOfMiddle(sp); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, CROSSBOLT, &s_CrossBolt[0][0], sp->sector(), nx, ny, nz, sp->ang, 750); @@ -16467,7 +16467,7 @@ int InitTurretMicro(DSWActor* actor, PLAYERp pp) if (dist != 0) { int zh; - zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); + zh = GetSpriteZOfTop(hp) + (GetSpriteSizeZ(hp) >> 2); wp->zvel = (wp->xvel * (zh - wp->pos.Z)) / dist; } @@ -17246,12 +17246,12 @@ int InitEnemyUzi(DSWActor* actor) if (u->ID == ZILLA_RUN_R0) { - zh = SPRITEp_TOS(sp); + zh = GetSpriteZOfTop(sp); zh += Z(20); } else { - zh = SPRITEp_SIZE_Z(sp); + zh = GetSpriteSizeZ(sp); zh -= (zh >> 2); } daz = sp->pos.Z - zh; @@ -17790,7 +17790,7 @@ int InitEnemyFireball(DSWActor* actor) // get angle to player and also face player when attacking sp->ang = NORM_ANGLE(getangle(tsp->pos.X - sp->pos.X, tsp->pos.Y - sp->pos.Y)); - size_z = Z(SPRITEp_SIZE_Y(sp)); + size_z = Z(GetSpriteSizeY(sp)); nz = sp->pos.Z - size_z + (size_z >> 2) + (size_z >> 3) + Z(4); xchange = MOVEx(GORO_FIREBALL_VELOCITY, sp->ang); @@ -17832,9 +17832,9 @@ int InitEnemyFireball(DSWActor* actor) //dist = Distance(wp->pos.X, wp->pos.Y, tsp->pos.X, tsp->pos.Y); // Determine target Z value - //targ_z = tsp->z - Z(SPRITEp_SIZE_Y(sp)) + Z(DIV2(SPRITEp_SIZE_Y(sp))); + //targ_z = tsp->z - Z(GetSpriteSizeY(sp)) + Z(DIV2(GetSpriteSizeY(sp))); //targ_z = tsp->z; - targ_z = tsp->pos.Z - DIV2(Z(SPRITEp_SIZE_Y(sp))); + targ_z = tsp->pos.Z - DIV2(Z(GetSpriteSizeY(sp))); // (velocity * difference between the target and the throwing star) / // distance @@ -19377,7 +19377,7 @@ int ShrapKillSprite(DSWActor* actor) break; case GORE_Lung: if (RandomRange(1000) > 500) break; - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SpawnFloorSplash(actor); if (RandomRange(1000) < 500) PlaySound(DIGI_GIBS1, actor, v3df_none); @@ -19399,7 +19399,7 @@ int ShrapKillSprite(DSWActor* actor) break; case GORE_Liver: if (RandomRange(1000) > 500) break; - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SpawnFloorSplash(actor); if (RandomRange(1000) < 500) PlaySound(DIGI_GIBS1, actor, v3df_none); @@ -19421,7 +19421,7 @@ int ShrapKillSprite(DSWActor* actor) break; case GORE_SkullCap: if (RandomRange(1000) > 500) break; - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); SpawnFloorSplash(actor); if (rnd_num > 683) { @@ -19439,7 +19439,7 @@ int ShrapKillSprite(DSWActor* actor) break; case GORE_Head: if (RandomRange(1000) > 500) break; - sp->clipdist = SPRITEp_SIZE_X(sp); + sp->clipdist = GetSpriteSizeX(sp); QueueFloorBlood(actor); QueueGeneric(actor,GORE_Head); return 0;