diff --git a/docs/rh-log.txt b/docs/rh-log.txt index a7e7681333..93f435838f 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +March 18, 2008 +- Fixed the TArray serializer declaration. + (Thank you for your warnings, GCC! ;-) +- Changed root sector marking so that it can happen incrementally. + March 18, 2008 (Changes by Graf Zahl) - VC++ doesn't seem to like the TArray serializer so I added a workaround to be able to save the 3dMidtex attachment info. diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 9a687b7e27..1bf3d483ce 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -89,6 +89,8 @@ */ #define DEFAULT_GCMUL 400 // GC runs 'quadruple the speed' of memory allocation +// Number of sectors to mark for each step. +#define SECTORSTEPSIZE 32 #define GCSTEPSIZE 1024u #define GCSWEEPMAX 40 @@ -97,6 +99,19 @@ // TYPES ------------------------------------------------------------------- +// This object is responsible for marking sectors during the propagate +// stage. In case there are many, many sectors, it lets us break them +// up instead of marking them all at once. +class DSectorMarker : public DObject +{ + DECLARE_CLASS(DSectorMarker, DObject) +public: + DSectorMarker() : SecNum(0) {} + size_t PropagateMark(); + int SecNum; +}; +IMPLEMENT_CLASS(DSectorMarker) + // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -125,6 +140,8 @@ size_t Dept; // PRIVATE DATA DEFINITIONS ------------------------------------------------ +static DSectorMarker *SectorMarker; + // CODE -------------------------------------------------------------------- //========================================================================== @@ -281,19 +298,15 @@ static void MarkRoot() if (playeringame[i]) players[i].PropagateMark(); } - if (sectors != NULL) + if (SectorMarker == NULL) { - for (i = 0; i < numsectors; ++i) - { - Mark(sectors[i].SoundTarget); - Mark(sectors[i].CeilingSkyBox); - Mark(sectors[i].FloorSkyBox); - Mark(sectors[i].SecActTarget); - Mark(sectors[i].floordata); - Mark(sectors[i].ceilingdata); - Mark(sectors[i].lightingdata); - } + SectorMarker = new DSectorMarker; } + else + { + SectorMarker->SecNum = 0; + } + Mark(SectorMarker); { // Silly bots DObject *foo = &bglobal; Mark(foo); @@ -564,6 +577,54 @@ void DelSoftRoot(DObject *obj) } +//========================================================================== +// +// DSectorMarker :: PropagateMark +// +// Propagates marks across a few sectors and reinserts itself into the +// gray list if it didn't do them all. +// +//========================================================================== + +size_t DSectorMarker::PropagateMark() +{ + int i; + + if (sectors == NULL) + { + return 0; + } + for (i = 0; i < SECTORSTEPSIZE && SecNum + i < numsectors; ++i) + { + sector_t *sec = §ors[SecNum + i]; + GC::Mark(sec->SoundTarget); + GC::Mark(sec->CeilingSkyBox); + GC::Mark(sec->FloorSkyBox); + GC::Mark(sec->SecActTarget); + GC::Mark(sec->floordata); + GC::Mark(sec->ceilingdata); + GC::Mark(sec->lightingdata); + } + // If there are more sectors to mark, put ourself back into the gray + // list. + if (SecNum + i < numsectors) + { + SecNum += i; + Black2Gray(); + GCNext = GC::Gray; + GC::Gray = this; + } + return i * sizeof(sector_t); +} + +//========================================================================== +// +// STAT gc +// +// Provides information about the current garbage collector state. +// +//========================================================================== + ADD_STAT(gc) { static const char *StateStrings[] = { diff --git a/src/farchive.h b/src/farchive.h index 90d8c0fd0b..6d751d9e82 100644 --- a/src/farchive.h +++ b/src/farchive.h @@ -287,11 +287,9 @@ inline FArchive &operator<< (FArchive &arc, T* &object) FArchive &operator<< (FArchive &arc, const PClass * &info); -template -inline FArchive &operator<< (FArchive &arc, TArray &self) +template +inline FArchive &operator<< (FArchive &arc, TArray &self) { - unsigned int i; - if (arc.IsStoring()) { arc.WriteCount(self.Count); @@ -301,7 +299,7 @@ inline FArchive &operator<< (FArchive &arc, TArray &self) DWORD numStored = arc.ReadCount(); self.Resize(numStored); } - for (i = 0; i < self.Count; ++i) + for (unsigned int i = 0; i < self.Count; ++i) { arc << self.Array[i]; } diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 3e48771cb1..d0c8944d87 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -305,4 +305,4 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opent return; } */ -} \ No newline at end of file +} diff --git a/src/p_3dmidtex.h b/src/p_3dmidtex.h index f1faadaf58..215da2b3df 100644 --- a/src/p_3dmidtex.h +++ b/src/p_3dmidtex.h @@ -16,4 +16,4 @@ bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side); bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opentop, fixed_t &openbottom); -#endif \ No newline at end of file +#endif diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 8373702987..90a05a33b4 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -408,8 +408,6 @@ void P_SerializeWorld (FArchive &arc) } } -#if 0 -// VC++ produces a linker error when using the templated << operator void extsector_t::Serialize(FArchive &arc) { arc << Midtex.Floor.AttachedLines @@ -418,39 +416,6 @@ void extsector_t::Serialize(FArchive &arc) << Midtex.Ceiling.AttachedSectors; } -#else - -// Remove this when the problem above has been sorted out. -template -void SaveArray (FArchive &arc, TArray &self) -{ - unsigned int i; - - if (arc.IsStoring()) - { - arc.WriteCount(self.Size()); - } - else - { - DWORD numStored = arc.ReadCount(); - self.Resize(numStored); - } - for (i = 0; i < self.Size(); ++i) - { - arc << self[i]; - } -} - -void extsector_t::Serialize(FArchive &arc) -{ - SaveArray(arc, Midtex.Floor.AttachedLines); - SaveArray(arc, Midtex.Floor.AttachedSectors); - SaveArray(arc, Midtex.Ceiling.AttachedLines); - SaveArray(arc, Midtex.Ceiling.AttachedSectors); -} - -#endif - // // Thinkers // diff --git a/src/r_defs.h b/src/r_defs.h index 09e8672d35..dd11745732 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -281,7 +281,6 @@ struct extsector_t } Floor, Ceiling; } Midtex; - void Serialize(FArchive &arc); }; diff --git a/src/tarray.h b/src/tarray.h index ed31a28a15..b556c84197 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -49,7 +49,7 @@ class FArchive; template class TArray { - friend FArchive &operator<< (FArchive &arc, TArray &self); + template friend FArchive &operator<< (FArchive &arc, TArray &self); public: ////////