本文整理汇总了C++中PClass::IsDescendantOf方法的典型用法代码示例。如果您正苦于以下问题:C++ PClass::IsDescendantOf方法的具体用法?C++ PClass::IsDescendantOf怎么用?C++ PClass::IsDescendantOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PClass
的用法示例。
在下文中一共展示了PClass::IsDescendantOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetKeyTypes
static void SetKeyTypes()
{
for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
{
PClass *ti = PClassActor::AllActorClasses[i];
auto kt = PClass::FindActor(NAME_Key);
if (ti->IsDescendantOf(kt))
{
PClassActor *tia = static_cast<PClassActor *>(ti);
AInventory *key = (AInventory*)(GetDefaultByType(tia));
if (key->Icon.isValid() && key->special1 > 0)
{
KeyTypes.Push(tia);
}
else
{
UnassignedKeyTypes.Push(tia);
}
}
}
if (KeyTypes.Size())
{
qsort(&KeyTypes[0], KeyTypes.Size(), sizeof(KeyTypes[0]), ktcmp);
}
else
{
// Don't leave the list empty
KeyTypes.Push(PClass::FindActor(NAME_Key));
}
}
示例2: SetKeyTypes
static void SetKeyTypes()
{
for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
{
PClass *ti = PClassActor::AllActorClasses[i];
if (ti->IsDescendantOf(RUNTIME_CLASS(AKey)))
{
PClassActor *tia = static_cast<PClassActor *>(ti);
AKey *key = (AKey*)GetDefaultByType(tia);
if (key->Icon.isValid() && key->KeyNumber>0)
{
KeyTypes.Push(tia);
}
else
{
UnassignedKeyTypes.Push(tia);
}
}
}
if (KeyTypes.Size())
{
qsort(&KeyTypes[0], KeyTypes.Size(), sizeof(KeyTypes[0]), ktcmp);
}
else
{
// Don't leave the list empty
PClassActor *ti = RUNTIME_CLASS(AKey);
KeyTypes.Push(ti);
}
}
示例3: P_SetupWeapons_ntohton
void P_SetupWeapons_ntohton()
{
unsigned int i;
const PClass *cls;
Weapons_ntoh.Clear();
Weapons_hton.Clear();
cls = NULL;
Weapons_ntoh.Push(cls); // Index 0 is always NULL.
for (i = 0; i < PClass::m_Types.Size(); ++i)
{
PClass *cls = PClass::m_Types[i];
if (cls->ActorInfo != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
Weapons_ntoh.Push(cls);
}
}
qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp);
for (i = 0; i < Weapons_ntoh.Size(); ++i)
{
Weapons_hton[Weapons_ntoh[i]] = i;
}
}
示例4: AddExtraWeapons
void FWeaponSlots::AddExtraWeapons()
{
unsigned int i;
// Set fractional positions for current weapons.
for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
Slots[i].SetInitialPositions();
}
// Append extra weapons to the slots.
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *cls = PClassActor::AllActorClasses[i];
if (!cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
continue;
}
PClassWeapon *acls = static_cast<PClassWeapon *>(cls);
if ((acls->GameFilter == GAME_Any || (acls->GameFilter & gameinfo.gametype)) &&
acls->Replacement == NULL && // Replaced weapons don't get slotted.
!(((AWeapon *)(acls->Defaults))->WeaponFlags & WIF_POWERED_UP) &&
!LocateWeapon(acls, NULL, NULL) // Don't duplicate it if it's already present.
)
{
int slot = acls->SlotNumber;
if ((unsigned)slot < NUM_WEAPON_SLOTS)
{
FWeaponSlot::WeaponInfo info = { acls, acls->SlotPriority };
Slots[slot].Weapons.Push(info);
}
}
}
// Now resort every slot to put the new weapons in their proper places.
for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
Slots[i].Sort();
}
}
示例5: FinishThingdef
static void FinishThingdef()
{
int errorcount = StateParams.ResolveAll();
for (unsigned i = 0;i < PClass::m_Types.Size(); i++)
{
PClass * ti = PClass::m_Types[i];
// Skip non-actors
if (!ti->IsDescendantOf(RUNTIME_CLASS(AActor))) continue;
if (ti->Size == (unsigned)-1)
{
Printf("Class %s referenced but not defined\n", ti->TypeName.GetChars());
errorcount++;
continue;
}
AActor *def = GetDefaultByType(ti);
if (!def)
{
Printf("No ActorInfo defined for class '%s'\n", ti->TypeName.GetChars());
errorcount++;
continue;
}
}
if (errorcount > 0)
{
I_Error("%d errors during actor postprocessing", errorcount);
}
// Since these are defined in DECORATE now the table has to be initialized here.
for(int i=0;i<31;i++)
{
char fmt[20];
mysnprintf(fmt, countof(fmt), "QuestItem%d", i+1);
QuestItemClasses[i] = PClass::FindClass(fmt);
}
}
示例6: AddExtraWeapons
void FWeaponSlots::AddExtraWeapons()
{
unsigned int i;
// Set fractional positions for current weapons.
for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
Slots[i].SetInitialPositions();
}
// Append extra weapons to the slots.
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
{
PClass *cls = PClass::m_Types[i];
if (cls->ActorInfo != NULL &&
(cls->ActorInfo->GameFilter == GAME_Any || (cls->ActorInfo->GameFilter & gameinfo.gametype)) &&
cls->ActorInfo->Replacement == NULL && // Replaced weapons don't get slotted.
cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)) &&
!(static_cast<AWeapon*>(GetDefaultByType(cls))->WeaponFlags & WIF_POWERED_UP) &&
!LocateWeapon(cls, NULL, NULL) // Don't duplicate it if it's already present.
)
{
int slot = cls->Meta.GetMetaInt(AWMETA_SlotNumber, -1);
if ((unsigned)slot < NUM_WEAPON_SLOTS)
{
fixed_t position = cls->Meta.GetMetaFixed(AWMETA_SlotPriority, INT_MAX);
FWeaponSlot::WeaponInfo info = { cls, position };
Slots[slot].Weapons.Push(info);
}
}
}
// Now resort every slot to put the new weapons in their proper places.
for (i = 0; i < NUM_WEAPON_SLOTS; ++i)
{
Slots[i].Sort();
}
}
示例7: HUD_InitHud
void HUD_InitHud()
{
switch (gameinfo.gametype)
{
case GAME_Heretic:
case GAME_Hexen:
healthpic = TexMan.FindTexture("ARTIPTN2");
HudFont=FFont::FindFont("HUDFONT_RAVEN");
break;
case GAME_Strife:
healthpic = TexMan.FindTexture("I_MDKT");
HudFont=BigFont; // Strife doesn't have anything nice so use the standard font
break;
default:
healthpic = TexMan.FindTexture("MEDIA0");
berserkpic = TexMan.FindTexture("PSTRA0");
HudFont=FFont::FindFont("HUDFONT_DOOM");
break;
}
IndexFont = V_GetFont("INDEXFONT");
if (HudFont == NULL) HudFont = BigFont;
if (IndexFont == NULL) IndexFont = ConFont; // Emergency fallback
invgems[0] = TexMan.FindTexture("INVGEML1");
invgems[1] = TexMan.FindTexture("INVGEML2");
invgems[2] = TexMan.FindTexture("INVGEMR1");
invgems[3] = TexMan.FindTexture("INVGEMR2");
fragpic = TexMan.FindTexture("HU_FRAGS"); // Sadly, I don't have anything usable for this. :(
KeyTypes.Clear();
UnassignedKeyTypes.Clear();
statspace = SmallFont->StringWidth("Ac:");
// Now read custom icon overrides
int lump, lastlump = 0;
while ((lump = Wads.FindLump ("ALTHUDCF", &lastlump)) != -1)
{
FScanner sc(lump);
while (sc.GetString())
{
if (sc.Compare("Health"))
{
sc.MustGetString();
FTextureID tex = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
if (tex.isValid()) healthpic = TexMan[tex];
}
else if (sc.Compare("Berserk"))
{
sc.MustGetString();
FTextureID tex = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
if (tex.isValid()) berserkpic = TexMan[tex];
}
else
{
PClass *ti = PClass::FindClass(sc.String);
if (!ti)
{
Printf("Unknown item class '%s' in ALTHUDCF\n", sc.String);
}
else if (!ti->IsDescendantOf(RUNTIME_CLASS(AInventory)))
{
Printf("Invalid item class '%s' in ALTHUDCF\n", sc.String);
ti=NULL;
}
sc.MustGetString();
FTextureID tex;
if (!sc.Compare("0") && !sc.Compare("NULL") && !sc.Compare(""))
{
tex = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
}
else tex.SetInvalid();
if (ti) SetHUDIcon(static_cast<PClassInventory*>(ti), tex);
}
}
}
}
示例8: if
//==========================================================================
//
// Starts a new actor definition
//
//==========================================================================
FActorInfo *CreateNewActor(const FScriptPosition &sc, FName typeName, FName parentName, bool native)
{
const PClass *replacee = NULL;
PClass *ti = NULL;
FActorInfo *info = NULL;
PClass *parent = RUNTIME_CLASS(AActor);
if (parentName != NAME_None)
{
parent = const_cast<PClass *> (PClass::FindClass (parentName));
const PClass *p = parent;
while (p != NULL)
{
if (p->TypeName == typeName)
{
sc.Message(MSG_ERROR, "'%s' inherits from a class with the same name", typeName.GetChars());
break;
}
p = p->ParentClass;
}
if (parent == NULL)
{
sc.Message(MSG_ERROR, "Parent type '%s' not found in %s", parentName.GetChars(), typeName.GetChars());
parent = RUNTIME_CLASS(AActor);
}
else if (!parent->IsDescendantOf(RUNTIME_CLASS(AActor)))
{
sc.Message(MSG_ERROR, "Parent type '%s' is not an actor in %s", parentName.GetChars(), typeName.GetChars());
parent = RUNTIME_CLASS(AActor);
}
else if (parent->ActorInfo == NULL)
{
sc.Message(MSG_ERROR, "uninitialized parent type '%s' in %s", parentName.GetChars(), typeName.GetChars());
parent = RUNTIME_CLASS(AActor);
}
}
if (native)
{
ti = (PClass*)PClass::FindClass(typeName);
if (ti == NULL)
{
sc.Message(MSG_ERROR, "Unknown native class '%s'", typeName.GetChars());
goto create;
}
else if (ti != RUNTIME_CLASS(AActor) && ti->ParentClass->NativeClass() != parent->NativeClass())
{
sc.Message(MSG_ERROR, "Native class '%s' does not inherit from '%s'", typeName.GetChars(), parentName.GetChars());
parent = RUNTIME_CLASS(AActor);
goto create;
}
else if (ti->ActorInfo != NULL)
{
sc.Message(MSG_ERROR, "Redefinition of internal class '%s'", typeName.GetChars());
goto create;
}
ti->InitializeActorInfo();
info = ti->ActorInfo;
}
else
{
create:
ti = parent->CreateDerivedClass (typeName, parent->Size);
info = ti->ActorInfo;
}
// Copy class lists from parent
info->ForbiddenToPlayerClass = parent->ActorInfo->ForbiddenToPlayerClass;
info->RestrictedToPlayerClass = parent->ActorInfo->RestrictedToPlayerClass;
info->VisibleToPlayerClass = parent->ActorInfo->VisibleToPlayerClass;
if (parent->ActorInfo->DamageFactors != NULL)
{
// copy damage factors from parent
info->DamageFactors = new DmgFactors;
*info->DamageFactors = *parent->ActorInfo->DamageFactors;
}
if (parent->ActorInfo->PainChances != NULL)
{
// copy pain chances from parent
info->PainChances = new PainChanceList;
*info->PainChances = *parent->ActorInfo->PainChances;
}
if (parent->ActorInfo->ColorSets != NULL)
{
// copy color sets from parent
info->ColorSets = new FPlayerColorSetMap;
*info->ColorSets = *parent->ActorInfo->ColorSets;
}
info->Replacee = info->Replacement = NULL;
info->DoomEdNum = -1;
return info;
//.........这里部分代码省略.........
示例9: FinishActor
void FinishActor(const FScriptPosition &sc, FActorInfo *info, Baggage &bag)
{
PClass *ti = info->Class;
AActor *defaults = (AActor*)ti->Defaults;
try
{
bag.statedef.FinishStates (info, defaults);
}
catch (CRecoverableError &err)
{
sc.Message(MSG_ERROR, "%s", err.GetMessage());
bag.statedef.MakeStateDefines(NULL);
return;
}
bag.statedef.InstallStates (info, defaults);
bag.statedef.MakeStateDefines(NULL);
if (bag.DropItemSet)
{
if (bag.DropItemList == NULL)
{
if (ti->Meta.GetMetaInt (ACMETA_DropItems) != 0)
{
ti->Meta.SetMetaInt (ACMETA_DropItems, 0);
}
}
else
{
ti->Meta.SetMetaInt (ACMETA_DropItems,
StoreDropItemChain(bag.DropItemList));
}
}
if (ti->IsDescendantOf (RUNTIME_CLASS(AInventory)))
{
defaults->flags |= MF_SPECIAL;
}
// Weapons must be checked for all relevant states. They may crash the game otherwise.
if (ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
FState * ready = ti->ActorInfo->FindState(NAME_Ready);
FState * select = ti->ActorInfo->FindState(NAME_Select);
FState * deselect = ti->ActorInfo->FindState(NAME_Deselect);
FState * fire = ti->ActorInfo->FindState(NAME_Fire);
// Consider any weapon without any valid state abstract and don't output a warning
// This is for creating base classes for weapon groups that only set up some properties.
if (ready || select || deselect || fire)
{
if (!ready)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a ready state.\n", ti->TypeName.GetChars());
}
if (!select)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a select state.\n", ti->TypeName.GetChars());
}
if (!deselect)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a deselect state.\n", ti->TypeName.GetChars());
}
if (!fire)
{
sc.Message(MSG_ERROR, "Weapon %s doesn't define a fire state.\n", ti->TypeName.GetChars());
}
}
}
}
示例10: cht_Take
void cht_Take (player_t *player, const char *name, int amount)
{
bool takeall;
PClassActor *type;
if (player->mo == NULL || player->health <= 0)
{
return;
}
takeall = (stricmp (name, "all") == 0);
if (!takeall && stricmp (name, "health") == 0)
{
if (player->mo->health - amount <= 0
|| player->health - amount <= 0
|| amount == 0)
{
cht_Suicide (player);
if (player == &players[consoleplayer])
C_HideConsole ();
return;
}
if (amount > 0)
{
if (player->mo)
{
player->mo->health -= amount;
player->health = player->mo->health;
}
else
{
player->health -= amount;
}
}
if (!takeall)
return;
}
if (takeall || stricmp (name, "backpack") == 0)
{
// Take away all types of backpacks the player might own.
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *type = PClassActor::AllActorClasses[i];
if (type->IsDescendantOf(RUNTIME_CLASS (ABackpackItem)))
{
AInventory *pack = player->mo->FindInventory(static_cast<PClassActor *>(type));
if (pack)
pack->Destroy();
}
}
if (!takeall)
return;
}
if (takeall || stricmp (name, "ammo") == 0)
{
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *type = PClassActor::AllActorClasses[i];
if (type->ParentClass == RUNTIME_CLASS (AAmmo))
{
AInventory *ammo = player->mo->FindInventory(static_cast<PClassActor *>(type));
if (ammo)
ammo->DepleteOrDestroy();
}
}
if (!takeall)
return;
}
if (takeall || stricmp (name, "armor") == 0)
{
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
type = PClassActor::AllActorClasses[i];
if (type->IsDescendantOf (RUNTIME_CLASS (AArmor)))
{
AInventory *armor = player->mo->FindInventory(static_cast<PClassActor *>(type));
if (armor)
armor->DepleteOrDestroy();
}
}
if (!takeall)
return;
//.........这里部分代码省略.........
示例11: NETWORK_Construct
//.........这里部分代码省略.........
// at this point is to parse all LOADACS lumps.
{
int lump, lastlump = 0;
while ((lump = Wads.FindLump ("LOADACS", &lastlump)) != -1)
{
FScanner sc(lump);
while (sc.GetString())
{
NETWORK_AddLumpForAuthentication ( Wads.CheckNumForName (sc.String, ns_acslibrary) );
}
}
}
// [BB] First check the lumps that were marked for authentication while initializing. This
// includes for example those lumps included by DECORATE lumps. It's much easier to mark those
// lumps while the engine parses the DECORATE code than trying to find all included lumps from
// the DECORATE lumps directly.
for ( unsigned int i = 0; i < g_LumpNumsToAuthenticate.Size(); ++i )
{
if ( !network_GenerateLumpMD5HashAndWarnIfNeeded( g_LumpNumsToAuthenticate[i], Wads.GetLumpFullName (g_LumpNumsToAuthenticate[i]), checksum ) )
noProtectedLumpsAutoloaded = false;
longChecksum += checksum;
}
for ( unsigned int i = 0; i < lumpsToAuthenticate.size(); i++ )
{
switch ( lumpsToAuthenticateMode[i] ){
case LAST_LUMP:
int lump;
lump = Wads.CheckNumForName(lumpsToAuthenticate[i].c_str());
// [BB] Possibly we find the COLORMAP lump only in the colormaps name space.
if ( ( lump == -1 ) && ( lumpsToAuthenticate[i].compare ( "COLORMAP" ) == 0 ) )
lump = Wads.CheckNumForName("COLORMAP", ns_colormaps);
if ( lump == -1 )
{
Printf ( PRINT_BOLD, "Warning: Can't find lump %s for authentication!\n", lumpsToAuthenticate[i].c_str() );
continue;
}
if ( !network_GenerateLumpMD5HashAndWarnIfNeeded( lump, lumpsToAuthenticate[i].c_str(), checksum ) )
noProtectedLumpsAutoloaded = false;
// [BB] To make Doom and Freedoom network compatible, substitue the Freedoom PLAYPAL/COLORMAP hash
// by the corresponding Doom hash.
// 4804c7f34b5285c334a7913dd98fae16 Doom PLAYPAL hash
// 061a4c0f80aa8029f2c1bc12dc2e261e Doom COLORMAP hash
// 2e01ae6258f2a0fdad32125537efe1af Freedoom PLAYPAL hash
// bb535e66cae508e3833a5d2de974267b Freedoom COLORMAP hash
if ( ( stricmp ( lumpsToAuthenticate[i].c_str(), "PLAYPAL" ) == 0 ) && ( stricmp ( checksum.GetChars(), "2e01ae6258f2a0fdad32125537efe1af" ) == 0 ) )
checksum = "4804c7f34b5285c334a7913dd98fae16";
else if ( ( stricmp ( lumpsToAuthenticate[i].c_str(), "COLORMAP" ) == 0 ) && ( stricmp ( checksum.GetChars(), "bb535e66cae508e3833a5d2de974267b" ) == 0 ) )
checksum = "061a4c0f80aa8029f2c1bc12dc2e261e";
longChecksum += checksum;
break;
case ALL_LUMPS:
int workingLump, lastLump;
lastLump = 0;
while ((workingLump = Wads.FindLump(lumpsToAuthenticate[i].c_str(), &lastLump)) != -1)
{
if ( !network_GenerateLumpMD5HashAndWarnIfNeeded( workingLump, lumpsToAuthenticate[i].c_str(), checksum ) )
noProtectedLumpsAutoloaded = false;
longChecksum += checksum;
}
break;
}
}
CMD5Checksum::GetMD5( reinterpret_cast<const BYTE *>(longChecksum.GetChars()), longChecksum.Len(), g_lumpsAuthenticationChecksum );
// [BB] Warn the user about problematic auto-loaded files.
if ( noProtectedLumpsAutoloaded == false )
{
Printf ( PRINT_BOLD, "Warning: Above auto-loaded files contain protected lumps.\n" );
if ( Args->CheckParm( "-host" ) )
Printf ( PRINT_BOLD, "Clients without these files can't connect to this server.\n" );
else
Printf ( PRINT_BOLD, "You can't connect to servers without these files.\n" );
}
// [BB] Initialize the actor network class indices.
for ( unsigned int i = 0; i < PClass::m_Types.Size(); i++ )
{
PClass* cls = PClass::m_Types[i];
if ( (cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
// [BB] The server only binaries don't know DynamicLight and derived classes.
&& !(cls->IsDescendantOf(PClass::FindClass("DynamicLight"))) )
cls->ActorNetworkIndex = 1 + g_ActorNetworkIndexClassPointerMap.Push ( cls );
else
cls->ActorNetworkIndex = 0;
}
// [RC/BB] Init the list of PWADs.
network_InitPWADList( );
// Call NETWORK_Destruct() when Skulltag closes.
atterm( NETWORK_Destruct );
Printf( "UDP Initialized.\n" );
}
示例12: if
FState *FStateDefinitions::ResolveGotoLabel (AActor *actor, PClassActor *mytype, char *name)
{
PClassActor *type = mytype;
FState *state;
char *namestart = name;
char *label, *offset, *pt;
int v;
// Check for classname
if ((pt = strstr (name, "::")) != NULL)
{
const char *classname = name;
*pt = '\0';
name = pt + 2;
// The classname may either be "Super" to identify this class's immediate
// superclass, or it may be the name of any class that this one derives from.
if (stricmp (classname, "Super") == 0)
{
type = dyn_cast<PClassActor>(type->ParentClass);
actor = GetDefaultByType(type);
}
else
{
// first check whether a state of the desired name exists
PClass *stype = PClass::FindClass (classname);
if (stype == NULL)
{
I_Error ("%s is an unknown class.", classname);
}
if (!stype->IsDescendantOf (RUNTIME_CLASS(AActor)))
{
I_Error ("%s is not an actor class, so it has no states.", stype->TypeName.GetChars());
}
if (!stype->IsAncestorOf (type))
{
I_Error ("%s is not derived from %s so cannot access its states.",
type->TypeName.GetChars(), stype->TypeName.GetChars());
}
if (type != stype)
{
type = static_cast<PClassActor *>(stype);
actor = GetDefaultByType (type);
}
}
}
label = name;
// Check for offset
offset = NULL;
if ((pt = strchr (name, '+')) != NULL)
{
*pt = '\0';
offset = pt + 1;
}
v = offset ? strtol (offset, NULL, 0) : 0;
// Get the state's address.
if (type == mytype)
{
state = FindState (label);
}
else
{
state = type->FindStateByString(label, true);
}
if (state != NULL)
{
state += v;
}
else if (v != 0)
{
I_Error ("Attempt to get invalid state %s from actor %s.", label, type->TypeName.GetChars());
}
else
{
Printf (TEXTCOLOR_RED "Attempt to get invalid state %s from actor %s.\n", label, type->TypeName.GetChars());
}
delete[] namestart; // free the allocated string buffer
return state;
}