From bc616dbf0680370dd43fe5a31d7626f44953ca73 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Feb 2016 10:04:52 +0100 Subject: [PATCH] - fixed: APowerupGiver::PowerupType also needs replacement handling for placeholder classes. --- src/dobject.h | 3 ++- src/dobjtype.cpp | 1 + src/g_shared/a_artifacts.cpp | 12 ++++++++++++ src/g_shared/a_artifacts.h | 12 +++++++++++- src/g_shared/a_weaponpiece.h | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/dobject.h b/src/dobject.h index f478cfc08..254891eb5 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -98,7 +98,8 @@ enum CLASSREG_PClassPlayerPawn, CLASSREG_PClassType, CLASSREG_PClassClass, - CLASSREG_PClassWeaponPiece + CLASSREG_PClassWeaponPiece, + CLASSREG_PClassPowerupGiver }; struct ClassReg diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 1762079fb..b5d758bfc 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2165,6 +2165,7 @@ PClass *ClassReg::RegisterClass() &PClassType::RegistrationInfo, &PClassClass::RegistrationInfo, &PClassWeaponPiece::RegistrationInfo, + &PClassPowerupGiver::RegistrationInfo, }; // Skip classes that have already been registered diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 58aee16fb..992e97cef 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -42,6 +42,18 @@ IMPLEMENT_CLASS (APowerup) // Powerup-Giver ------------------------------------------------------------- +IMPLEMENT_CLASS(PClassPowerupGiver) + +void PClassPowerupGiver::ReplaceClassRef(PClass *oldclass, PClass *newclass) +{ + Super::ReplaceClassRef(oldclass, newclass); + APowerupGiver *def = (APowerupGiver*)Defaults; + if (def != NULL) + { + if (def->PowerupType == oldclass) def->PowerupType = static_cast(newclass); + } +} + //=========================================================================== // // APowerupGiver :: Use diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index 5881fc52f..a99cf64c5 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -36,14 +36,24 @@ protected: friend void InitAllPowerupEffects(AInventory *item); }; +class PClassPowerupGiver: public PClassInventory +{ + DECLARE_CLASS(PClassPowerupGiver, PClassInventory) +protected: +public: + virtual void ReplaceClassRef(PClass *oldclass, PClass *newclass); +}; + + // An artifact is an item that gives the player a powerup when activated. class APowerupGiver : public AInventory { - DECLARE_CLASS (APowerupGiver, AInventory) + DECLARE_CLASS_WITH_META (APowerupGiver, AInventory, PClassPowerupGiver) public: virtual bool Use (bool pickup); virtual void Serialize (FArchive &arc); + PClassActor *PowerupType; int EffectTics; // Non-0 to override the powerup's default tics PalEntry BlendColor; // Non-0 to override the powerup's default blend diff --git a/src/g_shared/a_weaponpiece.h b/src/g_shared/a_weaponpiece.h index dfa30f5d7..4fa2118cd 100644 --- a/src/g_shared/a_weaponpiece.h +++ b/src/g_shared/a_weaponpiece.h @@ -1,5 +1,5 @@ -// Ammo: Something a weapon needs to operate +// class PClassWeaponPiece : public PClassInventory { DECLARE_CLASS(PClassWeaponPiece, PClassInventory)