mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +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;
|
||||
}
|
||||
|
||||
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 FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, TObjPtr<U> *);
|
||||
|
||||
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
|
||||
// the contents of a TObjPtr to a related type.
|
||||
template<class T,class U> inline T barrier_cast(TObjPtr<U> &o)
|
||||
|
|
|
@ -212,7 +212,6 @@ class PClassInventory;
|
|||
class FTextureID
|
||||
{
|
||||
friend class FTextureManager;
|
||||
friend FArchive &operator<< (FArchive &arc, FTextureID &tex);
|
||||
friend FTextureID GetHUDIcon(PClassInventory *cls);
|
||||
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();
|
||||
arc << modnum;
|
||||
|
||||
if (modnum != StaticModules.Size())
|
||||
if (arc.BeginObject("acsmodules"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
FBehavior *module = StaticModules[modnum];
|
||||
int ModSize = module->GetDataSize();
|
||||
if (modnum != StaticModules.Size())
|
||||
{
|
||||
I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
|
||||
}
|
||||
|
||||
if (arc.IsStoring())
|
||||
for (modnum = 0; modnum < StaticModules.Size(); ++modnum)
|
||||
{
|
||||
arc.WriteString (module->ModuleName);
|
||||
arc << ModSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *modname = NULL;
|
||||
arc << modname;
|
||||
arc << ModSize;
|
||||
if (stricmp (modname, module->ModuleName) != 0)
|
||||
if (arc.BeginArray("modules"))
|
||||
{
|
||||
delete[] modname;
|
||||
I_Error("Level was saved with a different set or order of ACS modules. (Have %s, save has %s)", module->ModuleName, modname);
|
||||
FBehavior *module = StaticModules[modnum];
|
||||
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);
|
||||
for (int i = 0; i < NumArrays; ++i)
|
||||
if (arc.BeginArray("variables"))
|
||||
{
|
||||
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;
|
||||
|
||||
if (arc.IsStoring ())
|
||||
if (arc.isWriting ())
|
||||
{
|
||||
// Find first non-zero variable
|
||||
for (first = 0; first < max; ++first)
|
||||
|
@ -1707,52 +1715,28 @@ void FBehavior::SerializeVarSet (FArchive &arc, SDWORD *vars, int max)
|
|||
|
||||
if (last < first)
|
||||
{ // no non-zero variables
|
||||
arcval = 0;
|
||||
arc << arcval;
|
||||
count = 0;
|
||||
arc("count", count);
|
||||
return;
|
||||
}
|
||||
|
||||
arcval = last - first + 1;
|
||||
arc << arcval;
|
||||
arcval = first;
|
||||
arc << arcval;
|
||||
|
||||
while (first <= last)
|
||||
{
|
||||
arc << vars[first];
|
||||
++first;
|
||||
}
|
||||
count = last - first + 1;
|
||||
arc("count", count);
|
||||
arc("first", first);
|
||||
arc.Array("values", &vars[first], count);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDWORD truelast;
|
||||
|
||||
memset (vars, 0, max*sizeof(*vars));
|
||||
arc("count", count);
|
||||
|
||||
arc << last;
|
||||
if (last == 0)
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
arc << first;
|
||||
last += first;
|
||||
truelast = last;
|
||||
|
||||
if (last > max)
|
||||
{
|
||||
last = max;
|
||||
}
|
||||
|
||||
while (first < last)
|
||||
{
|
||||
arc << vars[first];
|
||||
++first;
|
||||
}
|
||||
while (first < truelast)
|
||||
{
|
||||
arc << arcval;
|
||||
++first;
|
||||
}
|
||||
arc("first", first);
|
||||
if (first + count > max) count = max - first;
|
||||
arc.Array("values", &vars[first], count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ public:
|
|||
static void StaticUnloadModules ();
|
||||
static bool StaticCheckAllGood ();
|
||||
static FBehavior *StaticGetModule (int lib);
|
||||
static void StaticSerializeModuleStates (FArchive &arc);
|
||||
static void StaticSerializeModuleStates (FSerializer &arc);
|
||||
static void StaticMarkLevelVarStrings();
|
||||
static void StaticLockLevelVarStrings();
|
||||
static void StaticUnlockLevelVarStrings();
|
||||
|
@ -368,8 +368,8 @@ private:
|
|||
void UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool haspadding);
|
||||
int FindStringInChunk (DWORD *chunk, const char *varname) const;
|
||||
|
||||
void SerializeVars (FArchive &arc);
|
||||
void SerializeVarSet (FArchive &arc, SDWORD *vars, int max);
|
||||
void SerializeVars (FSerializer &arc);
|
||||
void SerializeVarSet (FSerializer &arc, SDWORD *vars, int max);
|
||||
|
||||
void MarkMapVarStrings() const;
|
||||
void LockMapVarStrings() const;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#define WEAPONTOP (32+6./16)
|
||||
|
||||
class AInventory;
|
||||
class FArchive;
|
||||
|
||||
//
|
||||
// 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
|
||||
AM_SerializeMarkers(arc);
|
||||
|
||||
//FBehavior::StaticSerializeModuleStates(arc);
|
||||
FBehavior::StaticSerializeModuleStates(arc);
|
||||
arc.Array("linedefs", lines, &loadlines[0], numlines);
|
||||
arc.Array("sidedefs", sides, &loadsides[0], numsides);
|
||||
arc.Array("sectors", sectors, &loadsectors[0], numsectors);
|
||||
|
|
|
@ -122,9 +122,7 @@ struct FTerrainDef
|
|||
extern TArray<FSplashDef> Splashes;
|
||||
extern TArray<FTerrainDef> Terrains;
|
||||
|
||||
class FArchive;
|
||||
int P_FindTerrain(FName name);
|
||||
void P_SerializeTerrain(FArchive &arc, int &terrainnum);
|
||||
FName P_GetTerrainName(int terrainnum);
|
||||
|
||||
#endif //__P_TERRAIN_H__
|
||||
|
|
|
@ -99,12 +99,6 @@ static struct LegacyInit
|
|||
|
||||
#endif
|
||||
|
||||
FArchive &operator<< (FArchive &arc, FRenderStyle &style)
|
||||
{
|
||||
arc << style.BlendOp << style.SrcAlpha << style.DestAlpha << style.Flags;
|
||||
return arc;
|
||||
}
|
||||
|
||||
double GetAlpha(int type, double alpha)
|
||||
{
|
||||
switch (type)
|
||||
|
|
|
@ -162,8 +162,4 @@ inline FRenderStyle &FRenderStyle::operator= (ERenderStyle legacy)
|
|||
return *this;
|
||||
}
|
||||
|
||||
class FArchive;
|
||||
|
||||
FArchive &operator<< (FArchive &arc, FRenderStyle &style);
|
||||
|
||||
#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+
|
||||
|
|
Loading…
Reference in a new issue