From 740c5e1e567489c974089a842686c3c78364f598 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Oct 2021 22:44:16 +0200 Subject: [PATCH] - DoSuicide --- source/games/sw/src/actor.cpp | 3 +- source/games/sw/src/break.cpp | 5 ++- source/games/sw/src/bunny.cpp | 6 +-- source/games/sw/src/coolg.cpp | 2 +- source/games/sw/src/jweapon.cpp | 8 ++-- source/games/sw/src/player.cpp | 8 ++-- source/games/sw/src/skull.cpp | 4 +- source/games/sw/src/sprite.cpp | 4 +- source/games/sw/src/weapon.cpp | 68 ++++++++++++++++----------------- source/games/sw/src/weapon.h | 2 +- source/games/sw/src/zombie.cpp | 4 +- 11 files changed, 57 insertions(+), 57 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 6f2783b3d..d0a6e2d1b 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -327,7 +327,6 @@ int DoActorSectorDamage(DSWActor* actor) SPRITEp sp = &actor->s(); SECT_USERp sectu = SectUser[sp->sectnum].Data(); SECTORp sectp = §or[sp->sectnum]; - int SpriteNum = actor->GetSpriteIndex(); if (u->Health <= 0) return false; @@ -374,7 +373,7 @@ int DoActorSectorDamage(DSWActor* actor) if (SpawnShrap(actor, nullptr, WPN_NM_SECTOR_SQUISH)) { UpdateSinglePlayKills(actor); - SetSuicide(SpriteNum); + SetSuicide(actor); } else { diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 18330540d..4cb7b615c 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -838,6 +838,7 @@ bool HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, short ang, short ty int KillBreakSprite(short BreakSprite) { + auto breakActor = &swActors[BreakSprite]; SPRITEp bp = &sprite[BreakSprite]; USERp bu = User[BreakSprite].Data(); @@ -856,11 +857,11 @@ int KillBreakSprite(short BreakSprite) // a few things have users and are not StateControlled KillSprite(BreakSprite); else - SetSuicide(BreakSprite); + SetSuicide(breakActor); } else { - change_sprite_stat(BreakSprite, STAT_SUICIDE); + change_actor_stat(breakActor, STAT_SUICIDE); } return 0; diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 22e06a316..b86f4e5e5 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1005,7 +1005,7 @@ DoBunnyQuickJump(DSWActor* actor) if (SpawnShrap(hitActor, actor)) { - SetSuicide(hit_sprite); + SetSuicide(hitActor); } else DoActorDie(hitActor, actor, 0); @@ -1225,7 +1225,7 @@ void BunnyHatch(short Weapon) if (SpawnShrap(actor, actorNew)) { - SetSuicide(Weapon); + SetSuicide(actor); } else DoActorDie(actor, actorNew, 0); @@ -1336,7 +1336,7 @@ DoBunnyMove(DSWActor* actor) // Sometimes they just won't die! if (u->Health <= 0) - SetSuicide(SpriteNum); + SetSuicide(actor); if (u->scale_speed) { diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 1202950e5..041c32f97 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -633,7 +633,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor) InitBloodSpray(SpriteNum, true, 105); InitBloodSpray(SpriteNum, true, 105); UpdateSinglePlayKills(actor); - SetSuicide(SpriteNum); + SetSuicide(actor); } // actor does a sine wave about u->sz - this is the z mid point diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index df6b3f11f..59fd37109 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -2256,7 +2256,7 @@ DoCarryFlag(DSWActor* actor) } } } - SetSuicide(Weapon); // Kill the flag, you scored! + SetSuicide(actor); // Kill the flag, you scored! } } else @@ -2328,7 +2328,7 @@ DoCarryFlag(DSWActor* actor) break; case FLAG_DETONATE_STATE + 1: SpawnGrenadeExp(Weapon); - SetSuicide(Weapon); + SetSuicide(actor); return false; break; } @@ -2368,7 +2368,7 @@ DoCarryFlagNoDet(DSWActor* actor) { if (u->FlagOwner >= 0) fu->WaitTics = 0; // Tell it to respawn - SetSuicide(Weapon); + SetSuicide(actor); return false; } @@ -2399,7 +2399,7 @@ DoCarryFlagNoDet(DSWActor* actor) } } } - SetSuicide(Weapon); // Kill the flag, you scored! + SetSuicide(actor); // Kill the flag, you scored! } return false; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index ffa1427a5..831083a9f 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2647,7 +2647,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) UpdateSinglePlayKills(actor); if (SpawnShrap(actor, nullptr, -99)) - SetSuicide(i); + SetSuicide(actor); else KillSprite(i); } @@ -2719,7 +2719,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) if (sp->statnum == STAT_ENEMY) { if (SpawnShrap(actor, nullptr, -99)) - SetSuicide(i); + SetSuicide(actor); else KillSprite(i); } @@ -4915,7 +4915,7 @@ DoPlayerFireOutWater(PLAYERp pp) if (pp->WadeDepth > 20) { if (u->flame >= 0) - SetSuicide(u->flame); + SetSuicide(&swActors[u->flame]); u->flame = -2; } } @@ -4929,7 +4929,7 @@ DoPlayerFireOutDeath(PLAYERp pp) return; if (u->flame >= 0) - SetSuicide(u->flame); + SetSuicide(&swActors[u->flame]); u->flame = -2; } diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 156b37bbc..46ed570f0 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -359,7 +359,7 @@ DoSkullBeginDeath(DSWActor* actor) sp->shade = -40; SpawnLittleExp(SpriteNum); - SetSuicide(SpriteNum); + SetSuicide(actor); //u->spal = sp->pal = PALETTE_RED_LIGHTING; @@ -775,7 +775,7 @@ DoBettyBeginDeath(DSWActor* actor) sp->shade = -40; SpawnLittleExp(SpriteNum); - SetSuicide(SpriteNum); + SetSuicide(actor); //u->spal = sp->pal = PALETTE_RED_LIGHTING; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 064fa4205..3605cec1e 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -778,7 +778,7 @@ KillSprite(int16_t SpriteNum) if (u->flame >= 0) { - SetSuicide(u->flame); + SetSuicide(&swActors[u->flame]); } User[SpriteNum].Clear(); } @@ -5014,7 +5014,7 @@ ActorDrop(short SpriteNum, int x, int y, int z, short new_sector, short min_heig if (florhit < 0 || ceilhit < 0) { - //SetSuicide(SpriteNum); + //SetSuicide(actor); return true; } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 26b4a9689..971dbe741 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3565,7 +3565,7 @@ AutoShrap: p = StoneShrap; shrap_xsize = shrap_ysize = 4; shrap_bounce = true; - SetSuicide(short(parent - sprite)); // kill next iteration + SetSuicide(parentActor); // kill next iteration break; case BOLT_EXP: return false; @@ -4431,8 +4431,9 @@ VehicleMoveHit(short SpriteNum) bool WeaponMoveHit(short SpriteNum) { - USERp u = User[SpriteNum].Data(); - SPRITEp sp = User[SpriteNum]->SpriteP; + auto actor = &swActors[SpriteNum]; + USERp u = actor->u(); + SPRITEp sp = &actor->s(); if (!u->ret) @@ -4441,7 +4442,7 @@ WeaponMoveHit(short SpriteNum) switch (TEST(u->ret, HIT_MASK)) { case HIT_PLAX_WALL: - SetSuicide(SpriteNum); + SetSuicide(actor); return true; case HIT_SECTOR: @@ -4476,7 +4477,7 @@ WeaponMoveHit(short SpriteNum) if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 0) { SpawnSplash(SpriteNum); - //SetSuicide(SpriteNum); + //SetSuicide(actor); return true; } @@ -4512,7 +4513,7 @@ WeaponMoveHit(short SpriteNum) { if (labs(sp->z - sectp->ceilingz) < SPRITEp_SIZE_Z(sp)) { - SetSuicide(SpriteNum); + SetSuicide(actor); return true; } } @@ -4894,10 +4895,8 @@ DoBreakFlames(DSWActor* actor) return 0; } -int -SetSuicide(short SpriteNum) +int SetSuicide(DSWActor* actor) { - auto actor = &swActors[SpriteNum]; USERp u = actor->u(); if (u != nullptr) @@ -5074,7 +5073,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) PlaySound(DIGI_TOILETGIRLSCREAM, sp, v3df_none); } if (SpawnShrap(actor, weapActor)) - SetSuicide(SpriteNum); + SetSuicide(actor); break; } @@ -5083,7 +5082,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) InitBloodSpray(SpriteNum,true,105); InitBloodSpray(SpriteNum,true,105); if (SpawnShrap(actor, weapActor)) - SetSuicide(SpriteNum); + SetSuicide(actor); break; default: @@ -5153,7 +5152,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) if (SpawnShrap(actor, weapActor)) { - SetSuicide(SpriteNum); + SetSuicide(actor); } else DoActorDie(actor, weapActor, 0); @@ -5163,7 +5162,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) #if 0 case PLASMA_FOUNTAIN: if (SpawnShrap(SpriteNum, Weapon)) - SetSuicide(SpriteNum); + SetSuicide(actor); else DoActorDie(actor, weapActor, 0); break; @@ -5237,7 +5236,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) if (SpawnShrap(actor, weapActor)) { - SetSuicide(SpriteNum); + SetSuicide(actor); } else DoActorDie(actor, weapActor, 0); @@ -5928,7 +5927,7 @@ DoDamage(short SpriteNum, short Weapon) PlayerSound(TauntAIVocs[choosesnd],v3df_dontpan|v3df_follow,pp); } SpawnShrap(actor, weapActor); - SetSuicide(SpriteNum); + SetSuicide(actor); return 0; } } @@ -6331,7 +6330,7 @@ DoDamage(short SpriteNum, short Weapon) StarBlood(SpriteNum, Weapon); wu->ID = 0; - SetSuicide(Weapon); + SetSuicide(weapActor); break; case SPEAR_R0: @@ -6364,7 +6363,7 @@ DoDamage(short SpriteNum, short Weapon) SpawnBlood(actor, weapActor, 0, 0, 0, 0); wu->ID = 0; - SetSuicide(Weapon); + SetSuicide(weapActor); break; case LAVA_BOULDER: @@ -6395,7 +6394,7 @@ DoDamage(short SpriteNum, short Weapon) SpawnBlood(actor, weapActor, 0, 0, 0, 0); wu->ID = 0; - SetSuicide(Weapon); + SetSuicide(weapActor); break; case LAVA_SHARD: @@ -6426,7 +6425,7 @@ DoDamage(short SpriteNum, short Weapon) SpawnBlood(actor, weapActor, 0, 0, 0, 0); wu->ID = 0; - SetSuicide(Weapon); + SetSuicide(weapActor); break; case UZI_SMOKE: @@ -6555,7 +6554,7 @@ DoDamage(short SpriteNum, short Weapon) ActorStdMissile(SpriteNum, Weapon); } - SetSuicide(Weapon); + SetSuicide(weapActor); break; case SERP_METEOR: @@ -6582,7 +6581,7 @@ DoDamage(short SpriteNum, short Weapon) ActorStdMissile(SpriteNum, Weapon); } - SetSuicide(Weapon); + SetSuicide(weapActor); break; case BOLT_THINMAN_R0: @@ -6611,7 +6610,7 @@ DoDamage(short SpriteNum, short Weapon) SpawnNuclearExp(Weapon); else SpawnBoltExp(Weapon); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case BOLT_THINMAN_R1: @@ -6656,7 +6655,7 @@ DoDamage(short SpriteNum, short Weapon) wu->ID = 0; // No more damage SpawnTracerExp(Weapon); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case BOLT_THINMAN_R2: @@ -6685,7 +6684,7 @@ DoDamage(short SpriteNum, short Weapon) SpawnNuclearExp(Weapon); else SpawnBoltExp(Weapon); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case BOLT_THINMAN_R4: @@ -6716,7 +6715,7 @@ DoDamage(short SpriteNum, short Weapon) //InitBloodSpray(Weapon,true,-1); //InitBloodSpray(Weapon,true,-1); //InitBloodSpray(Weapon,true,-1); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case SUMO_RUN_R0: @@ -7031,7 +7030,7 @@ DoDamage(short SpriteNum, short Weapon) ActorChooseDeath(SpriteNum, Weapon); } - SetSuicide(Weapon); + SetSuicide(weapActor); break; case Vomit1: @@ -7058,7 +7057,7 @@ DoDamage(short SpriteNum, short Weapon) ActorChooseDeath(SpriteNum, Weapon); } - SetSuicide(Weapon); + SetSuicide(weapActor); break; case COOLG_FIRE: @@ -7084,7 +7083,7 @@ DoDamage(short SpriteNum, short Weapon) } // u->ID = 0; - SetSuicide(Weapon); + SetSuicide(weapActor); break; // Skull Exp @@ -7153,7 +7152,7 @@ DoDamage(short SpriteNum, short Weapon) if (wp->owner >= 0) // For SerpGod Ring User[wp->owner]->Counter--; SpawnFireballFlames(Weapon, SpriteNum); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case FIREBALL: @@ -7186,7 +7185,7 @@ DoDamage(short SpriteNum, short Weapon) } SpawnGoroFireballExp(Weapon); - SetSuicide(Weapon); + SetSuicide(weapActor); break; case FIREBALL_FLAMES: @@ -7268,7 +7267,7 @@ DoDamage(short SpriteNum, short Weapon) ActorHealth(SpriteNum, damage); ActorStdMissile(SpriteNum, Weapon); ActorChooseDeath(SpriteNum, Weapon); - SetSuicide(Weapon); + SetSuicide(weapActor); break; } else if (u->ID == RIPPER_RUN_R0) @@ -7282,7 +7281,7 @@ DoDamage(short SpriteNum, short Weapon) InitPlasmaFountain(wp, sp); - SetSuicide(Weapon); + SetSuicide(weapActor); break; @@ -7312,7 +7311,7 @@ DoDamage(short SpriteNum, short Weapon) ActorChooseDeath(SpriteNum, Weapon); } - SetSuicide(Weapon); + SetSuicide(weapActor); break; #if 0 @@ -12235,6 +12234,7 @@ DoBloodWorm(DSWActor* actor) StatIterator it(STAT_ENEMY); while ((i = it.NextIndex()) >= 0) { + auto itActor = &swActors[i]; tsp = &sprite[i]; tu = User[i].Data(); @@ -12244,7 +12244,7 @@ DoBloodWorm(DSWActor* actor) { InitBloodSpray(i,true,105); InitBloodSpray(i,true,105); - SetSuicide(i); + SetSuicide(itActor); break; } } diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 228862263..d72869145 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -200,7 +200,7 @@ enum ShrapPos Z_BOT }; -int SetSuicide(short SpriteNum); +int SetSuicide(DSWActor*); void UpdateSinglePlayKills(DSWActor* actor); int InitPlasmaFountain(SPRITEp wp, SPRITEp sp); int InitCoolgDrip(short SpriteNum); diff --git a/source/games/sw/src/zombie.cpp b/source/games/sw/src/zombie.cpp index 21790007f..689f0bfb5 100644 --- a/source/games/sw/src/zombie.cpp +++ b/source/games/sw/src/zombie.cpp @@ -893,7 +893,7 @@ DoZombieMove(DSWActor* actor) InitBloodSpray(SpriteNum,true,105); InitBloodSpray(SpriteNum,true,105); InitBloodSpray(SpriteNum,true,105); - SetSuicide(SpriteNum); + SetSuicide(actor); return 0; } @@ -944,7 +944,7 @@ NullZombie(DSWActor* actor) InitBloodSpray(SpriteNum,true,105); InitBloodSpray(SpriteNum,true,105); InitBloodSpray(SpriteNum,true,105); - SetSuicide(SpriteNum); + SetSuicide(actor); return 0; }