mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- removed PClass::DeriveData because it is no longer needed.
- fixed: IsVisibleToPlayer and optimized it a bit more. - moved SourceLumpName to PClass, so that it can also be used for non-actors (there's a lot of non-Actor classes already.) - separated the serializer for PClassPointer from PPointer. Even though not doable, a pointer to a class type is something entirely different than a class pointer with a restriction so each should handle its own case.
This commit is contained in:
parent
0e0eca0e0f
commit
5350721ec5
8 changed files with 40 additions and 62 deletions
|
@ -91,7 +91,7 @@ CCMD (dumpactors)
|
|||
"25:DoomStrifeChex", "26:HereticStrifeChex", "27:NotHexen", "28:HexenStrifeChex", "29:NotHeretic",
|
||||
"30:NotDoom", "31:All",
|
||||
};
|
||||
Printf("%i object class types total\nActor\tEd Num\tSpawnID\tFilter\tSource\n", PClass::AllClasses.Size());
|
||||
Printf("%u object class types total\nActor\tEd Num\tSpawnID\tFilter\tSource\n", PClass::AllClasses.Size());
|
||||
for (unsigned int i = 0; i < PClass::AllClasses.Size(); i++)
|
||||
{
|
||||
PClass *cls = PClass::AllClasses[i];
|
||||
|
@ -102,11 +102,11 @@ CCMD (dumpactors)
|
|||
Printf("%s\t%i\t%i\t%s\t%s\n",
|
||||
acls->TypeName.GetChars(), ainfo->DoomEdNum,
|
||||
ainfo->SpawnID, filters[ainfo->GameFilter & 31],
|
||||
acls->ActorInfo()->SourceLumpName.GetChars());
|
||||
acls->SourceLumpName.GetChars());
|
||||
}
|
||||
else if (cls != NULL)
|
||||
{
|
||||
Printf("%s\tn/a\tn/a\tn/a\tEngine (not an actor type)\n", cls->TypeName.GetChars());
|
||||
Printf("%s\tn/a\tn/a\tn/a\tEngine (not an actor type)\tSource: %s\n", cls->TypeName.GetChars(), cls->SourceLumpName.GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1421,16 +1421,7 @@ void PPointer::WriteValue(FSerializer &ar, const char *key,const void *addr) con
|
|||
{
|
||||
if (PointedType->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
auto pt = static_cast<PClass*>(PointedType);
|
||||
|
||||
if (pt->IsDescendantOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
ar(key, *(PClass **)addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
ar(key, *(DObject **)addr);
|
||||
}
|
||||
ar(key, *(DObject **)addr);
|
||||
}
|
||||
else if (writer != nullptr)
|
||||
{
|
||||
|
@ -1452,17 +1443,8 @@ bool PPointer::ReadValue(FSerializer &ar, const char *key, void *addr) const
|
|||
{
|
||||
if (PointedType->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
auto pt = static_cast<PClass*>(PointedType);
|
||||
bool res = true;
|
||||
|
||||
if (pt->IsDescendantOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
::Serialize(ar, key, *(PClass **)addr, (PClass**)nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
::Serialize(ar, key, *(DObject **)addr, nullptr, &res);
|
||||
}
|
||||
bool res;
|
||||
::Serialize(ar, key, *(DObject **)addr, nullptr, &res);
|
||||
return res;
|
||||
}
|
||||
else if (reader != nullptr)
|
||||
|
@ -1550,13 +1532,34 @@ PClassPointer::PClassPointer(PClass *restrict)
|
|||
{
|
||||
if (restrict) mDescriptiveName.Format("ClassPointer<%s>", restrict->TypeName.GetChars());
|
||||
else mDescriptiveName = "ClassPointer";
|
||||
// class pointers do not need write barriers because all classes are stored in the global type table and won't get collected.
|
||||
// This means we can use the cheapoer non-barriered opcodes here.
|
||||
loadOp = OP_LOS;
|
||||
loadOp = OP_LP;
|
||||
storeOp = OP_SP;
|
||||
mVersion = restrict->mVersion;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PPointer :: WriteValue
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClassPointer::WriteValue(FSerializer &ar, const char *key, const void *addr) const
|
||||
{
|
||||
ar(key, *(PClass **)addr);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PPointer :: ReadValue
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool PClassPointer::ReadValue(FSerializer &ar, const char *key, void *addr) const
|
||||
{
|
||||
::Serialize(ar, key, *(PClass **)addr, (PClass**)nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClassPointer - isCompatible
|
||||
|
@ -3304,18 +3307,6 @@ void PClass::InitializeDefaults()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClass :: DeriveData
|
||||
//
|
||||
// Copies inheritable data to the child class.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClass::DeriveData(PClass *newclass)
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClass :: CreateDerivedClass
|
||||
|
@ -3365,7 +3356,6 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size)
|
|||
{
|
||||
type->InitializeDefaults();
|
||||
type->Virtuals = Virtuals;
|
||||
DeriveData(type);
|
||||
}
|
||||
else
|
||||
type->ObjectFlags &= OF_Transient;
|
||||
|
|
|
@ -429,6 +429,8 @@ public:
|
|||
class PClass *ClassRestriction;
|
||||
|
||||
bool isCompatible(PType *type);
|
||||
void WriteValue(FSerializer &ar, const char *key, const void *addr) const override;
|
||||
bool ReadValue(FSerializer &ar, const char *key, void *addr) const override;
|
||||
|
||||
void SetPointer(void *base, unsigned offset, TArray<size_t> *special = NULL) const override;
|
||||
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
|
||||
|
@ -600,7 +602,6 @@ public:
|
|||
bool ReadAllFields(FSerializer &ar, void *addr) const;
|
||||
void InitializeDefaults();
|
||||
int FindVirtualIndex(FName name, PPrototype *proto);
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
|
||||
static void StaticInit();
|
||||
static void StaticShutdown();
|
||||
|
@ -619,6 +620,7 @@ public:
|
|||
bool bExported; // This type has been declared in a script
|
||||
bool bDecorateClass; // may be subject to some idiosyncracies due to DECORATE backwards compatibility
|
||||
TArray<VMFunction*> Virtuals; // virtual function table
|
||||
FName SourceLumpName;
|
||||
|
||||
void (*ConstructNative)(void *);
|
||||
|
||||
|
|
12
src/info.cpp
12
src/info.cpp
|
@ -307,18 +307,6 @@ PClassActor::~PClassActor()
|
|||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClassActor :: Derive
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClassActor::DeriveData(PClass *newclass)
|
||||
{
|
||||
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
PClassActor *newa = static_cast<PClassActor *>(newclass);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClassActor :: SetReplacement
|
||||
|
|
|
@ -247,8 +247,7 @@ struct FActorInfo
|
|||
uint8_t GameFilter = GAME_Any;
|
||||
uint16_t SpawnID = 0;
|
||||
uint16_t ConversationID = 0;
|
||||
int16_t DoomEdNum = 0;
|
||||
FString SourceLumpName;
|
||||
int16_t DoomEdNum = -1;
|
||||
|
||||
FStateLabels *StateList = nullptr;
|
||||
DmgFactors DamageFactors;
|
||||
|
@ -294,7 +293,6 @@ protected:
|
|||
public:
|
||||
static void StaticInit ();
|
||||
static void StaticSetActorNums ();
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
|
||||
PClassActor();
|
||||
~PClassActor();
|
||||
|
|
|
@ -1605,11 +1605,14 @@ bool AActor::IsVisibleToPlayer() const
|
|||
(signed)(VisibleToTeam-1) != players[consoleplayer].userinfo.GetTeam() )
|
||||
return false;
|
||||
|
||||
auto &vis = GetInfo()->VisibleToPlayerClass;
|
||||
if (vis.Size() == 0) return true; // early out for the most common case.
|
||||
|
||||
const player_t* pPlayer = players[consoleplayer].camera->player;
|
||||
|
||||
if (pPlayer)
|
||||
{
|
||||
for(auto cls : GetInfo()->VisibleToPlayerClass)
|
||||
for(auto cls : vis)
|
||||
{
|
||||
if (cls && pPlayer->mo->GetClass()->IsDescendantOf(cls))
|
||||
{
|
||||
|
|
|
@ -1109,7 +1109,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag)
|
|||
{
|
||||
PClassActor *info = CreateNewActor(sc, typeName, parentName);
|
||||
info->ActorInfo()->DoomEdNum = DoomEdNum > 0 ? DoomEdNum : -1;
|
||||
info->ActorInfo()->SourceLumpName = Wads.GetLumpFullPath(sc.LumpNum);
|
||||
info->SourceLumpName = Wads.GetLumpFullPath(sc.LumpNum);
|
||||
|
||||
if (!info->SetReplacement(replaceName))
|
||||
{
|
||||
|
|
|
@ -625,8 +625,7 @@ void ZCCCompiler::CreateClassTypes()
|
|||
DPrintf(DMSG_SPAMMY, "Registered %s as native with parent %s\n", me->TypeName.GetChars(), parent->TypeName.GetChars());
|
||||
}
|
||||
c->cls->Type = me;
|
||||
auto ac = dyn_cast<PClassActor>(me);
|
||||
if (ac != nullptr) ac->ActorInfo()->SourceLumpName = *c->cls->SourceName;
|
||||
me->SourceLumpName = *c->cls->SourceName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2194,7 +2193,6 @@ void ZCCCompiler::InitDefaults()
|
|||
FString mename = ti->TypeName.GetChars();
|
||||
|
||||
ti->InitializeDefaults();
|
||||
ti->ParentClass->DeriveData(ti);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2215,7 +2213,6 @@ void ZCCCompiler::InitDefaults()
|
|||
auto ti = static_cast<PClassActor *>(c->Type());
|
||||
|
||||
ti->InitializeDefaults();
|
||||
ti->ParentClass->DeriveData(ti);
|
||||
|
||||
// We need special treatment for this one field in AActor's defaults which cannot be made visible to DECORATE as a property.
|
||||
// It's better to do this here under controlled conditions than deeper down in the class type classes.
|
||||
|
|
Loading…
Reference in a new issue