mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
- converted FBehavior::StaticSerializeModuleStates.
- removed some code which is no longer needed.
This commit is contained in:
parent
42e38f6cc1
commit
cf1e6d5275
10 changed files with 61 additions and 116 deletions
|
@ -414,18 +414,12 @@ public:
|
||||||
return GC::ReadBarrier(p) == u;
|
return GC::ReadBarrier(p) == u;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U> friend inline FArchive &operator<<(FArchive &arc, TObjPtr<U> &o);
|
|
||||||
template<class U> friend inline void GC::Mark(TObjPtr<U> &obj);
|
template<class U> friend inline void GC::Mark(TObjPtr<U> &obj);
|
||||||
template<class U> friend FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, TObjPtr<U> *);
|
template<class U> friend FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, TObjPtr<U> *);
|
||||||
|
|
||||||
friend class DObject;
|
friend class DObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T> inline FArchive &operator<<(FArchive &arc, TObjPtr<T> &o)
|
|
||||||
{
|
|
||||||
return arc << o.p;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use barrier_cast instead of static_cast when you need to cast
|
// Use barrier_cast instead of static_cast when you need to cast
|
||||||
// the contents of a TObjPtr to a related type.
|
// the contents of a TObjPtr to a related type.
|
||||||
template<class T,class U> inline T barrier_cast(TObjPtr<U> &o)
|
template<class T,class U> inline T barrier_cast(TObjPtr<U> &o)
|
||||||
|
|
|
@ -212,7 +212,6 @@ class PClassInventory;
|
||||||
class FTextureID
|
class FTextureID
|
||||||
{
|
{
|
||||||
friend class FTextureManager;
|
friend class FTextureManager;
|
||||||
friend FArchive &operator<< (FArchive &arc, FTextureID &tex);
|
|
||||||
friend FTextureID GetHUDIcon(PClassInventory *cls);
|
friend FTextureID GetHUDIcon(PClassInventory *cls);
|
||||||
friend void R_InitSpriteDefs();
|
friend void R_InitSpriteDefs();
|
||||||
|
|
||||||
|
|
130
src/p_acs.cpp
130
src/p_acs.cpp
|
@ -1628,64 +1628,72 @@ void FBehavior::UnlockMapVarStrings() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBehavior::StaticSerializeModuleStates (FArchive &arc)
|
void FBehavior::StaticSerializeModuleStates (FSerializer &arc)
|
||||||
{
|
{
|
||||||
DWORD modnum;
|
auto modnum = StaticModules.Size();
|
||||||
|
|
||||||
modnum = StaticModules.Size();
|
if (arc.BeginObject("acsmodules"))
|
||||||
arc << modnum;
|
|
||||||
|
|
||||||
if (modnum != StaticModules.Size())
|
|
||||||
{
|
{
|
||||||
I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
|
arc("count", modnum);
|
||||||
}
|
|
||||||
|
|
||||||
for (modnum = 0; modnum < StaticModules.Size(); ++modnum)
|
if (modnum != StaticModules.Size())
|
||||||
{
|
{
|
||||||
FBehavior *module = StaticModules[modnum];
|
I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
|
||||||
int ModSize = module->GetDataSize();
|
}
|
||||||
|
|
||||||
if (arc.IsStoring())
|
for (modnum = 0; modnum < StaticModules.Size(); ++modnum)
|
||||||
{
|
{
|
||||||
arc.WriteString (module->ModuleName);
|
if (arc.BeginArray("modules"))
|
||||||
arc << ModSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *modname = NULL;
|
|
||||||
arc << modname;
|
|
||||||
arc << ModSize;
|
|
||||||
if (stricmp (modname, module->ModuleName) != 0)
|
|
||||||
{
|
{
|
||||||
delete[] modname;
|
FBehavior *module = StaticModules[modnum];
|
||||||
I_Error("Level was saved with a different set or order of ACS modules. (Have %s, save has %s)", module->ModuleName, modname);
|
const char *modname;
|
||||||
|
int ModSize = module->GetDataSize();
|
||||||
|
|
||||||
|
if (arc.BeginObject(nullptr))
|
||||||
|
{
|
||||||
|
arc.StringPtr("modname", modname)
|
||||||
|
("modsize", ModSize);
|
||||||
|
|
||||||
|
if (arc.isReading())
|
||||||
|
{
|
||||||
|
if (stricmp(modname, module->ModuleName) != 0)
|
||||||
|
{
|
||||||
|
I_Error("Level was saved with a different set or order of ACS modules. (Have %s, save has %s)", module->ModuleName, modname);
|
||||||
|
}
|
||||||
|
else if (ModSize != module->GetDataSize())
|
||||||
|
{
|
||||||
|
I_Error("ACS module %s has changed from what was saved. (Have %d bytes, save has %d bytes)", module->ModuleName, module->GetDataSize(), ModSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module->SerializeVars(arc);
|
||||||
|
arc.EndObject();
|
||||||
|
}
|
||||||
|
arc.EndArray();
|
||||||
}
|
}
|
||||||
else if (ModSize != module->GetDataSize())
|
|
||||||
{
|
|
||||||
delete[] modname;
|
|
||||||
I_Error("ACS module %s has changed from what was saved. (Have %d bytes, save has %d bytes)", module->ModuleName, module->GetDataSize(), ModSize);
|
|
||||||
}
|
|
||||||
delete[] modname;
|
|
||||||
}
|
}
|
||||||
module->SerializeVars (arc);
|
arc.EndObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBehavior::SerializeVars (FArchive &arc)
|
void FBehavior::SerializeVars (FSerializer &arc)
|
||||||
{
|
{
|
||||||
SerializeVarSet (arc, MapVarStore, NUM_MAPVARS);
|
if (arc.BeginArray("variables"))
|
||||||
for (int i = 0; i < NumArrays; ++i)
|
|
||||||
{
|
{
|
||||||
SerializeVarSet (arc, ArrayStore[i].Elements, ArrayStore[i].ArraySize);
|
SerializeVarSet(arc, MapVarStore, NUM_MAPVARS);
|
||||||
|
for (int i = 0; i < NumArrays; ++i)
|
||||||
|
{
|
||||||
|
SerializeVarSet(arc, ArrayStore[i].Elements, ArrayStore[i].ArraySize);
|
||||||
|
}
|
||||||
|
arc.EndArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max)
|
void FBehavior::SerializeVarSet (FSerializer &arc, SDWORD *vars, int max)
|
||||||
{
|
{
|
||||||
SDWORD arcval;
|
SDWORD count;
|
||||||
SDWORD first, last;
|
SDWORD first, last;
|
||||||
|
|
||||||
if (arc.IsStoring ())
|
if (arc.isWriting ())
|
||||||
{
|
{
|
||||||
// Find first non-zero variable
|
// Find first non-zero variable
|
||||||
for (first = 0; first < max; ++first)
|
for (first = 0; first < max; ++first)
|
||||||
|
@ -1707,52 +1715,28 @@ void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max)
|
||||||
|
|
||||||
if (last < first)
|
if (last < first)
|
||||||
{ // no non-zero variables
|
{ // no non-zero variables
|
||||||
arcval = 0;
|
count = 0;
|
||||||
arc << arcval;
|
arc("count", count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
arcval = last - first + 1;
|
count = last - first + 1;
|
||||||
arc << arcval;
|
arc("count", count);
|
||||||
arcval = first;
|
arc("first", first);
|
||||||
arc << arcval;
|
arc.Array("values", &vars[first], count);
|
||||||
|
|
||||||
while (first <= last)
|
|
||||||
{
|
|
||||||
arc << vars[first];
|
|
||||||
++first;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDWORD truelast;
|
|
||||||
|
|
||||||
memset (vars, 0, max*sizeof(*vars));
|
memset (vars, 0, max*sizeof(*vars));
|
||||||
|
arc("count", count);
|
||||||
|
|
||||||
arc << last;
|
if (count == 0)
|
||||||
if (last == 0)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
arc << first;
|
arc("first", first);
|
||||||
last += first;
|
if (first + count > max) count = max - first;
|
||||||
truelast = last;
|
arc.Array("values", &vars[first], count);
|
||||||
|
|
||||||
if (last > max)
|
|
||||||
{
|
|
||||||
last = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (first < last)
|
|
||||||
{
|
|
||||||
arc << vars[first];
|
|
||||||
++first;
|
|
||||||
}
|
|
||||||
while (first < truelast)
|
|
||||||
{
|
|
||||||
arc << arcval;
|
|
||||||
++first;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,7 @@ public:
|
||||||
static void StaticUnloadModules ();
|
static void StaticUnloadModules ();
|
||||||
static bool StaticCheckAllGood ();
|
static bool StaticCheckAllGood ();
|
||||||
static FBehavior *StaticGetModule (int lib);
|
static FBehavior *StaticGetModule (int lib);
|
||||||
static void StaticSerializeModuleStates (FArchive &arc);
|
static void StaticSerializeModuleStates (FSerializer &arc);
|
||||||
static void StaticMarkLevelVarStrings();
|
static void StaticMarkLevelVarStrings();
|
||||||
static void StaticLockLevelVarStrings();
|
static void StaticLockLevelVarStrings();
|
||||||
static void StaticUnlockLevelVarStrings();
|
static void StaticUnlockLevelVarStrings();
|
||||||
|
@ -368,8 +368,8 @@ private:
|
||||||
void UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool haspadding);
|
void UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool haspadding);
|
||||||
int FindStringInChunk (DWORD *chunk, const char *varname) const;
|
int FindStringInChunk (DWORD *chunk, const char *varname) const;
|
||||||
|
|
||||||
void SerializeVars (FArchive &arc);
|
void SerializeVars (FSerializer &arc);
|
||||||
void SerializeVarSet (FArchive &arc, SDWORD *vars, int max);
|
void SerializeVarSet (FSerializer &arc, SDWORD *vars, int max);
|
||||||
|
|
||||||
void MarkMapVarStrings() const;
|
void MarkMapVarStrings() const;
|
||||||
void LockMapVarStrings() const;
|
void LockMapVarStrings() const;
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#define WEAPONTOP (32+6./16)
|
#define WEAPONTOP (32+6./16)
|
||||||
|
|
||||||
class AInventory;
|
class AInventory;
|
||||||
class FArchive;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Overlay psprites are scaled shapes
|
// Overlay psprites are scaled shapes
|
||||||
|
|
|
@ -857,7 +857,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
// fixme: This needs to ensure it reads from the correct place. Should be one once there's enough of this code converted to JSON
|
// fixme: This needs to ensure it reads from the correct place. Should be one once there's enough of this code converted to JSON
|
||||||
AM_SerializeMarkers(arc);
|
AM_SerializeMarkers(arc);
|
||||||
|
|
||||||
//FBehavior::StaticSerializeModuleStates(arc);
|
FBehavior::StaticSerializeModuleStates(arc);
|
||||||
arc.Array("linedefs", lines, &loadlines[0], numlines);
|
arc.Array("linedefs", lines, &loadlines[0], numlines);
|
||||||
arc.Array("sidedefs", sides, &loadsides[0], numsides);
|
arc.Array("sidedefs", sides, &loadsides[0], numsides);
|
||||||
arc.Array("sectors", sectors, &loadsectors[0], numsectors);
|
arc.Array("sectors", sectors, &loadsectors[0], numsectors);
|
||||||
|
|
|
@ -122,9 +122,7 @@ struct FTerrainDef
|
||||||
extern TArray<FSplashDef> Splashes;
|
extern TArray<FSplashDef> Splashes;
|
||||||
extern TArray<FTerrainDef> Terrains;
|
extern TArray<FTerrainDef> Terrains;
|
||||||
|
|
||||||
class FArchive;
|
|
||||||
int P_FindTerrain(FName name);
|
int P_FindTerrain(FName name);
|
||||||
void P_SerializeTerrain(FArchive &arc, int &terrainnum);
|
|
||||||
FName P_GetTerrainName(int terrainnum);
|
FName P_GetTerrainName(int terrainnum);
|
||||||
|
|
||||||
#endif //__P_TERRAIN_H__
|
#endif //__P_TERRAIN_H__
|
||||||
|
|
|
@ -99,12 +99,6 @@ static struct LegacyInit
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, FRenderStyle &style)
|
|
||||||
{
|
|
||||||
arc << style.BlendOp << style.SrcAlpha << style.DestAlpha << style.Flags;
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
double GetAlpha(int type, double alpha)
|
double GetAlpha(int type, double alpha)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -162,8 +162,4 @@ inline FRenderStyle &FRenderStyle::operator= (ERenderStyle legacy)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FArchive;
|
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, FRenderStyle &style);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1227,25 +1227,6 @@ int FTextureManager::CountLumpTextures (int lumpnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// operator<<
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FArchive &operator<< (FArchive &arc, FTextureID &tex)
|
|
||||||
{
|
|
||||||
if (arc.IsStoring())
|
|
||||||
{
|
|
||||||
TexMan.WriteTexture(arc, tex.texnum);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tex.texnum = TexMan.ReadTexture(arc);
|
|
||||||
}
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FTextureID::operator+
|
// FTextureID::operator+
|
||||||
|
|
Loading…
Reference in a new issue