diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 6ab38eca0..2088b3a50 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -3,6 +3,7 @@ #include #include "build.h" #include "iterators.h" +#include "serializer.h" class DCoreActor { @@ -65,6 +66,14 @@ enum EHitBits }; +inline FSerializer& Serialize(FSerializer& arc, const char* keyname, DCoreActor*& w, DCoreActor** def) +{ + int index = w ? w->GetSpriteIndex() : -1; + Serialize(arc, keyname, index, nullptr); + if (arc.isReading()) w = index == -1 ? nullptr : actorArray[index]; + return arc; +} + // This serves as input/output for all functions dealing with collisions, hits, etc. // Not all utilities use all variables. struct HitInfoBase @@ -139,6 +148,13 @@ struct HitInfoBase else setNone(); return type; } + + void clearObj() + { + hitSector = nullptr; + hitWall = nullptr; + hitActor = nullptr; + } }; @@ -261,6 +277,7 @@ inline int hitscan(int x, int y, int z, int sectnum, int vx, int vy, int vz, inline int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& direction, HitInfoBase& hitinfo, unsigned cliptype) { hitdata_t hd{}; + hd.pos.z = hitinfo.hitpos.z; // this can pass through unaltered. int res = hitscan_(&start, sector.IndexOf(startsect), direction.x, direction.y, direction.z, &hd, cliptype); hitinfo.hitpos = hd.pos; hitinfo.hitSector = hd.sect == -1? nullptr : §or[hd.sect]; diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 55dbbc2e4..1362afb7e 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -35,7 +35,7 @@ int cameradist, cameraclock; bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** psect, binangle ang, fixedhoriz horiz, double const smoothratio) { - hitdata_t hitinfo; + HitInfoBase hitinfo; binangle daang; short bakcstat; int newdist; @@ -46,15 +46,14 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p int ny = gi->chaseCamY(ang); int nz = gi->chaseCamZ(horiz); - vec3_t pvect = { *px, *py, *pz }; bakcstat = pspr->cstat; pspr->cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); updatesectorz(*px, *py, *pz, psect); - hitscan(&pvect, sectnum(*psect), nx, ny, nz, &hitinfo, CLIPMASK1); + hitscan({ *px, *py, *pz }, *psect, { nx, ny, nz }, hitinfo, CLIPMASK1); pspr->cstat = bakcstat; - int hx = hitinfo.pos.x - *px; - int hy = hitinfo.pos.y - *py; + int hx = hitinfo.hitpos.x - *px; + int hy = hitinfo.hitpos.y - *py; if (*psect == nullptr) { @@ -64,12 +63,12 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p // If something is in the way, make pp->camera_dist lower if necessary if (abs(nx) + abs(ny) > abs(hx) + abs(hy)) { - if (hitinfo.wall >= 0) + if (hitinfo.hitWall != nullptr) { // Push you a little bit off the wall - *psect = §or[hitinfo.sect]; - daang = bvectangbam(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x, - wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y); + *psect = hitinfo.hitSector; + daang = bvectangbam(hitinfo.hitWall->point2Wall()->x - hitinfo.hitWall->x, + hitinfo.hitWall->point2Wall()->y - hitinfo.hitWall->y); newdist = nx * daang.bsin() + ny * -daang.bcos(); if (abs(nx) > abs(ny)) @@ -77,10 +76,10 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p else hy -= MulScale(ny, newdist, 28); } - else if (hitinfo.sprite < 0) + else if (hitinfo.hitActor == nullptr) { // Push you off the ceiling/floor - *psect = §or[hitinfo.sect]; + *psect = hitinfo.hitSector; if (abs(nx) > abs(ny)) hx -= (nx >> 5); @@ -90,7 +89,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, sectortype** p else { // If you hit a sprite that's not a wall sprite - try again. - spritetype* hspr = &sprite[hitinfo.sprite]; + spritetype* hspr = &hitinfo.hitActor->s(); if (!(hspr->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) { diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index f7c6f6a47..a3bc5cbaf 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3835,7 +3835,7 @@ int actDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE damageT // //--------------------------------------------------------------------------- -void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype** ppWall) +void actHitcodeToData(int a1, HitInfo* pHitInfo, DBloodActor** pActor, walltype** ppWall) { assert(pHitInfo != nullptr); DBloodActor* actor = nullptr; @@ -3844,7 +3844,7 @@ void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype* { case 3: case 5: - actor = pHitInfo->hitactor; + actor = pHitInfo->actor(); break; case 0: case 4: @@ -4870,8 +4870,8 @@ void MoveDude(DBloodActor* actor) if (pHitSprite->statnum == kStatProjectile && !(pHitSprite->flags & 32) && actor != Owner) { - HITINFO hitInfo = gHitInfo; - gHitInfo.hitactor = actor; + auto hitInfo = gHitInfo; + gHitInfo.hitActor = actor; actImpactMissile(coll.actor, 3); gHitInfo = hitInfo; } @@ -5358,7 +5358,7 @@ int MoveMissile(DBloodActor* actor) } if (clipmoveresult.type == kHitSprite) { - gHitInfo.hitactor = clipmoveresult.actor; + gHitInfo.hitActor = clipmoveresult.actor; cliptype = 3; } else if (clipmoveresult.type == kHitWall) @@ -5430,10 +5430,10 @@ int MoveMissile(DBloodActor* actor) ChangeActorSect(actor, pSector); } CheckLink(actor); - gHitInfo.hitSect = pSprite->sector(); - gHitInfo.hitx = pSprite->x; - gHitInfo.hity = pSprite->y; - gHitInfo.hitz = pSprite->z; + gHitInfo.hitSector = pSprite->sector(); + gHitInfo.hitpos.x = pSprite->x; + gHitInfo.hitpos.y = pSprite->y; + gHitInfo.hitpos.z = pSprite->z; break; } if (pOwner) pOwner->cstat = bakCstat; @@ -6548,8 +6548,8 @@ DBloodActor* actFireThing(DBloodActor* actor, int a2, int a3, int a4, int thingT y += MulScale(pSprite->clipdist, Sin(pSprite->ang), 28); if (HitScan(actor, z, x - pSprite->x, y - pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1) { - x = gHitInfo.hitx - MulScale(pSprite->clipdist << 1, Cos(pSprite->ang), 28); - y = gHitInfo.hity - MulScale(pSprite->clipdist << 1, Sin(pSprite->ang), 28); + x = gHitInfo.hitpos.x - MulScale(pSprite->clipdist << 1, Cos(pSprite->ang), 28); + y = gHitInfo.hitpos.y - MulScale(pSprite->clipdist << 1, Sin(pSprite->ang), 28); } auto fired = actSpawnThing(pSprite->sector(), x, y, z, thingType); spritetype* pThing = &fired->s(); @@ -6668,13 +6668,13 @@ DBloodActor* actFireMissile(DBloodActor* actor, int a2, int a3, int a4, int a5, if (hit == 3 || hit == 0) { impact = true; - x = gHitInfo.hitx - MulScale(Cos(pSprite->ang), 16, 30); - y = gHitInfo.hity - MulScale(Sin(pSprite->ang), 16, 30); + x = gHitInfo.hitpos.x - MulScale(Cos(pSprite->ang), 16, 30); + y = gHitInfo.hitpos.y - MulScale(Sin(pSprite->ang), 16, 30); } else { - x = gHitInfo.hitx - MulScale(pMissileInfo->clipDist << 1, Cos(pSprite->ang), 28); - y = gHitInfo.hity - MulScale(pMissileInfo->clipDist << 1, Sin(pSprite->ang), 28); + x = gHitInfo.hitpos.x - MulScale(pMissileInfo->clipDist << 1, Cos(pSprite->ang), 28); + y = gHitInfo.hitpos.y - MulScale(pMissileInfo->clipDist << 1, Sin(pSprite->ang), 28); } } auto spawned = actSpawnSprite(pSprite->sector(), x, y, z, 5, 1); @@ -6841,7 +6841,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, int hit = VectorScan(shooter, a2, a3, a4, a5, a6, nRange, 1); if (hit == 3) { - auto hitactor = gHitInfo.hitactor; + auto hitactor = gHitInfo.actor(); assert(hitactor != nullptr); spritetype* pSprite = &hitactor->s(); if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pShooter, pSprite)) return; @@ -6850,19 +6850,19 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, PLAYER* pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; if (powerupCheck(pPlayer, kPwUpReflectShots)) { - gHitInfo.hitactor = shooter; - gHitInfo.hitx = pShooter->x; - gHitInfo.hity = pShooter->y; - gHitInfo.hitz = pShooter->z; + gHitInfo.hitActor = shooter; + gHitInfo.hitpos.x = pShooter->x; + gHitInfo.hitpos.y = pShooter->y; + gHitInfo.hitpos.z = pShooter->z; } } } - int x = gHitInfo.hitx - MulScale(a4, 16, 14); - int y = gHitInfo.hity - MulScale(a5, 16, 14); - int z = gHitInfo.hitz - MulScale(a6, 256, 14); - auto pSector = gHitInfo.hitSect; + int x = gHitInfo.hitpos.x - MulScale(a4, 16, 14); + int y = gHitInfo.hitpos.y - MulScale(a5, 16, 14); + int z = gHitInfo.hitpos.z - MulScale(a6, 256, 14); + auto pSector = gHitInfo.hitSector; uint8_t nSurf = kSurfNone; - if (nRange == 0 || approxDist(gHitInfo.hitx - pShooter->x, gHitInfo.hity - pShooter->y) < nRange) + if (nRange == 0 || approxDist(gHitInfo.hitpos.x - pShooter->x, gHitInfo.hitpos.y - pShooter->y) < nRange) { switch (hit) { @@ -6888,9 +6888,9 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, nSurf = surfType[pWall->picnum]; if (actCanSplatWall(pWall)) { - int x = gHitInfo.hitx - MulScale(a4, 16, 14); - int y = gHitInfo.hity - MulScale(a5, 16, 14); - int z = gHitInfo.hitz - MulScale(a6, 256, 14); + int x = gHitInfo.hitpos.x - MulScale(a4, 16, 14); + int y = gHitInfo.hitpos.y - MulScale(a5, 16, 14); + int z = gHitInfo.hitpos.z - MulScale(a6, 256, 14); int nSurf = surfType[pWall->picnum]; assert(nSurf < kSurfMax); if (pVectorData->surfHit[nSurf].fx1 >= 0) @@ -6918,7 +6918,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, } case 3: { - auto actor = gHitInfo.hitactor; + auto actor = gHitInfo.actor(); spritetype* pSprite = &actor->s(); nSurf = surfType[pSprite->picnum]; x -= MulScale(a4, 112, 14); @@ -6981,17 +6981,17 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, a4 += Random3(4000); a5 += Random3(4000); a6 += Random3(4000); - if (HitScan(actor, gHitInfo.hitz, a4, a5, a6, CLIPMASK1, t) == 0) + if (HitScan(actor, gHitInfo.hitpos.z, a4, a5, a6, CLIPMASK1, t) == 0) { - if (approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) <= t) + if (approxDist(gHitInfo.hitpos.x - pSprite->x, gHitInfo.hitpos.y - pSprite->y) <= t) { auto pWall = gHitInfo.hitWall; - auto pSector = gHitInfo.hitSect; + auto pSector = gHitInfo.hitSector; if (actCanSplatWall(pWall)) { - int x = gHitInfo.hitx - MulScale(a4, 16, 14); - int y = gHitInfo.hity - MulScale(a5, 16, 14); - int z = gHitInfo.hitz - MulScale(a6, 16 << 4, 14); + int x = gHitInfo.hitpos.x - MulScale(a4, 16, 14); + int y = gHitInfo.hitpos.y - MulScale(a5, 16, 14); + int z = gHitInfo.hitpos.z - MulScale(a6, 16 << 4, 14); int nSurf = surfType[pWall->picnum]; const VECTORDATA* pVectorData = &gVectorData[19]; FX_ID t2 = pVectorData->surfHit[nSurf].fx2; @@ -7328,16 +7328,4 @@ void SerializeActor(FSerializer& arc) } } -// dumping ground for temporary wrappers. - -void HITINFO::set(hitdata_t* hit) -{ - hitSect = validSectorIndex(hit->sect)? §or[hit->sect] : nullptr; - hitWall = validWallIndex(hit->wall)? &wall[hit->wall] : nullptr; - hitactor = hit->sprite >= 0 ? &bloodActors[hit->sprite] : nullptr; - hitx = hit->pos.x; - hity = hit->pos.y; - hitz = hit->pos.z; -} - END_BLD_NS diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index 46dc5cc4a..f7bdde833 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS class DBloodActor; +struct HitInfo; enum DAMAGE_TYPE { kDamageFall = 0, @@ -219,7 +220,7 @@ DBloodActor *actDropObject(DBloodActor *pSprite, int nType); bool actHealDude(DBloodActor* pXDude, int a2, int a3); void actKillDude(DBloodActor* a1, DBloodActor* pSprite, DAMAGE_TYPE a3, int a4); int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage); -void actHitcodeToData(int a1, HITINFO *pHitInfo, DBloodActor **actor, walltype **a7 = nullptr); +void actHitcodeToData(int a1, HitInfo *pHitInfo, DBloodActor **actor, walltype **a7 = nullptr); void actAirDrag(DBloodActor *pSprite, int a2); void actExplodeSprite(DBloodActor *pSprite); void actActivateGibObject(DBloodActor *actor); diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index eb896006e..3153c33fa 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -139,10 +139,10 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange) int y = pSprite->y; int z = pSprite->z; HitScan(actor, z, bcos(nAngle), bsin(nAngle), 0, CLIPMASK0, nRange); - int nDist = approxDist(x - gHitInfo.hitx, y - gHitInfo.hity); + int nDist = approxDist(x - gHitInfo.hitpos.x, y - gHitInfo.hitpos.y); if (nDist - (pSprite->clipdist << 2) < nRange) { - if (gHitInfo.hitactor == nullptr || target == nullptr || target != gHitInfo.hitactor) + if (gHitInfo.hitActor == nullptr || target == nullptr || target != gHitInfo.hitActor) return false; return true; } diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index a1c2b98ff..6707e7f00 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -269,7 +269,7 @@ static void beastThinkChase(DBloodActor* actor) aiNewState(actor, &beastStomp); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) { if (!pXSector || !pXSector->Underwater) aiNewState(actor, &beastStomp); @@ -301,7 +301,7 @@ static void beastThinkChase(DBloodActor* actor) aiNewState(actor, &beastSlash); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) { if (pXSector && pXSector->Underwater) aiNewState(actor, &beastSwimSlash); diff --git a/source/games/blood/src/aicaleb.cpp b/source/games/blood/src/aicaleb.cpp index 167e4a2dc..c7d3ec8f0 100644 --- a/source/games/blood/src/aicaleb.cpp +++ b/source/games/blood/src/aicaleb.cpp @@ -176,7 +176,7 @@ static void calebThinkChase(DBloodActor* actor) aiNewState(actor, &tinycalebAttack); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) { if (pXSector && pXSector->Underwater) aiNewState(actor, &tinycalebSwimAttack); diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index 60f9b8575..dd86d83dc 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -424,7 +424,7 @@ static void cerberusThinkChase(DBloodActor* actor) aiNewState(actor, &cerberusBite); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeHellHound) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeHellHound) aiNewState(actor, &cerberusBite); break; case 0: @@ -441,7 +441,7 @@ static void cerberusThinkChase(DBloodActor* actor) aiNewState(actor, &cerberus2Bite); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeHellHound) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeHellHound) aiNewState(actor, &cerberus2Bite); break; case 0: diff --git a/source/games/blood/src/aicult.cpp b/source/games/blood/src/aicult.cpp index 189e46ae4..d0db6fb9f 100644 --- a/source/games/blood/src/aicult.cpp +++ b/source/games/blood/src/aicult.cpp @@ -307,7 +307,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultistTThrow); break; default: @@ -329,7 +329,7 @@ static void cultThinkChase(DBloodActor* actor) aiNewState(actor, &cultistTSwimFire); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun) { if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) aiNewState(actor, &cultistTFire); @@ -375,7 +375,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultistSThrow); break; default: @@ -397,7 +397,7 @@ static void cultThinkChase(DBloodActor* actor) aiNewState(actor, &cultistSSwimFire); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistTommy) { if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) aiNewState(actor, &cultistSFire); @@ -443,7 +443,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultistTsThrow); break; default: @@ -465,7 +465,7 @@ static void cultThinkChase(DBloodActor* actor) aiNewState(actor, &cultistTsSwimFire); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistTommy) { if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) aiNewState(actor, &cultistTsFire); @@ -509,7 +509,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultistDThrow); break; default: @@ -530,7 +530,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultist139A78); break; default: @@ -555,7 +555,7 @@ static void cultThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistShotgun && pXSprite->medium != kMediumWater && pXSprite->medium != kMediumGoo) aiNewState(actor, &cultistSThrow); break; default: @@ -577,7 +577,7 @@ static void cultThinkChase(DBloodActor* actor) aiNewState(actor, &cultistSSwimFire); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeCultistTommy) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeCultistTommy) { if (!dudeIsPlayingSeq(actor, 14) && pXSprite->medium == kMediumNormal) aiNewState(actor, &cultistSFire); diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index 508e5d4d3..31759ddfd 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -404,7 +404,7 @@ static void gargThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeGargoyleStone) { sfxPlay3DSound(actor, 1408, 0, 0); aiNewState(actor, &gargoyleFThrow); @@ -429,7 +429,7 @@ static void gargThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleStone) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeGargoyleStone) { sfxPlay3DSound(actor, 1406, 0, 0); aiNewState(actor, &gargoyleFSlash); @@ -463,7 +463,7 @@ static void gargThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeGargoyleFlesh) { sfxPlay3DSound(actor, 1457, 0, 0); aiNewState(actor, &gargoyleSBlast); @@ -487,7 +487,7 @@ static void gargThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudeGargoyleFlesh) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudeGargoyleFlesh) aiNewState(actor, &gargoyleFSlash); break; default: diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index b1f472098..509df4dc1 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -381,7 +381,7 @@ static void ghostThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudePhantasm) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudePhantasm) aiNewState(actor, &ghostBlast); break; default: @@ -401,7 +401,7 @@ static void ghostThinkChase(DBloodActor* actor) case 4: break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type && gHitInfo.hitactor->s().type != kDudePhantasm) + if (pSprite->type != gHitInfo.actor()->s().type && gHitInfo.actor()->s().type != kDudePhantasm) aiNewState(actor, &ghostSlash); break; default: diff --git a/source/games/blood/src/aigilbst.cpp b/source/games/blood/src/aigilbst.cpp index 887d4b546..b23d40071 100644 --- a/source/games/blood/src/aigilbst.cpp +++ b/source/games/blood/src/aigilbst.cpp @@ -165,7 +165,7 @@ static void gillThinkChase(DBloodActor* actor) aiNewState(actor, &gillBeastBite); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) { if (pXSector && pXSector->Underwater) aiNewState(actor, &gillBeastSwimBite); diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index 483c198e8..63a114536 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -74,7 +74,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor) if (IsPlayerSprite(pTarget)) { int hit = HitScan(actor, pSprite->z, dx, dy, 0, CLIPMASK1, 0); - if (hit == 3 && gHitInfo.hitactor->IsPlayerActor()) + if (hit == 3 && gHitInfo.actor()->IsPlayerActor()) { dz += pTarget->z - pSprite->z; PLAYER* pPlayer = &gPlayer[pTarget->type - kDudePlayer1]; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 310600a4c..3cb038ff5 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -146,8 +146,8 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int for (int i = -8191; i < 8192; i += by) { HitScan(actor, pSprite->z, bcos(pSprite->ang), bsin(pSprite->ang), i, clipMask, dist); - if (!fStart && actor->GetTarget() == gHitInfo.hitactor) fStart = i; - else if (fStart && actor->GetTarget() != gHitInfo.hitactor) + if (!fStart && actor->GetTarget() == gHitInfo.hitActor) fStart = i; + else if (fStart && actor->GetTarget() != gHitInfo.hitActor) { fEnd = i; break; @@ -776,10 +776,10 @@ static void unicultThinkChase(DBloodActor* actor) if (hit >= 0) { targetDist = dist - (pTarget->clipdist << 2); - objDist = approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y); + objDist = approxDist(gHitInfo.hitpos.x - pSprite->x, gHitInfo.hitpos.y - pSprite->y); } - if (actor != gHitInfo.hitactor && targetDist > objDist) + if (actor != gHitInfo.hitActor && targetDist > objDist) { DBloodActor* hitactor = nullptr; walltype* pHWall = NULL; @@ -793,7 +793,7 @@ static void unicultThinkChase(DBloodActor* actor) switch (hit) { case 3: - hitactor = gHitInfo.hitactor; + hitactor = gHitInfo.actor(); if (hitactor) { pHSprite = &hitactor->s(); @@ -889,12 +889,12 @@ static void unicultThinkChase(DBloodActor* actor) { if (genDudeAdjustSlope(actor, dist, weaponType)) break; VectorScan(actor, 0, 0, bcos(pSprite->ang), bsin(pSprite->ang), actor->dudeSlope, dist, 1); - if (actor == gHitInfo.hitactor) break; + if (actor == gHitInfo.hitActor) break; bool immune = nnExtIsImmune(hitactor, gVectorData[curWeapon].dmgType); if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked)) { - if ((approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) <= 1500 && !blck) + if ((approxDist(gHitInfo.hitpos.x - pSprite->x, gHitInfo.hitpos.y - pSprite->y) <= 1500 && !blck) || (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1)))) { //viewSetSystemMessage("GO CHASE"); @@ -950,7 +950,7 @@ static void unicultThinkChase(DBloodActor* actor) bool masked = (pHWall->cstat & CSTAT_WALL_MASKED); if (masked) VectorScan(actor, 0, 0, bcos(pSprite->ang), bsin(pSprite->ang), actor->dudeSlope, dist, 1); - if ((actor != gHitInfo.hitactor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) + if ((actor != gHitInfo.hitActor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) { if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW); else aiGenDudeNewState(actor, &genDudeChaseL); @@ -969,8 +969,8 @@ static void unicultThinkChase(DBloodActor* actor) case kMissileFireballTchernobog: { // allow attack if dude is far from object, but target is close to it - int dudeDist = approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y); - int targetDist = approxDist(gHitInfo.hitx - pTarget->x, gHitInfo.hity - pTarget->y); + int dudeDist = approxDist(gHitInfo.hitpos.x - pSprite->x, gHitInfo.hitpos.y - pSprite->y); + int targetDist = approxDist(gHitInfo.hitpos.x - pTarget->x, gHitInfo.hitpos.y - pTarget->y); if (dudeDist < mdist) { //viewSetSystemMessage("DUDE CLOSE TO OBJ: %d, MDIST: %d", dudeDist, mdist); diff --git a/source/games/blood/src/aizombf.cpp b/source/games/blood/src/aizombf.cpp index 1e5f304ee..289996b44 100644 --- a/source/games/blood/src/aizombf.cpp +++ b/source/games/blood/src/aizombf.cpp @@ -152,7 +152,7 @@ static void zombfThinkChase(DBloodActor* actor) aiNewState(actor, &zombieFThrow); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) aiNewState(actor, &zombieFThrow); else aiNewState(actor, &zombieFDodge); @@ -171,7 +171,7 @@ static void zombfThinkChase(DBloodActor* actor) aiNewState(actor, &zombieFPuke); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) aiNewState(actor, &zombieFPuke); else aiNewState(actor, &zombieFDodge); @@ -190,7 +190,7 @@ static void zombfThinkChase(DBloodActor* actor) aiNewState(actor, &zombieFHack); break; case 3: - if (pSprite->type != gHitInfo.hitactor->s().type) + if (pSprite->type != gHitInfo.actor()->s().type) aiNewState(actor, &zombieFHack); else aiNewState(actor, &zombieFDodge); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 7dc58d42a..86ebd8874 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -252,6 +252,9 @@ struct HitInfo : public HitInfoBase } }; +extern HitInfo gHitInfo; + + // Iterator wrappers that return an actor pointer, not an index. class BloodStatIterator : public StatIterator { diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index fc2ac23b1..4895cb7d6 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -HITINFO gHitInfo; +HitInfo gHitInfo; bool FindSector(int nX, int nY, int nZ, sectortype** pSector) { @@ -354,16 +354,11 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas { hitscangoal.x = hitscangoal.y = 0x1ffffff; } -// HitInfo hitData; -// hitscan({ x, y, z }, pSprite->sector(), { dx, dy, dz << 4 }, hitData, nMask); - vec3_t pos = { x, y, z }; - hitdata_t hitData; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, pSprite->sectnum, dx, dy, dz << 4, &hitData, nMask); - gHitInfo.set(&hitData); + hitscan({ x, y, z }, pSprite->sector(), { dx, dy, dz << 4 }, gHitInfo, nMask); + hitscangoal.x = hitscangoal.y = 0x1ffffff; pSprite->cstat = bakCstat; - if (gHitInfo.hitactor != nullptr) + if (gHitInfo.hitActor != nullptr) return 3; if (gHitInfo.hitWall != nullptr) { @@ -372,13 +367,13 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas if (!pWall->twoSided()) return 0; int nZCeil, nZFloor; - getzsofslopeptr(pWall->nextSector(), gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor); - if (gHitInfo.hitz <= nZCeil || gHitInfo.hitz >= nZFloor) + getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.x, gHitInfo.hitpos.y, &nZCeil, &nZFloor); + if (gHitInfo.hitpos.z <= nZCeil || gHitInfo.hitpos.z >= nZFloor) return 0; return 4; } - if (gHitInfo.hitSect != nullptr) - return 1 + (z < gHitInfo.hitz); + if (gHitInfo.hitSector != nullptr) + return 1 + (z < gHitInfo.hitpos.z); return -1; } @@ -405,19 +400,17 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in hitscangoal.x = hitscangoal.y = 0x1fffffff; } vec3_t pos = { x1, y1, z1 }; - hitdata_t hitData; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, pSprite->sectnum, dx, dy, dz << 4, &hitData, CLIPMASK1); - gHitInfo.set(&hitData); + hitscan(pos, pSprite->sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + hitscangoal.x = hitscangoal.y = 0x1ffffff; pSprite->cstat = bakCstat; while (nNum--) { - if (nRange && approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) > nRange) + if (nRange && approxDist(gHitInfo.hitpos.x - pSprite->x, gHitInfo.hitpos.y - pSprite->y) > nRange) return -1; - if (gHitInfo.hitactor != nullptr) + if (gHitInfo.actor() != nullptr) { - spritetype *pOther = &gHitInfo.hitactor->s(); + spritetype *pOther = &gHitInfo.actor()->s(); if ((pOther->flags & 8) && !(ac & 1)) return 3; if ((pOther->cstat & 0x30) != 0) @@ -433,7 +426,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in if (nOffset) otherZ -= (nOffset*pOther->yrepeat)<<2; assert(height > 0); - int height2 = scale(otherZ-gHitInfo.hitz, tileHeight(nPicnum), height); + int height2 = scale(otherZ-gHitInfo.hitpos.z, tileHeight(nPicnum), height); if (!(pOther->cstat & 8)) height2 = tileHeight(nPicnum)-height2; if (height2 >= 0 && height2 < tileHeight(nPicnum)) @@ -455,13 +448,8 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in int bakCstat = pOther->cstat; pOther->cstat &= ~256; gHitInfo.clearObj(); - x1 = gHitInfo.hitx; - y1 = gHitInfo.hity; - z1 = gHitInfo.hitz; - pos = { x1, y1, z1 }; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, pOther->sectnum, dx, dy, dz << 4, &hitData, CLIPMASK1); - gHitInfo.set(&hitData); + pos = gHitInfo.hitpos; // must make a copy! + hitscan(pos, pOther->sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); pOther->cstat = bakCstat; continue; } @@ -470,13 +458,13 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in walltype *pWall = gHitInfo.hitWall; if (!pWall->twoSided()) return 0; - sectortype *pSector = gHitInfo.hitSect; + sectortype *pSector = gHitInfo.hitSector; sectortype *pSectorNext = pWall->nextSector(); int nZCeil, nZFloor; - getzsofslopeptr(pWall->nextSector(), gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor); - if (gHitInfo.hitz <= nZCeil) + getzsofslopeptr(pWall->nextSector(), gHitInfo.hitpos.x, gHitInfo.hitpos.y, &nZCeil, &nZFloor); + if (gHitInfo.hitpos.z <= nZCeil) return 0; - if (gHitInfo.hitz >= nZFloor) + if (gHitInfo.hitpos.z >= nZFloor) { if (!(pSector->floorstat&1) || !(pSectorNext->floorstat&1)) return 0; @@ -489,7 +477,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in nOffset = ClipHigh(pSector->floorz, pSectorNext->floorz); else nOffset = ClipLow(pSector->ceilingz, pSectorNext->ceilingz); - nOffset = (gHitInfo.hitz - nOffset) >> 8; + nOffset = (gHitInfo.hitpos.z - nOffset) >> 8; if (pWall->cstat & 256) nOffset = -nOffset; @@ -504,9 +492,9 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in int nLength = approxDist(pWall->x - pWall->point2Wall()->x, pWall->y - pWall->point2Wall()->y); int nHOffset; if (pWall->cstat & 8) - nHOffset = approxDist(gHitInfo.hitx - pWall->point2Wall()->x, gHitInfo.hity - pWall->point2Wall()->y); + nHOffset = approxDist(gHitInfo.hitpos.x - pWall->point2Wall()->x, gHitInfo.hitpos.y - pWall->point2Wall()->y); else - nHOffset = approxDist(gHitInfo.hitx - pWall->x, gHitInfo.hity - pWall->y); + nHOffset = approxDist(gHitInfo.hitpos.x - pWall->x, gHitInfo.hitpos.y - pWall->y); nHOffset = pWall->xpan() + ((nHOffset*pWall->xrepeat) << 3) / nLength; nHOffset %= nSizX; @@ -522,50 +510,42 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in int bakCstat2 = pWall->nextWall()->cstat; pWall->nextWall()->cstat &= ~64; gHitInfo.clearObj(); - x1 = gHitInfo.hitx; - y1 = gHitInfo.hity; - z1 = gHitInfo.hitz; - pos = { x1, y1, z1 }; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, pWall->nextsector, - dx, dy, dz << 4, &hitData, CLIPMASK1); - gHitInfo.set(&hitData); + pos = gHitInfo.hitpos; + hitscan(pos, pWall->nextSector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + pWall->cstat = bakCstat; pWall->nextWall()->cstat = bakCstat2; continue; } return 4; } - if (gHitInfo.hitSect != nullptr) + if (gHitInfo.hitSector != nullptr) { if (dz > 0) { - auto actor = gHitInfo.hitSect->upperLink; + auto actor = gHitInfo.hitSector->upperLink; if (!actor) return 2; auto link = actor->GetOwner(); gHitInfo.clearObj(); - x1 = gHitInfo.hitx + link->s().x - actor->s().x; - y1 = gHitInfo.hity + link->s().y - actor->s().y; - z1 = gHitInfo.hitz + link->s().z - actor->s().z; + x1 = gHitInfo.hitpos.x + link->s().x - actor->s().x; + y1 = gHitInfo.hitpos.y + link->s().y - actor->s().y; + z1 = gHitInfo.hitpos.z + link->s().z - actor->s().z; pos = { x1, y1, z1 }; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, link->s().sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1); - gHitInfo.set(&hitData); + hitscan(pos, link->s().sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); + continue; } else { - auto actor = gHitInfo.hitSect->lowerLink; + auto actor = gHitInfo.hitSector->lowerLink; if (!actor) return 1; auto link = actor->GetOwner(); gHitInfo.clearObj(); - x1 = gHitInfo.hitx + link->s().x - actor->s().x; - y1 = gHitInfo.hity + link->s().y - actor->s().y; - z1 = gHitInfo.hitz + link->s().z - actor->s().z; + x1 = gHitInfo.hitpos.x + link->s().x - actor->s().x; + y1 = gHitInfo.hitpos.y + link->s().y - actor->s().y; + z1 = gHitInfo.hitpos.z + link->s().z - actor->s().z; pos = { x1, y1, z1 }; - hitData.pos.z = gHitInfo.hitz; - hitscan(&pos, link->s().sectnum, dx, dy, dz<<4, &hitData, CLIPMASK1); - gHitInfo.set(&hitData); + hitscan(pos, link->s().sector(), { dx, dy, dz << 4 }, gHitInfo, CLIPMASK1); continue; } } diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index 679422c5d..bd0466043 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -26,25 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -struct HITINFO { - DBloodActor* hitactor; - sectortype* hitSect; - walltype* hitWall; - int hitx; - int hity; - int hitz; - - void clearObj() - { - hitSect = nullptr; - hitWall = nullptr; - hitactor = nullptr; - } - void set(hitdata_t* hit); -}; - -extern HITINFO gHitInfo; - enum { PARALLAXCLIP_CEILING = 1, PARALLAXCLIP_FLOOR = 2, diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index 6d032cffa..bc618e97c 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -642,16 +642,16 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XSPRITE& w, XSPRIT return arc; } -FSerializer& Serialize(FSerializer& arc, const char* keyname, HITINFO& w, HITINFO* def) +FSerializer& Serialize(FSerializer& arc, const char* keyname, HitInfo& w, HitInfo* def) { if (arc.BeginObject(keyname)) { - arc("sect", w.hitSect) - ("sprite", w.hitactor) + arc("sect", w.hitSector) + ("sprite", w.hitActor) ("wall", w.hitWall) - ("x", w.hitx) - ("y", w.hity) - ("z", w.hitz) + ("x", w.hitpos.x) + ("y", w.hitpos.y) + ("z", w.hitpos.z) .EndObject(); } return arc; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index cd26155c3..cf01ee880 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1280,14 +1280,12 @@ void nnExtProcessSuperSprites() HitScan(pPlayer->actor, pPlayer->zWeapon, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, CLIPMASK0 | CLIPMASK1, 0); - //VectorScan(pPlayer->actor, 0, pPlayer->zWeapon, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, 0, 1); - if (!vector) pSightSpr->cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; - if (gHitInfo.hitactor == gSightSpritesList[i]) + if (gHitInfo.hitActor == gSightSpritesList[i]) { - trTriggerSprite(gHitInfo.hitactor, kCmdSpriteSight); + trTriggerSprite(gHitInfo.actor(), kCmdSpriteSight); break; } } @@ -4493,8 +4491,8 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH) switch (var) { case 0: case 4: condPush(aCond, gHitInfo.hitWall); break; - case 1: case 2: condPush(aCond, gHitInfo.hitSect); break; - case 3: condPush(aCond, gHitInfo.hitactor); break; + case 1: case 2: condPush(aCond, gHitInfo.hitSector); break; + case 3: condPush(aCond, gHitInfo.actor()); break; } } @@ -7498,9 +7496,9 @@ bool nnExtCanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRang int x = pSprite->x, y = pSprite->y, z = pSprite->z; auto pSector = pSprite->sector(); HitScan(actor, z, Cos(nAngle) >> 16, Sin(nAngle) >> 16, 0, CLIPMASK0, nRange); - int nDist = approxDist(x - gHitInfo.hitx, y - gHitInfo.hity); + int nDist = approxDist(x - gHitInfo.hitpos.x, y - gHitInfo.hitpos.y); if (target != nullptr && nDist - (pSprite->clipdist << 2) < nRange) - return (target == gHitInfo.hitactor); + return (target == gHitInfo.hitActor); x += MulScale(nRange, Cos(nAngle), 30); y += MulScale(nRange, Sin(nAngle), 30); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 50752b922..30daad311 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1236,7 +1236,7 @@ void CheckPickUp(PLAYER *pPlayer) } } -int ActionScan(PLAYER *pPlayer, HITINFO* out) +int ActionScan(PLAYER *pPlayer, HitInfo* out) { *out = {}; spritetype *pSprite = pPlayer->pSprite; @@ -1244,22 +1244,22 @@ int ActionScan(PLAYER *pPlayer, HITINFO* out) int y = bsin(pSprite->ang); int z = pPlayer->slope; int hit = HitScan(pPlayer->actor, pPlayer->zView, x, y, z, 0x10000040, 128); - int hitDist = approxDist(pSprite->x-gHitInfo.hitx, pSprite->y-gHitInfo.hity)>>4; + int hitDist = approxDist(pSprite->x-gHitInfo.hitpos.x, pSprite->y-gHitInfo.hitpos.y)>>4; if (hitDist < 64) { switch (hit) { case 3: { - if (!gHitInfo.hitactor || !gHitInfo.hitactor->hasX()) return -1; - out->hitactor = gHitInfo.hitactor; - spritetype* pSprite = &gHitInfo.hitactor->s(); - XSPRITE* pXSprite = &gHitInfo.hitactor->x(); + if (!gHitInfo.hitActor || !gHitInfo.actor()->hasX()) return -1; + out->hitActor = gHitInfo.actor(); + spritetype* pSprite = &gHitInfo.actor()->s(); + XSPRITE* pXSprite = &gHitInfo.actor()->x(); if (pSprite->statnum == kStatThing) { if (pSprite->type == kThingDroppedLifeLeech) { - if (gGameOptions.nGameType > 1 && findDroppedLeech(pPlayer, gHitInfo.hitactor)) + if (gGameOptions.nGameType > 1 && findDroppedLeech(pPlayer, gHitInfo.actor())) return -1; pXSprite->data4 = pPlayer->nPlayer; pXSprite->isTriggered = 0; @@ -1273,12 +1273,12 @@ int ActionScan(PLAYER *pPlayer, HITINFO* out) if (nMass) { int t2 = DivScale(0xccccc, nMass, 8); - gHitInfo.hitactor->xvel += MulScale(x, t2, 16); - gHitInfo.hitactor->yvel += MulScale(y, t2, 16); - gHitInfo.hitactor->zvel += MulScale(z, t2, 16); + gHitInfo.actor()->xvel += MulScale(x, t2, 16); + gHitInfo.actor()->yvel += MulScale(y, t2, 16); + gHitInfo.actor()->zvel += MulScale(z, t2, 16); } if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered) - trTriggerSprite(gHitInfo.hitactor, kCmdSpritePush); + trTriggerSprite(gHitInfo.actor(), kCmdSpritePush); } break; } @@ -1293,7 +1293,7 @@ int ActionScan(PLAYER *pPlayer, HITINFO* out) { auto sect = pWall->nextSector(); out->hitWall = nullptr; - out->hitSect = sect; + out->hitSector = sect; if (sect->hasX() && sect->xs().Wallpush) return 6; } @@ -1302,15 +1302,15 @@ int ActionScan(PLAYER *pPlayer, HITINFO* out) case 1: case 2: { - auto pSector = gHitInfo.hitSect; - out->hitSect = gHitInfo.hitSect; + auto pSector = gHitInfo.hitSector; + out->hitSector = gHitInfo.hitSector; if (pSector->hasX() && pSector->xs().Push) return 6; break; } } } - out->hitSect = pSprite->sector(); + out->hitSector = pSprite->sector(); if (pSprite->sector()->hasX() && pSprite->sector()->xs().Push) return 6; return -1; @@ -1501,14 +1501,14 @@ void ProcessInput(PLAYER *pPlayer) } if (pInput->actions & SB_OPEN) { - HITINFO result; + HitInfo result; int hit = ActionScan(pPlayer, &result); switch (hit) { case 6: { - auto pSector = result.hitSect; + auto pSector = result.hitSector; auto pXSector = &pSector->xs(); int key = pXSector->Key; if (pXSector->locked && pPlayer == gMe) @@ -1558,7 +1558,7 @@ void ProcessInput(PLAYER *pPlayer) } case 3: { - auto act = result.hitactor; + auto act = result.actor(); XSPRITE *pXSprite = &act->x(); int key = pXSprite->key; if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg) diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index cdcd6a76c..8be7448a8 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -119,9 +119,9 @@ void viewDrawAimedPlayerName(void) int hit = HitScan(gView->actor, gView->zView, gView->aim.dx, gView->aim.dy, gView->aim.dz, CLIPMASK0, 512); if (hit == 3) { - if (gHitInfo.hitactor && gHitInfo.hitactor->IsPlayerActor()) + if (gHitInfo.actor() && gHitInfo.actor()->IsPlayerActor()) { - spritetype* pSprite = &gHitInfo.hitactor->s(); + spritetype* pSprite = &gHitInfo.actor()->s(); int nPlayer = pSprite->type-kDudePlayer1; const char* szName = PlayerName(nPlayer); int nPalette = (gPlayer[nPlayer].teamId&3)+11;