mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- replaced more dyn_casts and checks for RUNTIME_CLASS(PClassActor)
It is preferable to use IsDescendantOf wherever possible if we ever want to be able to separate PClass from PType.
This commit is contained in:
parent
5350721ec5
commit
9c9b2ccf6d
13 changed files with 28 additions and 23 deletions
11
src/actor.h
11
src/actor.h
|
@ -1572,6 +1572,17 @@ template<class T> inline T *Spawn() // for inventory items we do not need coordi
|
|||
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), DVector3(0, 0, 0), NO_REPLACE));
|
||||
}
|
||||
|
||||
inline PClassActor *PClass::FindActor(FName name)
|
||||
{
|
||||
auto cls = FindClass(name);
|
||||
return cls && cls->IsDescendantOf(RUNTIME_CLASS(AActor)) ? static_cast<PClassActor*>(cls) : nullptr;
|
||||
}
|
||||
|
||||
inline PClassActor *ValidateActor(PClass *cls)
|
||||
{
|
||||
return cls && cls->IsDescendantOf(RUNTIME_CLASS(AActor)) ? static_cast<PClassActor*>(cls) : nullptr;
|
||||
}
|
||||
|
||||
void PrintMiscActorInfo(AActor * query);
|
||||
AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, uint32_t wallMask);
|
||||
|
||||
|
|
|
@ -2827,7 +2827,7 @@ static bool LoadDehSupp ()
|
|||
{
|
||||
sc.ScriptError ("Can't find type %s", sc.String);
|
||||
}
|
||||
else if (!type->IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
else if (!type->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
sc.ScriptError ("%s is not an actor", sc.String);
|
||||
}
|
||||
|
|
|
@ -2592,7 +2592,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
|||
char *classname = ReadString(stream);
|
||||
int removecount = 0;
|
||||
PClassActor *cls = PClass::FindActor(classname);
|
||||
if (cls != NULL && cls->IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
removecount = RemoveClass(cls);
|
||||
const PClass *cls_rep = cls->GetReplacement();
|
||||
|
|
|
@ -95,7 +95,7 @@ CCMD (dumpactors)
|
|||
for (unsigned int i = 0; i < PClass::AllClasses.Size(); i++)
|
||||
{
|
||||
PClass *cls = PClass::AllClasses[i];
|
||||
PClassActor *acls = dyn_cast<PClassActor>(cls);
|
||||
PClassActor *acls = ValidateActor(cls);
|
||||
if (acls != NULL)
|
||||
{
|
||||
auto ainfo = acls->ActorInfo();
|
||||
|
|
|
@ -3229,7 +3229,7 @@ void PClass::Derive(PClass *newclass, FName name)
|
|||
|
||||
void PClass::InitializeDefaults()
|
||||
{
|
||||
if (IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
if (IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
assert(Defaults == nullptr);
|
||||
Defaults = (uint8_t *)M_Malloc(Size);
|
||||
|
|
|
@ -354,11 +354,6 @@ public:
|
|||
static TArray<PClassActor *> AllActorClasses;
|
||||
};
|
||||
|
||||
inline PClassActor *PClass::FindActor(FName name)
|
||||
{
|
||||
return dyn_cast<PClassActor>(FindClass(name));
|
||||
}
|
||||
|
||||
struct FDoomEdEntry
|
||||
{
|
||||
PClassActor *Type;
|
||||
|
|
|
@ -9777,8 +9777,7 @@ scriptwait:
|
|||
}
|
||||
else
|
||||
{
|
||||
AInventory *item = activator->FindInventory (dyn_cast<PClassActor>(
|
||||
PClass::FindClass (FBehavior::StaticLookupString (STACK(1)))));
|
||||
AInventory *item = activator->FindInventory (PClass::FindActor (FBehavior::StaticLookupString (STACK(1))));
|
||||
|
||||
if (item == NULL || !item->IsKindOf(NAME_Weapon))
|
||||
{
|
||||
|
|
|
@ -367,7 +367,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, uint32_t &prevSpea
|
|||
node->SpeakerName = speech.Name;
|
||||
|
||||
// The item the speaker should drop when killed.
|
||||
node->DropType = dyn_cast<PClassActor>(GetStrifeType(speech.DropType));
|
||||
node->DropType = GetStrifeType(speech.DropType);
|
||||
|
||||
// Items you need to have to make the speaker use a different node.
|
||||
node->ItemCheck.Resize(3);
|
||||
|
@ -447,7 +447,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, uint32_t &prevSpea
|
|||
node->SpeakerName = speech.Name;
|
||||
|
||||
// The item the speaker should drop when killed.
|
||||
node->DropType = dyn_cast<PClassActor>(GetStrifeType (speech.DropType));
|
||||
node->DropType = GetStrifeType (speech.DropType);
|
||||
|
||||
// Items you need to have to make the speaker use a different node.
|
||||
node->ItemCheck.Resize(3);
|
||||
|
@ -512,7 +512,7 @@ static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses)
|
|||
reply->LogString = "";
|
||||
|
||||
// The item to receive when this reply is used.
|
||||
reply->GiveType = dyn_cast<PClassActor>(GetStrifeType (rsp->GiveType));
|
||||
reply->GiveType = GetStrifeType (rsp->GiveType);
|
||||
reply->ActionSpecial = 0;
|
||||
|
||||
// Do you need anything special for this reply to succeed?
|
||||
|
|
|
@ -5041,7 +5041,7 @@ PClassActor *ClassForSpawn(FName classname)
|
|||
{
|
||||
I_Error("Attempt to spawn actor of unknown type '%s'\n", classname.GetChars());
|
||||
}
|
||||
if (!cls->IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
if (!cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
I_Error("Attempt to spawn non-actor of type '%s'\n", classname.GetChars());
|
||||
}
|
||||
|
@ -5863,7 +5863,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
|
|||
Printf ("%s at (%.1f, %.1f) has no frames\n",
|
||||
i->TypeName.GetChars(), mthing->pos.X, mthing->pos.Y);
|
||||
i = PClass::FindActor("Unknown");
|
||||
assert(i->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
assert(i->IsDescendantOf(RUNTIME_CLASS(AActor)));
|
||||
}
|
||||
|
||||
const AActor *info = GetDefaultByType (i);
|
||||
|
|
|
@ -120,7 +120,7 @@ PClassActor *FState::StaticFindStateOwner (const FState *state, PClassActor *inf
|
|||
{
|
||||
return info;
|
||||
}
|
||||
info = dyn_cast<PClassActor>(info->ParentClass);
|
||||
info = ValidateActor(info->ParentClass);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -739,7 +739,7 @@ FState *FStateDefinitions::ResolveGotoLabel (AActor *actor, PClassActor *mytype,
|
|||
// 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);
|
||||
type = ValidateActor(type->ParentClass);
|
||||
actor = GetDefaultByType(type);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -10982,7 +10982,7 @@ FxExpression *FxMultiNameState::Resolve(FCompileContext &ctx)
|
|||
}
|
||||
else if (names[0] == NAME_Super)
|
||||
{
|
||||
scope = dyn_cast<PClassActor>(clstype->ParentClass);
|
||||
scope = ValidateActor(clstype->ParentClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -582,7 +582,7 @@ static FState *CheckState(FScanner &sc, PClass *type)
|
|||
FState *state = NULL;
|
||||
sc.MustGetString();
|
||||
|
||||
PClassActor *info = dyn_cast<PClassActor>(type->ParentClass);
|
||||
PClassActor *info = ValidateActor(type->ParentClass);
|
||||
|
||||
if (info != NULL)
|
||||
{
|
||||
|
@ -999,7 +999,7 @@ PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName par
|
|||
sc.Message(MSG_ERROR, "'%s' inherits from a class with the same name", typeName.GetChars());
|
||||
break;
|
||||
}
|
||||
p = dyn_cast<PClassActor>(p->ParentClass);
|
||||
p = ValidateActor(p->ParentClass);
|
||||
}
|
||||
|
||||
if (parent == NULL)
|
||||
|
|
|
@ -1385,7 +1385,7 @@ void ZCCCompiler::CompileAllProperties()
|
|||
|
||||
bool ZCCCompiler::CompileProperties(PClass *type, TArray<ZCC_Property *> &Properties, FName prefix)
|
||||
{
|
||||
if (!type->IsKindOf(RUNTIME_CLASS(PClassActor)))
|
||||
if (!type->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
Error(Properties[0], "Properties can only be defined for actors");
|
||||
return false;
|
||||
|
@ -2850,7 +2850,7 @@ void ZCCCompiler::CompileStates()
|
|||
|
||||
FString statename; // The state builder wants the label as one complete string, not separated into tokens.
|
||||
FStateDefinitions statedef;
|
||||
statedef.MakeStateDefines(dyn_cast<PClassActor>(c->Type()->ParentClass));
|
||||
statedef.MakeStateDefines(ValidateActor(c->Type()->ParentClass));
|
||||
int numframes = 0;
|
||||
|
||||
for (auto s : c->States)
|
||||
|
|
Loading…
Reference in a new issue