mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-26 23:05:30 +03:00
Made VBSP's OnMapLoaded into a hook using the new system
This commit is contained in:
parent
653d48d2c4
commit
b2116d07e9
@ -2806,14 +2806,12 @@ bool LoadMapFile( const char *pszFileName )
|
|||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
if ( g_pScriptVM )
|
if ( g_pScriptVM )
|
||||||
{
|
{
|
||||||
HSCRIPT hFunc = g_pScriptVM->LookupFunction( "OnMapLoaded" );
|
if (CMapFile::g_Hook_OnMapLoaded.CanRunInScope( NULL ))
|
||||||
if ( hFunc )
|
|
||||||
{
|
{
|
||||||
// Use GetLoadingMap()
|
// Use GetLoadingMap()
|
||||||
//g_pScriptVM->SetValue( "map", g_LoadingMap->GetScriptInstance() );
|
//g_pScriptVM->SetValue( "map", g_LoadingMap->GetScriptInstance() );
|
||||||
|
|
||||||
g_pScriptVM->Call( hFunc );
|
CMapFile::g_Hook_OnMapLoaded.Call( NULL, NULL, NULL );
|
||||||
g_pScriptVM->ReleaseFunction( hFunc );
|
|
||||||
|
|
||||||
//g_pScriptVM->ClearValue( "map" );
|
//g_pScriptVM->ClearValue( "map" );
|
||||||
}
|
}
|
||||||
|
@ -347,6 +347,8 @@ public:
|
|||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
HSCRIPT GetScriptInstance();
|
HSCRIPT GetScriptInstance();
|
||||||
|
|
||||||
|
static ScriptHook_t g_Hook_OnMapLoaded;
|
||||||
|
|
||||||
// VScript functions
|
// VScript functions
|
||||||
ALLOW_SCRIPT_ACCESS();
|
ALLOW_SCRIPT_ACCESS();
|
||||||
private:
|
private:
|
||||||
|
@ -169,6 +169,8 @@ bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMiss
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptHook_t CMapFile::g_Hook_OnMapLoaded;
|
||||||
|
|
||||||
BEGIN_SCRIPTDESC_ROOT( CMapFile, "Map file" )
|
BEGIN_SCRIPTDESC_ROOT( CMapFile, "Map file" )
|
||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetMins, "Get the map's mins." )
|
DEFINE_SCRIPTFUNC( GetMins, "Get the map's mins." )
|
||||||
@ -185,6 +187,11 @@ BEGIN_SCRIPTDESC_ROOT( CMapFile, "Map file" )
|
|||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetNumEntities, "Get the number of entities in the map." )
|
DEFINE_SCRIPTFUNC( GetNumEntities, "Get the number of entities in the map." )
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hooks
|
||||||
|
//
|
||||||
|
DEFINE_SIMPLE_SCRIPTHOOK( CMapFile::g_Hook_OnMapLoaded, "OnMapLoaded", FIELD_VOID, "Called when the NPC is deciding whether to hear a CSound or not." )
|
||||||
|
|
||||||
END_SCRIPTDESC();
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user