Merge pull request #33 from ReDucTor/vscript/register-all-classes

Making vscript register all classes
This commit is contained in:
Blixibon 2020-07-16 10:40:45 -05:00 committed by GitHub
commit b0739b8296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -487,6 +487,8 @@ bool VScriptClientInit()
}
#ifdef MAPBASE_VSCRIPT
g_pScriptVM->RegisterAllClasses();
g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
IGameSystem::RegisterVScriptAllSystems();

View File

@ -569,6 +569,8 @@ bool VScriptServerInit()
g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
#ifdef MAPBASE_VSCRIPT
g_pScriptVM->RegisterAllClasses();
IGameSystem::RegisterVScriptAllSystems();
RegisterSharedScriptFunctions();

View File

@ -297,7 +297,12 @@ public:
struct ScriptClassDesc_t
{
ScriptClassDesc_t() : m_pszScriptName( 0 ), m_pszClassname( 0 ), m_pszDescription( 0 ), m_pBaseDesc( 0 ), m_pfnConstruct( 0 ), m_pfnDestruct( 0 ), pHelper(NULL) {}
ScriptClassDesc_t() : m_pszScriptName( 0 ), m_pszClassname( 0 ), m_pszDescription( 0 ), m_pBaseDesc( 0 ), m_pfnConstruct( 0 ), m_pfnDestruct( 0 ), pHelper(NULL)
{
#ifdef MAPBASE_VSCRIPT
AllClassesDesc().AddToTail(this);
#endif
}
const char * m_pszScriptName;
const char * m_pszClassname;
@ -308,6 +313,14 @@ struct ScriptClassDesc_t
void *(*m_pfnConstruct)();
void (*m_pfnDestruct)( void *);
IScriptInstanceHelper * pHelper; // optional helper
#ifdef MAPBASE_VSCRIPT
static CUtlVector<ScriptClassDesc_t*>& AllClassesDesc()
{
static CUtlVector<ScriptClassDesc_t*> classes;
return classes;
}
#endif
};
//---------------------------------------------------------
@ -875,6 +888,16 @@ public:
return ExecuteFunction( hFunction, args, ARRAYSIZE(args), pReturn, hScope, bWait );
}
#ifdef MAPBASE_VSCRIPT
void RegisterAllClasses()
{
CUtlVector<ScriptClassDesc_t*>& classDescs = ScriptClassDesc_t::AllClassesDesc();
FOR_EACH_VEC(classDescs, i)
{
RegisterClass(classDescs[i]);
}
}
#endif
};