mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Make the function environment optional in global callbacks.
This commit is contained in:
parent
3ed0b22426
commit
f8e845ebd2
@ -525,6 +525,28 @@ void Core::CompilerErrorHandler(HSQUIRRELVM /*vm*/, CSStr desc, CSStr src, SQInt
|
||||
LogFtl("Message: %s\n[\n=>Location: %s\n=>Line: %d\n=>Column: %d\n]", desc, src, line, column);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::BindEvent(Int32 id, Object & env, Function & func)
|
||||
{
|
||||
// Obtain the function instance called for this event
|
||||
Function & event = GetEvent(id);
|
||||
// Is the specified callback function null?
|
||||
if (func.IsNull())
|
||||
{
|
||||
event.Release(); // Then release the current callback
|
||||
}
|
||||
// Does this function need a custom environment?
|
||||
else if (env.IsNull())
|
||||
{
|
||||
event = func;
|
||||
}
|
||||
// Assign the specified environment and function
|
||||
else
|
||||
{
|
||||
event = Function(env.GetVM(), env, func.GetFunc());
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Core::BlipInst::~BlipInst()
|
||||
{
|
||||
|
@ -860,23 +860,6 @@ bool Core::DelVehicle(Int32 id, Int32 header, Object & payload)
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::BindEvent(Int32 id, Object & env, Function & func)
|
||||
{
|
||||
// Obtain the function instance called for this event
|
||||
Function & event = GetEvent(id);
|
||||
// Is the specified callback function null?
|
||||
if (func.IsNull())
|
||||
{
|
||||
event.Release(); // Then release the current callback
|
||||
}
|
||||
// Assign the specified environment and function
|
||||
else
|
||||
{
|
||||
event = Function(env.GetVM(), env, func.GetFunc());
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
void Core::ConnectPlayer(Int32 id, Int32 header, Object & payload)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user