- another cleanup batch.

This commit is contained in:
Christoph Oelckers 2021-11-14 21:46:41 +01:00
parent 35ba63cb3e
commit 1128d20747
9 changed files with 73 additions and 90 deletions

View file

@ -354,7 +354,7 @@ void InitItems()
break;
case 6:
for (j = 0; j < 8; j++)
explosion(actor->GetSpriteIndex(), spr.x, spr.y, spr.z, 0);
explosion(actor, spr.x, spr.y, spr.z, 0);
spritesound(S_EXPLODE, actor);
DeleteActor(actor);
break;

View file

@ -888,10 +888,9 @@ void madenoise(PLAYER& plr, int val, int x, int y, int z) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if ((abs(x - spr.x) + abs(y - spr.y) < (val * 4096)))
newstatus(i, FINDME);
SetNewStatus(actor, FINDME);
}
}
@ -1048,7 +1047,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (isWh2() && plr.currweapon == 3)
if (plr.weapon[plr.currweapon] == 3) {
explosion(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, 4096);
explosion(hitActor, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, 4096);
}
if (plr.invisibletime > 0) {
@ -1617,11 +1616,11 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
|| hitspr.picnum == SKELETONDIE)
spritesound(S_SKELHIT1 + (krand() % 2), hitActor);
}
newstatus(pHitInfo.hitsprite, DIE);
SetNewStatus(hitActor, DIE);
}
hitspr.ang = plr.angle.ang.asbuild() + ((krand() & 32) - 64);
if (hitspr.hitag > 0)
newstatus(pHitInfo.hitsprite, PAIN);
SetNewStatus(hitActor, PAIN);
break;
} // switch enemytype
@ -1650,7 +1649,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
addscore(&plr, 100);
deletesprite((short) pHitInfo.hitsprite);
DeleteActor(hitActor);
}
break;
} // switch frozen
@ -1672,7 +1671,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
case VASEB:
case VASEC:
newstatus(pHitInfo.hitsprite, BROKENVASE);
SetNewStatus(hitActor, BROKENVASE);
break;
} // switch
} // if weapondist
@ -1701,8 +1700,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
Neartag ntag;
neartag(pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, (short) pHitInfo.hitsect, (short) daang,
ntag, 1024, 3);
neartag(pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, pHitInfo.hitsect, daang, ntag, 1024, 3);
if (ntag.tagsector < 0) {
auto spawnedactor = InsertActor(pHitInfo.hitsect, (short) 0);
@ -1814,14 +1812,14 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
hitspr.hitag -= (krand() & 15) + 15;
if (hitspr.hitag <= 0) {
newstatus(pHitInfo.hitsprite, DIE);
SetNewStatus(hitActor, DIE);
if (hitspr.picnum == RAT)
chunksofmeat(plr, hitActor, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsect, daang);
} else {
hitspr.ang = (short) (getangle(plr.x - hitspr.x,
plr.y - hitspr.y) & 2047);
newstatus(pHitInfo.hitsprite, PAIN);
SetNewStatus(hitActor, PAIN);
}
break;
}
@ -1851,7 +1849,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
for (k = 0; k < 32; k++)
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
deletesprite((short) pHitInfo.hitsprite);
DeleteActor(hitActor);
}
} // switch frozen
@ -1872,7 +1870,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
case VASEA:
case VASEB:
case VASEC:
newstatus(pHitInfo.hitsprite, BROKENVASE);
SetNewStatus(hitActor, BROKENVASE);
break;
} // switch
}

View file

@ -38,7 +38,9 @@ void getzrange(int x, int y, int z, short sectnum, int walldist, int cliptype)
//This was done better. Strange.
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, Neartag& nt, int32_t neartagrange, uint8_t tagsearch)
{
::neartag(xs, ys, zs, sectnum, ange, &nt.tagsector, &nt.tagwall, &nt.tagsprite, &nt.taghitdist, neartagrange, tagsearch);
short tagsprite;
::neartag(xs, ys, zs, sectnum, ange, &nt.tagsector, &nt.tagwall, &tagsprite, &nt.taghitdist, neartagrange, tagsearch);
nt.tagactor = tagsprite >= 0 ? &whActors[tagsprite] : nullptr;
}
int hitscan(int xs, int ys, int zs, short sectnum, int vx, int vy, int vz, Hitscan& hit, int cliptype)

View file

