- converted gHitInfo.hitwall to a pointer.

This commit is contained in:
Christoph Oelckers 2021-11-23 17:00:00 +01:00
parent 2f6bd64746
commit d5e660a40c
9 changed files with 61 additions and 67 deletions

View file

@ -3850,8 +3850,7 @@ void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype*
break;
case 0:
case 4:
nWall = pHitInfo->hitwall;
if (validWallIndex(nWall)) pWall = &wall[nWall];
pWall = pHitInfo->hitWall;
break;
default:
break;
@ -5367,8 +5366,8 @@ int MoveMissile(DBloodActor* actor)
}
else if (clipmoveresult.type == kHitWall)
{
gHitInfo.hitwall = clipmoveresult.index;
if (clipmoveresult.wall()->nextsector == -1) cliptype = 0;
gHitInfo.hitWall = clipmoveresult.wall();
if (!gHitInfo.hitWall->twoSided()) cliptype = 0;
else
{
int32_t fz, cz;
@ -5434,7 +5433,7 @@ int MoveMissile(DBloodActor* actor)
ChangeActorSect(actor, nSector);
}
CheckLink(actor);
gHitInfo.hitsect = pSprite->sectnum;
gHitInfo.hitSect = pSprite->sector();
gHitInfo.hitx = pSprite->x;
gHitInfo.hity = pSprite->y;
gHitInfo.hitz = pSprite->z;
@ -6864,7 +6863,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
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 nSector = gHitInfo.hitsect;
auto pSector = gHitInfo.hitSect;
uint8_t nSurf = kSurfNone;
if (nRange == 0 || approxDist(gHitInfo.hitx - pShooter->x, gHitInfo.hity - pShooter->y) < nRange)
{
@ -6872,27 +6871,23 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
{
case 1:
{
int nSector = gHitInfo.hitsect;
if (sector[nSector].ceilingstat & 1)
if (pSector->ceilingstat & 1)
nSurf = kSurfNone;
else
nSurf = surfType[sector[nSector].ceilingpicnum];
nSurf = surfType[pSector->ceilingpicnum];
break;
}
case 2:
{
int nSector = gHitInfo.hitsect;
if (sector[nSector].floorstat & 1)
if (pSector->floorstat & 1)
nSurf = kSurfNone;
else
nSurf = surfType[sector[nSector].floorpicnum];
nSurf = surfType[pSector->floorpicnum];
break;
}
case 0:
{
int nWall = gHitInfo.hitwall;
assert(validWallIndex(nWall));
auto pWall = &wall[nWall];
auto pWall = gHitInfo.hitWall;
nSurf = surfType[pWall->picnum];
if (actCanSplatWall(pWall))
{
@ -6903,7 +6898,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
assert(nSurf < kSurfMax);
if (pVectorData->surfHit[nSurf].fx1 >= 0)
{
auto pFX = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx1, nSector, x, y, z, 0);
auto pFX = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx1, pSector, x, y, z, 0);
if (pFX)
{
pFX->s().ang = (GetWallAngle(pWall) + 512) & 2047;
@ -6915,9 +6910,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
}
case 4:
{
int nWall = gHitInfo.hitwall;
assert(validWallIndex(nWall));
auto pWall = &wall[nWall];
auto pWall = gHitInfo.hitWall;
nSurf = surfType[pWall->overpicnum];
if (pWall->hasX())
{
@ -6995,25 +6988,25 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
{
if (approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) <= t)
{
int nWall = gHitInfo.hitwall;
int nSector = gHitInfo.hitsect;
if (actCanSplatWall(&wall[nWall]))
auto pWall = gHitInfo.hitWall;
auto pSector = gHitInfo.hitSect;
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 nSurf = surfType[wall[nWall].picnum];
int nSurf = surfType[pWall->picnum];
const VECTORDATA* pVectorData = &gVectorData[19];
FX_ID t2 = pVectorData->surfHit[nSurf].fx2;
FX_ID t3 = pVectorData->surfHit[nSurf].fx3;
DBloodActor* pFX = nullptr;
if (t2 > FX_NONE && (t3 == FX_NONE || Chance(0x4000))) pFX = gFX.fxSpawnActor(t2, nSector, x, y, z, 0);
else if (t3 > FX_NONE) pFX = gFX.fxSpawnActor(t3, nSector, x, y, z, 0);
if (t2 > FX_NONE && (t3 == FX_NONE || Chance(0x4000))) pFX = gFX.fxSpawnActor(t2, pSector, x, y, z, 0);
else if (t3 > FX_NONE) pFX = gFX.fxSpawnActor(t3, pSector, x, y, z, 0);
if (pFX)
{
pFX->zvel = 0x2222;
pFX->s().ang = (GetWallAngle(&wall[nWall]) + 512) & 2047;
pFX->s().ang = (GetWallAngle(pWall) + 512) & 2047;
pFX->s().cstat |= 16;
}
}
@ -7069,14 +7062,14 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
if (pVectorData->surfHit[nSurf].fx2 >= 0) {
auto pFX2 = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx2, nSector, x, y, z, 0);
auto pFX2 = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx2, pSector, x, y, z, 0);
if (pFX2 && gModernMap)
pFX2->SetOwner(shooter);
}
if (pVectorData->surfHit[nSurf].fx3 >= 0) {
auto pFX3 = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx3, nSector, x, y, z, 0);
auto pFX3 = gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx3, pSector, x, y, z, 0);
if (pFX3 && gModernMap)
pFX3->SetOwner(shooter);
@ -7084,13 +7077,13 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
#else
if (pVectorData->surfHit[nSurf].fx2 >= 0)
gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx2, nSector, x, y, z, 0);
gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx2, pSector, x, y, z, 0);
if (pVectorData->surfHit[nSurf].fx3 >= 0)
gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx3, nSector, x, y, z, 0);
gFX.fxSpawnActor(pVectorData->surfHit[nSurf].fx3, pSector, x, y, z, 0);
#endif
if (pVectorData->surfHit[nSurf].fxSnd >= 0)
sfxPlay3DSound(x, y, z, pVectorData->surfHit[nSurf].fxSnd, nSector);
sfxPlay3DSound(x, y, z, pVectorData->surfHit[nSurf].fxSnd, pSector);
}
//---------------------------------------------------------------------------
@ -7342,8 +7335,8 @@ void SerializeActor(FSerializer& arc)
void HITINFO::set(hitdata_t* hit)
{
hitsect = hit->sect;
hitwall = hit->wall;
hitSect = validSectorIndex(hit->sect)? &sector[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;

View file

@ -803,7 +803,7 @@ static void unicultThinkChase(DBloodActor* actor)
break;
case 0:
case 4:
pHWall = &wall[gHitInfo.hitwall];
pHWall = gHitInfo.hitWall;
if (pHWall->hasX()) pXHWall = &pHWall->xw();
hscn = (pHWall->cstat & CSTAT_WALL_BLOCK_HITSCAN); blck = (pHWall->cstat & CSTAT_WALL_BLOCK);
break;
@ -811,13 +811,8 @@ static void unicultThinkChase(DBloodActor* actor)
switch (hit) {
case 0:
//if (hit == 0) viewSetSystemMessage("WALL HIT %d", gHitInfo.hitwall);
[[fallthrough]];
case 1:
//if (hit == 1) viewSetSystemMessage("CEIL HIT %d", gHitInfo.hitsect);
[[fallthrough]];
case 2:
//if (hit == 2) viewSetSystemMessage("FLOOR HIT %d", gHitInfo.hitsect);
if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(actor, dist, weaponType)
&& dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break;
@ -955,7 +950,6 @@ 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);
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((actor != gHitInfo.hitactor) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked))
{
if (spriteIsUnderwater(actor)) aiGenDudeNewState(actor, &genDudeChaseW);

View file

@ -94,6 +94,10 @@ public:
void destroy(DBloodActor*);
void remove(DBloodActor*);
DBloodActor* fxSpawnActor(FX_ID, int, int, int, int, unsigned int);
DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f)
{
return fxSpawnActor(a, sectnum(b), c, d, e, f);
}
void fxProcess(void);
};

