diff --git a/source/games/whaven/src/ai.cpp b/source/games/whaven/src/ai.cpp index e5a3d54b1..62287081c 100644 --- a/source/games/whaven/src/ai.cpp +++ b/source/games/whaven/src/ai.cpp @@ -633,7 +633,7 @@ void castspell(PLAYER& plr, DWHActor* actor) { else spawned.zvel = (short)(((plr.z + (48 << 8) - spawned.z) << 7) / discrim); - spawned.owner = (short)actor->GetSpriteIndex(); + spawnedactor->SetOwner(actor); spawned.clipdist = 16; spawned.lotag = 512; spawned.hitag = 0; diff --git a/source/games/whaven/src/aigoblin.cpp b/source/games/whaven/src/aigoblin.cpp index 0d9e73757..07725250c 100644 --- a/source/games/whaven/src/aigoblin.cpp +++ b/source/games/whaven/src/aigoblin.cpp @@ -379,7 +379,7 @@ static void goblinWar(PLAYER& plr, DWHActor* actor) if (dist < olddist) { found = true; olddist = dist; - spr.owner = itActor->GetSpriteIndex(); + actor->SetOwner(itActor); spr.ang = getangle(spk.x - spr.x, spk.y - spr.y); spr.extra = 1; } @@ -403,7 +403,9 @@ static void goblinWar(PLAYER& plr, DWHActor* actor) } case 1: // chase { - auto owneractor = &whActors[spr.owner]; + auto owneractor = actor->GetOwner(); + assert(owneractor); + if (!owneractor) break; auto ownerspr = owneractor->s(); auto moveStat = aimove(actor); @@ -415,8 +417,7 @@ static void goblinWar(PLAYER& plr, DWHActor* actor) spr.lotag = 60; } else if (moveStat.type == kHitSprite) { - int sprnum = moveStat.actor->GetSpriteIndex(); - if (sprnum != spr.owner) { + if (moveStat.actor != owneractor) { spr.extra = 3; spr.ang = (short)((spr.ang + (krand() & 256 - 128)) & 2047); spr.lotag = 60; @@ -440,7 +441,9 @@ static void goblinWar(PLAYER& plr, DWHActor* actor) } case 2: // attack { - auto owneractor = &whActors[spr.owner]; + auto owneractor = actor->GetOwner(); + assert(owneractor); + if (!owneractor) break; auto& ownerspr = owneractor->s(); if (checkdist(actor, ownerspr.x, ownerspr.y, ownerspr.z)) { if ((krand() & 1) != 0) { @@ -594,7 +597,7 @@ void premapGoblin(DWHActor* actor) { if (spr.pal != 0) spr.xrepeat = 30; spr.extra = 0; - spr.owner = 0; + actor->SetOwner(nullptr); spr.hitag = ohitag; return; } diff --git a/source/games/whaven/src/aigonzo.cpp b/source/games/whaven/src/aigonzo.cpp index e87ca5e51..0d874741f 100644 --- a/source/games/whaven/src/aigonzo.cpp +++ b/source/games/whaven/src/aigonzo.cpp @@ -801,7 +801,7 @@ void deaddude(short sn) { spawned.pal = 0; spawned.xrepeat = spr.xrepeat; spawned.yrepeat = spr.yrepeat; - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.lotag = 0; spawned.hitag = 0; spawned.backuploc(); diff --git a/source/games/whaven/src/airat.cpp b/source/games/whaven/src/airat.cpp index b264e44f8..22142289b 100644 --- a/source/games/whaven/src/airat.cpp +++ b/source/games/whaven/src/airat.cpp @@ -21,7 +21,7 @@ static void facerat(PLAYER& plr, DWHActor* actor) spr.ang = getangle(plr.x - spr.x, plr.y - spr.y); spr.ang = (short) (((krand() & 512 - 256) + spr.ang + 1024) & 2047); // NEW - spr.owner = plr.actor()->s().owner; + actor->SetPlayerOwner(plr.playerNum()); SetNewStatus(actor, FLEE); } @@ -53,13 +53,13 @@ static void fleerat(PLAYER& plr, DWHActor* actor) if (moveStat.type == kHitSprite) { SPRITE& sp = moveStat.actor->s(); - spr.owner = moveStat.actor->GetSpriteIndex(); + actor->SetOwner(moveStat.actor); spr.ang = getangle(sp.x - spr.x, sp.y - spr.y); spr.ang = (short)(((krand() & 512 - 256) + spr.ang + 1024) & 2047); } if (abs(plr.x - spr.x) <= 1024 && abs(plr.y - spr.y) <= 1024) { - spr.owner = plr.actor()->s().owner; + actor->SetPlayerOwner(plr.playerNum()); SetNewStatus(actor, FACE); } diff --git a/source/games/whaven/src/animatesprites.cpp b/source/games/whaven/src/animatesprites.cpp index ac28c33f0..7f5412fd4 100644 --- a/source/games/whaven/src/animatesprites.cpp +++ b/source/games/whaven/src/animatesprites.cpp @@ -3,7 +3,7 @@ BEGIN_WH_NS -void analyzesprites(PLAYER& plr, int dasmoothratio,spritetype* tsprite, int& spritesortcnt) +void analyzesprites(PLAYER& plr, int dasmoothratio,tspritetype* tsprite, int& spritesortcnt) { int k; tspritelistcnt = spritesortcnt; diff --git a/source/games/whaven/src/items.cpp b/source/games/whaven/src/items.cpp index f9d885634..bba4f94e4 100644 --- a/source/games/whaven/src/items.cpp +++ b/source/games/whaven/src/items.cpp @@ -354,7 +354,7 @@ void InitItems() break; case 6: for (j = 0; j < 8; j++) - explosion(actor->GetSpriteIndex(), spr.x, spr.y, spr.z, spr.owner); + explosion(actor->GetSpriteIndex(), spr.x, spr.y, spr.z, 0); spritesound(S_EXPLODE, actor); DeleteActor(actor); break; diff --git a/source/games/whaven/src/player.h b/source/games/whaven/src/player.h index 20cc0a031..82ec455a1 100644 --- a/source/games/whaven/src/player.h +++ b/source/games/whaven/src/player.h @@ -25,6 +25,7 @@ struct PLAYER { short spritenum; DWHActor* actor() { return &whActors[spritenum]; } sectortype* Sector() { return &::sector[sector]; } + int playerNum(); boolean keytoggle; int flags; int weapon[MAXWEAPONS], preenchantedweapon[MAXWEAPONS]; diff --git a/source/games/whaven/src/weapons.cpp b/source/games/whaven/src/weapons.cpp index 0d4f92ea9..5cd87f067 100644 --- a/source/games/whaven/src/weapons.cpp +++ b/source/games/whaven/src/weapons.cpp @@ -1720,7 +1720,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = 0; spawned.yvel = 0; spawned.zvel = 0; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 32; spawned.hitag = 0; spawned.backuploc(); @@ -1743,7 +1743,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = 0; spawned.yvel = 0; spawned.zvel = 0; - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.lotag = 1200; spawned.hitag = 0; spawned.backuploc(); @@ -1771,7 +1771,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = 0; spawned.yvel = 0; spawned.zvel = 0; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 32; spawned.hitag = 0; movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3, @@ -1978,7 +1978,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { } else { spawned.zvel = plr.horizon.horiz.asq16() >> 12; } - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2005,7 +2005,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = plr.horizon.horiz.asq16() >> 12; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2034,7 +2034,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.yvel = (short) ((krand() & 256) - 128); // spawned.zvel=((krand()&256)-128); spawned.zvel = plr.horizon.horiz.asq16() >> 12; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2075,7 +2075,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = plr.horizon.horiz.asq16() >> 12; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2102,7 +2102,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = plr.horizon.horiz.asq16() >> 12; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2129,7 +2129,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = (short) ((krand() & 256) - 128); - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; @@ -2168,7 +2168,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.zvel = plr.horizon.horiz.asq16() >> 12; } - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 256; spawned.hitag = 0; spawned.clipdist = 48; @@ -2209,7 +2209,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.zvel = plr.horizon.horiz.asq16() >> 12; } - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 256; spawned.hitag = 0; spawned.clipdist = 64; @@ -2259,7 +2259,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { case WILLOWTYPE: if (cansee(plr.x, plr.y, plr.z, plr.sector, spk.x, spk.y, spk.z - (tileHeight(spk.picnum) << 7), spk.sectnum)) - if ((isWh2() && spk.owner != plr.actor()->s().owner) + if ((isWh2() && itActor->GetPlayerOwner() != plr.playerNum()) || checkmedusadist(j, plr.x, plr.y, plr.z, 12)) nukespell(plr, j); break; diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index ec63c82e7..16710cedb 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -209,6 +209,10 @@ void spikeanimation(PLAYER& plr); // whplr extern PLAYER player[MAXPLAYERS]; +inline int PLAYER::playerNum() +{ + return int(this - player); +} extern PLOCATION gPrevPlayerLoc[MAXPLAYERS]; extern short monsterangle[MAXSPRITESONSCREEN], monsterlist[MAXSPRITESONSCREEN]; extern int shootgunzvel; diff --git a/source/games/whaven/src/whactor.h b/source/games/whaven/src/whactor.h index d1ea05f72..3bfca045c 100644 --- a/source/games/whaven/src/whactor.h +++ b/source/games/whaven/src/whactor.h @@ -49,11 +49,6 @@ public: s().owner = other->s().owner; } - bool CompareOwner(DWHActor* other) - { - return s().owner == other->s().owner; - } - int GetSpriteIndex() const { return index; diff --git a/source/games/whaven/src/whani.cpp b/source/games/whaven/src/whani.cpp index 13247a5d0..8e844de93 100644 --- a/source/games/whaven/src/whani.cpp +++ b/source/games/whaven/src/whani.cpp @@ -267,7 +267,7 @@ void animateobjs(PLAYER& plr) { spawned.pal = 0; spawned.xrepeat = spr.xrepeat; spawned.yrepeat = spr.yrepeat; - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.lotag = 40; spawned.hitag = 0; spawned.detail = GONZOTYPE; @@ -784,7 +784,7 @@ void animateobjs(PLAYER& plr) { if (moveStat.type == kHitSprite) { // Bullet hit a sprite - if (spr.owner != moveStat.actor->GetSpriteIndex()) { + if (actor->GetOwner() != moveStat.actor) { hitdamage = damageactor(plr, moveStat.actor, actor); if (hitdamage) { SetNewStatus(actor, BROKENVASE); @@ -971,7 +971,7 @@ void animateobjs(PLAYER& plr) { } if (moveStat.type != kHitNone && spr.picnum == MONSTERBALL) - if (actor->CompareOwner(plr.actor())) { + if (actor->GetPlayerOwner() == plr.playerNum()) { explosion2(i, spr.x, spr.y, spr.z, i); } else { explosion(i, spr.x, spr.y, spr.z, i); @@ -990,7 +990,7 @@ void animateobjs(PLAYER& plr) { } else if (moveStat.type == kHitWall) { // hit a wall if (spr.picnum == MONSTERBALL) { - if (actor->CompareOwner(plr.actor())) + if (actor->GetPlayerOwner() == plr.playerNum()) explosion2(i, spr.x, spr.y, spr.z, i); else explosion(i, spr.x, spr.y, spr.z, i); @@ -1009,13 +1009,13 @@ void animateobjs(PLAYER& plr) { if (moveStat.type == kHitSprite) { // Bullet hit a sprite if (spr.picnum == MONSTERBALL) { - if (actor->CompareOwner(plr.actor())) + if (actor->GetPlayerOwner() == plr.playerNum()) explosion2(i, spr.x, spr.y, spr.z, i); else explosion(i, spr.x, spr.y, spr.z, i); } - if (spr.owner != moveStat.actor->GetSpriteIndex()) + if (actor->GetOwner() != moveStat.actor) hitdamage = damageactor(plr, moveStat.actor, actor); if (hitdamage) { DeleteActor(actor); @@ -1345,7 +1345,7 @@ void animateobjs(PLAYER& plr) { spawned.xrepeat = spr.xrepeat; spawned.yrepeat = spr.yrepeat; - spawned.owner = spr.owner; + spawnedactor->CopyOwner(actor); spawned.lotag = 256; spawned.hitag = 0; spawned.backuploc(); @@ -1379,7 +1379,7 @@ void animateobjs(PLAYER& plr) { int dz = abs((spr.z >> 8) - (tspr.z >> 8)); // z distance to sprite int dh = tileHeight(tspr.picnum) >> 1; // height of sprite if (dx + dy < PICKDISTANCE && dz - dh <= getPickHeight()) { - if (tspr.owner == 4096) { + if (sectactor->GetPlayerOwner() == 0) { // strcpy(displaybuf,"hit player"); } else { switch (tspr.detail) { diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index 021cb1461..f6c3e3e4f 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -813,7 +813,7 @@ void makeasplash(int picnum, PLAYER& plr) { spawned.pal = 0; spawned.xrepeat = 64; spawned.yrepeat = 64; - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.clipdist = 16; spawned.lotag = 8; spawned.hitag = 0; @@ -861,7 +861,7 @@ void makemonstersplash(int picnum, int i) { spawned.xrepeat = 64; spawned.yrepeat = 64; } - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.clipdist = 16; spawned.lotag = 8; spawned.hitag = 0; @@ -892,22 +892,24 @@ void makemonstersplash(int picnum, int i) { } void bats(PLAYER& plr, int k) { - auto spawnedactor = InsertActor(sprite[k].sectnum, FLOCK); + auto actor = &whActors[k]; + auto& spr = actor->s(); + auto spawnedactor = InsertActor(spr.sectnum, FLOCK); auto& spawned = spawnedactor->s(); - spawned.x = sprite[k].x; - spawned.y = sprite[k].y; - spawned.z = sprite[k].z; + spawned.x = spr.x; + spawned.y = spr.y; + spawned.z = spr.z; spawned.cstat = 0; spawned.picnum = BAT; spawned.shade = 0; spawned.xrepeat = 64; spawned.yrepeat = 64; - spawned.ang = (short) ((sprite[k].ang + (krand() & 128 - 256)) & 2047); - spawned.owner = (short) k; + spawned.ang = (short) ((spr.ang + (krand() & 128 - 256)) & 2047); + spawnedactor->SetOwner(actor); spawned.clipdist = 16; spawned.lotag = 128; - spawned.hitag = (short) k; + spawned.hitag = (short) k; // see: flying in circles spawned.extra = 0; spawned.backuploc(); @@ -998,14 +1000,16 @@ void lavadryland() { } void warpfxsprite(int s) { + auto actor = &whActors[s]; + auto& spr = actor->s(); PLAYER& plr = player[pyrn]; - auto spawnedactor = InsertActor(sprite[s].sectnum, WARPFX); + auto spawnedactor = InsertActor(spr.sectnum, WARPFX); auto& spawned = spawnedactor->s(); - spawned.x = sprite[s].x; - spawned.y = sprite[s].y; - spawned.z = sprite[s].z - (32 << 8); + spawned.x = spr.x; + spawned.y = spr.y; + spawned.z = spr.z - (32 << 8); spawned.cstat = 0; @@ -1015,7 +1019,7 @@ void warpfxsprite(int s) { daang = plr.angle.ang.asbuild(); spawned.ang = daang; } else { - daang = sprite[s].ang; + daang = spr.ang; spawned.ang = daang; } @@ -1028,7 +1032,7 @@ void warpfxsprite(int s) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = (short) ((krand() & 256) - 128); - spawned.owner = (short) s; + spawnedactor->SetOwner(actor); spawned.lotag = 12; spawned.hitag = 0; spawned.pal = 0; @@ -1121,7 +1125,7 @@ void makesparks(short i, int type) { spawned.xrepeat = 24; spawned.yrepeat = 24; spawned.ang = (short) ((krand() % 2047) & 2047); - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.clipdist = 16; spawned.lotag = (short) (krand() % 100); spawned.hitag = 0; @@ -1132,20 +1136,22 @@ void makesparks(short i, int type) { } void shards(int i, int type) { - auto spawnedactor = InsertActor(sprite[i].sectnum, SHARDOFGLASS); + auto actor = &whActors[i]; + auto& spr = actor->s(); + auto spawnedactor = InsertActor(spr.sectnum, SHARDOFGLASS); auto& spawned = spawnedactor->s(); - spawned.x = sprite[i].x + (((krand() % 512) - 256) << 2); - spawned.y = sprite[i].y + (((krand() % 512) - 256) << 2); - spawned.z = sprite[i].z - (getPlayerHeight() << 8) + (((krand() % 48) - 16) << 7); + spawned.x = spr.x + (((krand() % 512) - 256) << 2); + spawned.y = spr.y + (((krand() % 512) - 256) << 2); + spawned.z = spr.z - (getPlayerHeight() << 8) + (((krand() % 48) - 16) << 7); spawned.zvel = (short) (krand() % 256); spawned.cstat = 0; spawned.picnum = (short) (SHARD + (krand() % 3)); spawned.shade = 0; spawned.xrepeat = 64; spawned.yrepeat = 64; - spawned.ang = (short) (sprite[i].ang + ((krand() % 512) - 256) & 2047); - spawned.owner = (short) i; + spawned.ang = (short) (spr.ang + ((krand() % 512) - 256) & 2047); + spawnedactor->SetOwner(actor); spawned.clipdist = 16; spawned.lotag = (short) (120 + (krand() % 100)); spawned.hitag = 0; diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index 134569de0..89ee2a104 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -774,9 +774,11 @@ boolean prepareboard(const char* fname) { if (justteleported) { // next level plr.hvel = 0; - plr.spritenum = insertsprite(plr.sector, (short) 0); + auto pactor = InsertActor(plr.sector, (short)0); + auto& pspr = pactor->s(); + + plr.spritenum = pactor->GetSpriteIndex(); plr.oldsector = plr.sector; - auto& pspr = plr.actor()->s(); pspr.x = plr.x; pspr.y = plr.y; @@ -790,7 +792,7 @@ boolean prepareboard(const char* fname) { pspr.xvel = 0; pspr.yvel = 0; pspr.zvel = 0; - pspr.owner = (short) (4096 + myconnectindex); + pactor->SetPlayerOwner(myconnectindex); pspr.lotag = 0; pspr.hitag = 0; pspr.pal = (short) (isWh2() ? 10 : 1); diff --git a/source/games/whaven/src/whobj.cpp b/source/games/whaven/src/whobj.cpp index 32bd3e196..dc6c69615 100644 --- a/source/games/whaven/src/whobj.cpp +++ b/source/games/whaven/src/whobj.cpp @@ -127,7 +127,7 @@ void processobjs(PLAYER& plr) { if(isItemSprite(actor->GetSpriteIndex())) items[(tspr.detail & 0xFF) - ITEMSBASE].pickup(plr, actor); - if (tspr.picnum >= EXPLOSTART && tspr.picnum <= EXPLOEND && tspr.owner != plr.actor()->s().owner) + if (tspr.picnum >= EXPLOSTART && tspr.picnum <= EXPLOEND && actor->GetPlayerOwner() != plr.playerNum()) if (plr.manatime < 1) addhealth(plr, -1); } @@ -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, spr.owner); + explosion(sn, 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, spr.owner); + explosion(sn, spr.x, spr.y, spr.z, 0); DeleteActor(actor); addscore(aiGetPlayerTarget(actor), 1500); kills++; @@ -1372,12 +1372,14 @@ void newstatus(short sn, int seq) { } void makeafire(int i, int firetype) { - auto spawnedactor = InsertActor(sprite[i].sectnum, FIRE); + auto actor = &whActors[i]; + auto& spr = actor->s(); + auto spawnedactor = InsertActor(spr.sectnum, FIRE); auto& spawned = spawnedactor->s(); - spawned.x = sprite[i].x + (krand() & 1024) - 512; - spawned.y = sprite[i].y + (krand() & 1024) - 512; - spawned.z = sprite[i].z; + spawned.x = spr.x + (krand() & 1024) - 512; + spawned.y = spr.y + (krand() & 1024) - 512; + spawned.z = spr.z; spawned.cstat = 0; spawned.xrepeat = 64; @@ -1386,7 +1388,8 @@ void makeafire(int i, int firetype) { spawned.shade = 0; spawned.clipdist = 64; - spawned.owner = sprite[i].owner; + + spawnedactor->CopyOwner(actor); spawned.lotag = 2047; spawned.hitag = 0; ChangeActorStat(spawnedactor, FIRE); @@ -1394,7 +1397,10 @@ void makeafire(int i, int firetype) { } void explosion(int i, int x, int y, int z, int ownr) { - auto spawnedactor = InsertActor(sprite[i].sectnum, EXPLO); + auto actor = &whActors[i]; + auto& spr = actor->s(); + + auto spawnedactor = InsertActor(spr.sectnum, EXPLO); auto& spawned = spawnedactor->s(); boolean isWH2 = isWh2(); @@ -1418,7 +1424,7 @@ void explosion(int i, int x, int y, int z, int ownr) { spawned.xvel = (short) ((krand() & 511) - 256); spawned.yvel = (short) ((krand() & 511) - 256); spawned.zvel = (short) ((krand() & 511) - 256); - spawned.owner = sprite[i].owner; + spawnedactor->CopyOwner(actor); spawned.hitag = 0; spawned.pal = 0; if(!isWH2) { @@ -1432,7 +1438,9 @@ void explosion(int i, int x, int y, int z, int ownr) { } void explosion2(int i, int x, int y, int z, int ownr) { - auto spawnedactor = InsertActor(sprite[i].sectnum, EXPLO); + auto actor = &whActors[i]; + auto& spr = actor->s(); + auto spawnedactor = InsertActor(spr.sectnum, EXPLO); auto& spawned = spawnedactor->s(); boolean isWH2 = isWh2(); @@ -1457,7 +1465,7 @@ void explosion2(int i, int x, int y, int z, int ownr) { spawned.xvel = (short) ((krand() & 256) - 128); spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = (short) ((krand() & 256) - 128); - spawned.owner = sprite[i].owner; + spawnedactor->CopyOwner(actor); spawned.hitag = 0; spawned.pal = 0; @@ -1494,7 +1502,7 @@ void trailingsmoke(DWHActor* actor, boolean ball) { } spawned.pal = 0; - spawned.owner = spr.owner; + spawnedactor->CopyOwner(actor); spawned.lotag = 256; spawned.hitag = 0; spawned.backuploc(); @@ -1523,8 +1531,8 @@ void icecubes(int i, int x, int y, int z, int ownr) { spawned.zvel = (short) ((krand() & 1023) - 512); spawned.pal = 6; - spawned.owner = spr.owner; - + spawnedactor->CopyOwner(actor); + if(isWh2()) spawned.lotag = 2048; else spawned.lotag = 999; @@ -1537,10 +1545,11 @@ boolean damageactor(PLAYER& plr, DWHActor* hitactor, DWHActor* actor) { auto& spr = actor->s(); auto& hitspr = hitactor->s(); - if (hitactor == plr.actor() && actor->CompareOwner(plr.actor())) + if (hitactor == plr.actor() && actor->GetPlayerOwner() == plr.playerNum()) return false; - if (hitactor == plr.actor() && spr.owner != plr.actor()->s().owner) { + if (hitactor == plr.actor() && actor->GetPlayerOwner() != plr.playerNum()) + { if (plr.invincibletime > 0 || plr.godMode) { DeleteActor(actor); return false; @@ -1609,7 +1618,7 @@ boolean damageactor(PLAYER& plr, DWHActor* hitactor, DWHActor* actor) } if (hitactor == plr.actor() && !netgame) // Les 08/11/95 - if (spr.owner != hitactor->GetSpriteIndex()) { + if (actor->GetOwner() != hitactor) { // final int DEMONTYPE = 1; XXX // final int DRAGONTYPE = 3; @@ -1834,7 +1843,7 @@ void trowajavlin(int s) { spawned.yvel = (short) ((krand() & 256) - 128); spawned.zvel = (short) ((krand() & 256) - 128); - spawned.owner = 0; + spawnedactor->SetOwner(nullptr); spawned.lotag = 0; spawned.hitag = 0; spawned.pal = 0; diff --git a/source/games/whaven/src/whplr.cpp b/source/games/whaven/src/whplr.cpp index 056405dde..a268d0770 100644 --- a/source/games/whaven/src/whplr.cpp +++ b/source/games/whaven/src/whplr.cpp @@ -90,8 +90,9 @@ void initplayersprite(PLAYER& plr) { plr.height = getPlayerHeight(); plr.z = plr.Sector()->floorz - (plr.height << 8); - plr.spritenum = (short) insertsprite(plr.sector, (short) 0); - auto& spr = sprite[plr.spritenum]; + auto pactor = InsertActor(plr.sector, (short)0); + plr.spritenum = pactor->GetSpriteIndex(); + auto& spr = pactor->s(); plr.onsomething = 1; @@ -107,7 +108,7 @@ void initplayersprite(PLAYER& plr) { spr.xvel = 0; spr.yvel = 0; spr.zvel = 0; - spr.owner = (short) (4096 + myconnectindex); + pactor->SetPlayerOwner(myconnectindex); spr.lotag = 0; spr.hitag = 0; spr.pal = (short) (isWh2() ? 10 : 1); @@ -427,7 +428,7 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz, spawned.zvel = (short) ((krand() & 1023) - 512); if (newchunk == 1) spawned.zvel <<= 1; - spawnedactor->CopyOwner(plr.actor()); + spawnedactor->SetPlayerOwner(plr.playerNum()); spawned.lotag = 512; spawned.hitag = 0; spawned.pal = 0;