diff --git a/src/dobject.h b/src/dobject.h index b47915659..51102bc4c 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -39,7 +39,6 @@ class PClass; -class FArchive; class FSerializer; class DObject; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index a82d26a54..5629fa4aa 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1873,10 +1873,10 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const BYTE *addrb = (BYTE *)addr; for(unsigned i=0;iReadValue(ar, key, addrb); + readsomething |= ElementType->ReadValue(ar, nullptr, addrb); addrb += ElementSize; } - if (loop < ElementCount) + if (loop < count) { DPrintf(DMSG_WARNING, "Array on disk (%u) is bigger than in memory (%u)\n", count, ElementCount); diff --git a/src/doomdata.h b/src/doomdata.h index f809f05ea..eca7dcd4a 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -339,7 +339,6 @@ struct mapthinghexen_t BYTE args[5]; }; -class FArchive; struct FDoomEdEntry; // Internal representation of a mapthing diff --git a/src/doomtype.h b/src/doomtype.h index ccf8ccc3d..129c5f122 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -206,7 +206,6 @@ struct PalEntry #endif }; -class FArchive; class PClassInventory; class FTextureID diff --git a/src/info.h b/src/info.h index 2c8365dd4..0e49e1f8f 100644 --- a/src/info.h +++ b/src/info.h @@ -52,7 +52,6 @@ struct Baggage; class FScanner; struct FActorInfo; -class FArchive; class FIntCVar; enum EStateType diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 581d66fd6..80cad3eb5 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -893,6 +893,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) arc("subsectors", subsectors); StatusBar->SerializeMessages(arc); AM_SerializeMarkers(arc); + FRemapTable::StaticSerializeTranslations(arc); } @@ -933,37 +934,6 @@ void P_SerializeSounds (FArchive &arc) void G_SerializeLevel(FArchive &arc, bool hubLoad) { #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! FCanvasTextureInfo::Serialize(arc); diff --git a/src/p_saveg.h b/src/p_saveg.h index a62e5c5b8..fee2874fd 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -41,12 +41,7 @@ struct PNGHandle; // These are the load / save game routines. // Also see farchive.(h|cpp) void P_SerializePlayers (FArchive &arc, bool fakeload); -void P_SerializeWorldActors(FArchive &arc); -void P_SerializeWorld (FArchive &arc); 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_ReadACSDefereds (PNGHandle *png); diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index c7c2848c0..2504bad94 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -46,7 +46,6 @@ #include "s_sound.h" #include "p_local.h" #include "templates.h" -#include "farchive.h" // 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); - - } -} diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 1772bc07f..c55f69016 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -46,8 +46,10 @@ #include "i_system.h" #include "w_wad.h" #include "r_data/colormaps.h" -#include "farchive.h" +#include "serializer.h" #include "d_player.h" +#include "r_data/sprites.h" +#include "r_state.h" #include "gi.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; - arc << NumEntries; - if (arc.IsStoring()) - { - arc.Write (Remap, NumEntries); - } - else + arc("numentries", NumEntries); + if (arc.isReading()) { if (n != NumEntries) { Free(); 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 } //---------------------------------------------------------------------------- diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index 7df9dcb6d..a549f0759 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -5,7 +5,7 @@ #include "tarray.h" class FNativePalette; -class FArchive; +class FSerializer; enum { @@ -36,7 +36,8 @@ struct FRemapTable void UpdateNative(); FNativePalette *GetNative(); 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 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); diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp index 4d1fd0371..ccf12e7ed 100644 --- a/src/r_swrenderer.cpp +++ b/src/r_swrenderer.cpp @@ -44,7 +44,6 @@ #include "r_data/voxels.h" -class FArchive; void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio); void R_SetupColormap(player_t *); void R_SetupFreelook(); diff --git a/src/s_environment.cpp b/src/s_environment.cpp index d3bd8c58c..377537a6c 100644 --- a/src/s_environment.cpp +++ b/src/s_environment.cpp @@ -1,7 +1,6 @@ #include "doomtype.h" #include "tarray.h" #include "s_sound.h" -#include "farchive.h" #include "sc_man.h" #include "cmdlib.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) { FScanner sc; diff --git a/src/s_sound.h b/src/s_sound.h index 774d859c8..c2e0f187e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -387,9 +387,6 @@ void S_NoiseDebug (); extern ReverbContainer *Environments; extern ReverbContainer *DefaultEnvironments[26]; -class FArchive; -FArchive &operator<< (FArchive &arc, ReverbContainer *&env); - void S_SetEnvironment (const ReverbContainer *settings); ReverbContainer *S_FindEnvironment (const char *name); ReverbContainer *S_FindEnvironment (int id); diff --git a/src/serializer.cpp b/src/serializer.cpp index 8e249e9d8..66d23cd72 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -133,9 +133,9 @@ struct FReader 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; } diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index ba4db5e1d..9c7e98d08 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1074,61 +1074,6 @@ FTextureID FTextureManager::PalCheck(FTextureID tex) 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 diff --git a/src/textures/textures.h b/src/textures/textures.h index 14667093c..954936fe1 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -380,9 +380,6 @@ public: int NumTextures () const { return (int)Textures.Size(); } - void WriteTexture (FArchive &arc, int picnum); - int ReadTexture (FArchive &arc); - void UpdateAnimations (DWORD mstime); int GuesstimateNumTextures (); @@ -498,7 +495,6 @@ protected: // A texture that can be drawn to. class DSimpleCanvas; class AActor; -class FArchive; class FCanvasTexture : public FTexture { diff --git a/src/v_font.h b/src/v_font.h index 762ba4cd7..7523e6bf0 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -39,7 +39,6 @@ class DCanvas; struct FRemapTable; class FTexture; -class FArchive; enum EColorRange {