View file

@ -362,21 +362,21 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas
gHitInfo.set(&hitData);
hitscangoal.x = hitscangoal.y = 0x1ffffff;
pSprite->cstat = bakCstat;
if (gHitInfo.hitwall >= numwalls || gHitInfo.hitsect >= numsectors)
return -1;
if (gHitInfo.hitactor != nullptr)
return 3;
if (gHitInfo.hitwall >= 0)
if (gHitInfo.hitWall != nullptr)
{
if (wall[gHitInfo.hitwall].nextsector == -1)
auto pWall = gHitInfo.hitWall;
if (pWall->nextsector == -1)
return 0;
int nZCeil, nZFloor;
getzsofslope(wall[gHitInfo.hitwall].nextsector, gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor);
getzsofslopeptr(pWall->nextSector(), gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor);
if (gHitInfo.hitz <= nZCeil || gHitInfo.hitz >= nZFloor)
return 0;
return 4;
}
if (gHitInfo.hitsect >= 0)
if (gHitInfo.hitSect != nullptr)
return 1 + (z < gHitInfo.hitz);
return -1;
}
@ -413,8 +413,6 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
pSprite->cstat = bakCstat;
while (nNum--)
{
if (gHitInfo.hitwall >= numwalls || gHitInfo.hitsect >= numsectors)
return -1;
if (nRange && approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) > nRange)
return -1;
if (gHitInfo.hitactor != nullptr)
@ -467,15 +465,15 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
pOther->cstat = bakCstat;
continue;
}
if (gHitInfo.hitwall >= 0)
if (gHitInfo.hitWall != nullptr)
{
walltype *pWall = &wall[gHitInfo.hitwall];
if (pWall->nextsector == -1)
walltype *pWall = gHitInfo.hitWall;
if (!pWall->twoSided())
return 0;
sectortype *pSector = &sector[gHitInfo.hitsect];
sectortype *pSector = gHitInfo.hitSect;
sectortype *pSectorNext = pWall->nextSector();
int nZCeil, nZFloor;
getzsofslope(pWall->nextsector, gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor);
getzsofslopeptr(pWall->nextSector(), gHitInfo.hitx, gHitInfo.hity, &nZCeil, &nZFloor);
if (gHitInfo.hitz <= nZCeil)
return 0;
if (gHitInfo.hitz >= nZFloor)
@ -538,11 +536,11 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
}
return 4;
}
if (gHitInfo.hitsect >= 0)
if (gHitInfo.hitSect != nullptr)
{
if (dz > 0)
{
auto actor = getUpperLink(gHitInfo.hitsect);
auto actor = gHitInfo.hitSect->upperLink;
if (!actor) return 2;
auto link = actor->GetOwner();
gHitInfo.clearObj();
@ -557,7 +555,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
}
else
{
auto actor = getLowerLink(gHitInfo.hitsect);
auto actor = gHitInfo.hitSect->lowerLink;
if (!actor) return 1;
auto link = actor->GetOwner();
gHitInfo.clearObj();

View file

@ -28,15 +28,16 @@ BEGIN_BLD_NS
struct HITINFO {
DBloodActor* hitactor;
int hitsect;
int hitwall;
sectortype* hitSect;
walltype* hitWall;
int hitx;
int hity;
int hitz;
void clearObj()
{
hitsect = hitwall = -1;
hitSect = nullptr;
hitWall = nullptr;
hitactor = nullptr;
}
void set(hitdata_t* hit);

View file

@ -662,9 +662,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, HITINFO& w, HITINF
{
if (arc.BeginObject(keyname))
{
arc("sect", w.hitsect)
arc("sect", w.hitSect)
("sprite", w.hitactor)
("wall", w.hitwall)
("wall", w.hitWall)
("x", w.hitx)
("y", w.hity)
("z", w.hitz)

View file

@ -4541,8 +4541,8 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH)
if (!PUSH) return retn;
switch (var)
{
case 0: case 4: condPush(aCond, OBJ_WALL, gHitInfo.hitwall, nullptr); break;
case 1: case 2: condPush(aCond, OBJ_SECTOR, gHitInfo.hitsect, nullptr); break;
case 0: case 4: condPush(aCond, OBJ_WALL, wallnum(gHitInfo.hitWall), nullptr); break;
case 1: case 2: condPush(aCond, OBJ_SECTOR, sectnum(gHitInfo.hitSect), nullptr); break;
case 3: condPush(aCond, OBJ_SPRITE, 0, gHitInfo.hitactor); break;
}

View file

@ -1286,8 +1286,8 @@ int ActionScan(PLAYER *pPlayer, int *pIndex, DBloodActor** pAct)
case 0:
case 4:
{
auto pWall = &wall[gHitInfo.hitwall];
*pIndex = gHitInfo.hitwall;
auto pWall = gHitInfo.hitWall;
*pIndex = wallnum(gHitInfo.hitWall);
if (pWall->hasX() && pWall->xw().triggerPush)
return 0;
if (pWall->twoSided())
@ -1302,8 +1302,8 @@ int ActionScan(PLAYER *pPlayer, int *pIndex, DBloodActor** pAct)
case 1:
case 2:
{
auto pSector = &sector[gHitInfo.hitsect];
*pIndex = gHitInfo.hitsect;
auto pSector = gHitInfo.hitSect;
*pIndex = sectnum(gHitInfo.hitSect);
if (pSector->hasX() && pSector->xs().Push)
return 6;
break;

View file

@ -51,6 +51,10 @@ void sndTerm(void);
void sndInit(void);
void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector);
void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector)
{
sfxPlay3DSound(x, y, z, soundId, sectnum(pSector));
}
void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0);
void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0);
void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1);