- cleanup of collision maintenance.

u->ret is gone, and for clearing the collision info the proper utilities are being called now.
This commit is contained in:
Christoph Oelckers 2021-11-05 21:12:01 +01:00
parent 5f32bc17ef
commit 606ce997ac
7 changed files with 47 additions and 68 deletions

View file

@ -81,7 +81,7 @@ bool ActorMoveHitReact(DSWActor* actor)
// Should only return true if there is a reaction to what was hit that
// would cause the calling function to abort
auto coll = u->hitCode();
auto coll = u->coll;
if (coll.type == kHitSprite)
{
auto hitActor = coll.actor;

View file

@ -69,6 +69,7 @@ struct Collision
Collision() = default;
Collision(int legacyval) { setFromEngine(legacyval); }
void invalidate() { type = -1; } // something invalid that's not a valid hit type.
int setNone();
int setSector(int num);
int setWall(int num);
@ -1073,8 +1074,6 @@ struct USER
memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP));
}
Collision hitCode() const;
//
// Variables that can be used by actors and Player
//
@ -1208,7 +1207,6 @@ struct USER
short sang;
uint8_t spal; // save off default palette number
int ret; //holder for move_sprite return value
Collision coll; // same thing broken up into useful components.
// Need to get rid of these flags
@ -2243,11 +2241,6 @@ DSWActor* PLAYERstruct::Actor()
return &swActors[PlayerSprite];
}
Collision USER::hitCode() const
{
return Collision(ret);
}
inline int ActorUpper(DSWActor* actor)
{
return SPRITEp_UPPER(&actor->s());
@ -2273,7 +2266,6 @@ inline int Facing(DSWActor* actor1, DSWActor* actor2)
// temporary helper.
inline void SetCollision(USER* u, int coll)
{
u->ret = coll;
u->coll.setFromEngine(coll);
}

View file

@ -446,7 +446,7 @@ int DoBloodSpray(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -514,7 +514,7 @@ int DoBloodSpray(DSWActor* actor)
{
SpawnFloorSplash(actor);
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 32000); // Was 18000
@ -659,7 +659,7 @@ int DoPhosphorus(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -682,7 +682,7 @@ int DoPhosphorus(DSWActor* actor)
{
// hit a wall
ScaleSpriteVector(actor, 28000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -696,7 +696,7 @@ int DoPhosphorus(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE);
ScaleSpriteVector(actor, 32000); // was 18000
u->zchange /= 6;
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -730,7 +730,7 @@ int DoPhosphorus(DSWActor* actor)
if (!TEST(u->Flags, SPR_BOUNCE))
{
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 32000); // Was 18000
@ -875,7 +875,7 @@ int DoChemBomb(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -900,7 +900,7 @@ int DoChemBomb(DSWActor* actor)
{
// hit a wall
ScaleSpriteVector(actor, 28000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -916,7 +916,7 @@ int DoChemBomb(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE);
ScaleSpriteVector(actor, 32000); // was 18000
u->zchange /= 6;
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -960,7 +960,7 @@ int DoChemBomb(DSWActor* actor)
if (!TEST(sp->cstat, CSTAT_SPRITE_INVISIBLE))
PlaySound(DIGI_CHEMBOUNCE, actor, v3df_dontpan);
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 32000); // Was 18000
@ -1102,7 +1102,7 @@ int DoCaltrops(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -1126,7 +1126,7 @@ int DoCaltrops(DSWActor* actor)
{
// hit a wall
ScaleSpriteVector(actor, 1000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -1140,7 +1140,7 @@ int DoCaltrops(DSWActor* actor)
PlaySound(DIGI_CALTROPS, actor, v3df_dontpan);
SET(u->Flags, SPR_BOUNCE);
ScaleSpriteVector(actor, 1000); // was 18000
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -1176,7 +1176,7 @@ int DoCaltrops(DSWActor* actor)
{
PlaySound(DIGI_CALTROPS, actor, v3df_dontpan);
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 1000); // Was 18000

View file

@ -2692,7 +2692,7 @@ void DoPlayerMoveVehicle(PLAYERp pp)
else if (hitinfo.sprite >= 0)
SetCollision(u, hitinfo.sprite|HIT_SPRITE);
else
SetCollision(u, 0);
u->coll.setNone();
VehicleMoveHit(actor);
}

View file

@ -912,7 +912,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
("sz", w.sz, def->sz)
("sang", w.sang, def->sang)
("spal", w.spal, def->spal)
("ret", w.ret, def->ret)
("ret", w.coll.legacyVal, def->coll.legacyVal) // is this needed?
("Flag1", w.Flag1, def->Flag1)
("LastWeaponNum", w.LastWeaponNum, def->LastWeaponNum)
("WeaponNum", w.WeaponNum, def->WeaponNum)
@ -933,7 +933,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
if (arc.isReading())
{
w.oangdiff = 0;
SetCollision(&w, w.ret);
SetCollision(&w, w.coll.legacyVal);
}
}
return arc;

View file

@ -5022,7 +5022,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
u->highActor = highActor;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;
SetCollision(u, -1); // caution!!
u->coll.invalidate();
ChangeActorSect(actor, sectnum);
return false;
}
@ -5041,7 +5041,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
u->highActor = highActor;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;
SetCollision(u, -1); // caution!!
u->coll.invalidate();
ChangeActorSect(actor, sectnum);
return false;
}

View file

@ -4481,7 +4481,7 @@ bool WeaponMoveHit(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(&wall[wal], sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
return true;
}
@ -7803,7 +7803,7 @@ int DoStar(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(&wall[hit_wall], sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -7839,7 +7839,7 @@ int DoStar(DSWActor* actor)
ScaleSpriteVector(actor, 36000);
SET(u->Flags, SPR_BOUNCE);
u->motion_blur_num = 0;
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -7897,7 +7897,7 @@ int DoStar(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE);
u->motion_blur_num = 0;
SetCollision(u, 0);
u->coll.setNone();
}
else
@ -7905,7 +7905,7 @@ int DoStar(DSWActor* actor)
// hit a sloped sector < 45 degrees
SET(u->Flags, SPR_BOUNCE);
u->motion_blur_num = 0;
SetCollision(u, 0);
u->coll.setNone();
}
// BREAK HERE - LOOOK !!!!!!!!!!!!!!!!!!!!!!!!
@ -7914,7 +7914,7 @@ int DoStar(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE);
u->motion_blur_num = 0;
SetCollision(u, 0);
u->coll.setNone();
u->zchange = -u->zchange;
// 32000 to 96000
@ -7964,20 +7964,11 @@ int DoCrossBolt(DSWActor* actor)
MissileHitDiveArea(actor);
if (u->ret)
if (u->coll.type != kHitNone)
{
if (WeaponMoveHit(actor))
{
switch (TEST(u->ret, HIT_MASK))
{
case HIT_SPRITE:
{
break;
}
}
KillActor(actor);
return true;
}
}
@ -8506,10 +8497,7 @@ int DoCoolgFire(DSWActor* actor)
if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256)
SpawnBubble(actor);
// !JIM! //!FRANK WHY???
//DoDamageTest(Weapon);
if (u->ret)
if (u->coll.type != kHitNone)
{
if (WeaponMoveHit(actor))
{
@ -8589,7 +8577,7 @@ bool SlopeBounce(DSWActor* actor, bool *hit_wall)
short hit_sector;
short daang;
hit_sector = NORM_SECTOR(u->ret);
hit_sector = u->coll.index;
getzsofslope(hit_sector, sp->x, sp->y, &hiz, &loz);
@ -8737,7 +8725,7 @@ int DoGrenade(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -8762,7 +8750,7 @@ int DoGrenade(DSWActor* actor)
{
// hit a wall
ScaleSpriteVector(actor, 22000); // 28000
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -8775,7 +8763,7 @@ int DoGrenade(DSWActor* actor)
{
SET(u->Flags, SPR_BOUNCE);
ScaleSpriteVector(actor, 40000); // 18000
SetCollision(u, 0);
u->coll.setNone();
u->zchange /= 4;
u->Counter = 0;
}
@ -8815,7 +8803,7 @@ int DoGrenade(DSWActor* actor)
if (!TEST(u->Flags, SPR_BOUNCE))
{
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 40000); // 18000
@ -8952,7 +8940,7 @@ int DoVulcanBoulder(DSWActor* actor)
if (wph->lotag == TAG_WALL_BREAK)
{
HitBreakWall(wph, sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -8974,7 +8962,7 @@ int DoVulcanBoulder(DSWActor* actor)
{
// hit a sloped sector - treated as a wall because of large slope
ScaleSpriteVector(actor, 30000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -8986,7 +8974,7 @@ int DoVulcanBoulder(DSWActor* actor)
u->xchange = MulScale(u->xchange, 30000, 16);
u->ychange = MulScale(u->ychange, 30000, 16);
u->zchange = MulScale(u->zchange, 12000, 16);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
// limit to a reasonable bounce value
@ -8996,7 +8984,7 @@ int DoVulcanBoulder(DSWActor* actor)
else
{
// hit a sloped ceiling
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
ScaleSpriteVector(actor, 30000);
}
@ -9007,7 +8995,7 @@ int DoVulcanBoulder(DSWActor* actor)
// hit unsloped floor
if (sp->z > DIV2(u->hiz + u->loz))
{
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->xchange = MulScale(u->xchange, 20000, 16);
@ -9379,7 +9367,7 @@ int DoMine(DSWActor* actor)
if (wall[hit_wall].lotag == TAG_WALL_BREAK)
{
HitBreakWall(&wall[hit_wall], sp->x, sp->y, sp->z, sp->ang, u->ID);
SetCollision(u, 0);
u->coll.setNone();
break;
}
@ -9425,7 +9413,7 @@ int DoMine(DSWActor* actor)
}
}
SetCollision(u, 0);
u->coll.setNone();
}
return false;
@ -9654,7 +9642,6 @@ int DoLaser(DSWActor* actor)
SPRITEp sp = &actor->s();
SPRITEp np;
USERp nu;
short New;
short spawn_count = 0;
if (SW_SHAREWARE) return false; // JBF: verify
@ -11622,7 +11609,7 @@ int DoBloodWorm(DSWActor* actor)
{
u->xchange = -u->xchange;
u->ychange = -u->ychange;
SetCollision(u, 0);
u->coll.setNone();
sp->ang = NORM_ANGLE(sp->ang + 1024);
return true;
}
@ -18493,7 +18480,7 @@ bool MissileHitDiveArea(DSWActor* actor)
SET(u->Flags, SPR_UNDERWATER);
SpawnSplash(actor);
SpriteWarpToUnderwater(actor);
SetCollision(u, 0);
u->coll.setNone();
PlaySound(DIGI_PROJECTILEWATERHIT, actor, v3df_none);
return true;
}
@ -18509,7 +18496,7 @@ bool MissileHitDiveArea(DSWActor* actor)
return false;
}
SpawnSplash(actor);
SetCollision(u, 0);
u->coll.setNone();
return true;
}
}
@ -19483,7 +19470,7 @@ int DoShrapVelocity(DSWActor* actor)
{
// hit a wall
ScaleSpriteVector(actor, 28000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -19496,7 +19483,7 @@ int DoShrapVelocity(DSWActor* actor)
{
SET(u->Flags, SPR_BOUNCE);
ScaleSpriteVector(actor, 18000);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
}
else
@ -19530,7 +19517,7 @@ int DoShrapVelocity(DSWActor* actor)
if (!TEST(u->Flags, SPR_BOUNCE))
{
SET(u->Flags, SPR_BOUNCE);
SetCollision(u, 0);
u->coll.setNone();
u->Counter = 0;
u->zchange = -u->zchange;
ScaleSpriteVector(actor, 18000);