Fix vscript global hook calls

This commit is contained in:
samisalreadytaken 2022-03-04 16:02:00 +03:00
parent 4af6d0cdaa
commit f2f874939d

View File

@ -215,16 +215,17 @@ Hooks <-
function Call( scope, event, ... ) function Call( scope, event, ... )
{ {
local firstReturn = null local firstReturn
if ( scope == null ) // global hook; call all scopes
if ( !scope )
{ {
// null scope = global hook; call all scopes vargv.insert( 0, null )
vargv.insert(0,this) foreach( sc,t in s_List )
foreach ( t in s_List )
{ {
if ( event in t ) if ( event in t )
{ {
vargv[0] = sc
foreach( context, callback in t[event] ) foreach( context, callback in t[event] )
{ {
//printf( "(%.4f) Calling hook '%s' of context '%s' in static iteration\n", Time(), event, context ) //printf( "(%.4f) Calling hook '%s' of context '%s' in static iteration\n", Time(), event, context )
@ -241,7 +242,7 @@ Hooks <-
local t = s_List[scope] local t = s_List[scope]
if ( event in t ) if ( event in t )
{ {
vargv.insert(0,scope) vargv.insert( 0, scope )
foreach( context, callback in t[event] ) foreach( context, callback in t[event] )
{ {
//printf( "(%.4f) Calling hook '%s' of context '%s'\n", Time(), event, context ) //printf( "(%.4f) Calling hook '%s' of context '%s'\n", Time(), event, context )
@ -258,13 +259,7 @@ Hooks <-
function ScopeHookedToEvent( scope, event ) function ScopeHookedToEvent( scope, event )
{ {
if ( scope in s_List ) return ( scope in s_List ) && ( event in s_List[scope] )
{
if (event in s_List[scope])
return true
}
return false
} }
} }