From a5fac26a90aaff39a3775fb7e876ba49bc785ebb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Nov 2021 21:47:04 +0100 Subject: [PATCH] - DIVx macro removal. Only DIV2 left because there are too many calls to quickly remove them. --- source/games/sw/src/actor.cpp | 8 +-- source/games/sw/src/ai.cpp | 4 +- source/games/sw/src/bunny.cpp | 4 +- source/games/sw/src/game.h | 4 +- source/games/sw/src/jweapon.cpp | 18 +++---- source/games/sw/src/mytypes.h | 8 --- source/games/sw/src/panel.cpp | 2 +- source/games/sw/src/player.cpp | 10 ++-- source/games/sw/src/ripper.cpp | 4 +- source/games/sw/src/track.cpp | 16 +++--- source/games/sw/src/weapon.cpp | 91 ++++++++++++++++----------------- 11 files changed, 78 insertions(+), 91 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 70adc4672..bdd021e27 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -300,8 +300,8 @@ void DoDebrisCurrent(DSWActor* actor) //sp->clipdist = (256+128)>>2; - nx = MulScale(DIV4(sectu->speed), bcos(sectu->ang), 14); - ny = MulScale(DIV4(sectu->speed), bsin(sectu->ang), 14); + nx = MulScale((sectu->speed >> 2), bcos(sectu->ang), 14); + ny = MulScale((sectu->speed >> 2), bsin(sectu->ang), 14); Collision ret = move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); @@ -310,8 +310,8 @@ void DoDebrisCurrent(DSWActor* actor) { short rang = RANDOM_P2(2048); - nx = MulScale(DIV4(sectu->speed), bcos(sectu->ang + rang), 14); - nx = MulScale(DIV4(sectu->speed), bsin(sectu->ang + rang), 14); + nx = MulScale((sectu->speed >> 2), bcos(sectu->ang + rang), 14); + nx = MulScale((sectu->speed >> 2), bsin(sectu->ang + rang), 14); move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); } diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index c6b48f185..20975981b 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -111,7 +111,7 @@ bool ActorFlaming(DSWActor* actor) int size; SPRITEp fp = &u->flameActor->s(); - size = SPRITEp_SIZE_Z(sp) - DIV4(SPRITEp_SIZE_Z(sp)); + size = SPRITEp_SIZE_Z(sp) - (SPRITEp_SIZE_Z(sp) >> 2); if (SPRITEp_SIZE_Z(fp) > size) return true; @@ -1611,7 +1611,7 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove) // if on fire, run shorter distances if (ActorFlaming(actor)) - DistToMove = DIV4(DistToMove) + DIV8(DistToMove); + DistToMove = (DistToMove >> 2) + (DistToMove >> 3); // Find angle to from the player oang = NORM_ANGLE(getangle(u->targetActor->s().x - sp->x, u->targetActor->s().y - sp->y)); diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index fe6a205c5..40080e862 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -807,9 +807,7 @@ int GetBunnyJumpHeight(int jump_speed, int jump_grav) height = jump_speed * jump_iterations * ACTORMOVETICS; - height = DIV256(height); - - return DIV2(height); + return height >> 9; } int PickBunnyJumpSpeed(DSWActor* actor, int pix_height) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index edc80fde5..c10f661d8 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -297,8 +297,8 @@ inline int SPRITEp_SIZE_BOS(const spritetype* sp) // mid and upper/lower sprite calculations #define SPRITEp_MID(sp) (DIV2(SPRITEp_TOS(sp) + SPRITEp_BOS(sp))) -#define SPRITEp_UPPER(sp) (SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp))) -#define SPRITEp_LOWER(sp) (SPRITEp_BOS(sp) - DIV4(SPRITEp_SIZE_Z(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)) #define Z(value) ((int)(value) << 8) #define PIXZ(value) ((int)(value) >> 8) diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index d9fde6d5c..a27124943 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -499,7 +499,7 @@ int DoBloodSpray(DSWActor* actor) case kHitSector: { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (TEST(u->Flags, SPR_UNDERWATER)) SET(u->Flags, SPR_BOUNCE); // no bouncing @@ -688,7 +688,7 @@ int DoPhosphorus(DSWActor* actor) else { // hit a sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor if (!TEST(u->Flags, SPR_BOUNCE)) @@ -717,7 +717,7 @@ int DoPhosphorus(DSWActor* actor) else { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (TEST(u->Flags, SPR_UNDERWATER)) SET(u->Flags, SPR_BOUNCE); // no bouncing @@ -906,7 +906,7 @@ int DoChemBomb(DSWActor* actor) else { // hit a sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor if (!TEST(u->Flags, SPR_BOUNCE)) @@ -945,7 +945,7 @@ int DoChemBomb(DSWActor* actor) else { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (TEST(u->Flags, SPR_UNDERWATER)) SET(u->Flags, SPR_BOUNCE); // no bouncing @@ -1132,7 +1132,7 @@ int DoCaltrops(DSWActor* actor) else { // hit a sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor if (!TEST(u->Flags, SPR_BOUNCE)) @@ -1162,7 +1162,7 @@ int DoCaltrops(DSWActor* actor) else { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (TEST(u->Flags, SPR_UNDERWATER)) SET(u->Flags, SPR_BOUNCE); // no bouncing @@ -1339,7 +1339,7 @@ int PlayerInitChemBomb(PLAYERp pp) // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) { - wp->xvel -= DIV4(wp->xvel); + wp->xvel -= (wp->xvel >> 2); } // wu->RotNum = 5; @@ -1762,7 +1762,7 @@ int PlayerInitCaltrops(PLAYERp pp) // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) { - wp->xvel -= DIV4(wp->xvel); + wp->xvel -= (wp->xvel >> 2); } SET(wu->Flags, SPR_XFLIP_TOGGLE); diff --git a/source/games/sw/src/mytypes.h b/source/games/sw/src/mytypes.h index e41cbc4b5..0524f51a9 100644 --- a/source/games/sw/src/mytypes.h +++ b/source/games/sw/src/mytypes.h @@ -42,15 +42,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms =========================== */ -// For fast DIVision of integers - #define DIV2(x) ((x) >> 1) -#define DIV4(x) ((x) >> 2) -#define DIV8(x) ((x) >> 3) -#define DIV256(x) ((x) >> 8) - -// Fast mods of any power of 2 - #define MOD_P2(number,modby) ((number) & ((modby)-1)) diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index 3718e9649..0d1df76b0 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -2303,7 +2303,7 @@ pUziAction(PANEL_SPRITEp psp) } // Only Recoil if shooting pUziBobSetup(psp); - UziRecoilYadj = DIV256(RANDOM_P2(1024)); // global hack for + UziRecoilYadj = (RANDOM_P2(1024)) >> 8; // global hack for // weapon Bob pWeaponBob(psp, PLAYER_MOVING(psp->PlayerP) || shooting); UziRecoilYadj = 0; // reset my global hack diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 2ffe91af0..849a19e5b 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1201,11 +1201,11 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets if (u && u->PlayerP) zh = u->PlayerP->posz; else - zh = SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)); + zh = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); - ezh = SPRITEp_TOS(ep) + DIV4(SPRITEp_SIZE_Z(ep)); + ezh = SPRITEp_TOS(ep) + (SPRITEp_SIZE_Z(ep) >> 2); ezhm = SPRITEp_TOS(ep) + DIV2(SPRITEp_SIZE_Z(ep)); - ezhl = SPRITEp_BOS(ep) - DIV4(SPRITEp_SIZE_Z(ep)); + ezhl = SPRITEp_BOS(ep) - (SPRITEp_SIZE_Z(ep) >> 2); // If you can't see 'em you can't shoot 'em if (!FAFcansee(sp->x, sp->y, zh, sp->sectnum, ep->x, ep->y, ezh, ep->sectnum) && @@ -1454,7 +1454,7 @@ void DoPlayerHeight(PLAYERp pp) diff = pp->posz - (pp->loz - PLAYER_HEIGHT); - pp->posz = pp->posz - (DIV4(diff) + DIV8(diff)); + pp->posz = pp->posz - ((diff >> 2) + (diff >> 3)); } void DoPlayerJumpHeight(PLAYERp pp) @@ -1474,7 +1474,7 @@ void DoPlayerCrawlHeight(PLAYERp pp) int diff; diff = pp->posz - (pp->loz - PLAYER_CRAWL_HEIGHT); - pp->posz = pp->posz - (DIV4(diff) + DIV8(diff)); + pp->posz = pp->posz - ((diff >> 2) + (diff >> 3)); } void UpdatePlayerSpriteAngle(PLAYERp pp) diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index d33cda300..6d27cc1c8 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -871,9 +871,7 @@ int GetJumpHeight(int jump_speed, int jump_grav) height = jump_speed * jump_iterations * ACTORMOVETICS; - height = DIV256(height); - - return DIV2(height); + return height >> 9; } int PickJumpSpeed(DSWActor* actor, int pix_height) diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 84eaa65a7..146f33d3d 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -749,8 +749,8 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop) KillActor(BoundActor); // set radius for explosion checking - based on bounding box - u->Radius = DIV4((xhigh - xlow) + (yhigh - ylow)); - u->Radius -= DIV4(u->Radius); // trying to get it a good size + u->Radius = ((xhigh - xlow) + (yhigh - ylow)) >> 2; + u->Radius -= (u->Radius >> 2); // trying to get it a good size // search for center sprite if it exists @@ -2693,8 +2693,8 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) // calculate a new x and y if (sop->vel && !TEST(sop->flags,SOBJ_MOVE_VERTICAL)) { - *nx = (DIV256(sop->vel)) * locktics * bcos(sop->ang_moving) >> 14; - *ny = (DIV256(sop->vel)) * locktics * bsin(sop->ang_moving) >> 14; + *nx = ((sop->vel) >> 8) * locktics * bcos(sop->ang_moving) >> 14; + *ny = ((sop->vel) >> 8) * locktics * bsin(sop->ang_moving) >> 14; dist = Distance(sop->xmid, sop->ymid, sop->xmid + *nx, sop->ymid + *ny); sop->target_dist -= dist; @@ -2861,7 +2861,7 @@ void DoTornadoObject(SECTOR_OBJECTp sop) yvect = sop->vel * bcos(*ang); cursect = sop->op_main_sector; // for sop->vel - floor_dist = DIV4(labs(sector[cursect].ceilingz - sector[cursect].floorz)); + floor_dist = (labs(sector[cursect].ceilingz - sector[cursect].floorz)) >> 2; pos.x = sop->xmid; pos.y = sop->ymid; pos.z = floor_dist; @@ -3673,7 +3673,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics) } // update the real velocity - sp->xvel = DIV256(u->track_vel); + sp->xvel = (u->track_vel) >> 8; } else if (TEST(u->Flags, SPR_SLOW_DOWN)) { @@ -3683,7 +3683,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics) RESET(u->Flags, SOBJ_SLOW_DOWN); } - sp->xvel = DIV256(u->track_vel); + sp->xvel = (u->track_vel) >> 8; } nx = 0; @@ -3691,7 +3691,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics) if (TEST(u->Flags, SPR_CLIMBING)) { - if (SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)) < u->sz) + if (SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2) < u->sz) { RESET(u->Flags, SPR_CLIMBING); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 8cae78d2b..fd3e77af3 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -4067,7 +4067,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->x; hit_y = sp->y; - hit_z = SPRITEp_TOS(wp) + DIV4(SPRITEp_SIZE_Z(wp)); + hit_z = SPRITEp_TOS(wp) + (SPRITEp_SIZE_Z(wp) >> 2); //ASSERT(wu->PlayerP); } @@ -4077,7 +4077,7 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->x; hit_y = sp->y; - hit_z = SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)); + hit_z = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); break; case BLADE1: case BLADE2: @@ -4102,14 +4102,14 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i hit_ang = wp->ang; hit_x = sp->x; hit_y = sp->y; - hit_z = SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)); + hit_z = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); break; default: p = SomeBlood; hit_ang = NORM_ANGLE(wp->ang + 1024); hit_x = sp->x; hit_y = sp->y; - hit_z = SPRITEp_TOS(wp) + DIV4(SPRITEp_SIZE_Z(wp)); + hit_z = SPRITEp_TOS(wp) + (SPRITEp_SIZE_Z(wp) >> 2); break; } } @@ -4320,7 +4320,7 @@ bool WeaponMoveHit(DSWActor* actor) ASSERT(sectp->extra != -1); // hit floor - closer to floor than ceiling - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor sprite if (u->lowActor) @@ -5416,7 +5416,7 @@ int GetDamage(DSWActor* actor, DSWActor* weapActor, int DamageNdx) //return(damage_amt); // formula: damage_amt = 75% + random(25%) - return DIV2(damage_amt) + DIV4(damage_amt) + RandomRange(DIV4(damage_amt)); + return (damage_amt >> 1) + (damage_amt >> 2) + RandomRange(damage_amt >> 2); } else { @@ -7676,7 +7676,7 @@ int DoStar(DSWActor* actor) bool did_hit_wall; short hit_sect = u->coll.index; - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 0) { @@ -7706,7 +7706,7 @@ int DoStar(DSWActor* actor) u->xchange = MulScale(u->xchange, 64000 + (RandomRange(64000) - 32000), 16); u->ychange = MulScale(u->ychange, 64000 + (RandomRange(64000) - 32000), 16); - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) u->zchange = MulScale(u->zchange, 50000, 16); // floor else u->zchange = MulScale(u->zchange, 40000, 16); // ceiling @@ -7748,7 +7748,7 @@ int DoStar(DSWActor* actor) // 32000 to 96000 u->xchange = MulScale(u->xchange, 64000 + (RandomRange(64000) - 32000), 16); u->ychange = MulScale(u->ychange, 64000 + (RandomRange(64000) - 32000), 16); - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) u->zchange = MulScale(u->zchange, 50000, 16); // floor else u->zchange = MulScale(u->zchange, 40000, 16); // ceiling @@ -7904,7 +7904,7 @@ int MissileSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range/*, int1 sp->ang -= delta_ang; - zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); delta_ang = (zh - sp->z)>>1; @@ -7980,7 +7980,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) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); dist = ksqrt(SQ(sp->x - hp->x) + SQ(sp->y - hp->y) + (SQ(sp->z - zh)>>8)); @@ -8060,7 +8060,7 @@ int VectorMissileSeek(DSWActor* actor, int16_t delay_tics, int16_t turn_speed, i if (!hp) return 0; - zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); dist = ksqrt(SQ(sp->x - hp->x) + SQ(sp->y - hp->y) + (SQ(sp->z - zh)>>8)); @@ -8125,7 +8125,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) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); dist = ksqrt(SQ(sp->x - hp->x) + SQ(sp->y - hp->y) + (SQ(sp->z - zh)>>8)); @@ -8584,7 +8584,7 @@ int DoGrenade(DSWActor* actor) else { // hit a sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor if (!TEST(u->Flags, SPR_BOUNCE)) @@ -8620,7 +8620,7 @@ int DoGrenade(DSWActor* actor) else { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { if (TEST(u->Flags, SPR_UNDERWATER)) SET(u->Flags, SPR_BOUNCE); // no bouncing underwater @@ -8796,7 +8796,7 @@ int DoVulcanBoulder(DSWActor* actor) else { // hit a sloped sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor u->xchange = MulScale(u->xchange, 30000, 16); @@ -8821,7 +8821,7 @@ int DoVulcanBoulder(DSWActor* actor) else { // hit unsloped floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { u->coll.setNone(); u->Counter = 0; @@ -9172,7 +9172,7 @@ int DoMine(DSWActor* actor) else if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR)) { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) SET(u->Flags2, SPR2_ATTACH_FLOOR); else SET(u->Flags2, SPR2_ATTACH_CEILING); @@ -9224,7 +9224,7 @@ int DoMine(DSWActor* actor) SetMineStuck(actor); // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) SET(u->Flags2, SPR2_ATTACH_FLOOR); else SET(u->Flags2, SPR2_ATTACH_CEILING); @@ -10086,7 +10086,7 @@ int SpawnCoolieExp(DSWActor* actor) u->Counter = RandomRange(120); // This is the wait til birth time! - zh = sp->z - SPRITEp_SIZE_Z(sp) + DIV4(SPRITEp_SIZE_Z(sp)); + zh = sp->z - SPRITEp_SIZE_Z(sp) + (SPRITEp_SIZE_Z(sp) >> 2); nx = sp->x + MOVEx(64, sp->ang+1024); ny = sp->y + MOVEy(64, sp->ang+1024); @@ -10135,7 +10135,7 @@ void SpawnFireballFlames(DSWActor* actor, DSWActor* enemyActor) if (eu->flameActor != nullptr) { - int sizez = SPRITEp_SIZE_Z(ep) + DIV4(SPRITEp_SIZE_Z(ep)); + int sizez = SPRITEp_SIZE_Z(ep) + (SPRITEp_SIZE_Z(ep) >> 2); auto np = &eu->flameActor->s(); auto nu = eu->flameActor->u(); @@ -10184,7 +10184,7 @@ void SpawnFireballFlames(DSWActor* actor, DSWActor* enemyActor) // large flame for trees and such if (TEST(ep->extra, SPRX_BURNABLE)) { - int sizez = SPRITEp_SIZE_Z(ep) + DIV4(SPRITEp_SIZE_Z(ep)); + int sizez = SPRITEp_SIZE_Z(ep) + (SPRITEp_SIZE_Z(ep) >> 2); nu->Counter = SPRITEp_SIZE_Z_2_YREPEAT(np, sizez); } else @@ -12025,7 +12025,7 @@ int InitLavaThrow(DSWActor* actor) nx = sp->x; ny = sp->y; - nz = SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)); + nz = SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2); // Spawn a shot auto actorNew = SpawnActor(STAT_MISSILE, LAVA_BOULDER, s_LavaBoulder, sp->sectnum, @@ -12331,7 +12331,7 @@ int InitEnemyNapalm(DSWActor* actor) for (i = 0; i < SIZ(mp); i++) { auto actorNew = SpawnActor(STAT_MISSILE, FIREBALL1, s_Napalm, sp->sectnum, - sp->x, sp->y, SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)), sp->ang, NAPALM_VELOCITY); + sp->x, sp->y, SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2), sp->ang, NAPALM_VELOCITY); wp = &actorNew->s(); wu = actorNew->u(); @@ -12445,7 +12445,7 @@ int InitEnemyMirv(DSWActor* actor) PlaySound(DIGI_MIRVFIRE, actor, v3df_none); auto actorNew = SpawnActor(STAT_MISSILE, MIRV_METEOR, s_Mirv, sp->sectnum, - sp->x, sp->y, SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)), sp->ang, MIRV_VELOCITY); + sp->x, sp->y, SPRITEp_TOS(sp) + (SPRITEp_SIZE_Z(sp) >> 2), sp->ang, MIRV_VELOCITY); wp = &actorNew->s(); wu = actorNew->u(); @@ -13122,13 +13122,13 @@ int WeaponAutoAim(DSWActor* actor, DSWActor* mislActor, short ang, bool test) // hit_sprite is below if (diff < -Z(50)) - zh = tos + DIV2(siz); + zh = tos + (siz >> 1); else // hit_sprite is above if (diff > Z(50)) - zh = tos + DIV8(siz); + zh = tos + (siz >> 3); else - zh = tos + DIV4(siz); + zh = tos + (siz >> 2); wp->zvel = (wp->xvel * (zh - wp->z)) / dist; } @@ -13189,13 +13189,13 @@ int WeaponAutoAimZvel(DSWActor* actor, DSWActor* missileActor, int *zvel, short // hit_sprite is below if (diff < -Z(50)) - zh = tos + DIV2(siz); + zh = tos + (siz >> 1); else - // hit_sprite is above - if (diff > Z(50)) - zh = tos + DIV8(siz); - else - zh = tos + DIV4(siz); + // hit_sprite is above + if (diff > Z(50)) + zh = tos + (siz >> 3); + else + zh = tos + (siz >> 2); *zvel = (wp->xvel * (zh - wp->z)) / dist; } @@ -13292,7 +13292,7 @@ DSWActor* WeaponAutoAimHitscan(DSWActor* actor, int *z, short *ang, bool test) if (dist != 0) { - zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); xvect = bcos(*ang); yvect = bsin(*ang); @@ -14570,7 +14570,7 @@ int InitMicro(PLAYERp pp) if (dist != 0) { int zh; - zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); wp->zvel = (wp->xvel * (zh - wp->z)) / dist; } @@ -16507,7 +16507,7 @@ int InitTurretMicro(DSWActor* actor, PLAYERp pp) if (dist != 0) { int zh; - zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp)); + zh = SPRITEp_TOS(hp) + (SPRITEp_SIZE_Z(hp) >> 2); wp->zvel = (wp->xvel * (zh - wp->z)) / dist; } @@ -17294,7 +17294,7 @@ int InitEnemyUzi(DSWActor* actor) else { zh = SPRITEp_SIZE_Z(sp); - zh -= DIV4(zh); + zh -= (zh >> 2); } daz = sp->z - zh; @@ -17464,7 +17464,7 @@ int InitGrenade(PLAYERp pp) // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) { - wp->xvel -= DIV4(wp->xvel); + wp->xvel -= (wp->xvel >> 2); } wu->RotNum = 5; @@ -17833,8 +17833,7 @@ int InitEnemyFireball(DSWActor* actor) sp->ang = NORM_ANGLE(getangle(tsp->x - sp->x, tsp->y - sp->y)); size_z = Z(SPRITEp_SIZE_Y(sp)); - //nz = sp->z - size_z + DIV4(size_z) + DIV8(size_z); - nz = sp->z - size_z + DIV4(size_z) + DIV8(size_z) + Z(4); + nz = sp->z - size_z + (size_z >> 2) + (size_z >> 3) + Z(4); xchange = MOVEx(GORO_FIREBALL_VELOCITY, sp->ang); ychange = MOVEy(GORO_FIREBALL_VELOCITY, sp->ang); @@ -18297,7 +18296,7 @@ bool MissileHitDiveArea(DSWActor* actor) if (SpriteInDiveArea(sp)) { // make sure you are close to the floor - if (sp->z < DIV2(u->hiz + u->loz)) + if (sp->z < ((u->hiz + u->loz) >> 1)) return false; // Check added by Jim because of sprite bridge over water @@ -18314,7 +18313,7 @@ bool MissileHitDiveArea(DSWActor* actor) else if (SpriteInUnderwaterArea(sp)) { // make sure you are close to the ceiling - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) return false; RESET(u->Flags, SPR_UNDERWATER); @@ -19303,7 +19302,7 @@ int DoShrapVelocity(DSWActor* actor) else { // hit a sector - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { // hit a floor if (!TEST(u->Flags, SPR_BOUNCE)) @@ -19332,7 +19331,7 @@ int DoShrapVelocity(DSWActor* actor) else { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { sp->z = u->loz; if (TEST(u->Flags, SPR_UNDERWATER)) @@ -19625,7 +19624,7 @@ int DoItemFly(DSWActor* actor) case kHitSector: { // hit floor - if (sp->z > DIV2(u->hiz + u->loz)) + if (sp->z > ((u->hiz + u->loz) >> 1)) { sp->z = u->loz; u->Counter = 0;