- Fixed the TArray serializer declaration.

(Thank you for your warnings, GCC! ;-)
- Changed root sector marking so that it can happen incrementally.


SVN r811 (trunk)
This commit is contained in:
Randy Heit 2008-03-19 02:20:19 +00:00
parent 7c87465d35
commit 02071140a5
8 changed files with 83 additions and 55 deletions

View file

@ -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.

View file

@ -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 = &sectors[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[] = {

View file

@ -287,11 +287,9 @@ inline FArchive &operator<< (FArchive &arc, T* &object)
FArchive &operator<< (FArchive &arc, const PClass * &info);
template<class T>
inline FArchive &operator<< (FArchive &arc, TArray<T> &self)
template<class T,class TT>
inline FArchive &operator<< (FArchive &arc, TArray<T,TT> &self)
{
unsigned int i;
if (arc.IsStoring())
{
arc.WriteCount(self.Count);
@ -301,7 +299,7 @@ inline FArchive &operator<< (FArchive &arc, TArray<T> &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];
}

View file

@ -305,4 +305,4 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, fixed_t &opent
return;
}
*/
}
}

View file

@ -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
#endif

View file

@ -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<class T>
void SaveArray (FArchive &arc, TArray<T> &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
//

View file

@ -281,7 +281,6 @@ struct extsector_t
} Floor, Ceiling;
} Midtex;
void Serialize(FArchive &arc);
};

View file

@ -49,7 +49,7 @@ class FArchive;
template <class T, class TT=T>
class TArray
{
friend FArchive &operator<< (FArchive &arc, TArray<T> &self);
template<class U, class UU> friend FArchive &operator<< (FArchive &arc, TArray<U,UU> &self);
public:
////////