mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-26 05:51:30 +00:00
added class registration code for Blood
This commit is contained in:
parent
cb443d443c
commit
d86e99a2e1
3 changed files with 38 additions and 0 deletions
|
@ -203,4 +203,11 @@ bool IsUnderwaterSector(sectortype* pSector);
|
|||
#define AF(func) DBloodActor_##func##_VMPtr
|
||||
|
||||
|
||||
#define xx(n) inline PClassActor* n##Class;
|
||||
#include "classnames.h"
|
||||
#undef xx
|
||||
|
||||
void RegisterClasses();
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -598,6 +598,7 @@ void GameInterface::app_init()
|
|||
PlayerArray[i] = Create<DBloodPlayer>(i);
|
||||
GC::WriteBarrier(PlayerArray[i]);
|
||||
}
|
||||
RegisterClasses();
|
||||
|
||||
mirrortile = tileGetTextureID(504);
|
||||
InitTextureIDs();
|
||||
|
@ -736,4 +737,32 @@ inline DBloodPlayer* getPlayer(DBloodActor* actor)
|
|||
return getPlayer(actor->GetType() - kDudePlayer1);
|
||||
}
|
||||
|
||||
|
||||
// Register all internally used classes at game startup so that we can find naming errors right away without having them cause bugs later.
|
||||
void RegisterClasses()
|
||||
{
|
||||
#define xx(n) { #n, &n##Class},
|
||||
static std::pair<const char*, PClassActor**> classreg[] = {
|
||||
#include "classnames.h"
|
||||
};
|
||||
#undef xx
|
||||
|
||||
int error = 0;
|
||||
for (auto& classdef : classreg)
|
||||
{
|
||||
auto cls = PClass::FindActor(classdef.first);
|
||||
if (cls == nullptr || !cls->IsDescendantOf(RUNTIME_CLASS(DBloodActor)))
|
||||
{
|
||||
Printf(TEXTCOLOR_RED "%s: Attempt to register unknown actor class\n", classdef.first);
|
||||
error++;
|
||||
}
|
||||
|
||||
*classdef.second = cls;
|
||||
}
|
||||
if (error > 0)
|
||||
{
|
||||
I_FatalError("Unable to register %d actor classes", error);
|
||||
}
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
2
source/games/blood/src/classnames.h
Normal file
2
source/games/blood/src/classnames.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
xx(BloodMissileBase)
|
||||
|
Loading…
Reference in a new issue