- 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
commit a6785afddb
28 changed files with 126 additions and 97 deletions

View file

@ -2629,7 +2629,7 @@ void FParser::SF_MaxPlayerAmmo()
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]);
else amount*=2;
@ -2676,7 +2676,7 @@ void FParser::SF_PlayerWeapon()
return;
}
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);
return;
@ -2712,7 +2712,7 @@ void FParser::SF_PlayerWeapon()
{
if (!wp)
{
AWeapon * pw=players[playernum].PendingWeapon;
auto pw=players[playernum].PendingWeapon;
players[playernum].mo->GiveInventoryType(ti);
players[playernum].PendingWeapon=pw;
}
@ -2757,7 +2757,7 @@ void FParser::SF_PlayerSelectedWeapon()
return;
}
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);
return;
@ -2862,7 +2862,7 @@ void FParser::SF_SetWeapon()
{
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)
@ -2874,7 +2874,7 @@ void FParser::SF_SetWeapon()
}
else
{
AWeapon *weap = static_cast<AWeapon *> (item);
auto weap = static_cast<AWeapon *> (item);
if (weap->CheckAmmo (AWeapon::EitherFire, false))
{