- moved all service code to 'common'.

This needs to work on Raze as well!
This commit is contained in:
Christoph Oelckers 2023-03-26 10:55:09 +02:00
parent 7537f415ce
commit 9fbac8f1d4
2 changed files with 32 additions and 27 deletions

View file

@ -55,6 +55,35 @@
#include "maps.h"
static ZSMap<FName, DObject*> AllServices;
static void MarkServices() {
ZSMap<FName, DObject*>::Iterator it(AllServices);
ZSMap<FName, DObject*>::Pair* pair;
while (it.NextPair(pair))
{
GC::Mark<DObject>(pair->Value);
}
}
void InitServices()
{
PClass* cls = PClass::FindClass("Service");
for (PClass* clss : PClass::AllClasses)
{
if (clss != cls && cls->IsAncestorOf(clss))
{
DObject* obj = clss->CreateNew();
obj->ObjectFlags |= OF_Transient;
AllServices.Insert(clss->TypeName, obj);
}
}
GC::AddMarkerFunc(&MarkServices);
}
//==========================================================================
//
// status bar exports
@ -1161,8 +1190,6 @@ DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, baseorder);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, loop);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, handle);
extern ZSMap<FName, DObject* > AllServices;
DEFINE_GLOBAL_NAMED(PClass::AllClasses, AllClasses)
DEFINE_GLOBAL(AllServices)

View file

@ -369,18 +369,7 @@ static void LoadAltHudStuff()
// PClassActor :: StaticInit STATIC
//
//==========================================================================
ZSMap<FName, DObject*> AllServices;
static void MarkServices(){
ZSMap<FName, DObject*>::Iterator it(AllServices);
ZSMap<FName, DObject*>::Pair *pair;
while (it.NextPair(pair))
{
GC::Mark<DObject>(pair->Value);
}
}
void InitServices();
void PClassActor::StaticInit()
{
@ -407,6 +396,8 @@ void PClassActor::StaticInit()
if (!batchrun) Printf ("LoadActors: Load actor definitions.\n");
ClearStrifeTypes();
LoadActors ();
InitServices();
for (auto cls : AllClasses)
{
@ -416,19 +407,6 @@ void PClassActor::StaticInit()
}
}
PClass * cls = PClass::FindClass("Service");
for(PClass * clss : PClass::AllClasses)
{
if(clss != cls && cls->IsAncestorOf(clss))
{
DObject * obj = clss->CreateNew();
obj->ObjectFlags |= OF_Transient;
AllServices.Insert(clss->TypeName, obj);
}
}
GC::AddMarkerFunc(&MarkServices);
LoadAltHudStuff();
InitBotStuff();