From a5a366923819bd17a7ef1a64c4e9beb890ed0cc3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2022 23:57:39 +0200 Subject: [PATCH] - eliminated the SetActor/Z function receiving a vec3_t pointer. The only one left is the one with a DVector3 now. --- source/core/coreactor.h | 12 ---------- source/games/blood/src/actor.cpp | 35 ++++++++++++---------------- source/games/blood/src/aiunicult.cpp | 21 ++++++----------- source/games/blood/src/nnexts.cpp | 17 +++++--------- source/games/duke/src/actors.cpp | 4 ++-- source/games/duke/src/actors_d.cpp | 10 ++++---- source/games/duke/src/actors_r.cpp | 14 +++++------ source/games/duke/src/funct.h | 2 +- source/games/exhumed/src/player.cpp | 4 +--- source/games/sw/src/break.cpp | 4 ++-- source/games/sw/src/skel.cpp | 19 ++++++--------- 11 files changed, 53 insertions(+), 89 deletions(-) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 97ec71603..0a6e8019d 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -533,18 +533,6 @@ void InitSpriteLists(); void SetActorZ(DCoreActor* actor, const DVector3& newpos); void SetActor(DCoreActor* actor, const DVector3& newpos); -inline void SetActor(DCoreActor* actor, const vec3_t* newpos) -{ - DVector3 ipos = { newpos->X * inttoworld, newpos->Y * inttoworld, newpos->Z * zinttoworld }; - SetActor(actor, ipos); -} - -inline void SetActorZ(DCoreActor* actor, const vec3_t* newpos) -{ - DVector3 ipos = { newpos->X * inttoworld, newpos->Y * inttoworld, newpos->Z * zinttoworld }; - SetActorZ(actor, ipos); -} - inline int clipmove(vec3_t& pos, sectortype** const sect, int xvect, int yvect, int const walldist, int const ceildist, int const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3) { diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index c62d47b5b..2a3611cf4 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6142,14 +6142,12 @@ void actCheckFlares() } if (target->hasX() && target->xspr.health > 0) { - int x = target->int_pos().X + mulscale30r(Cos(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2); - int y = target->int_pos().Y + mulscale30r(Sin(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2); - int z = target->int_pos().Z + actor->xspr.int_TargetPos().Z; - vec3_t pos = { x, y, z }; - SetActor(actor, &pos); - actor->vel.X = target->vel.X; - actor->vel.Y = target->vel.Y; - actor->vel.Z = target->vel.Z; + DVector3 pos = target->spr.pos; + pos.X += mulscale30r(Cos(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2) * inttoworld; + pos.Y += mulscale30r(Sin(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2) * inttoworld; + pos.Z += actor->xspr.TargetPos.Z; + SetActor(actor, pos); + actor->vel = target->vel; } else { @@ -6236,24 +6234,21 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, int a3, int a4) if (!spawned) return nullptr; int angle = source->int_ang(); int nDude = nType - kDudeBase; - int x, y, z; - z = a4 + source->int_pos().Z; - if (a3 < 0) + + auto pos = source->spr.pos; + pos.Z += a4 * zinttoworld; + + if (a3 >= 0) { - x = source->int_pos().X; - y = source->int_pos().Y; - } - else - { - x = source->int_pos().X + mulscale30r(Cos(angle), a3); - y = source->int_pos().Y + mulscale30r(Sin(angle), a3); + pos.X += mulscale30r(Cos(angle), a3) * inttoworld; + pos.Y += mulscale30r(Sin(angle), a3) * inttoworld; } spawned->spr.type = nType; if (!VanillaMode()) spawned->spr.inittype = nType; spawned->set_int_ang(angle); - vec3_t pos = { x, y, z }; - SetActor(spawned, &pos); + SetActor(spawned, pos); + spawned->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_BLOOD_BIT1; spawned->spr.clipdist = getDudeInfo(nDude + kDudeBase)->clipdist; spawned->xspr.health = getDudeInfo(nDude + kDudeBase)->startHealth << 4; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 63ed9237c..0232ba841 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1875,25 +1875,18 @@ bool doExplosion(DBloodActor* actor, int nType) DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist) { auto spawned = actSpawnSprite(actor, kStatDude); - int x, y, z = actor->int_pos().Z, nAngle = actor->int_ang(), nType = kDudeModernCustom; + int nAngle = actor->int_ang(), nType = kDudeModernCustom; + auto pos = actor->spr.pos; if (nDist > 0) { - - x = actor->int_pos().X + mulscale30r(Cos(nAngle), nDist); - y = actor->int_pos().Y + mulscale30r(Sin(nAngle), nDist); - } - else - { - - x = actor->int_pos().X; - y = actor->int_pos().Y; - + pos.X += mulscale30r(Cos(nAngle), nDist) * inttoworld; + pos.Y += mulscale30r(Sin(nAngle), nDist) * inttoworld; } - spawned->spr.type = nType; spawned->set_int_ang(nAngle); - vec3_t pos = { x, y, z }; - SetActor(spawned, &pos); + spawned->spr.type = nType; + spawned->spr.angle = actor->spr.angle; + SetActor(spawned, pos); spawned->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_BLOOD_BIT1; spawned->spr.clipdist = dudeInfo[nType - kDudeBase].clipdist; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 3d674a220..a51ee9291 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -263,20 +263,15 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceactor, DBloodActor* origin return NULL; int angle = origin->int_ang(); - int x, y, z = a4 + origin->int_pos().Z; - if (a3 < 0) + auto pos = origin->spr.pos.plusZ(a4 * zinttoworld); + + if (a3 >= 0) { - x = origin->int_pos().X; - y = origin->int_pos().Y; - } - else - { - x = origin->int_pos().X + mulscale30r(Cos(angle), a3); - y = origin->int_pos().Y + mulscale30r(Sin(angle), a3); + pos.X += mulscale30r(Cos(angle), a3) * inttoworld; + pos.Y += mulscale30r(Sin(angle), a3) * inttoworld; } - vec3_t pos = { x, y, z }; - SetActor(pDudeActor, &pos); + SetActor(pDudeActor, pos); pDudeActor->spr.type = nType; pDudeActor->set_int_ang(angle); diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 45107e0c4..34ec0c4a1 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1353,11 +1353,11 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) // //--------------------------------------------------------------------------- -void rpgexplode(DDukeActor *actor, int hit, const vec3_t &pos, int EXPLOSION2, int EXPLOSION2BOT, int newextra, int playsound) +void rpgexplode(DDukeActor *actor, int hit, const DVector3 &pos, int EXPLOSION2, int EXPLOSION2BOT, int newextra, int playsound) { auto explosion = spawn(actor, EXPLOSION2); if (!explosion) return; - explosion->set_int_pos(pos); + explosion->spr.pos = pos; if (actor->spr.xrepeat < 10) { diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index ae93e4b44..fdaf47588 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1410,7 +1410,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball) // //--------------------------------------------------------------------------- -static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t &oldpos) +static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3 &oldpos) { if (proj->spr.picnum != RPG && proj->spr.picnum != FREEZEBLAST && proj->spr.picnum != SPIT && (!isWorldTour() || proj->spr.picnum != FIREBALL) && @@ -1424,7 +1424,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t &oldpos) } else { - SetActor(proj, &oldpos); + SetActor(proj, oldpos); fi.checkhitwall(proj, wal, proj->int_pos().X, proj->int_pos().Y, proj->int_pos().Z, proj->spr.picnum); if (proj->spr.picnum == FREEZEBLAST) @@ -1449,9 +1449,9 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t &oldpos) // //--------------------------------------------------------------------------- -static bool weaponhitsector(DDukeActor* proj, const vec3_t& oldpos, bool fireball) +static bool weaponhitsector(DDukeActor* proj, const DVector3& oldpos, bool fireball) { - SetActor(proj, &oldpos); + SetActor(proj, oldpos); if (proj->spr.zvel < 0) { @@ -1505,7 +1505,7 @@ static void weaponcommon_d(DDukeActor* proj) S_PlayActorSound(WIERDSHOT_FLY, proj); int k, ll; - vec3_t oldpos = proj->int_pos(); + auto oldpos = proj->spr.pos; if (proj->spr.picnum == RPG && proj->sector()->lotag == 2) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 50d31e086..a5806f70f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -966,7 +966,7 @@ static void chickenarrow(DDukeActor* actor) // //--------------------------------------------------------------------------- -static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const vec3_t &oldpos) +static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &oldpos) { if (isRRRA()) { @@ -977,7 +977,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const vec3_t &ol S_PlayActorSound(RPG_EXPLODE, proj); auto spawned = spawn(proj, EXPLOSION2); if (spawned) - spawned->set_int_pos( oldpos); + spawned->spr.pos = oldpos; return true; } } @@ -1040,7 +1040,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const vec3_t &ol // //--------------------------------------------------------------------------- -static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) +static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3& oldpos) { if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA) { @@ -1059,7 +1059,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) } else { - SetActor(proj, &oldpos); + SetActor(proj, oldpos); fi.checkhitwall(proj, wal, proj->int_pos().X, proj->int_pos().Y, proj->int_pos().Z, proj->spr.picnum); if (!isRRRA() && proj->spr.picnum == FREEZEBLAST) @@ -1124,9 +1124,9 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) // //--------------------------------------------------------------------------- -bool weaponhitsector(DDukeActor *proj, const vec3_t& oldpos) +bool weaponhitsector(DDukeActor *proj, const DVector3& oldpos) { - SetActor(proj, &oldpos); + SetActor(proj, oldpos); if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA) { @@ -1191,7 +1191,7 @@ static void weaponcommon_r(DDukeActor *proj) ll = proj->spr.zvel; } - auto oldpos = proj->int_pos(); + auto oldpos = proj->spr.pos; getglobalz(proj); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 1fea5f8db..beb7f0e06 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -44,7 +44,7 @@ void movetouchplate(DDukeActor* i, int plate); void movecanwithsomething(DDukeActor* i); void bounce(DDukeActor* i); void movetongue(DDukeActor* i, int tongue, int jaw); -void rpgexplode(DDukeActor* i, int j, const vec3_t& pos, int EXPLOSION2, int EXPLOSIONBOT2, int newextra, int playsound); +void rpgexplode(DDukeActor* i, int j, const DVector3& pos, int EXPLOSION2, int EXPLOSIONBOT2, int newextra, int playsound); void moveooz(DDukeActor* i, int seenine, int seeninedead, int ooz, int explosion); void lotsofstuff(DDukeActor* s, int n, int spawntype); bool respawnmarker(DDukeActor* i, int yellow, int green); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index d6df9d30e..50fbcf5e1 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -874,9 +874,7 @@ void AIPlayer::Tick(RunListEvent* ev) { pPlayerActor->add_int_pos({ (x >> 14), (y >> 14), 0 }); - vec3_t pos = pPlayerActor->int_pos(); - SetActor(pPlayerActor, &pos); - + SetActor(pPlayerActor, pPlayerActor->spr.pos); pPlayerActor->spr.pos.Z = pPlayerActor->sector()->floorz; } else diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 3b304ab1e..9adc37709 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -584,7 +584,7 @@ int AutoBreakWall(walltype* wallp, int hit_x, int hit_y, int hit_z, int ang, int if (hit_x != INT32_MAX) { - vec3_t hit_pos = { hit_x, hit_y, hit_z }; + DVector3 hit_pos( hit_x * inttoworld, hit_y * inttoworld, hit_z * zinttoworld); // need correct location for spawning shrap auto breakActor = insertActor(0, STAT_DEFAULT); breakActor->spr.cstat = 0; @@ -592,7 +592,7 @@ int AutoBreakWall(walltype* wallp, int hit_x, int hit_y, int hit_z, int ang, int breakActor->set_int_ang(ang); breakActor->spr.picnum = ST1; breakActor->spr.xrepeat = breakActor->spr.yrepeat = 64; - SetActorZ(breakActor, &hit_pos); + SetActorZ(breakActor, hit_pos); SpawnShrap(breakActor, nullptr, -1, break_info); KillActor(breakActor); } diff --git a/source/games/sw/src/skel.cpp b/source/games/sw/src/skel.cpp index c3c0170f1..47f38c21c 100644 --- a/source/games/sw/src/skel.cpp +++ b/source/games/sw/src/skel.cpp @@ -534,28 +534,23 @@ int DoSkelInitTeleport(DSWActor* actor) int DoSkelTeleport(DSWActor* actor) { - int x,y; - - auto pos = actor->int_pos(); - x = pos.X; - y = pos.Y; + auto pos = actor->spr.pos; while (true) { - pos.X = x; - pos.Y = y; + pos.XY() = actor->spr.pos.XY(); if (RANDOM_P2(1024) < 512) - pos.X += 512 + RANDOM_P2(1024); + pos.X += 32 + RANDOM_P2F(64, 4); else - pos.X -= 512 + RANDOM_P2(1024); + pos.X -= 32 + RANDOM_P2F(64, 4); if (RANDOM_P2(1024) < 512) - pos.Y += 512 + RANDOM_P2(1024); + pos.Y += 32 + RANDOM_P2F(64, 4); else - pos.Y -= 512 + RANDOM_P2(1024); + pos.Y -= 32 + RANDOM_P2F(64, 4); - SetActorZ(actor, &pos); + SetActorZ(actor, pos); if (actor->insector()) break;