@ -169,7 +169,8 @@ void getzrange(int x, int y, int z, short sectnum, int walldist, int cliptype);
struct Neartag {
int taghitdist;
short tagsector, tagwall, tagsprite;
short tagsector, tagwall;
DWHActor* tagactor;
};
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, Neartag& nt, int32_t neartagrange, uint8_t tagsearch);
@ -190,17 +191,17 @@ extern int monsterwarptime;
void timerprocess(PLAYER& plr);
int getPickHeight();
void processobjs(PLAYER& plr);
void newstatus(short sn, int seq);
void makeafire(int i, int firetype);
void explosion(int i, int x, int y, int z, int ownr);
void explosion2(int i, int x, int y, int z, int ownr);
void SetNewStatus(DWHActor* actor, const int seq);
void makeafire(DWHActor*, int firetype);
void explosion(DWHActor* i, int x, int y, int z, int ownr);
void explosion2(DWHActor* i, int x, int y, int z, int ownr);
void trailingsmoke(DWHActor* actor, boolean ball);
void icecubes(int i, int x, int y, int z, int ownr);
boolean damageactor(PLAYER& plr, DWHActor* hitobject, DWHActor* actor);
Collision movesprite(DWHActor*, int dx, int dy, int dz, int ceildist, int flordist, int cliptype);
void trowajavlin(int s);
void spawnhornskull(short i);
void spawnapentagram(int sn);
void spawnhornskull(DWHActor* i);
void spawnapentagram(DWHActor* sn);
void processinput(int num);
void DrawHud(double const dasmoothratio);
void spikeanimation(PLAYER& plr);
@ -387,7 +388,7 @@ void makemonstersplash(int picnum, int i);
void bats(PLAYER& plr, int k);
void cracks();
void lavadryland();
void warpfxsprite(int s);
void warpfxsprite(DWHActor* s);
void resetEffects();
void weaponpowerup(PLAYER& plr);
void makesparks(short i, int type);
@ -554,10 +555,5 @@ struct GameInterface : public ::GameInterface
};
inline void SetNewStatus(DWHActor* actor, const int seq)
{
newstatus(actor->GetSpriteIndex(), seq);
}
END_WH_NS

View file

