1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Minor adjustment when creating command listeners directly from the command manager.

This commit is contained in:
Sandu Liviu Catalin 2016-07-12 00:11:54 +03:00
parent 8ad3eb8c4e
commit 749f232d06

View File

@ -126,13 +126,9 @@ Object Manager::Create(CSStr name, CSStr spec, Array & tags, Uint8 min, Uint8 ma
// Create the command listener // Create the command listener
{ {
// Create a new instance of this class and make sure it can't get leaked due to exceptions // Create a new instance of this class and make sure it can't get leaked due to exceptions
AutoDelete< Listener > ad(new Listener(name, spec,tags, min, max, auth, prot, assoc)); AutoDelete< Listener > ad(new Listener(name, spec, tags, min, max, auth, prot, assoc));
// Obtain the initial stack size // Transform the instance into a script object
const StackGuard sg; obj = Object(ad.Get());
// Push the instance on the stack
ClassType< Listener >::PushInstance(DefaultVM::Get(), ad.Get());
// Grab the script object with the instance instance from the stack
obj = Var< Object >(DefaultVM::Get(), -1).value;
// Validate the obtained script object // Validate the obtained script object
if (obj.IsNull()) if (obj.IsNull())
{ {
@ -143,6 +139,7 @@ Object Manager::Create(CSStr name, CSStr spec, Array & tags, Uint8 min, Uint8 ma
} }
// Attempt to attach the command listener to the controller // Attempt to attach the command listener to the controller
Object & o = m_Controller->Attach(obj, ptr); Object & o = m_Controller->Attach(obj, ptr);
// Return the script object
return o; return o;
} }