From a79bcb73ac32e85c70c6108b4ca4258372b9e795 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 22 Apr 2012 07:23:59 +0000 Subject: [PATCH] - fixed the bloodspawning completely: It has to check for parent class's states, too, so that inherited blood still works - made the 'Spray' state in P_SpawnBlood available for all games. SVN r3580 (trunk) --- src/info.h | 5 +++++ src/p_mobj.cpp | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/info.h b/src/info.h index ff59a4656..03f285000 100644 --- a/src/info.h +++ b/src/info.h @@ -232,6 +232,11 @@ struct FActorInfo return FindState(1, &name); } + bool OwnsState(const FState *state) + { + return state >= OwnedStates && state < OwnedStates + NumOwnedStates; + } + FActorInfo *GetReplacement (bool lookskill=true); FActorInfo *GetReplacee (bool lookskill=true); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 44eadc623..553a7a5e0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4657,19 +4657,20 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc { th->Translation = TRANSLATION(TRANSLATION_Blood, bloodcolor.a); } - + + FState *state = th->FindState(NAME_Spray); + if (state != NULL) + { + if (damage > 13) + { + th->SetState (state); + } + else damage += 2; + } + // Moved out of the blood actor so that replacing blood is easier if (gameinfo.gametype & GAME_DoomStrifeChex) { - if (gameinfo.gametype == GAME_Strife) - { - if (damage > 13) - { - FState *state = th->FindState(NAME_Spray); - if (state != NULL) th->SetState (state); - } - else damage += 2; - } int advance = 0; if (damage <= 12 && damage >= 9) { @@ -4679,19 +4680,31 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc { advance = 2; } - FActorInfo *ai = th->GetClass()->ActorInfo; - for (; advance > 0; --advance) + + PClass *cls = th->GetClass(); + + while (cls != RUNTIME_CLASS(AActor)) { - // [RH] Do not set to a state we do not own. - if (th->SpawnState + advance < ai->OwnedStates + ai->NumOwnedStates) + FActorInfo *ai = cls->ActorInfo; + if (ai->OwnsState(th->SpawnState)) { - th->SetState(th->SpawnState + advance); - break; + for (; advance > 0; --advance) + { + // [RH] Do not set to a state we do not own. + if (ai->OwnsState(th->SpawnState + advance)) + { + th->SetState(th->SpawnState + advance); + goto statedone; + } + } } + cls = cls->ParentClass; } } } +statedone: + if (bloodtype >= 1) P_DrawSplash2 (40, x, y, z, dir, 2, bloodcolor); }