@ -23,7 +23,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
switch (spr.extra) {
@ -56,7 +55,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
osectnum = spr.sectnum;
@ -86,7 +84,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
osectnum = spr.sectnum;
@ -118,8 +115,7 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
osectnum = spr.sectnum;
spr.lotag -= TICSPERFRAME;
if (spr.lotag < -100)
@ -149,7 +145,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
@ -228,7 +223,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
@ -246,8 +240,7 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if (spr.picnum >= (GONZOBSHDEAD - 8)) {
if (--spr.extra <= 0) {
spr.picnum--;
@ -280,7 +273,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
playertorch = spr.lotag -= TICSPERFRAME;
if (plr.selectedgun > 4) {
@ -353,7 +345,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
@ -370,7 +361,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
@ -387,7 +377,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
@ -404,7 +393,6 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
@ -740,7 +728,7 @@ void animateobjs(PLAYER& plr) {
default:
if (spr.picnum == TORCH) {
for (k = 0; k < 16; k++)
makeafire(i, 0);
makeafire(actor, 0);
DeleteActor(actor);
break;
}
@ -972,9 +960,9 @@ void animateobjs(PLAYER& plr) {
if (moveStat.type != kHitNone && spr.picnum == MONSTERBALL)
if (actor->GetPlayerOwner() == plr.playerNum()) {
explosion2(i, spr.x, spr.y, spr.z, i);
explosion2(actor, spr.x, spr.y, spr.z, i);
} else {
explosion(i, spr.x, spr.y, spr.z, i);
explosion(actor, spr.x, spr.y, spr.z, i);
}
if (moveStat.type == kHitSector) { // Hits a ceiling / floor
@ -991,9 +979,9 @@ void animateobjs(PLAYER& plr) {
if (spr.picnum == MONSTERBALL) {
if (actor->GetPlayerOwner() == plr.playerNum())
explosion2(i, spr.x, spr.y, spr.z, i);
explosion2(actor, spr.x, spr.y, spr.z, i);
else
explosion(i, spr.x, spr.y, spr.z, i);
explosion(actor, spr.x, spr.y, spr.z, i);
}
if (spr.picnum == THROWPIKE) {
spr.picnum++;
@ -1010,9 +998,9 @@ void animateobjs(PLAYER& plr) {
if (moveStat.type == kHitSprite) { // Bullet hit a sprite
if (spr.picnum == MONSTERBALL) {
if (actor->GetPlayerOwner() == plr.playerNum())
explosion2(i, spr.x, spr.y, spr.z, i);
explosion2(actor, spr.x, spr.y, spr.z, i);
else
explosion(i, spr.x, spr.y, spr.z, i);
explosion(actor, spr.x, spr.y, spr.z, i);
}
if (actor->GetOwner() != moveStat.actor)

View file

@ -431,7 +431,7 @@ void teleporter() {
if (plr.Sector()->lotag == 10) {
if (plr.sector != plr.oldsector) {
daang = plr.angle.ang.asbuild();
warpfxsprite(plr.spritenum);
warpfxsprite(plr.actor());
warp(plr.x, plr.y, plr.z, daang, plr.sector);
viewBackupPlayerLoc(pyrn);
plr.x = warpx;
@ -439,7 +439,7 @@ void teleporter() {
plr.z = warpz;
daang = (short) warpang;
plr.sector = (short) warpsect;
warpfxsprite(plr.spritenum);
warpfxsprite(plr.actor());
plr.angle.settarget(daang);
plr.justwarpedfx = 48;
spritesound(S_WARP, plr.actor());
@ -518,7 +518,7 @@ void warpsprite(DWHActor* actor) {
return;
auto& spr = actor->s();
short dasectnum = spr.sectnum;
warpfxsprite(actor->GetSpriteIndex());
warpfxsprite(actor);
warp(spr.x, spr.y, spr.z, spr.ang, dasectnum);
spr.x = warpx;
spr.y = warpy;
@ -526,7 +526,7 @@ void warpsprite(DWHActor* actor) {
spr.ang = (short) warpang;
dasectnum = (short) warpsect;
warpfxsprite(actor->GetSpriteIndex());
warpfxsprite(actor);
SetActorPos(actor, spr.x, spr.y, spr.z);
// EG 19 Aug 2017 - Try to prevent monsters teleporting back and forth wildly
@ -999,8 +999,7 @@ void lavadryland() {
}
void warpfxsprite(int s) {
auto actor = &whActors[s];
void warpfxsprite(DWHActor* actor) {
auto& spr = actor->s();
PLAYER& plr = player[pyrn];
@ -1015,7 +1014,7 @@ void warpfxsprite(int s) {
spawned.picnum = ANNIHILATE;
short daang;
if (s == plr.spritenum) {
if (actor == plr.actor()) {
daang = plr.angle.ang.asbuild();
spawned.ang = daang;
} else {

View file

@ -801,7 +801,7 @@ boolean prepareboard(const char* fname) {
SetActorPos(plr.actor(), plr.x, plr.y, plr.z + (getPlayerHeight() << 8));
warpfxsprite(plr.spritenum);
warpfxsprite(plr.actor());
plr.treasure[TBRASSKEY] = plr.treasure[TBLACKKEY] = plr.treasure[TGLASSKEY] = plr.treasure[TIVORYKEY] = 0;
plr.treasure[TBLUESCEPTER] = plr.treasure[TYELLOWSCEPTER] = 0;

View file

@ -134,8 +134,8 @@ void processobjs(PLAYER& plr) {
}
}
void newstatus(short sn, int seq) {
auto actor = &whActors[sn];
void SetNewStatus(DWHActor* actor, const int seq)
{
auto& spr = actor->s();
switch (seq) {
case AMBUSH:
@ -836,7 +836,7 @@ void newstatus(short sn, int seq) {
break;
case DEMONTYPE:
spritesound(S_GUARDIANDIE, actor);
explosion(sn, spr.x, spr.y, spr.z, 0);
explosion(actor, spr.x, spr.y, spr.z, 0);
addscore(aiGetPlayerTarget(actor), 1500);
DeleteActor(actor);
kills++;
@ -930,7 +930,7 @@ void newstatus(short sn, int seq) {
case GUARDIANTYPE:
spritesound(S_GUARDIANDIE, actor);
for (int j = 0; j < 4; j++)
explosion(sn, spr.x, spr.y, spr.z, 0);
explosion(actor, spr.x, spr.y, spr.z, 0);
DeleteActor(actor);
addscore(aiGetPlayerTarget(actor), 1500);
kills++;
@ -989,7 +989,7 @@ void newstatus(short sn, int seq) {
spr.picnum = KATIEDEAD;
spr.cstat &= ~3;
ChangeActorStat(actor, RESURECT);
spawnhornskull(sn);
spawnhornskull(actor);
addscore(aiGetPlayerTarget(actor), 5000);
spr.detail = KATIETYPE;
break;
@ -1255,7 +1255,7 @@ void newstatus(short sn, int seq) {
spr.picnum = DEVILDEAD;
spr.cstat &= ~3;
ChangeActorStat(actor, DEAD);
spawnhornskull(sn);
spawnhornskull(actor);
addscore(aiGetPlayerTarget(actor), 500);
break;
case IMPDEAD:
@ -1332,7 +1332,7 @@ void newstatus(short sn, int seq) {
spr.picnum = JUDYDEAD;
spr.cstat &= ~3;
ChangeActorStat(actor, DEAD);
spawnapentagram(sn);
spawnapentagram(actor);
addscore(aiGetPlayerTarget(actor), 7000);
break;
case WILLOWEXPLO + 2:
@ -1371,8 +1371,7 @@ void newstatus(short sn, int seq) {
//
}
void makeafire(int i, int firetype) {
auto actor = &whActors[i];
void makeafire(DWHActor* actor, int firetype) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, FIRE);
auto& spawned = spawnedactor->s();
@ -1396,8 +1395,7 @@ void makeafire(int i, int firetype) {
spawned.backuploc();
}
void explosion(int i, int x, int y, int z, int ownr) {
auto actor = &whActors[i];
void explosion(DWHActor* actor, int x, int y, int z, int ownr) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, EXPLO);
@ -1437,8 +1435,7 @@ void explosion(int i, int x, int y, int z, int ownr) {
spawned.backuploc();
}
void explosion2(int i, int x, int y, int z, int ownr) {
auto actor = &whActors[i];
void explosion2(DWHActor* actor, int x, int y, int z, int ownr) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, EXPLO);
auto& spawned = spawnedactor->s();
@ -1850,13 +1847,14 @@ void trowajavlin(int s) {
spawned.backuploc();
}
void spawnhornskull(short i) {
auto spawnedactor = InsertActor(sprite[i].sectnum, (short) 0);
void spawnhornskull(DWHActor* actor) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, (short) 0);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
spawned.z = sprite[i].z - (24 << 8);
spawned.x = spr.x;
spawned.y = spr.y;
spawned.z = spr.z - (24 << 8);
spawned.shade = -15;
spawned.cstat = 0;
@ -1869,13 +1867,14 @@ void spawnhornskull(short i) {
spawned.backuploc();
}
void spawnapentagram(int sn) {
auto spawnedactor = InsertActor(sprite[sn].sectnum, (short) 0);
void spawnapentagram(DWHActor* actor) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, (short) 0);
auto& spawned = spawnedactor->s();
spawned.x = sprite[sn].x;
spawned.y = sprite[sn].y;
spawned.z = sprite[sn].z - (8 << 8);
spawned.x = spr.x;
spawned.y = spr.y;
spawned.z = spr.z - (8 << 8);
spawned.xrepeat = spawned.yrepeat = 64;
spawned.pal = 0;

View file

@ -264,20 +264,21 @@ void plruse(PLAYER& plr) {
spritesound(S_PUSH1 + (krand() % 2), plr.actor());
}
}
if (nt.tagsprite >= 0) {
if (sprite[nt.tagsprite].lotag == 1) {
if(sprite[nt.tagsprite].picnum == PULLCHAIN1 || sprite[nt.tagsprite].picnum == SKULLPULLCHAIN1) {
sprite[nt.tagsprite].lotag = 0;
newstatus(nt.tagsprite, PULLTHECHAIN);
} else if(sprite[nt.tagsprite].picnum == LEVERUP) {
sprite[nt.tagsprite].lotag = 0;
newstatus(nt.tagsprite, ANIMLEVERUP);
if (nt.tagactor != nullptr) {
auto& spr = nt.tagactor->s();
if (spr.lotag == 1) {
if(spr.picnum == PULLCHAIN1 || spr.picnum == SKULLPULLCHAIN1) {
spr.lotag = 0;
SetNewStatus(nt.tagactor, PULLTHECHAIN);
} else if(spr.picnum == LEVERUP) {
spr.lotag = 0;
SetNewStatus(nt.tagactor, ANIMLEVERUP);
}
for (int i = 0; i < numsectors; i++)
if (sector[i].hitag == sprite[nt.tagsprite].hitag)
if (sector[i].hitag == spr.hitag)
operatesector(plr, i);
} else
operatesprite(plr, nt.tagsprite);
operatesprite(plr, nt.tagactor->GetSpriteIndex());
}
}