diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index bad6db478..bb06747a7 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -305,9 +305,6 @@ int CanHitPlayer(DSWActor* actor) if (hitinfo.sprite == u->targetActor->GetSpriteIndex()) return true; - ////DSPRINTF(ds,"CanHit %s",ret ? "true" : "false"); - //MONO_PRINT(ds); - return false; } diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 1e83280c5..5b868ed1f 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1197,7 +1197,7 @@ void BunnyHatch(short Weapon) np->x = sp->x; np->y = sp->y; np->z = sp->z; - np->owner = -1; + ClearOwner(actorNew); np->xrepeat = 30; // Baby size np->yrepeat = 24; np->ang = rip_ang[i]; @@ -1267,7 +1267,7 @@ int BunnyHatch2(short Weapon) np->x = wp->x; np->y = wp->y; np->z = wp->z; - np->owner = -1; + ClearOwner(actorNew); np->xrepeat = 30; // Baby size np->yrepeat = 24; np->ang = RANDOM_P2(2048); diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 86a3dec4b..c169300b5 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1978,6 +1978,7 @@ void change_actor_stat(DSWActor* actor, int stat); void SetOwner(DSWActor*, DSWActor*); void SetOwner(int a, int b); // we still need this... void ClearOwner(DSWActor* ownr); +DSWActor* GetOwner(DSWActor* child); void SetAttach(DSWActor*, DSWActor*); void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int viewy, int viewz, int camang); void ChangeSpriteState(short SpriteNum, STATEp statep); diff --git a/source/games/sw/src/quake.cpp b/source/games/sw/src/quake.cpp index 843a7af56..f96d14902 100644 --- a/source/games/sw/src/quake.cpp +++ b/source/games/sw/src/quake.cpp @@ -54,11 +54,8 @@ BEGIN_SW_NS short CopyQuakeSpotToOn(SPRITEp sp) { - short New; - SPRITEp np; - - New = COVERinsertsprite(sp->sectnum, STAT_QUAKE_SPOT); - np = &sprite[New]; + auto actorNew = InsertActor(sp->sectnum, STAT_QUAKE_SPOT); + auto np = &actorNew->s(); memcpy(np, sp, sizeof(SPRITE)); @@ -67,13 +64,13 @@ short CopyQuakeSpotToOn(SPRITEp sp) np->cstat = 0; np->extra = 0; - np->owner = -1; + ClearOwner(actorNew); - change_sprite_stat(New, STAT_QUAKE_ON); + change_actor_stat(actorNew, STAT_QUAKE_ON); QUAKE_Duration(np) *= 120; - return New; + return actorNew->GetSpriteIndex(); } @@ -249,19 +246,15 @@ void QuakeViewChange(PLAYERp pp, int *z_diff, int *x_diff, int *y_diff, short *a int SpawnQuake(short sectnum, int x, int y, int z, short tics, short amt, int radius) { - short SpriteNum; - SPRITEp sp; - SpriteNum = COVERinsertsprite(sectnum, STAT_QUAKE_ON); - sp = &sprite[SpriteNum]; - - ASSERT(SpriteNum >= 0); + auto actorNew = InsertActor(sectnum, STAT_QUAKE_ON); + auto sp = &actorNew->s(); sp->x = x; sp->y = y; sp->z = z; sp->cstat = 0; - sp->owner = -1; + ClearOwner(actorNew); sp->extra = 0; QUAKE_Match(sp) = -1; @@ -272,9 +265,9 @@ int SpawnQuake(short sectnum, int x, int y, int z, QUAKE_PosAmt(sp) = 0; PlaySound(DIGI_ERUPTION, sp, v3df_follow|v3df_dontpan); - Set3DSoundOwner(SpriteNum); + Set3DSoundOwner(actorNew->GetSpriteIndex()); - return SpriteNum; + return actorNew->GetSpriteIndex(); } bool diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 4c6bc38f4..d6003538d 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -1263,7 +1263,7 @@ void RipperHatch(short Weapon) np->x = wp->x; np->y = wp->y; np->z = wp->z; - np->owner = -1; + ClearOwner(actorNew); //np->xrepeat = np->yrepeat = 36; np->xrepeat = np->yrepeat = 64; np->ang = rip_ang[i]; diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index bf97735ed..a67f9bf56 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -1274,7 +1274,7 @@ void Ripper2Hatch(short Weapon) np->x = wp->x; np->y = wp->y; np->z = wp->z; - np->owner = -1; + ClearOwner(actorNew); //np->xrepeat = np->yrepeat = 36; np->xrepeat = np->yrepeat = 64; np->ang = rip_ang[i]; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 9a06263f7..e4e0d9a78 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -596,6 +596,12 @@ void SetOwner(DSWActor* ownr, DSWActor* child) } +DSWActor* GetOwner(DSWActor* child) +{ + if (!child || child->s().owner < 0) return nullptr; + return &swActors[child->s().owner]; +} + void ClearOwner(DSWActor* child) { if (child) child->s().owner = -1; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 70d4a81c2..5f9d7409a 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -11712,7 +11712,7 @@ SpawnSectorExp(int16_t Weapon) eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness - exp->owner = -1; + ClearOwner(expActor); exp->shade = -40; exp->xrepeat = 90; // was 40,40 exp->yrepeat = 90; @@ -11745,7 +11745,7 @@ SpawnLargeExp(int16_t Weapon) eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness - exp->owner = -1; + ClearOwner(expActor); exp->shade = -40; exp->xrepeat = 90; // was 40,40 exp->yrepeat = 90; @@ -11788,11 +11788,12 @@ SpawnMeteorExp(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 0); } + auto expActor = &swActors[explosion]; exp = &sprite[explosion]; eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness - exp->owner = -1; + ClearOwner(expActor); exp->shade = -40; if (sp->yrepeat < 64) { @@ -11830,7 +11831,7 @@ SpawnLittleExp(int16_t Weapon) eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness - exp->owner = -1; + ClearOwner(expActor); exp->shade = -127; SET(exp->cstat, CSTAT_SPRITE_YCENTER); @@ -16048,11 +16049,12 @@ SpawnDemonFist(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, 0, s_TeleportEffect, sp->sectnum, sp->x, sp->y, SPRITEp_MID(sp), sp->ang, 0); + auto expActor = &swActors[explosion]; exp = &sprite[explosion]; eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness - exp->owner = -1; + ClearOwner(expActor); exp->shade = -40; exp->xrepeat = 32; exp->yrepeat = 32;