- FAFhitscan migration to HITINFO.

This commit is contained in:
Christoph Oelckers 2021-11-04 00:23:05 +01:00
parent 63f9330f53
commit da1e97469e
10 changed files with 61 additions and 38 deletions

View file

@ -257,15 +257,12 @@ int CanHitPlayer(DSWActor* actor)
{
USERp u = actor->u();
SPRITEp sp = &actor->s();
hitdata_t hitinfo;
HITINFO hitinfo;
int xvect,yvect,zvect;
short ang;
// if actor can still see the player
int zhs, zhh;
//if (FAF_Sector(sp->sectnum))
// return(true);
zhs = sp->z - DIV2(SPRITEp_SIZE_Z(sp));
@ -302,7 +299,7 @@ int CanHitPlayer(DSWActor* actor)
if (hitinfo.sect < 0)
return false;
if (hitinfo.sprite == u->targetActor->GetSpriteIndex())
if (hitinfo.hitactor == u->targetActor)
return true;
return false;

View file

@ -1927,10 +1927,16 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i
bool PlayerCeilingHit(PLAYERp pp, int zlimit);
bool PlayerFloorHit(PLAYERp pp, int zlimit);
struct HITINFO;
void FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum,
int32_t xvect, int32_t yvect, int32_t zvect,
hitdata_t* hitinfo, int32_t clipmask);
void FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum,
int32_t xvect, int32_t yvect, int32_t zvect,
HITINFO* hitinfo, int32_t clipmask);
bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, int32_t xe, int32_t ye, int32_t ze, int16_t secte);
void FAFgetzrange(vec3_t pos, int16_t sectnum,

View file

@ -3431,7 +3431,7 @@ void DoPlayerClimb(PLAYERp pp)
int DoPlayerWadeSuperJump(PLAYERp pp)
{
hitdata_t hitinfo;
HITINFO hitinfo;
unsigned i;
//short angs[3];
static short angs[3] = {0, 0, 0};
@ -3735,7 +3735,7 @@ bool PlayerOnLadder(PLAYERp pp)
int dist, nx, ny;
unsigned i;
SPRITEp lsp;
hitdata_t hitinfo;
HITINFO hitinfo;
int dir;
int neartaghitdist;
@ -3778,12 +3778,13 @@ bool PlayerOnLadder(PLAYERp pp)
dist = DIST(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y);
if (hitinfo.sprite >= 0)
if (hitinfo.hitactor != nullptr)
{
int cstat = hitinfo.hitactor->s().cstat;
// if the sprite blocking you hit is not a wall sprite there is something between
// you and the ladder
if (TEST(sprite[hitinfo.sprite].cstat, CSTAT_SPRITE_BLOCK) &&
!TEST(sprite[hitinfo.sprite].cstat, CSTAT_SPRITE_ALIGNMENT_WALL))
if (TEST(cstat, CSTAT_SPRITE_BLOCK) &&
!TEST(cstat, CSTAT_SPRITE_ALIGNMENT_WALL))
{
return false;
}

View file

@ -937,7 +937,7 @@ int InitRipperHang(DSWActor* actor)
SPRITEp sp = &actor->s();
int dist;
hitdata_t hitinfo = { { 0, 0, 0 }, -2, 0, -2 };
HITINFO hitinfo;
bool Found = false;
short dang, tang;

View file

@ -938,7 +938,7 @@ int InitRipper2Hang(DSWActor* actor)
SPRITEp sp = &actor->s();
int dist;
hitdata_t hitinfo = { { 0, 0, 0 }, -2, 0, -2 };
HITINFO hitinfo;
bool Found = false;
short dang, tang;

View file

@ -144,6 +144,17 @@ void ResetWallWarpHitscan(short sectnum)
while (wall_num != start_wall);
}
void
FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum,
int32_t xvect, int32_t yvect, int32_t zvect,
HITINFO* hitinfo, int32_t clipmask)
{
hitdata_t hitdata;
FAFhitscan(x, y, z, sectnum, xvect, yvect, zvect, &hitdata, clipmask);
hitinfo->set(&hitdata);
}
void
FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum,
int32_t xvect, int32_t yvect, int32_t zvect,

View file

@ -2188,7 +2188,7 @@ bool NearThings(PLAYERp pp)
}
// This only gets called if nothing else worked, check for nearness to a wall
{
hitdata_t hitinfo = { { 0, 0, 0 }, 0, 0, 0 };
HITINFO hitinfo;
short dang = pp->angle.ang.asbuild();
FAFhitscan(pp->posx, pp->posy, pp->posz - Z(30), pp->cursectnum, // Start position
@ -2204,7 +2204,7 @@ bool NearThings(PLAYERp pp)
return false;
// hit a sprite?
if (hitinfo.sprite >= 0)
if (hitinfo.hitactor != nullptr)
return false;
if (neartagsect >= 0)

View file

@ -194,6 +194,30 @@ inline int Collision::setFromEngine(int value)
return type;
}
struct HITINFO {
DSWActor* hitactor;
short sect;
short wall;
short hitsprite;
vec3_t pos;
void clearObj()
{
pos = {};
sect = wall = -1;
hitsprite = -1;
hitactor = nullptr;
}
void set(hitdata_t* hit)
{
sect = hit->sect;
wall = hit->wall;
hitsprite = hit->sprite;
hitactor = hit->sprite >= 0 ? &swActors[hit->sprite] : nullptr;
pos = hit->pos;
}
};
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, DSWActor*& w, DSWActor** def)
{

View file

@ -3208,7 +3208,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum)
if (u->ActorActionSet->Jump)
{
int zdiff;
hitdata_t hitinfo;
HITINFO hitinfo;
sp->ang = tpoint->ang;
@ -3233,7 +3233,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum)
ASSERT(hitinfo.sect >= 0);
if (hitinfo.sprite >= 0)
if (hitinfo.hitactor != nullptr)
return false;
if (hitinfo.wall < 0)

