From d2843c199e1d5c1513649e733172df9b4e9534da Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 21 Jul 2012 02:58:52 +0000 Subject: [PATCH] - Fixed: Pain flashes were not inheritable. SVN r3779 (trunk) --- src/info.cpp | 26 ++++++++++++++++++++++++++ src/info.h | 1 + src/v_blend.cpp | 9 +-------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index a1dd4723e..69476d290 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -329,6 +329,32 @@ void FActorInfo::SetPainFlash(FName type, PalEntry color) // //========================================================================== +bool FActorInfo::GetPainFlash(FName type, PalEntry *color) const +{ + const FActorInfo *info = this; + + while (info != NULL) + { + if (info->PainFlashes != NULL) + { + PalEntry *flash = info->PainFlashes->CheckKey(type); + if (flash != NULL) + { + *color = *flash; + return true; + } + } + // Try parent class + info = info->Class->ParentClass->ActorInfo; + } + return false; +} + +//========================================================================== +// +// +//========================================================================== + void FActorInfo::SetColorSet(int index, const FPlayerColorSet *set) { if (set != NULL) diff --git a/src/info.h b/src/info.h index b6da1ccd8..c2962512d 100644 --- a/src/info.h +++ b/src/info.h @@ -224,6 +224,7 @@ struct FActorInfo void SetDamageFactor(FName type, fixed_t factor); void SetPainChance(FName type, int chance); void SetPainFlash(FName type, PalEntry color); + bool GetPainFlash(FName type, PalEntry *color) const; void SetColorSet(int index, const FPlayerColorSet *set); FState *FindState (int numnames, FName *names, bool exact=false) const; diff --git a/src/v_blend.cpp b/src/v_blend.cpp index 1ec7837a0..0faa501ce 100644 --- a/src/v_blend.cpp +++ b/src/v_blend.cpp @@ -120,15 +120,8 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int BPART(gameinfo.pickupcolor)/255.f, cnt > 128 ? 0.5f : cnt / 255.f, blend); } - PainFlashList * pfl = CPlayer->mo->GetClass()->ActorInfo->PainFlashes; PalEntry painFlash = CPlayer->mo->DamageFade; - - if (pfl) - { - PalEntry * color = pfl->CheckKey(CPlayer->mo->DamageTypeReceived); - - if (color) painFlash = *color; - } + CPlayer->mo->GetClass()->ActorInfo->GetPainFlash(CPlayer->mo->DamageTypeReceived, &painFlash); if (painFlash.a != 0) {