Export DecalBase
Allows setting this between Actors with type safety. Now also serializes these fields.
This commit is contained in:
parent
4acc5f2a7d
commit
b6b3c311e1
8 changed files with 61 additions and 2 deletions
|
|
@ -871,6 +871,13 @@ void FDecalLib::AddDecal (FDecalBase *decal)
|
|||
}
|
||||
}
|
||||
|
||||
FDecalBase* FDecalLib::GetDecalBaseByName(const char* name) const
|
||||
{
|
||||
if (name == nullptr)
|
||||
return nullptr;
|
||||
return ScanTreeForName(name, Root);
|
||||
}
|
||||
|
||||
const FDecalTemplate *FDecalLib::GetDecalByNum (uint16_t num) const
|
||||
{
|
||||
if (num == 0)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public:
|
|||
void ReadDecals (FScanner &sc);
|
||||
void ReadAllDecals ();
|
||||
|
||||
FDecalBase* GetDecalBaseByName(const char* name) const;
|
||||
const FDecalTemplate *GetDecalByNum (uint16_t num) const;
|
||||
const FDecalTemplate *GetDecalByName (const char *name) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -434,7 +434,8 @@ void AActor::Serialize(FSerializer &arc)
|
|||
("premorphproperties", PremorphProperties)
|
||||
("morphexitflash", MorphExitFlash)
|
||||
("damagesource", damagesource)
|
||||
("behaviors", Behaviors);
|
||||
("behaviors", Behaviors)
|
||||
A("decalgenerator", DecalGenerator);
|
||||
|
||||
|
||||
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
#include "types.h"
|
||||
#include "dictionary.h"
|
||||
#include "events.h"
|
||||
#include "decallib.h"
|
||||
|
||||
static TArray<FPropertyInfo*> properties;
|
||||
static TArray<AFuncDesc> AFTable;
|
||||
|
|
@ -779,6 +780,21 @@ void InitThingdef()
|
|||
skillstruct->Size = sizeof(FSkillInfo);
|
||||
skillstruct->Align = alignof(FSkillInfo);
|
||||
|
||||
auto decalbasestruct = NewStruct("DecalBase", nullptr, true);
|
||||
decalbasestruct->Size = sizeof(FDecalBase);
|
||||
decalbasestruct->Align = alignof(FDecalBase);
|
||||
NewPointer(decalbasestruct, false)->InstallHandlers(
|
||||
[](FSerializer& ar, const char* key, const void* addr)
|
||||
{
|
||||
ar(key, *(FDecalBase**)addr);
|
||||
},
|
||||
[](FSerializer& ar, const char* key, void* addr)
|
||||
{
|
||||
Serialize<FDecalBase>(ar, key, *(FDecalBase**)addr, nullptr);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
PStruct *pstruct = NewStruct("PlayerInfo", nullptr, true);
|
||||
pstruct->Size = sizeof(player_t);
|
||||
pstruct->Align = alignof(player_t);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "p_conversation.h"
|
||||
#include "p_terrain.h"
|
||||
#include "decallib.h"
|
||||
|
||||
#include "serializer_internal.h"
|
||||
|
||||
|
|
@ -449,6 +450,34 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState
|
|||
|
||||
}
|
||||
|
||||
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FDecalBase*& decal, FDecalBase** def)
|
||||
{
|
||||
if (arc.isWriting())
|
||||
{
|
||||
if (!arc.w->inObject() || def == nullptr || decal != *def)
|
||||
{
|
||||
arc.WriteKey(key);
|
||||
if (decal == nullptr)
|
||||
arc.w->Null();
|
||||
else
|
||||
arc.w->String(decal->GetDecalName().GetChars());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto d = arc.r->FindKey(key);
|
||||
if (d != nullptr)
|
||||
{
|
||||
if (!d->IsString())
|
||||
decal = nullptr;
|
||||
else
|
||||
decal = DecalLibrary.GetDecalBaseByName(d->GetString());
|
||||
}
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ struct FDoorAnimation;
|
|||
struct FPolyObj;
|
||||
struct FInterpolator;
|
||||
struct FLevelLocals;
|
||||
class FDecalBase;
|
||||
|
||||
class FDoomSerializer : public FSerializer
|
||||
{
|
||||
|
|
@ -59,6 +60,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, FDoorAnimat
|
|||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, char *&pstr, char **def);
|
||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, FLevelLocals *&font, FLevelLocals **def);
|
||||
FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState **def, bool *retcode);
|
||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, FDecalBase *&decal, FDecalBase **def);
|
||||
template<> inline FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState **def)
|
||||
{
|
||||
return Serialize(arc, key, state, def, nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue