- re-added serialization of treanslations.

- removed more dead code.
This commit is contained in:
Christoph Oelckers 2016-09-20 19:45:32 +02:00
parent e101014432
commit 970c168b13
17 changed files with 56 additions and 164 deletions

View file

@ -39,7 +39,6 @@
class PClass; class PClass;
class FArchive;
class FSerializer; class FSerializer;
class DObject; class DObject;

View file

@ -1873,10 +1873,10 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const
BYTE *addrb = (BYTE *)addr; BYTE *addrb = (BYTE *)addr;
for(unsigned i=0;i<loop;i++) for(unsigned i=0;i<loop;i++)
{ {
readsomething |= ElementType->ReadValue(ar, key, addrb); readsomething |= ElementType->ReadValue(ar, nullptr, addrb);
addrb += ElementSize; addrb += ElementSize;
} }
if (loop < ElementCount) if (loop < count)
{ {
DPrintf(DMSG_WARNING, "Array on disk (%u) is bigger than in memory (%u)\n", DPrintf(DMSG_WARNING, "Array on disk (%u) is bigger than in memory (%u)\n",
count, ElementCount); count, ElementCount);

View file

@ -339,7 +339,6 @@ struct mapthinghexen_t
BYTE args[5]; BYTE args[5];
}; };
class FArchive;
struct FDoomEdEntry; struct FDoomEdEntry;
// Internal representation of a mapthing // Internal representation of a mapthing

View file

@ -206,7 +206,6 @@ struct PalEntry
#endif #endif
}; };
class FArchive;
class PClassInventory; class PClassInventory;
class FTextureID class FTextureID

View file

@ -52,7 +52,6 @@
struct Baggage; struct Baggage;
class FScanner; class FScanner;
struct FActorInfo; struct FActorInfo;
class FArchive;
class FIntCVar; class FIntCVar;
enum EStateType enum EStateType

View file

@ -893,6 +893,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
arc("subsectors", subsectors); arc("subsectors", subsectors);
StatusBar->SerializeMessages(arc); StatusBar->SerializeMessages(arc);
AM_SerializeMarkers(arc); AM_SerializeMarkers(arc);
FRemapTable::StaticSerializeTranslations(arc);
} }
@ -933,37 +934,6 @@ void P_SerializeSounds (FArchive &arc)
void G_SerializeLevel(FArchive &arc, bool hubLoad) void G_SerializeLevel(FArchive &arc, bool hubLoad)
{ {
#if 0 #if 0
// Does this level have custom translations?
FRemapTable *trans;
WORD w;
if (arc.IsStoring())
{
for (unsigned int i = 0; i < translationtables[TRANSLATION_LevelScripted].Size(); ++i)
{
trans = translationtables[TRANSLATION_LevelScripted][i];
if (trans != NULL && !trans->IsIdentity())
{
w = WORD(i);
arc << w;
trans->Serialize(arc);
}
}
w = 0xffff;
arc << w;
}
else
{
while (arc << w, w != 0xffff)
{
trans = translationtables[TRANSLATION_LevelScripted].GetVal(w);
if (trans == NULL)
{
trans = new FRemapTable;
translationtables[TRANSLATION_LevelScripted].SetVal(w, trans);
}
trans->Serialize(arc);
}
}
// This must be saved, too, of course! // This must be saved, too, of course!
FCanvasTextureInfo::Serialize(arc); FCanvasTextureInfo::Serialize(arc);

View file

@ -41,12 +41,7 @@ struct PNGHandle;
// These are the load / save game routines. // These are the load / save game routines.
// Also see farchive.(h|cpp) // Also see farchive.(h|cpp)
void P_SerializePlayers (FArchive &arc, bool fakeload); void P_SerializePlayers (FArchive &arc, bool fakeload);
void P_SerializeWorldActors(FArchive &arc);
void P_SerializeWorld (FArchive &arc);
void P_DestroyThinkers(bool hubLoad); void P_DestroyThinkers(bool hubLoad);
void P_SerializeThinkers (FArchive &arc, bool);
void P_SerializePolyobjs (FArchive &arc);
void P_SerializeSubsectors(FArchive &arc);
void P_SerializeSounds (FArchive &arc); void P_SerializeSounds (FArchive &arc);
void P_ReadACSDefereds (PNGHandle *png); void P_ReadACSDefereds (PNGHandle *png);

View file

@ -46,7 +46,6 @@
#include "s_sound.h" #include "s_sound.h"
#include "p_local.h" #include "p_local.h"
#include "templates.h" #include "templates.h"
#include "farchive.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -725,18 +724,3 @@ FName P_GetTerrainName(int terrainnum)
} }
} }
void P_SerializeTerrain(FArchive &arc, int &terrainnum)
{
FName val;
if (arc.IsStoring())
{
val = P_GetTerrainName(terrainnum);
arc << val;
}
else
{
arc << val;
terrainnum = P_FindTerrain(val);
}
}

