diff --git a/source/games/whaven/src/ai.cpp b/source/games/whaven/src/ai.cpp index 7ac76a980..7dd1d6e44 100644 --- a/source/games/whaven/src/ai.cpp +++ b/source/games/whaven/src/ai.cpp @@ -419,7 +419,6 @@ void aiProcess() { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); getzrange(spr.x, spr.y, spr.z - 1, spr.sectnum, (spr.clipdist) << 2, CLIPMASK0); switch (checkfluid(actor, zr_florHit)) { diff --git a/source/games/whaven/src/main.cpp b/source/games/whaven/src/main.cpp index 05ec75ced..9e842780c 100644 --- a/source/games/whaven/src/main.cpp +++ b/source/games/whaven/src/main.cpp @@ -842,7 +842,7 @@ DEFINE_FIELD_X(WhPlayer,PLAYER,height); DEFINE_FIELD_X(WhPlayer,PLAYER,hvel); DEFINE_FIELD_X(WhPlayer,PLAYER, sector); DEFINE_FIELD_X(WhPlayer,PLAYER, oldsector); -DEFINE_FIELD_X(WhPlayer,PLAYER, spritenum); +//DEFINE_FIELD_X(WhPlayer,PLAYER, spritenum); DEFINE_FIELD_X(WhPlayer,PLAYER, keytoggle); DEFINE_FIELD_X(WhPlayer,PLAYER,flags); DEFINE_FIELD_X(WhPlayer,PLAYER,weapon); diff --git a/source/games/whaven/src/player.h b/source/games/whaven/src/player.h index 82ec455a1..2a917d295 100644 --- a/source/games/whaven/src/player.h +++ b/source/games/whaven/src/player.h @@ -22,8 +22,8 @@ struct PLAYER { int hvel; int sector; int oldsector; - short spritenum; - DWHActor* actor() { return &whActors[spritenum]; } + DWHActor* theactor; + DWHActor* actor() { return theactor; } sectortype* Sector() { return &::sector[sector]; } int playerNum(); boolean keytoggle; diff --git a/source/games/whaven/src/sound.cpp b/source/games/whaven/src/sound.cpp index 09d335462..53343a819 100644 --- a/source/games/whaven/src/sound.cpp +++ b/source/games/whaven/src/sound.cpp @@ -138,7 +138,7 @@ void GameInterface::UpdateSounds() return false; }); - if (player[pyrn].spritenum >= 0) + if (player[pyrn].actor() != nullptr) { listener.angle = float(-FixedToFloat(player[pyrn].angle.ang.asq16()) * pi::pi() / 1024); // Build uses a period of 2048. listener.velocity.Zero(); diff --git a/source/games/whaven/src/spellbooks.cpp b/source/games/whaven/src/spellbooks.cpp index 592baa657..177c23003 100644 --- a/source/games/whaven/src/spellbooks.cpp +++ b/source/games/whaven/src/spellbooks.cpp @@ -240,8 +240,7 @@ void speelbookprocess(PLAYER& plr) { } } -void nukespell(PLAYER& plr, short const j) { - auto actor = &whActors[j]; +void nukespell(PLAYER& plr, DWHActor* actor) { auto& spr = actor->s(); if(spr.detail != WILLOWTYPE && spr.pal == 6) //don't nuke freezed enemies diff --git a/source/games/whaven/src/weapons.cpp b/source/games/whaven/src/weapons.cpp index cf2b799e3..ac714144b 100644 --- a/source/games/whaven/src/weapons.cpp +++ b/source/games/whaven/src/weapons.cpp @@ -2230,7 +2230,6 @@ void shootgun(PLAYER& plr, float ang, int guntype) { while (auto itActor = it.Next()) { auto& spk = itActor->s(); - int j = itActor->GetSpriteIndex(); switch (spk.detail) { case DEMONTYPE: case NEWGUYTYPE: @@ -2257,7 +2256,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spk.z - (tileHeight(spk.picnum) << 7), spk.sectnum)) if ((isWh2() && itActor->GetPlayerOwner() != plr.playerNum()) || checkmedusadist(itActor, plr.x, plr.y, plr.z, 12)) - nukespell(plr, j); + nukespell(plr, itActor); break; } } diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index f45044d45..ea2724c94 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -256,7 +256,8 @@ extern Delayitem delayitem[MAXSECTORS]; extern short ironbarsector[16]; extern short ironbarscnt; extern int ironbarsgoal1[16], ironbarsgoal2[16]; -extern short ironbarsdone[16], ironbarsanim[16]; +extern short ironbarsdone[16]; +extern DWHActor* ironbarsanim[16]; extern int ironbarsgoal[16]; extern short warpsectorlist[64], warpsectorcnt; @@ -334,7 +335,7 @@ void bookprocess(int snum); boolean changebook(PLAYER& plr, int i); boolean lvlspellcheck(PLAYER& plr); void speelbookprocess(PLAYER& plr); -void nukespell(PLAYER& plr, short j); +void nukespell(PLAYER& plr, DWHActor* j); void medusa(PLAYER& plr, DWHActor* j); void displayspelltext(PLAYER& plr); void orbpic(PLAYER& plr, int currentorb); diff --git a/source/games/whaven/src/whani.cpp b/source/games/whaven/src/whani.cpp index 6031710bb..d0582c4d8 100644 --- a/source/games/whaven/src/whani.cpp +++ b/source/games/whaven/src/whani.cpp @@ -491,7 +491,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); osectnum = spr.sectnum; j = (torchpattern[PlayClock % 38]); @@ -508,7 +507,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); osectnum = spr.sectnum; j = (torchpattern[PlayClock % 38]); @@ -533,7 +531,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); switch (spr.lotag) { case 1821: @@ -576,7 +573,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); int ironbarmove = 0; @@ -623,7 +619,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; spr.z = spr.sector()->floorz + (tileHeight(spr.picnum) << 8); @@ -646,7 +641,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; @@ -666,8 +660,7 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); - + spr.lotag -= TICSPERFRAME; if (spr.z < spr.sector()->floorz) @@ -698,7 +691,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); getzrange(spr.x, spr.y, spr.z - 1, spr.sectnum, (spr.clipdist) << 2, CLIPMASK0); @@ -744,7 +736,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); getzrange(spr.x, spr.y, spr.z - 1, spr.sectnum, (spr.clipdist) << 2, CLIPMASK0); @@ -788,7 +779,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; @@ -820,7 +810,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); if (isWh2()) { osectnum = spr.sectnum; @@ -849,7 +838,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); if (isWh2()) { spr.lotag -= TICSPERFRAME; @@ -888,7 +876,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; @@ -960,9 +947,9 @@ void animateobjs(PLAYER& plr) { if (moveStat.type != kHitNone && spr.picnum == MONSTERBALL) if (actor->GetPlayerOwner() == plr.playerNum()) { - explosion2(actor, spr.x, spr.y, spr.z, i); + explosion2(actor, spr.x, spr.y, spr.z, 0); } else { - explosion(actor, spr.x, spr.y, spr.z, i); + explosion(actor, spr.x, spr.y, spr.z, 0); } if (moveStat.type == kHitSector) { // Hits a ceiling / floor @@ -979,9 +966,9 @@ void animateobjs(PLAYER& plr) { if (spr.picnum == MONSTERBALL) { if (actor->GetPlayerOwner() == plr.playerNum()) - explosion2(actor, spr.x, spr.y, spr.z, i); + explosion2(actor, spr.x, spr.y, spr.z, 0); else - explosion(actor, spr.x, spr.y, spr.z, i); + explosion(actor, spr.x, spr.y, spr.z, 0); } if (spr.picnum == THROWPIKE) { spr.picnum++; @@ -998,9 +985,9 @@ void animateobjs(PLAYER& plr) { if (moveStat.type == kHitSprite) { // Bullet hit a sprite if (spr.picnum == MONSTERBALL) { if (actor->GetPlayerOwner() == plr.playerNum()) - explosion2(actor, spr.x, spr.y, spr.z, i); + explosion2(actor, spr.x, spr.y, spr.z, 0); else - explosion(actor, spr.x, spr.y, spr.z, i); + explosion(actor, spr.x, spr.y, spr.z, 0); } if (actor->GetOwner() != moveStat.actor) @@ -1035,7 +1022,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; if (isBlades(spr.picnum)) { @@ -1126,7 +1112,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; dax = spr.xvel >> 3; @@ -1156,8 +1141,7 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); - + spr.lotag -= TICSPERFRAME; spr.z += spr.zvel; @@ -1213,7 +1197,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) { @@ -1231,8 +1214,7 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); - + if (plr.invisibletime < 0) { spr.lotag -= TICSPERFRAME; if (spr.lotag < 0) { @@ -1251,7 +1233,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; spr.z += spr.zvel; @@ -1274,17 +1255,12 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; -// -// spr.z -= (TICSPERFRAME << 6); - if (spr.xrepeat > 1) spr.xrepeat = spr.yrepeat -= TICSPERFRAME; -// SetActorPos(actor, &spr.pos); if (spr.lotag < 0) { DeleteActor(actor); } @@ -1295,7 +1271,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; spr.x += ((spr.xvel * TICSPERFRAME) >> 5); @@ -1348,7 +1323,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; spr.picnum++; @@ -1360,7 +1334,6 @@ void animateobjs(PLAYER& plr) { while (auto sectactor = it.Next()) { SPRITE& tspr = sectactor->s(); - int j = sectactor->GetSpriteIndex(); int dx = abs(spr.x - tspr.x); // x distance to sprite int dy = abs(spr.y - tspr.y); // y distance to sprite @@ -1400,7 +1373,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) { @@ -1437,7 +1409,6 @@ void animateobjs(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& spr = actor->s(); - int i = actor->GetSpriteIndex(); spr.lotag -= TICSPERFRAME; diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index b65a356ee..1653a7eb8 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -536,8 +536,7 @@ void warpsprite(DWHActor* actor) { void ironbars() { for (int i = 0; i < ironbarscnt; i++) { if (ironbarsdone[i] == 1) { - short spritenum = ironbarsanim[i]; - auto actor = &whActors[spritenum]; + auto actor = ironbarsanim[i]; auto& spr = actor->s(); switch (spr.hitag) { case 1: @@ -1083,7 +1082,6 @@ void weaponpowerup(PLAYER& plr) { while (auto actor = it.Next()) { SPRITE& tspr = actor->s(); - int j = actor->GetSpriteIndex(); if (tspr.picnum == CONE) { DeleteActor(actor); diff --git a/source/games/whaven/src/whldsv.cpp b/source/games/whaven/src/whldsv.cpp index 49c81872b..8814f0bba 100644 --- a/source/games/whaven/src/whldsv.cpp +++ b/source/games/whaven/src/whldsv.cpp @@ -36,7 +36,7 @@ FSerializer& Serialize(FSerializer& arc, const char* key, PLAYER& sw, PLAYER* de ("hvel", sw.hvel) ("sector", sw.sector) ("oldsector", sw.oldsector) - ("spritenum", sw.spritenum) + ("spritenum", sw.theactor) ("keytoggle", sw.keytoggle) ("flags", sw.flags) .Array("weapon", sw.weapon, countof(sw.weapon)) diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index 2aca09abd..20a62753c 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -327,7 +327,7 @@ boolean prepareboard(const char* fname) { if (spr.lotag == 80) { ironbarsector[ironbarscnt] = spr.sectnum; ironbarsdone[ironbarscnt] = 0; - ironbarsanim[ironbarscnt] = (short) i; + ironbarsanim[ironbarscnt] = actor; ironbarsgoal[ironbarscnt] = 0; ironbarscnt++; } @@ -776,7 +776,7 @@ boolean prepareboard(const char* fname) { auto pactor = InsertActor(plr.sector, (short)0); auto& pspr = pactor->s(); - plr.spritenum = pactor->GetSpriteIndex(); + plr.theactor = pactor; plr.oldsector = plr.sector; pspr.x = plr.x; diff --git a/source/games/whaven/src/whobj.cpp b/source/games/whaven/src/whobj.cpp index 9b94a0380..915fed916 100644 --- a/source/games/whaven/src/whobj.cpp +++ b/source/games/whaven/src/whobj.cpp @@ -1698,7 +1698,7 @@ boolean damageactor(PLAYER& plr, DWHActor* hitactor, DWHActor* actor) // raf because monsters could shatter a guy thats been frozen if (hitspr.pal == 6) { for (int k = 0; k < 32; k++) - icecubes(hitactor, hitspr.x, hitspr.y, hitspr.z, hitactor->GetSpriteIndex()); + icecubes(hitactor, hitspr.x, hitspr.y, hitspr.z, 0); // EG 26 Oct 2017: Move this here from medusa (anti multi-freeze exploit) addscore(&plr, 100); DeleteActor(hitactor); diff --git a/source/games/whaven/src/whplr.cpp b/source/games/whaven/src/whplr.cpp index 90156a28b..f76473ffc 100644 --- a/source/games/whaven/src/whplr.cpp +++ b/source/games/whaven/src/whplr.cpp @@ -91,7 +91,7 @@ void initplayersprite(PLAYER& plr) { plr.z = plr.Sector()->floorz - (plr.height << 8); auto pactor = InsertActor(plr.sector, (short)0); - plr.spritenum = pactor->GetSpriteIndex(); + plr.theactor = pactor; auto& spr = pactor->s(); plr.onsomething = 1; diff --git a/source/games/whaven/src/whtag.cpp b/source/games/whaven/src/whtag.cpp index 11b0ee9c4..b50a41aa7 100644 --- a/source/games/whaven/src/whtag.cpp +++ b/source/games/whaven/src/whtag.cpp @@ -10,7 +10,8 @@ Delayitem delayitem[MAXSECTORS]; short ironbarsector[16]; short ironbarscnt; int ironbarsgoal1[16], ironbarsgoal2[16]; -short ironbarsdone[16], ironbarsanim[16]; +short ironbarsdone[16]; +DWHActor* ironbarsanim[16]; int ironbarsgoal[16]; short warpsectorlist[64], warpsectorcnt; @@ -798,7 +799,7 @@ void operatesector(PLAYER& plr, int s) { if (ironbarsector[k] == s) { ironbarsdone[k] = 1; - switch (sprite[ironbarsanim[k]].picnum) { + switch (ironbarsanim[k]->s().picnum) { case SWINGDOOR: @@ -829,7 +830,7 @@ void operatesector(PLAYER& plr, int s) { break; } - int pic = sprite[ironbarsanim[k]].picnum; + int pic = ironbarsanim[k]->s().picnum; if(pic == SWINGGATE3 || pic == SWINGGATE4 || pic == SWINGGATE5 || pic == GEARS2START) SND_Sound(S_CREAKDOOR1); } diff --git a/wadsrc/static/zscript/games/wh/whgame.zs b/wadsrc/static/zscript/games/wh/whgame.zs index 637bffdb3..776f7b27b 100644 --- a/wadsrc/static/zscript/games/wh/whgame.zs +++ b/wadsrc/static/zscript/games/wh/whgame.zs @@ -232,7 +232,7 @@ struct WhPlayer native { native int hvel; native int sector; native int oldsector; - native int16 spritenum; + //native int16 spritenum; native bool keytoggle; native int flags; native int weapon[Witchaven.MAXWEAPONS], preenchantedweapon[Witchaven.MAXWEAPONS];