mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-26 06:45:31 +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
|
||||
if ( g_pScriptVM )
|
||||
{
|
||||
HSCRIPT hFunc = g_pScriptVM->LookupFunction( "OnMapLoaded" );
|
||||
if ( hFunc )
|
||||
if (CMapFile::g_Hook_OnMapLoaded.CanRunInScope( NULL ))
|
||||
{
|
||||
// Use GetLoadingMap()
|
||||
//g_pScriptVM->SetValue( "map", g_LoadingMap->GetScriptInstance() );
|
||||
|
||||
g_pScriptVM->Call( hFunc );
|
||||
g_pScriptVM->ReleaseFunction( hFunc );
|
||||
CMapFile::g_Hook_OnMapLoaded.Call( NULL, NULL, NULL );
|
||||
|
||||
//g_pScriptVM->ClearValue( "map" );
|
||||
}
|
||||
|
@ -347,6 +347,8 @@ public:
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
HSCRIPT GetScriptInstance();
|
||||
|
||||
static ScriptHook_t g_Hook_OnMapLoaded;
|
||||
|
||||
// VScript functions
|
||||
ALLOW_SCRIPT_ACCESS();
|
||||
private:
|
||||
|
@ -169,6 +169,8 @@ bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMiss
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
ScriptHook_t CMapFile::g_Hook_OnMapLoaded;
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT( CMapFile, "Map file" )
|
||||
|
||||
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." )
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user