View file

@ -46,8 +46,10 @@
#include "i_system.h" #include "i_system.h"
#include "w_wad.h" #include "w_wad.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "farchive.h" #include "serializer.h"
#include "d_player.h" #include "d_player.h"
#include "r_data/sprites.h"
#include "r_state.h"
#include "gi.h" #include "gi.h"
#include "stats.h" #include "stats.h"
@ -192,30 +194,63 @@ bool FRemapTable::operator==(const FRemapTable &o)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void FRemapTable::Serialize(FArchive &arc) void FRemapTable::Serialize(FSerializer &arc)
{ {
#if 0
int n = NumEntries; int n = NumEntries;
arc << NumEntries; arc("numentries", NumEntries);
if (arc.IsStoring()) if (arc.isReading())
{
arc.Write (Remap, NumEntries);
}
else
{ {
if (n != NumEntries) if (n != NumEntries)
{ {
Free(); Free();
Alloc(NumEntries); Alloc(NumEntries);
} }
arc.Read (Remap, NumEntries);
} }
for (int j = 0; j < NumEntries; ++j) arc.Array("remap", Remap, NumEntries);
arc.Array("palette", Palette, NumEntries);
}
void FRemapTable::StaticSerializeTranslations(FSerializer &arc)
{
if (arc.BeginArray("translations"))
{ {
arc << Palette[j]; // Does this level have custom translations?
FRemapTable *trans;
int w;
if (arc.isWriting())
{
for (unsigned int i = 0; i < translationtables[TRANSLATION_LevelScripted].Size(); ++i)
{
trans = translationtables[TRANSLATION_LevelScripted][i];
if (trans != NULL && !trans->IsIdentity())
{
if (arc.BeginObject(nullptr))
{
arc("index", i);
trans->Serialize(arc);
arc.EndObject();
}
}
}
}
else
{
while (arc.BeginObject(nullptr))
{
arc("index", w);
trans = translationtables[TRANSLATION_LevelScripted].GetVal(w);
if (trans == NULL)
{
trans = new FRemapTable;
translationtables[TRANSLATION_LevelScripted].SetVal(w, trans);
}
trans->Serialize(arc);
arc.EndObject();
}
}
arc.EndArray();
} }
#endif
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View file

@ -5,7 +5,7 @@
#include "tarray.h" #include "tarray.h"
class FNativePalette; class FNativePalette;
class FArchive; class FSerializer;
enum enum
{ {
@ -36,7 +36,8 @@ struct FRemapTable
void UpdateNative(); void UpdateNative();
FNativePalette *GetNative(); FNativePalette *GetNative();
bool IsIdentity() const; bool IsIdentity() const;
void Serialize(FArchive &ar); void Serialize(FSerializer &arc);
static void StaticSerializeTranslations(FSerializer &arc);
void AddIndexRange(int start, int end, int pal1, int pal2); void AddIndexRange(int start, int end, int pal1, int pal2);
void AddColorRange(int start, int end, int r1,int g1, int b1, int r2, int g2, int b2); void AddColorRange(int start, int end, int r1,int g1, int b1, int r2, int g2, int b2);
void AddDesaturation(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2); void AddDesaturation(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2);

View file

@ -44,7 +44,6 @@
#include "r_data/voxels.h" #include "r_data/voxels.h"
class FArchive;
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio);
void R_SetupColormap(player_t *); void R_SetupColormap(player_t *);
void R_SetupFreelook(); void R_SetupFreelook();

View file

@ -1,7 +1,6 @@
#include "doomtype.h" #include "doomtype.h"
#include "tarray.h" #include "tarray.h"
#include "s_sound.h" #include "s_sound.h"
#include "farchive.h"
#include "sc_man.h" #include "sc_man.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "templates.h" #include "templates.h"
@ -481,30 +480,6 @@ void S_AddEnvironment (ReverbContainer *settings)
} }
} }
FArchive &operator<< (FArchive &arc, ReverbContainer *&env)
{
WORD id;
if (arc.IsStoring())
{
if (env != NULL)
{
arc << env->ID;
}
else
{
id = 0;
arc << id;
}
}
else
{
arc << id;
env = S_FindEnvironment (id);
}
return arc;
}
static void ReadReverbDef (int lump) static void ReadReverbDef (int lump)
{ {
FScanner sc; FScanner sc;

View file

@ -387,9 +387,6 @@ void S_NoiseDebug ();
extern ReverbContainer *Environments; extern ReverbContainer *Environments;
extern ReverbContainer *DefaultEnvironments[26]; extern ReverbContainer *DefaultEnvironments[26];
class FArchive;
FArchive &operator<< (FArchive &arc, ReverbContainer *&env);
void S_SetEnvironment (const ReverbContainer *settings); void S_SetEnvironment (const ReverbContainer *settings);
ReverbContainer *S_FindEnvironment (const char *name); ReverbContainer *S_FindEnvironment (const char *name);
ReverbContainer *S_FindEnvironment (int id); ReverbContainer *S_FindEnvironment (int id);

View file

@ -133,9 +133,9 @@ struct FReader
return &it->value; return &it->value;
} }
} }
else if (obj.mObject->IsArray()) else if (obj.mObject->IsArray() && obj.mIndex < obj.mObject->Size())
{ {
return &obj.mObject[obj.mIndex++]; return &(*obj.mObject)[obj.mIndex++];
} }
return nullptr; return nullptr;
} }

