- fixed: APowerupGiver::PowerupType also needs replacement handling for placeholder classes.

This commit is contained in:
Christoph Oelckers 2016-02-10 10:04:52 +01:00
parent 3358181f18
commit bc616dbf06
5 changed files with 27 additions and 3 deletions

View File

@ -98,7 +98,8 @@ enum
CLASSREG_PClassPlayerPawn,
CLASSREG_PClassType,
CLASSREG_PClassClass,
CLASSREG_PClassWeaponPiece
CLASSREG_PClassWeaponPiece,
CLASSREG_PClassPowerupGiver
};
struct ClassReg

View File

@ -2165,6 +2165,7 @@ PClass *ClassReg::RegisterClass()
&PClassType::RegistrationInfo,
&PClassClass::RegistrationInfo,
&PClassWeaponPiece::RegistrationInfo,
&PClassPowerupGiver::RegistrationInfo,
};
// Skip classes that have already been registered

View File

@ -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<PClassWeapon *>(newclass);
}
}
//===========================================================================
//
// APowerupGiver :: Use

View File

@ -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

View File

@ -1,5 +1,5 @@
// Ammo: Something a weapon needs to operate
//
class PClassWeaponPiece : public PClassInventory
{
DECLARE_CLASS(PClassWeaponPiece, PClassInventory)