- optimized the FName versions of IsDescendantOf and IsKindOf. These can be done without first looking up the class type itself.

This commit is contained in:
Christoph Oelckers 2017-02-08 15:47:22 +01:00
parent 31223ca180
commit a6785afddb
28 changed files with 126 additions and 97 deletions

View file

@ -2857,7 +2857,7 @@ void AM_drawThings ()
// Find the key's own color. // Find the key's own color.
// Only works correctly if single-key locks have lower numbers than any-key locks. // Only works correctly if single-key locks have lower numbers than any-key locks.
// That is the case for all default keys, however. // That is the case for all default keys, however.
if (t->IsKindOf(PClass::FindActor(NAME_Key))) if (t->IsKindOf(NAME_Key))
{ {
if (G_SkillProperty(SKILLP_EasyKey)) if (G_SkillProperty(SKILLP_EasyKey))
{ {

View file

@ -263,7 +263,7 @@ void InitBotStuff()
for(unsigned i=0;i<sizeof(botinits)/sizeof(botinits[0]);i++) for(unsigned i=0;i<sizeof(botinits)/sizeof(botinits[0]);i++)
{ {
const PClass *cls = PClass::FindClass(botinits[i].type); const PClass *cls = PClass::FindClass(botinits[i].type);
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (cls != NULL && cls->IsDescendantOf(NAME_Weapon))
{ {
AWeapon *w = (AWeapon*)GetDefaultByType(cls); AWeapon *w = (AWeapon*)GetDefaultByType(cls);
if (w != NULL) if (w != NULL)

View file

@ -328,7 +328,7 @@ void DBot::WhatToGet (AActor *item)
//if(pos && !bglobal.thingvis[pos->id][item->id]) continue; //if(pos && !bglobal.thingvis[pos->id][item->id]) continue;
// if (item->IsKindOf (RUNTIME_CLASS(AArtifact))) // if (item->IsKindOf (RUNTIME_CLASS(AArtifact)))
// return; // don't know how to use artifacts // return; // don't know how to use artifacts
if (item->IsKindOf (RUNTIME_CLASS(AWeapon))) if (item->IsKindOf(NAME_Weapon))
{ {
// FIXME // FIXME
AWeapon *heldWeapon; AWeapon *heldWeapon;

View file

@ -1210,7 +1210,7 @@ static void PrintSecretString(const char *string, bool thislevel)
{ {
while ((actor = it.Next())) while ((actor = it.Next()))
{ {
if (!actor->IsKindOf(PClass::FindClass("SecretTrigger"))) continue; if (!actor->IsKindOf("SecretTrigger")) continue;
foundone = true; foundone = true;
break; break;
} }

View file

@ -2916,7 +2916,7 @@ static bool LoadDehSupp ()
else else
{ {
auto cls = PClass::FindActor(sc.String); auto cls = PClass::FindActor(sc.String);
if (cls == NULL || !cls->IsDescendantOf(PClass::FindActor(NAME_Ammo))) if (cls == NULL || !cls->IsDescendantOf(NAME_Ammo))
{ {
sc.ScriptError("Unknown ammo type '%s'", sc.String); sc.ScriptError("Unknown ammo type '%s'", sc.String);
} }
@ -2934,7 +2934,7 @@ static bool LoadDehSupp ()
{ {
sc.MustGetString(); sc.MustGetString();
PClass *cls = PClass::FindClass(sc.String); PClass *cls = PClass::FindClass(sc.String);
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (cls == NULL || !cls->IsDescendantOf(NAME_Weapon))
{ {
sc.ScriptError("Unknown weapon type '%s'", sc.String); sc.ScriptError("Unknown weapon type '%s'", sc.String);
} }

View file

@ -458,6 +458,7 @@ public:
virtual ~DObject (); virtual ~DObject ();
inline bool IsKindOf (const PClass *base) const; inline bool IsKindOf (const PClass *base) const;
inline bool IsKindOf(FName base) const;
inline bool IsA (const PClass *type) const; inline bool IsA (const PClass *type) const;
void SerializeUserVars(FSerializer &arc); void SerializeUserVars(FSerializer &arc);
@ -615,6 +616,11 @@ inline bool DObject::IsKindOf (const PClass *base) const
return base->IsAncestorOf (GetClass ()); return base->IsAncestorOf (GetClass ());
} }
inline bool DObject::IsKindOf(FName base) const
{
return GetClass()->IsDescendantOf(base);
}
inline bool DObject::IsA (const PClass *type) const inline bool DObject::IsA (const PClass *type) const
{ {
return (type == GetClass()); return (type == GetClass());

View file

@ -622,11 +622,24 @@ public:
} }
return false; return false;
} }
inline bool IsDescendantOf(const PClass *ti) const inline bool IsDescendantOf(const PClass *ti) const
{ {
return ti->IsAncestorOf(this); return ti->IsAncestorOf(this);
} }
inline bool IsDescendantOf(FName ti) const
{
auto me = this;
while (me)
{
if (me->TypeName == ti)
return true;
me = me->ParentClass;
}
return false;
}
// Find a type, given its name. // Find a type, given its name.
const PClass *FindParentClass(FName name) const; const PClass *FindParentClass(FName name) const;
PClass *FindParentClass(FName name) { return const_cast<PClass *>(const_cast<const PClass *>(this)->FindParentClass(name)); } PClass *FindParentClass(FName name) { return const_cast<PClass *>(const_cast<const PClass *>(this)->FindParentClass(name)); }

View file

@ -2629,7 +2629,7 @@ void FParser::SF_MaxPlayerAmmo()
for (AInventory *item = players[playernum].mo->Inventory; item != NULL; item = item->Inventory) for (AInventory *item = players[playernum].mo->Inventory; item != NULL; item = item->Inventory)
{ {
if (item->IsKindOf(PClass::FindClass(NAME_BackpackItem))) if (item->IsKindOf(NAME_BackpackItem))
{ {
if (t_argc>=4) amount = intvalue(t_argv[3]); if (t_argc>=4) amount = intvalue(t_argv[3]);
else amount*=2; else amount*=2;
@ -2676,7 +2676,7 @@ void FParser::SF_PlayerWeapon()
return; return;
} }
auto ti = PClass::FindActor(WeaponNames[weaponnum]); auto ti = PClass::FindActor(WeaponNames[weaponnum]);
if (!ti || !ti->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (!ti || !ti->IsDescendantOf(NAME_Weapon))
{ {
script_error("incompatibility in playerweapon %d\n", weaponnum); script_error("incompatibility in playerweapon %d\n", weaponnum);
return; return;
@ -2712,7 +2712,7 @@ void FParser::SF_PlayerWeapon()
{ {
if (!wp) if (!wp)
{ {
AWeapon * pw=players[playernum].PendingWeapon; auto pw=players[playernum].PendingWeapon;
players[playernum].mo->GiveInventoryType(ti); players[playernum].mo->GiveInventoryType(ti);
players[playernum].PendingWeapon=pw; players[playernum].PendingWeapon=pw;
} }
@ -2757,7 +2757,7 @@ void FParser::SF_PlayerSelectedWeapon()
return; return;
} }
auto ti = PClass::FindActor(WeaponNames[weaponnum]); auto ti = PClass::FindActor(WeaponNames[weaponnum]);
if (!ti || !ti->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (!ti || !ti->IsDescendantOf(NAME_Weapon))
{ {
script_error("incompatibility in playerweapon %d\n", weaponnum); script_error("incompatibility in playerweapon %d\n", weaponnum);
return; return;
@ -2862,7 +2862,7 @@ void FParser::SF_SetWeapon()
{ {
AInventory *item = players[playernum].mo->FindInventory (PClass::FindActor (stringvalue(t_argv[1]))); AInventory *item = players[playernum].mo->FindInventory (PClass::FindActor (stringvalue(t_argv[1])));
if (item == NULL || !item->IsKindOf (RUNTIME_CLASS(AWeapon))) if (item == NULL || !item->IsKindOf(NAME_Weapon))
{ {
} }
else if (players[playernum].ReadyWeapon == item) else if (players[playernum].ReadyWeapon == item)
@ -2874,7 +2874,7 @@ void FParser::SF_SetWeapon()
} }
else else
{ {
AWeapon *weap = static_cast<AWeapon *> (item); auto weap = static_cast<AWeapon *> (item);
if (weap->CheckAmmo (AWeapon::EitherFire, false)) if (weap->CheckAmmo (AWeapon::EitherFire, false))
{ {

View file

@ -187,7 +187,7 @@ static void AddOneKey(Keygroup *keygroup, PClassActor *mi, FScanner &sc)
keygroup->anykeylist.Push (k); keygroup->anykeylist.Push (k);
//... but only keys get key numbers! //... but only keys get key numbers!
if (mi->IsDescendantOf(PClass::FindActor(NAME_Key))) if (mi->IsDescendantOf(NAME_Key))
{ {
if (!ignorekey && if (!ignorekey &&
GetDefaultByType(mi)->special1 == 0) GetDefaultByType(mi)->special1 == 0)

View file

@ -528,7 +528,7 @@ bool FWeaponSlot::AddWeapon(PClassActor *type)
return false; return false;
} }
if (!type->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (!type->IsDescendantOf(NAME_Weapon))
{ {
Printf("Can't add non-weapon %s to weapon slots\n", type->TypeName.GetChars()); Printf("Can't add non-weapon %s to weapon slots\n", type->TypeName.GetChars());
return false; return false;
@ -635,7 +635,7 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player, bool checkammo)
{ {
AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[j].Type)); AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[j].Type));
if (weap != nullptr && weap->IsKindOf(RUNTIME_CLASS(AWeapon))) if (weap != nullptr && weap->IsKindOf(NAME_Weapon))
{ {
if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false)) if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false))
{ {
@ -650,7 +650,7 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player, bool checkammo)
{ {
AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[i].Type)); AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[i].Type));
if (weap != nullptr && weap->IsKindOf(RUNTIME_CLASS(AWeapon))) if (weap != nullptr && weap->IsKindOf(NAME_Weapon))
{ {
if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false)) if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false))
{ {
@ -982,7 +982,7 @@ void FWeaponSlots::AddExtraWeapons()
{ {
PClassActor *cls = PClassActor::AllActorClasses[i]; PClassActor *cls = PClassActor::AllActorClasses[i];
if (!cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (!cls->IsDescendantOf(NAME_Weapon))
{ {
continue; continue;
} }
@ -1342,7 +1342,7 @@ CCMD (weaponsection)
//=========================================================================== //===========================================================================
void FWeaponSlots::AddSlotDefault(int slot, PClassActor *type, bool feedback) void FWeaponSlots::AddSlotDefault(int slot, PClassActor *type, bool feedback)
{ {
if (type != nullptr && type->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (type != nullptr && type->IsDescendantOf(NAME_Weapon))
{ {
switch (AddDefaultWeapon(slot, type)) switch (AddDefaultWeapon(slot, type))
{ {
@ -1441,7 +1441,7 @@ void P_SetupWeapons_ntohton()
{ {
PClassActor *cls = PClassActor::AllActorClasses[i]; PClassActor *cls = PClassActor::AllActorClasses[i];
if (cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (cls->IsDescendantOf(NAME_Weapon))
{ {
Weapons_ntoh.Push(static_cast<PClassActor *>(cls)); Weapons_ntoh.Push(static_cast<PClassActor *>(cls));
} }

View file

@ -337,7 +337,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
if (correctweapon) if (correctweapon)
{ // Better "lose morphed weapon" semantics { // Better "lose morphed weapon" semantics
PClassActor *morphweapon = PClass::FindActor(pmo->MorphWeapon); PClassActor *morphweapon = PClass::FindActor(pmo->MorphWeapon);
if (morphweapon != nullptr && morphweapon->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (morphweapon != nullptr && morphweapon->IsDescendantOf(NAME_Weapon))
{ {
AWeapon *OriginalMorphWeapon = static_cast<AWeapon *>(mo->FindInventory (morphweapon)); AWeapon *OriginalMorphWeapon = static_cast<AWeapon *>(mo->FindInventory (morphweapon));
if ((OriginalMorphWeapon != nullptr) && (OriginalMorphWeapon->GivenAsMorphWeapon)) if ((OriginalMorphWeapon != nullptr) && (OriginalMorphWeapon->GivenAsMorphWeapon))

View file

@ -612,7 +612,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
// Now check for the remaining weapons that are in the inventory but not in the weapon slots // Now check for the remaining weapons that are in the inventory but not in the weapon slots
for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory) for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory)
{ {
if (inv->IsKindOf(RUNTIME_CLASS(AWeapon))) if (inv->IsKindOf(NAME_Weapon))
{ {
AddAmmoToList((AWeapon*)inv); AddAmmoToList((AWeapon*)inv);
} }
@ -713,7 +713,7 @@ FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale=NULL
} }
} }
// no spawn state - now try the ready state if it's weapon // no spawn state - now try the ready state if it's weapon
else if (!(flags & DI_SKIPREADY) && item->GetClass()->IsDescendantOf(RUNTIME_CLASS(AWeapon)) && (ReadyState = item->FindState(NAME_Ready)) && ReadyState->sprite!=0) else if (!(flags & DI_SKIPREADY) && item->GetClass()->IsDescendantOf(NAME_Weapon) && (ReadyState = item->FindState(NAME_Ready)) && ReadyState->sprite!=0)
{ {
state = ReadyState; state = ReadyState;
} }
@ -767,7 +767,7 @@ static void DrawWeapons(player_t *CPlayer, int x, int y)
// First draw all weapons in the inventory that are not assigned to a weapon slot // First draw all weapons in the inventory that are not assigned to a weapon slot
for(inv = CPlayer->mo->Inventory; inv; inv = inv->Inventory) for(inv = CPlayer->mo->Inventory; inv; inv = inv->Inventory)
{ {
if (inv->IsKindOf(RUNTIME_CLASS(AWeapon)) && if (inv->IsKindOf(NAME_Weapon) &&
!CPlayer->weapons.LocateWeapon(static_cast<AWeapon*>(inv)->GetClass(), NULL, NULL)) !CPlayer->weapons.LocateWeapon(static_cast<AWeapon*>(inv)->GetClass(), NULL, NULL))
{ {
DrawOneWeapon(CPlayer, x, y, static_cast<AWeapon*>(inv)); DrawOneWeapon(CPlayer, x, y, static_cast<AWeapon*>(inv));

View file

@ -148,7 +148,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{ {
type = INVENTORYICON; type = INVENTORYICON;
const PClass* item = PClass::FindClass(sc.String); const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory if(item == NULL || !item->IsDescendantOf(NAME_Inventory)) //must be a kind of Inventory
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
} }
@ -418,7 +418,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i) for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{ {
PClassActor *cls = PClassActor::AllActorClasses[i]; PClassActor *cls = PClassActor::AllActorClasses[i];
if (cls->IsDescendantOf(PClass::FindActor(NAME_Key))) if (cls->IsDescendantOf(NAME_Key))
{ {
auto key = GetDefaultByType(cls); auto key = GetDefaultByType(cls);
if (key->special1 == keynum) if (key->special1 == keynum)
@ -471,7 +471,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
{ {
inventoryItem[0] = sc.String; inventoryItem[0] = sc.String;
const PClass* item = PClass::FindClass(sc.String); const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory if(item == NULL || !item->IsDescendantOf(NAME_Inventory)) //must be a kind of Inventory
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
} }
@ -498,7 +498,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
inventoryItem[1] = sc.String; inventoryItem[1] = sc.String;
const PClass* item = PClass::FindClass(sc.String); const PClass* item = PClass::FindClass(sc.String);
if(item == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item)) //must be a kind of Inventory if(item == NULL || !item->IsDescendantOf(NAME_Inventory)) //must be a kind of Inventory
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
} }
@ -556,7 +556,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory) for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
{ {
if(item->IsKindOf(PClass::FindActor(NAME_Key))) if(item->IsKindOf(NAME_Key))
{ {
int keynum = item->special1; int keynum = item->special1;
if(keynum) if(keynum)
@ -1078,7 +1078,7 @@ class CommandDrawNumber : public CommandDrawString
if(!parenthesized || !sc.CheckToken(TK_StringConst)) if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindActor(sc.String); inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo if(inventoryItem == NULL || !inventoryItem->IsDescendantOf(NAME_Ammo)) //must be a kind of ammo
{ {
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String); sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = PClass::FindActor(NAME_Ammo); inventoryItem = PClass::FindActor(NAME_Ammo);
@ -1094,7 +1094,7 @@ class CommandDrawNumber : public CommandDrawString
if(!parenthesized || !sc.CheckToken(TK_StringConst)) if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindActor(sc.String); inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo if (inventoryItem == NULL || !inventoryItem->IsDescendantOf(NAME_Ammo)) //must be a kind of ammo
{ {
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String); sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
inventoryItem = PClass::FindActor(NAME_Ammo); inventoryItem = PClass::FindActor(NAME_Ammo);
@ -1160,7 +1160,7 @@ class CommandDrawNumber : public CommandDrawString
if(!parenthesized || !sc.CheckToken(TK_StringConst)) if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
inventoryItem = PClass::FindActor(sc.String); inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !PClass::FindActor(NAME_PowerupGiver)->IsAncestorOf(inventoryItem)) if (inventoryItem == NULL || !inventoryItem->IsDescendantOf(NAME_PowerupGiver))
{ {
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String); sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
inventoryItem = PClass::FindActor(NAME_PowerupGiver); inventoryItem = PClass::FindActor(NAME_PowerupGiver);
@ -1203,7 +1203,7 @@ class CommandDrawNumber : public CommandDrawString
if(value == INVENTORY) if(value == INVENTORY)
{ {
inventoryItem = PClass::FindActor(sc.String); inventoryItem = PClass::FindActor(sc.String);
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo if (inventoryItem == NULL || !inventoryItem->IsDescendantOf(NAME_Inventory))
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
inventoryItem = RUNTIME_CLASS(AInventory); inventoryItem = RUNTIME_CLASS(AInventory);
@ -1476,7 +1476,7 @@ class CommandDrawNumber : public CommandDrawString
num = 0; num = 0;
for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory) for(AInventory *item = statusBar->CPlayer->mo->Inventory;item != NULL;item = item->Inventory)
{ {
if(item->IsKindOf(PClass::FindActor(NAME_Key))) if(item->IsKindOf(NAME_Key))
num++; num++;
} }
break; break;
@ -2431,7 +2431,7 @@ class CommandDrawKeyBar : public SBarInfoCommand
int rowWidth = 0; int rowWidth = 0;
for(unsigned int i = 0;i < number+keyOffset;i++) for(unsigned int i = 0;i < number+keyOffset;i++)
{ {
while(!item->Icon.isValid() || !item->IsKindOf(PClass::FindActor(NAME_Key))) while(!item->Icon.isValid() || !item->IsKindOf(NAME_Key))
{ {
item = item->Inventory; item = item->Inventory;
if(item == NULL) if(item == NULL)
@ -2632,7 +2632,7 @@ class CommandDrawBar : public SBarInfoCommand
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
type = AMMO; type = AMMO;
data.inventoryItem = PClass::FindActor(sc.String); data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo if (data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_Ammo)) //must be a kind of ammo
{ {
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String); sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
data.inventoryItem = PClass::FindActor(NAME_Ammo); data.inventoryItem = PClass::FindActor(NAME_Ammo);
@ -2660,7 +2660,7 @@ class CommandDrawBar : public SBarInfoCommand
if(!parenthesized || !sc.CheckToken(TK_StringConst)) if(!parenthesized || !sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
data.inventoryItem = PClass::FindActor(sc.String); data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !PClass::FindActor(NAME_PowerupGiver)->IsAncestorOf(data.inventoryItem)) if(data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_PowerupGiver))
{ {
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String); sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
data.inventoryItem = PClass::FindActor(NAME_PowerupGiver); data.inventoryItem = PClass::FindActor(NAME_PowerupGiver);
@ -2672,7 +2672,7 @@ class CommandDrawBar : public SBarInfoCommand
{ {
type = INVENTORY; type = INVENTORY;
data.inventoryItem = PClass::FindActor(sc.String); data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) if(data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_Inventory))
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
data.inventoryItem = RUNTIME_CLASS(AInventory); data.inventoryItem = RUNTIME_CLASS(AInventory);
@ -2894,7 +2894,7 @@ class CommandDrawBar : public SBarInfoCommand
if(sc.CheckToken(TK_Identifier) || (extendedSyntax && sc.CheckToken(TK_StringConst))) //comparing reference if(sc.CheckToken(TK_Identifier) || (extendedSyntax && sc.CheckToken(TK_StringConst))) //comparing reference
{ {
data.inventoryItem = PClass::FindActor(sc.String); data.inventoryItem = PClass::FindActor(sc.String);
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory if(data.inventoryItem == NULL || !data.inventoryItem->IsDescendantOf(NAME_Inventory)) //must be a kind of inventory
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
data.inventoryItem = RUNTIME_CLASS(AInventory); data.inventoryItem = RUNTIME_CLASS(AInventory);
@ -2977,7 +2977,7 @@ class CommandIsSelected : public SBarInfoNegatableFlowControl
for(int i = 0;i < 2;i++) for(int i = 0;i < 2;i++)
{ {
weapon[i] = PClass::FindClass(sc.String); weapon[i] = PClass::FindClass(sc.String);
if(weapon[i] == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon[i])) if(weapon[i] == NULL || !weapon[i]->IsDescendantOf(NAME_Weapon))
{ {
sc.ScriptMessage("'%s' is not a type of weapon.", sc.String); sc.ScriptMessage("'%s' is not a type of weapon.", sc.String);
weapon[i] = RUNTIME_CLASS(AWeapon); weapon[i] = RUNTIME_CLASS(AWeapon);
@ -3130,7 +3130,7 @@ class CommandHasWeaponPiece : public SBarInfoCommandFlowControl
if(!sc.CheckToken(TK_StringConst)) if(!sc.CheckToken(TK_StringConst))
sc.MustGetToken(TK_Identifier); sc.MustGetToken(TK_Identifier);
weapon = PClass::FindClass(sc.String); weapon = PClass::FindClass(sc.String);
if(weapon == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon)) //must be a weapon if (weapon == NULL || !weapon->IsDescendantOf(NAME_Weapon)) //must be a weapon
{ {
sc.ScriptMessage("%s is not a kind of weapon.", sc.String); sc.ScriptMessage("%s is not a kind of weapon.", sc.String);
weapon = RUNTIME_CLASS(AWeapon); weapon = RUNTIME_CLASS(AWeapon);
@ -3317,7 +3317,7 @@ class CommandWeaponAmmo : public SBarInfoNegatableFlowControl
for(int i = 0;i < 2;i++) for(int i = 0;i < 2;i++)
{ {
ammo[i] = PClass::FindClass(sc.String); ammo[i] = PClass::FindClass(sc.String);
if(ammo[i] == NULL || !PClass::FindActor(NAME_Ammo)->IsAncestorOf(ammo[i])) //must be a kind of ammo if(ammo[i] == NULL || !ammo[i]->IsDescendantOf(NAME_Ammo)) //must be a kind of ammo
{ {
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String); sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
ammo[i] = PClass::FindActor(NAME_Ammo); ammo[i] = PClass::FindActor(NAME_Ammo);
@ -3400,7 +3400,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
for(int i = 0;i < 2;i++) for(int i = 0;i < 2;i++)
{ {
item[i] = PClass::FindActor(sc.String); item[i] = PClass::FindActor(sc.String);
if(item[i] == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(item[i])) if (item[i] == NULL || !item[i]->IsDescendantOf(NAME_Inventory)) //must be a kind of ammo
{ {
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String); sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
item[i] = RUNTIME_CLASS(AInventory); item[i] = RUNTIME_CLASS(AInventory);

View file

@ -77,7 +77,7 @@ void gl_ParseVavoomSkybox();
inline PClassActor * GetRealType(PClassActor * ti) inline PClassActor * GetRealType(PClassActor * ti)
{ {
PClassActor *rep = ti->GetReplacement(false); PClassActor *rep = ti->GetReplacement(false);
if (rep != ti && rep != NULL && rep->IsDescendantOf(PClass::FindActor(NAME_DehackedPickup))) if (rep != ti && rep != NULL && rep->IsDescendantOf(NAME_DehackedPickup))
{ {
return rep; return rep;
} }

View file

@ -110,7 +110,7 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info,
const char *callinfo = ""; const char *callinfo = "";
if (info != nullptr && info->mStateType == STATE_Psprite) if (info != nullptr && info->mStateType == STATE_Psprite)
{ {
if (stateowner->IsKindOf(RUNTIME_CLASS(AWeapon)) && stateowner != self) callinfo = "weapon "; if (stateowner->IsKindOf(NAME_Weapon) && stateowner != self) callinfo = "weapon ";
else callinfo = "overlay "; else callinfo = "overlay ";
} }
err.stacktrace.AppendFormat("Called from %sstate %s.%d in %s\n", callinfo, owner->TypeName.GetChars(), offs, stateowner->GetClass()->TypeName.GetChars()); err.stacktrace.AppendFormat("Called from %sstate %s.%d in %s\n", callinfo, owner->TypeName.GetChars(), offs, stateowner->GetClass()->TypeName.GetChars());

View file

@ -317,7 +317,7 @@ void cht_DoCheat (player_t *player, int cheat)
case CHT_RESSURECT: case CHT_RESSURECT:
if (player->playerstate != PST_LIVE && player->mo != nullptr) if (player->playerstate != PST_LIVE && player->mo != nullptr)
{ {
if (player->mo->IsKindOf(PClass::FindActor("PlayerChunk"))) if (player->mo->IsKindOf("PlayerChunk"))
{ {
Printf("Unable to resurrect. Player is no longer connected to its body.\n"); Printf("Unable to resurrect. Player is no longer connected to its body.\n");
} }
@ -421,7 +421,7 @@ void cht_DoCheat (player_t *player, int cheat)
{ {
lastinvp = invp; lastinvp = invp;
invp = &(*invp)->Inventory; invp = &(*invp)->Inventory;
if (item->IsKindOf (RUNTIME_CLASS(AWeapon))) if (item->IsKindOf(NAME_Weapon))
{ {
AWeapon *weap = static_cast<AWeapon *> (item); AWeapon *weap = static_cast<AWeapon *> (item);
if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) || if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) ||

View file

@ -5716,7 +5716,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
if (argCount >= 2) if (argCount >= 2)
{ {
PClassActor *powerupclass = PClass::FindActor(FBehavior::StaticLookupString(args[1])); PClassActor *powerupclass = PClass::FindActor(FBehavior::StaticLookupString(args[1]));
if (powerupclass == NULL || !powerupclass->IsDescendantOf(PClass::FindActor(NAME_Powerup))) if (powerupclass == NULL || !powerupclass->IsDescendantOf(NAME_Powerup))
{ {
Printf("'%s' is not a type of Powerup.\n", FBehavior::StaticLookupString(args[1])); Printf("'%s' is not a type of Powerup.\n", FBehavior::StaticLookupString(args[1]));
return 0; return 0;
@ -9042,7 +9042,7 @@ scriptwait:
AInventory *item = activator->FindInventory (dyn_cast<PClassActor>( AInventory *item = activator->FindInventory (dyn_cast<PClassActor>(
PClass::FindClass (FBehavior::StaticLookupString (STACK(1))))); PClass::FindClass (FBehavior::StaticLookupString (STACK(1)))));
if (item == NULL || !item->IsKindOf (RUNTIME_CLASS(AWeapon))) if (item == NULL || !item->IsKindOf(NAME_Weapon))
{ {
STACK(1) = 0; STACK(1) = 0;
} }
@ -9110,7 +9110,7 @@ scriptwait:
} }
else else
{ {
if (activator != nullptr && activator->IsKindOf(PClass::FindClass("ScriptedMarine"))) if (activator != nullptr && activator->IsKindOf("ScriptedMarine"))
{ {
SetMarineSprite(activator, type); SetMarineSprite(activator, type);
} }

View file

@ -2387,7 +2387,7 @@ static bool DoGiveInventory(AActor *receiver, bool orresult, VM_ARGS)
{ {
return false; return false;
} }
if (item->IsKindOf(PClass::FindActor(NAME_Health))) if (item->IsKindOf(NAME_Health))
{ {
item->Amount *= amount; item->Amount *= amount;
} }
@ -3123,7 +3123,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectWeapon)
AWeapon *weaponitem = static_cast<AWeapon*>(self->FindInventory(cls)); AWeapon *weaponitem = static_cast<AWeapon*>(self->FindInventory(cls));
if (weaponitem != NULL && weaponitem->IsKindOf(RUNTIME_CLASS(AWeapon))) if (weaponitem != NULL && weaponitem->IsKindOf(NAME_Weapon))
{ {
if (self->player->ReadyWeapon != weaponitem) if (self->player->ReadyWeapon != weaponitem)
{ {
@ -5668,7 +5668,7 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo
if ((flags & RGF_NOSIGHT) || P_CheckSight(thing, self, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) if ((flags & RGF_NOSIGHT) || P_CheckSight(thing, self, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY))
{ // OK to give; target is in direct path, or the monster doesn't care about it being in line of sight. { // OK to give; target is in direct path, or the monster doesn't care about it being in line of sight.
AInventory *gift = static_cast<AInventory *>(Spawn(item)); AInventory *gift = static_cast<AInventory *>(Spawn(item));
if (gift->IsKindOf(PClass::FindActor(NAME_Health))) if (gift->IsKindOf(NAME_Health))
{ {
gift->Amount *= amount; gift->Amount *= amount;
} }

View file

@ -1331,7 +1331,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
{ {
if (reply->GiveType->IsDescendantOf(RUNTIME_CLASS(AInventory))) if (reply->GiveType->IsDescendantOf(RUNTIME_CLASS(AInventory)))
{ {
if (reply->GiveType->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (reply->GiveType->IsDescendantOf(NAME_Weapon))
{ {
if (player->mo->FindInventory(reply->GiveType) != NULL) if (player->mo->FindInventory(reply->GiveType) != NULL)
{ {
@ -1357,7 +1357,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
} }
} }
if (reply->GiveType->IsDescendantOf(PClass::FindActor("SlideshowStarter"))) if (reply->GiveType->IsDescendantOf("SlideshowStarter"))
gameaction = ga_slideshow; gameaction = ga_slideshow;
} }
else else

View file

@ -3226,7 +3226,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
if (dropamount > 0) if (dropamount > 0)
{ {
if (flagmask != 0 && inv->IsKindOf(PClass::FindActor(NAME_Ammo))) if (flagmask != 0 && inv->IsKindOf(NAME_Ammo))
{ {
inv->Amount = int(dropamount * dropammofactor); inv->Amount = int(dropamount * dropammofactor);
inv->ItemFlags |= IF_IGNORESKILL; inv->ItemFlags |= IF_IGNORESKILL;
@ -3252,7 +3252,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
inv->FloatVar("AmmoFactor") = dropammofactor; inv->FloatVar("AmmoFactor") = dropammofactor;
inv->ItemFlags |= flagmask; inv->ItemFlags |= flagmask;
} }
else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) else if (inv->IsKindOf(NAME_Weapon))
{ {
// The same goes for ammo from a weapon. // The same goes for ammo from a weapon.
static_cast<AWeapon *>(inv)->AmmoGive1 = int(static_cast<AWeapon *>(inv)->AmmoGive1 * dropammofactor); static_cast<AWeapon *>(inv)->AmmoGive1 = int(static_cast<AWeapon *>(inv)->AmmoGive1 * dropammofactor);

View file

@ -789,7 +789,7 @@ bool AActor::GiveInventory(PClassInventory *type, int amount, bool givecheat)
item->ClearCounters(); item->ClearCounters();
if (!givecheat || amount > 0) if (!givecheat || amount > 0)
{ {
if (type->IsDescendantOf (PClass::FindActor(NAME_BasicArmorPickup)) || type->IsDescendantOf(PClass::FindActor(NAME_BasicArmorBonus))) if (type->IsDescendantOf (NAME_BasicArmorPickup) || type->IsDescendantOf(NAME_BasicArmorBonus))
{ {
item->IntVar(NAME_SaveAmount) *= amount; item->IntVar(NAME_SaveAmount) *= amount;
} }
@ -903,7 +903,7 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate
// and infinite ammo is on // and infinite ammo is on
if (notakeinfinite && if (notakeinfinite &&
((dmflags & DF_INFINITE_AMMO) || (player && player->cheats & CF_INFINITEAMMO)) && ((dmflags & DF_INFINITE_AMMO) || (player && player->cheats & CF_INFINITEAMMO)) &&
item->IsKindOf(PClass::FindActor(NAME_Ammo))) item->IsKindOf(NAME_Ammo))
{ {
// Nothing to do here, except maybe res = false;? Would it make sense? // Nothing to do here, except maybe res = false;? Would it make sense?
result = false; result = false;

View file

@ -166,7 +166,7 @@ DPSprite::DPSprite(player_t *owner, AActor *caller, int id)
if (Next && Next->ID == ID && ID != 0) if (Next && Next->ID == ID && ID != 0)
Next->Destroy(); // Replace it. Next->Destroy(); // Replace it.
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) || Caller->IsKindOf(RUNTIME_CLASS(APlayerPawn))) if (Caller->IsKindOf(NAME_Weapon) || Caller->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
Flags = (PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_POWDOUBLE|PSPF_CVARFAST); Flags = (PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_POWDOUBLE|PSPF_CVARFAST);
} }
@ -353,7 +353,7 @@ void DPSprite::SetState(FState *newstate, bool pending)
} }
else if (!(newstate->UseFlags & SUF_WEAPON)) else if (!(newstate->UseFlags & SUF_WEAPON))
{ {
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon))) if (Caller->IsKindOf(NAME_Weapon))
{ {
auto so = FState::StaticFindStateOwner(newstate); auto so = FState::StaticFindStateOwner(newstate);
Printf(TEXTCOLOR_RED "State %s.%d not flagged for use in weapons\n", so->TypeName.GetChars(), int(newstate - so->OwnedStates)); Printf(TEXTCOLOR_RED "State %s.%d not flagged for use in weapons\n", so->TypeName.GetChars(), int(newstate - so->OwnedStates));
@ -1333,7 +1333,7 @@ void player_t::TickPSprites()
// or if it's from an inventory item that the player no longer owns. // or if it's from an inventory item that the player no longer owns.
if ((pspr->Caller == nullptr || if ((pspr->Caller == nullptr ||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AInventory)) && barrier_cast<AInventory *>(pspr->Caller)->Owner != pspr->Owner->mo) || (pspr->Caller->IsKindOf(RUNTIME_CLASS(AInventory)) && barrier_cast<AInventory *>(pspr->Caller)->Owner != pspr->Owner->mo) ||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && pspr->Caller != pspr->Owner->ReadyWeapon))) (pspr->Caller->IsKindOf(NAME_Weapon) && pspr->Caller != pspr->Owner->ReadyWeapon)))
{ {
pspr->Destroy(); pspr->Destroy();
} }

View file

@ -963,7 +963,7 @@ AWeapon *APlayerPawn::BestWeapon(PClassInventory *ammotype)
// Find the best weapon the player has. // Find the best weapon the player has.
for (item = Inventory; item != NULL; item = item->Inventory) for (item = Inventory; item != NULL; item = item->Inventory)
{ {
if (!item->IsKindOf (RUNTIME_CLASS(AWeapon))) if (!item->IsKindOf(NAME_Weapon))
continue; continue;
weap = static_cast<AWeapon *> (item); weap = static_cast<AWeapon *> (item);
@ -1136,29 +1136,29 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
if ((dmflags & DF_COOP_LOSE_KEYS) && if ((dmflags & DF_COOP_LOSE_KEYS) &&
defitem == NULL && defitem == NULL &&
item->IsKindOf(PClass::FindActor(NAME_Key))) item->IsKindOf(NAME_Key))
{ {
item->Destroy(); item->Destroy();
} }
else if ((dmflags & DF_COOP_LOSE_WEAPONS) && else if ((dmflags & DF_COOP_LOSE_WEAPONS) &&
defitem == NULL && defitem == NULL &&
item->IsKindOf(RUNTIME_CLASS(AWeapon))) item->IsKindOf(NAME_Weapon))
{ {
item->Destroy(); item->Destroy();
} }
else if ((dmflags & DF_COOP_LOSE_ARMOR) && else if ((dmflags & DF_COOP_LOSE_ARMOR) &&
item->IsKindOf(PClass::FindActor(NAME_Armor))) item->IsKindOf(NAME_Armor))
{ {
if (defitem == NULL) if (defitem == NULL)
{ {
item->Destroy(); item->Destroy();
} }
else if (item->IsKindOf(PClass::FindActor(NAME_BasicArmor))) else if (item->IsKindOf(NAME_BasicArmor))
{ {
item->IntVar(NAME_SavePercent) = defitem->IntVar(NAME_SavePercent); item->IntVar(NAME_SavePercent) = defitem->IntVar(NAME_SavePercent);
item->Amount = defitem->Amount; item->Amount = defitem->Amount;
} }
else if (item->IsKindOf(PClass::FindActor(NAME_HexenArmor))) else if (item->IsKindOf(NAME_HexenArmor))
{ {
double *SlotsTo = (double*)item->ScriptVar(NAME_Slots, nullptr); double *SlotsTo = (double*)item->ScriptVar(NAME_Slots, nullptr);
double *SlotsFrom = (double*)defitem->ScriptVar(NAME_Slots, nullptr); double *SlotsFrom = (double*)defitem->ScriptVar(NAME_Slots, nullptr);
@ -1167,12 +1167,12 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
} }
else if ((dmflags & DF_COOP_LOSE_POWERUPS) && else if ((dmflags & DF_COOP_LOSE_POWERUPS) &&
defitem == NULL && defitem == NULL &&
item->IsKindOf(PClass::FindActor(NAME_PowerupGiver))) item->IsKindOf(NAME_PowerupGiver))
{ {
item->Destroy(); item->Destroy();
} }
else if ((dmflags & (DF_COOP_LOSE_AMMO | DF_COOP_HALVE_AMMO)) && else if ((dmflags & (DF_COOP_LOSE_AMMO | DF_COOP_HALVE_AMMO)) &&
item->IsKindOf(PClass::FindActor(NAME_Ammo))) item->IsKindOf(NAME_Ammo))
{ {
if (defitem == NULL) if (defitem == NULL)
{ {
@ -1412,7 +1412,7 @@ void APlayerPawn::GiveDefaultInventory ()
item = static_cast<AInventory *>(Spawn(ti)); item = static_cast<AInventory *>(Spawn(ti));
item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here
item->Amount = di->Amount; item->Amount = di->Amount;
if (item->IsKindOf(RUNTIME_CLASS(AWeapon))) if (item->IsKindOf(NAME_Weapon))
{ {
// To allow better control any weapon is emptied of // To allow better control any weapon is emptied of
// ammo before being given to the player. // ammo before being given to the player.
@ -1432,7 +1432,7 @@ void APlayerPawn::GiveDefaultInventory ()
item = NULL; item = NULL;
} }
} }
if (item != NULL && item->IsKindOf(RUNTIME_CLASS(AWeapon)) && if (item != NULL && item->IsKindOf(NAME_Weapon) &&
static_cast<AWeapon*>(item)->CheckAmmo(AWeapon::EitherFire, false)) static_cast<AWeapon*>(item)->CheckAmmo(AWeapon::EitherFire, false))
{ {
player->ReadyWeapon = player->PendingWeapon = static_cast<AWeapon *> (item); player->ReadyWeapon = player->PendingWeapon = static_cast<AWeapon *> (item);
@ -1536,7 +1536,7 @@ void APlayerPawn::Die (AActor *source, AActor *inflictor, int dmgflags)
weap->SpawnState != ::GetDefault<AActor>()->SpawnState) weap->SpawnState != ::GetDefault<AActor>()->SpawnState)
{ {
item = P_DropItem (this, weap->GetClass(), -1, 256); item = P_DropItem (this, weap->GetClass(), -1, 256);
if (item != NULL && item->IsKindOf(RUNTIME_CLASS(AWeapon))) if (item != NULL && item->IsKindOf(NAME_Weapon))
{ {
if (weap->AmmoGive1 && weap->Ammo1) if (weap->AmmoGive1 && weap->Ammo1)
{ {
@ -1709,7 +1709,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullPop)
player_t *player; player_t *player;
// [GRB] Parameterized version // [GRB] Parameterized version
if (spawntype == NULL || !spawntype->IsDescendantOf(PClass::FindActor("PlayerChunk"))) if (spawntype == NULL || !spawntype->IsDescendantOf("PlayerChunk"))
{ {
spawntype = dyn_cast<PClassPlayerPawn>(PClass::FindClass("BloodySkull")); spawntype = dyn_cast<PClassPlayerPawn>(PClass::FindClass("BloodySkull"));
if (spawntype == NULL) if (spawntype == NULL)

View file

@ -670,7 +670,7 @@ unsigned P_GetSkyboxPortal(AActor *actor)
unsigned i = level.sectorPortals.Reserve(1); unsigned i = level.sectorPortals.Reserve(1);
memset(&level.sectorPortals[i], 0, sizeof(level.sectorPortals[i])); memset(&level.sectorPortals[i], 0, sizeof(level.sectorPortals[i]));
level.sectorPortals[i].mType = PORTS_SKYVIEWPOINT; level.sectorPortals[i].mType = PORTS_SKYVIEWPOINT;
level.sectorPortals[i].mFlags = actor->GetClass()->IsDescendantOf(PClass::FindActor("SkyCamCompat")) ? 0 : PORTSF_SKYFLATONLY; level.sectorPortals[i].mFlags = actor->GetClass()->IsDescendantOf("SkyCamCompat") ? 0 : PORTSF_SKYFLATONLY;
level.sectorPortals[i].mSkybox = actor; level.sectorPortals[i].mSkybox = actor;
level.sectorPortals[i].mDestination = actor->Sector; level.sectorPortals[i].mDestination = actor->Sector;
return i; return i;

View file

@ -246,7 +246,7 @@ static void CheckForUnsafeStates(PClassActor *obj)
TMap<FState *, bool> checked; TMap<FState *, bool> checked;
ENamedName *test; ENamedName *test;
if (obj->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (obj->IsDescendantOf(NAME_Weapon))
{ {
if (obj->Size == RUNTIME_CLASS(AWeapon)->Size) return; // This class cannot have user variables. if (obj->Size == RUNTIME_CLASS(AWeapon)->Size) return; // This class cannot have user variables.
test = weaponstates; test = weaponstates;
@ -336,11 +336,11 @@ static void CheckStates(PClassActor *obj)
CheckStateLabels(obj, actorstates, SUF_ACTOR, "actor sprites"); CheckStateLabels(obj, actorstates, SUF_ACTOR, "actor sprites");
if (obj->IsDescendantOf(RUNTIME_CLASS(AWeapon))) if (obj->IsDescendantOf(NAME_Weapon))
{ {
CheckStateLabels(obj, weaponstates, SUF_WEAPON, "weapon sprites"); CheckStateLabels(obj, weaponstates, SUF_WEAPON, "weapon sprites");
} }
else if (obj->IsDescendantOf(PClass::FindActor(NAME_CustomInventory))) else if (obj->IsDescendantOf(NAME_CustomInventory))
{ {
CheckStateLabels(obj, pickupstates, SUF_ITEM, "CustomInventory state chain"); CheckStateLabels(obj, pickupstates, SUF_ITEM, "CustomInventory state chain");
} }

View file

@ -2096,9 +2096,9 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory)
int alpha; int alpha;
PalEntry *pBlendColor; PalEntry *pBlendColor;
bool isgiver = info->IsDescendantOf(PClass::FindActor(NAME_PowerupGiver)); bool isgiver = info->IsDescendantOf(NAME_PowerupGiver);
if (info->IsDescendantOf(PClass::FindActor(NAME_Powerup)) || isgiver) if (info->IsDescendantOf(NAME_Powerup) || isgiver)
{ {
pBlendColor = &defaults->ColorVar(NAME_BlendColor); pBlendColor = &defaults->ColorVar(NAME_BlendColor);
} }
@ -2148,7 +2148,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFfff, Inventory)
{ {
PalEntry BlendColor; PalEntry BlendColor;
if (!info->IsDescendantOf(PClass::FindActor(NAME_Powerup)) && !info->IsDescendantOf(PClass::FindActor(NAME_PowerupGiver))) if (!info->IsDescendantOf(NAME_Powerup) && !info->IsDescendantOf(NAME_PowerupGiver))
{ {
I_Error("\"powerup.colormap\" requires an actor of type \"Powerup\"\n"); I_Error("\"powerup.colormap\" requires an actor of type \"Powerup\"\n");
return; return;
@ -2183,7 +2183,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, colormap, FFFfff, Inventory)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY_PREFIX(powerup, duration, I, Inventory) DEFINE_CLASS_PROPERTY_PREFIX(powerup, duration, I, Inventory)
{ {
if (!info->IsDescendantOf(PClass::FindActor(NAME_Powerup)) && !info->IsDescendantOf(PClass::FindActor(NAME_PowerupGiver))) if (!info->IsDescendantOf(NAME_Powerup) && !info->IsDescendantOf(NAME_PowerupGiver))
{ {
I_Error("\"powerup.duration\" requires an actor of type \"Powerup\"\n"); I_Error("\"powerup.duration\" requires an actor of type \"Powerup\"\n");
return; return;
@ -2198,7 +2198,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, duration, I, Inventory)
//========================================================================== //==========================================================================
DEFINE_CLASS_PROPERTY_PREFIX(powerup, strength, F, Inventory) DEFINE_CLASS_PROPERTY_PREFIX(powerup, strength, F, Inventory)
{ {
if (!info->IsDescendantOf(PClass::FindActor(NAME_Powerup)) && !info->IsDescendantOf(PClass::FindActor(NAME_PowerupGiver))) if (!info->IsDescendantOf(NAME_Powerup) && !info->IsDescendantOf(NAME_PowerupGiver))
{ {
I_Error("\"powerup.strength\" requires an actor of type \"Powerup\"\n"); I_Error("\"powerup.strength\" requires an actor of type \"Powerup\"\n");
return; return;
@ -2214,7 +2214,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, mode, S, Inventory)
{ {
PROP_STRING_PARM(str, 0); PROP_STRING_PARM(str, 0);
if (!info->IsDescendantOf(PClass::FindActor(NAME_Powerup)) && !info->IsDescendantOf(PClass::FindActor(NAME_PowerupGiver))) if (!info->IsDescendantOf(NAME_Powerup) && !info->IsDescendantOf(NAME_PowerupGiver))
{ {
I_Error("\"powerup.mode\" requires an actor of type \"Powerup\"\n"); I_Error("\"powerup.mode\" requires an actor of type \"Powerup\"\n");
return; return;

View file

@ -449,4 +449,14 @@ template<> struct THashTraits<FString>
// Compares two keys, returning zero if they are the same. // Compares two keys, returning zero if they are the same.
int Compare(const FString &left, const FString &right) { return left.Compare(right); } int Compare(const FString &left, const FString &right) { return left.Compare(right); }
}; };
class FStringNoInit
{
char mem[sizeof(FString)];
operator FString&()
{
return *reinterpret_cast<FString*>(&mem);
}
};
#endif #endif

View file

@ -252,7 +252,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: TryPickup // Weapon :: TryPickup
// //
// If you can't see the weapon when it's active, then you can't pick it up. // If you can't see the weapon when it's active, then you can't pick it up.
// //
@ -277,7 +277,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: TryPickup // Weapon :: TryPickup
// //
//=========================================================================== //===========================================================================
@ -293,7 +293,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: Use // Weapon :: Use
// //
// Make the player switch to self weapon. // Make the player switch to self weapon.
// //
@ -324,7 +324,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: Destroy // Weapon :: Destroy
// //
//=========================================================================== //===========================================================================
@ -347,7 +347,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: HandlePickup // Weapon :: HandlePickup
// //
// Try to leach ammo from the weapon if you have it already. // Try to leach ammo from the weapon if you have it already.
// //
@ -372,7 +372,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: PickupForAmmo // Weapon :: PickupForAmmo
// //
// The player already has self weapon, so try to pick it up for ammo. // The player already has self weapon, so try to pick it up for ammo.
// //
@ -411,7 +411,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: CreateCopy // Weapon :: CreateCopy
// //
//=========================================================================== //===========================================================================
@ -428,7 +428,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: CreateTossable // Weapon :: CreateTossable
// //
// A weapon that's tossed out should contain no ammo, so you can't cheat // A weapon that's tossed out should contain no ammo, so you can't cheat
// by dropping it and then picking it back up. // by dropping it and then picking it back up.
@ -464,7 +464,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: AttachToOwner // Weapon :: AttachToOwner
// //
//=========================================================================== //===========================================================================
@ -491,7 +491,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: AddAmmo // Weapon :: AddAmmo
// //
// Give some ammo to the owner, even if it's just 0. // Give some ammo to the owner, even if it's just 0.
// //
@ -536,7 +536,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: AddExistingAmmo // Weapon :: AddExistingAmmo
// //
// Give the owner some more ammo he already has. // Give the owner some more ammo he already has.
// //
@ -563,7 +563,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: AddWeapon // Weapon :: AddWeapon
// //
// Give the owner a weapon if they don't have it already. // Give the owner a weapon if they don't have it already.
// //
@ -588,7 +588,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: ShouldStay // Weapon :: ShouldStay
// //
//=========================================================================== //===========================================================================
@ -606,7 +606,7 @@ class Weapon : StateProvider native
//=========================================================================== //===========================================================================
// //
// AWeapon :: EndPowerUp // Weapon :: EndPowerUp
// //
// The Tome of Power just expired. // The Tome of Power just expired.
// //