View file

@ -1074,61 +1074,6 @@ FTextureID FTextureManager::PalCheck(FTextureID tex)
return *newtex; return *newtex;
} }
//==========================================================================
//
// FTextureManager :: WriteTexture
//
//==========================================================================
void FTextureManager::WriteTexture (FArchive &arc, int picnum)
{
FTexture *pic;
if (picnum < 0)
{
arc.WriteName(NULL);
return;
}
else if ((size_t)picnum >= Textures.Size())
{
pic = Textures[0].Texture;
}
else
{
pic = Textures[picnum].Texture;
}
if (Wads.GetLinkedTexture(pic->SourceLump) == pic)
{
arc.WriteName(Wads.GetLumpFullName(pic->SourceLump));
}
else
{
arc.WriteName(pic->Name);
}
arc.WriteCount(pic->UseType);
}
//==========================================================================
//
// FTextureManager :: ReadTexture
//
//==========================================================================
int FTextureManager::ReadTexture (FArchive &arc)
{
int usetype;
const char *name;
name = arc.ReadName ();
if (name != NULL)
{
usetype = arc.ReadCount ();
return GetTexture (name, usetype).GetIndex();
}
else return -1;
}
//=========================================================================== //===========================================================================
// //
// R_GuesstimateNumTextures // R_GuesstimateNumTextures

View file

@ -380,9 +380,6 @@ public:
int NumTextures () const { return (int)Textures.Size(); } int NumTextures () const { return (int)Textures.Size(); }
void WriteTexture (FArchive &arc, int picnum);
int ReadTexture (FArchive &arc);
void UpdateAnimations (DWORD mstime); void UpdateAnimations (DWORD mstime);
int GuesstimateNumTextures (); int GuesstimateNumTextures ();
@ -498,7 +495,6 @@ protected:
// A texture that can be drawn to. // A texture that can be drawn to.
class DSimpleCanvas; class DSimpleCanvas;
class AActor; class AActor;
class FArchive;
class FCanvasTexture : public FTexture class FCanvasTexture : public FTexture
{ {

View file

@ -39,7 +39,6 @@
class DCanvas; class DCanvas;
struct FRemapTable; struct FRemapTable;
class FTexture; class FTexture;
class FArchive;
enum EColorRange enum EColorRange
{ {