View file

@ -14526,8 +14526,6 @@ InitShotgun(PLAYERp pp)
if (hitinfo.sect < 0)
{
////DSPRINTF(ds,"PROBLEM! - FAFhitscan returned a bad hitinfo.sect");
//MONO_PRINT(ds);
continue;
}
@ -17566,21 +17564,9 @@ InitEMP(PLAYERp pp)
if (hitinfo.sect < 0)
{
////DSPRINTF(ds,"PROBLEM! - FAFhitscan returned a bad hitinfo.sect");
//MONO_PRINT(ds);
return 0;
}
#if 0
if (TEST(pp->Flags, PF_DIVING) ||
(hitinfo.wall < 0 && hitinfo.sprite < 0 && SectorIsDiveArea(hitinfo.sect))
)
{
InitUziBullet(pp);
return 0;
}
#endif
SetVisHigh();
// check to see what you hit
@ -18106,8 +18092,6 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
if (hitinfo.sect < 0)
{
//DSPRINTF(ds,"PROBLEM! - FAFhitscan returned a bad hitinfo.sect");
MONO_PRINT(ds);
return 0;
}
@ -18614,7 +18598,7 @@ int InitEnemyUzi(DSWActor* actor)
SPRITEp sp = &actor->s(), wp;
USERp wu;
short daang;
hitdata_t hitinfo = { { -2, -2, -2 }, -2, -2, -2 };
HITINFO hitinfo;
int daz;
int zh;
void InitUziShell(PLAYERp);
@ -18707,9 +18691,9 @@ int InitEnemyUzi(DSWActor* actor)
QueueHole(hitinfo.sect,hitinfo.wall,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z);
}
if (hitinfo.sprite >= 0)
if (hitinfo.hitactor != nullptr)
{
if (BulletHitSprite(sp, hitinfo.sprite, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, 0))
if (BulletHitSprite(sp, hitinfo.hitactor->GetSpriteIndex(), hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, 0))
return 0;
}
@ -18740,7 +18724,7 @@ int InitEnemyUzi(DSWActor* actor)
wp->clipdist = 8 >> 2;
HitscanSpriteAdjust(actorNew->GetSpriteIndex(), hitinfo.wall);
DoHitscanDamage(actorNew->GetSpriteIndex(), hitinfo.sprite);
DoHitscanDamage(actorNew->GetSpriteIndex(), hitinfo.hitactor? hitinfo.hitactor->GetSpriteIndex() : -1);
actorNew = SpawnActor(STAT_MISSILE, UZI_SPARK, s_UziSpark, hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0);
wu = actorNew->u();
@ -20271,7 +20255,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
int sectnum;
short rndnum;
int daz;
hitdata_t hitinfo;
HITINFO hitinfo;
USERp u = actor->u();
@ -20296,7 +20280,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
return nullptr;
// hit a sprite?
if (hitinfo.sprite >= 0)
if (hitinfo.hitactor != nullptr)
return nullptr; // Don't try to put blood on a sprite
if (hitinfo.wall >= 0) // Don't check if blood didn't hit a wall, otherwise the ASSERT fails!