Skip to content

Commit

Permalink
- Standardized use of PClassActor::AllActorClasses for iterating over…
Browse files Browse the repository at this point in the history
… all classes of actors

  instead of PClass::m_Types (now PClass::AllClasses).
- Removed ClassIndex from PClass. It was only needed by FArchive, and maps take care of the
  problem just as well.
- Moved PClass into a larger type system (which is likely to change some/lots once I try and actually use it and have a better feel for what I need from it).

SVN r2281 (scripting)
  • Loading branch information
Randy Heit committed Apr 16, 2010
1 parent 900324c commit ee55e03
Show file tree
Hide file tree
Showing 24 changed files with 1,200 additions and 346 deletions.
4 changes: 2 additions & 2 deletions src/d_dehacked.cpp
Expand Up @@ -1453,9 +1453,9 @@ static int PatchAmmo (int ammoNum)
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
if (oldclip != *per)
{
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
{
PClass *type = PClass::m_Types[i];
PClassActor *type = PClassActor::AllActorClasses[i];

if (type == ammoType)
continue;
Expand Down
6 changes: 4 additions & 2 deletions src/d_main.cpp
Expand Up @@ -1754,14 +1754,16 @@ void D_DoomMain (void)
#endif
#endif

PClass::StaticInit();
PType::StaticInit();

// Combine different file parameters with their pre-switch bits.
Args->CollectFiles("-deh", ".deh");
Args->CollectFiles("-bex", ".bex");
Args->CollectFiles("-exec", ".cfg");
Args->CollectFiles("-playdemo", ".lmp");
Args->CollectFiles("-file", NULL); // anythnig left goes after -file
Args->CollectFiles("-file", NULL); // anything left goes after -file

PClass::StaticInit ();
atterm (C_DeinitConsole);

gamestate = GS_STARTUP;
Expand Down
4 changes: 2 additions & 2 deletions src/decallib.cpp
Expand Up @@ -353,9 +353,9 @@ void FDecalLib::ReadAllDecals ()
ReadDecals (sc);
}
// Supporting code to allow specifying decals directly in the DECORATE lump
for (i = 0; i < PClass::m_RuntimeActors.Size(); i++)
for (i = 0; i < PClassActor::AllActorClasses.Size(); i++)
{
AActor *def = (AActor*)GetDefaultByType (PClass::m_RuntimeActors[i]);
AActor *def = (AActor*)GetDefaultByType (PClassActor::AllActorClasses[i]);

FName v = ENamedName(intptr_t(def->DecalGenerator));
if (v.IsValidName())
Expand Down
4 changes: 2 additions & 2 deletions src/dobject.cpp
Expand Up @@ -180,9 +180,9 @@ CCMD (dumpclasses)

shown = omitted = 0;
DumpInfo::AddType (&tree, root != NULL ? root : RUNTIME_CLASS(DObject));
for (i = 0; i < PClass::m_Types.Size(); i++)
for (i = 0; i < PClass::AllClasses.Size(); i++)
{
PClass *cls = PClass::m_Types[i];
PClass *cls = PClass::AllClasses[i];
if (root == NULL || cls == root || cls->IsDescendantOf(root))
{
DumpInfo::AddType (&tree, cls);
Expand Down
25 changes: 22 additions & 3 deletions src/dobject.h
Expand Up @@ -94,7 +94,9 @@ enum
CLASSREG_PClassHealth,
CLASSREG_PClassPuzzleItem,
CLASSREG_PClassWeapon,
CLASSREG_PClassPlayerPawn
CLASSREG_PClassPlayerPawn,
CLASSREG_PClassType,
CLASSREG_PClassClass,
};

struct ClassReg
Expand All @@ -104,10 +106,11 @@ struct ClassReg
ClassReg *ParentType;
const size_t *Pointers;
void (*ConstructNative)(void *);
unsigned int SizeOf:29;
unsigned int MetaClassNum:3;
unsigned int SizeOf:28;
unsigned int MetaClassNum:4;

PClass *RegisterClass();
void SetupClass(PClass *cls);
};

enum EInPlace { EC_InPlace };
Expand Down Expand Up @@ -178,6 +181,10 @@ protected: \
#define IMPLEMENT_ABSTRACT_CLASS(cls) \
_IMP_PCLASS(cls,NULL,NULL)

#define IMPLEMENT_ABSTRACT_POINTY_CLASS(cls) \
_IMP_PCLASS(cls,cls::PointerOffsets,NULL) \
const size_t cls::PointerOffsets[] = {

enum EObjectFlags
{
// GC flags
Expand Down Expand Up @@ -292,6 +299,9 @@ namespace GC
// is NULLed instead.
void Mark(DObject **obj);

// Marks an array of objects.
void MarkArray(DObject **objs, size_t count);

// Soft-roots an object.
void AddSoftRoot(DObject *obj);

Expand All @@ -310,6 +320,15 @@ namespace GC
obj = t;
}
template<class T> void Mark(TObjPtr<T> &obj);

template<class T> void MarkArray(T **obj, size_t count)
{
MarkArray((DObject **)(obj), count);
}
template<class T> void MarkArray(TArray<T> &arr)
{
MarkArray(&arr[0], arr.Size());
}
}

// A template class to help with handling read barriers. It does not
Expand Down
20 changes: 18 additions & 2 deletions src/dobjgc.cpp
Expand Up @@ -283,6 +283,22 @@ void Mark(DObject **obj)
}
}

//==========================================================================
//
// MarkArray
//
// Mark an array of objects gray.
//
//==========================================================================

void MarkArray(DObject **obj, size_t count)
{
for (size_t i = 0; i < count; ++i)
{
Mark(obj[i]);
}
}

//==========================================================================
//
// MarkRoot
Expand Down Expand Up @@ -341,9 +357,9 @@ static void MarkRoot()
}
}
// Mark classes
for (unsigned j = 0; j < PClass::m_Types.Size(); ++j)
for (unsigned j = 0; j < PClass::AllClasses.Size(); ++j)
{
Mark(PClass::m_Types[j]);
Mark(PClass::AllClasses[j]);
}
// Mark bot stuff.
Mark(bglobal.firstthing);
Expand Down

0 comments on commit ee55e03

Please sign in to comment.