diff --git a/cbp/Module.cbp b/cbp/Module.cbp index 74945f6d..54865251 100644 --- a/cbp/Module.cbp +++ b/cbp/Module.cbp @@ -263,6 +263,7 @@ + diff --git a/cbp/Sample.cbp b/cbp/Sample.cbp new file mode 100644 index 00000000..bb4520df --- /dev/null +++ b/cbp/Sample.cbp @@ -0,0 +1,199 @@ + + + + + + diff --git a/cbp/default.workspace b/cbp/default.workspace index 76bb1e41..a316b486 100644 --- a/cbp/default.workspace +++ b/cbp/default.workspace @@ -5,6 +5,7 @@ - + + diff --git a/external/Sqrat/sqratThread.cpp b/external/Sqrat/sqratThread.cpp deleted file mode 100644 index 64275247..00000000 --- a/external/Sqrat/sqratThread.cpp +++ /dev/null @@ -1,373 +0,0 @@ -// -// SqratThread: Sqrat threading module -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -//#include "sqratlib/sqratBase.h" -#include "sqratThread.h" -#include -#include - -static HSQAPI sq; - -// -// Thread lib utility functions (not visible externally) -// - -static SQFloat sqrat_clock() { - return ((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC; -} - -static SQInteger sqrat_strlen(const SQChar* str) { -#if defined(_UNICODE) - return static_cast(wcslen(str) * sizeof(SQChar)); -#else - return static_cast(strlen(str) * sizeof(SQChar)); -#endif -} - -static void sqrat_pushtaskarray(HSQUIRRELVM v) { - HSQOBJECT taskarray; - - sq->pushroottable(v); - sq->pushstring(v,_SC("__sqrat_taskarray__"),-1); - if(SQ_FAILED(sq->get(v, -2))) { - // Not found, create a new namespace - sq->pushstring(v,_SC("__sqrat_taskarray__"),-1); - sq->newarray(v, 0); - sq->getstackobj(v,-1,&taskarray); // Save namespace for later use - sq->newslot(v, -3, 0); - sq->pop(v, 1); // pop root table - - sq->pushobject(v, taskarray); // push the newly bound array - } else { - sq->remove(v, -2); // pop sqrat table - } -} - -static SQRESULT sqrat_pushclosure(HSQUIRRELVM v, const SQChar* script) { - if(SQ_FAILED(sq->compilebuffer(v, script, sqrat_strlen(script), _SC(""), true))) { - return SQ_ERROR; - } - - sq->pushroottable(v); - if(SQ_FAILED(sq->call(v, 1, 0, 1))) { - sq->remove(v, -1); // remove compiled closure - return SQ_ERROR; - } - sq->remove(v, -2); // remove compiled closure - return SQ_OK; -} - -static SQInteger sqrat_schedule_argcall(HSQUIRRELVM v) { - SQInteger nparams = sq->gettop(v) - 2; // Get the number of parameters provided - - // The task table is the last argument (free variable), so we can operate on immediately - sq->pushstring(v, _SC("args"), -1); - - sq->newarray(v, 0); // Create the array for the arguments - - // Loop through all arguments and push them into the arg array - for(SQInteger i = 0; i < nparams; ++i) { - sq->push(v, i+2); - sq->arrayappend(v, -2); - } - - sq->newslot(v, -3, 0); // Push the arg array into the task table - return 0; -} - -// This is a horrid way to get this functionality in there, but I can't find any alternatives right now. -static SQRESULT sqrat_pushsleep(HSQUIRRELVM v) { - SQChar* sleep_script = _SC(" \ - __sqratsleep__ <- function(timeout) { \ - local begin = clock(); \ - local now; \ - do { \ - ::suspend(); \ - now = clock(); \ - } while( (now - begin) < timeout ); \ - } \ - "); - - if(SQ_FAILED(sq->compilebuffer(v, sleep_script, sqrat_strlen(sleep_script), _SC(""), true))) { - return SQ_ERROR; - } - - sq->pushroottable(v); - if(SQ_FAILED(sq->call(v, 1, 0, 1))) { - sq->remove(v, -1); // remove compiled closure - return SQ_ERROR; - } - sq->remove(v, -1); // remove compiled closure - - sq->pushroottable(v); - sq->pushstring(v, _SC("__sqratsleep__"), -1); - SQRESULT res = sq->get(v, -2); - - sq->remove(v, -2); // remove root table - - return res; -} - -// -// Thread lib main functions -// - -static SQRESULT sqrat_sleep(HSQUIRRELVM v, SQFloat timeout) { - return sq->suspendvm(v); - - // Get "::suspend" - /*HSQOBJECT suspend; - sq->pushroottable(v); - sq->pushstring(v, _SC("suspend"), -1); - if(SQ_FAILED(sq->get(v, -2))) { - return SQ_ERROR; - } - sq->getstackobj(v, -1, &suspend); - sq->pop(v, 2); - - // Loop ::suspend until the appropriate time has passed - SQFloat timeStart = sqrat_clock(); - SQFloat timeNow = 0; - - while(timeNow - timeStart < timeout) { - sq->pushobject(v, suspend); - sq->pushroottable(v); - if(SQ_FAILED(sq->call(v, 1, 0, 1))) { - return SQ_ERROR; - } - timeNow = sqrat_clock(); - } - - return SQ_OK;*/ -} - -static void sqrat_schedule(HSQUIRRELVM v, SQInteger idx) { - HSQOBJECT thread; - HSQOBJECT func; - HSQOBJECT task; - - sq->getstackobj(v, idx, &func); - SQInteger stksize = 256; // TODO: Allow initial stack size to be configurable - - sqrat_pushtaskarray(v); // Push the task array - - // Create the task - sq->newtable(v); - sq->getstackobj(v, -1, &task); - - // Create the thread and add it to the task table - sq->pushstring(v, _SC("thread"), -1); - sq->newthread(v, stksize); - sq->getstackobj(v, -1, &thread); - sq->newslot(v, -3, 0); - - // Push the function to be called onto the thread stack - sq->pushobject(v, func); - sq->move(thread._unVal.pThread, v, -1); - sq->pop(v, 1); - - // Args will be pushed later, in the closure - - sq->arrayappend(v, -2); // Add the task to the task array - - sq->pushobject(v, task); // Push the task object as a free variable for the temporary closure - sq->newclosure(v, sqrat_schedule_argcall, 1); // push a temporary closure used to retrieve call args -} - -// Wow... this has to be one of the ugliest functions I've ever writter. Ever. -// Building complex logic with the squirrel stack really sucks. -static void sqrat_run(HSQUIRRELVM v) { - - HSQOBJECT taskArray; - HSQOBJECT thread; - HSQUIRRELVM threadVm; - SQInteger nparams; // Number of parameters to pass to a function - SQInteger arrayidx; //Cached index of the task array - - // Push the tasklist - sqrat_pushtaskarray(v); // Push the task array to the stack - - sq->getstackobj(v, -1, &taskArray); - arrayidx = sq->gettop(v); // Cache the stack location of the task array - - SQInteger tasklistSize = sq->getsize(v, arrayidx); // Query the initial size of the task array - do { - SQInteger i = 0; - - // This outer while is to allow us to pick up any new tasks that are added during the loop, - // but still give us an opportunity to sleep after running through the initial tasks - while(i < tasklistSize) { - - for(; i < tasklistSize; ++i) { - sq->pushinteger(v, i); - if(SQ_FAILED(sq->get(v, -2))) { // Get the task - sq->arrayremove(v, -2, i); - sq->pop(v, 1); - --tasklistSize; - --i; - continue; - } - - // Now that we have the task, get the thread - sq->pushstring(v, _SC("thread"), -1); - if(SQ_FAILED(sq->get(v, -2))) { - sq->arrayremove(v, -3, i); - sq->pop(v, 1); - --tasklistSize; - --i; - continue; - } - sq->getstackobj(v, -1, &thread); - sq->pop(v, 1); - - threadVm = thread._unVal.pThread; - - if(sq->getvmstate(threadVm) == SQ_VMSTATE_IDLE) { // New thread? If so we need to call it - - // Function to be called is already pushed to the thread (happens in schedule) - sq->pushroottable(threadVm); // Pus the threads root table - - sq->pushstring(v, _SC("args"), -1); - if(SQ_FAILED(sq->get(v, -2))) { // Check to see if we have arguments for this thread - nparams = 0; // No arguments - } else { - nparams = sq->getsize(v, -1); // Get the number of args in the arg array - - // Push the arguments onto the thread stack - for(SQInteger a = 0; a < nparams; ++a) { - sq->pushinteger(v, a); - if(SQ_FAILED(sq->get(v, -2))) { - sq->pushnull(threadVm); // Is this the best way to handle this? - } else { - sq->move(threadVm, v, -1); - sq->pop(v, 1); - } - } - - sq->pop(v, 1); // Pop the arg array - } - - sq->call(threadVm, nparams+1, 0, 1); // Call the thread - - } else { - // If the thread is suspended, wake it up. - // This function changed in Squirrel 2.2.3, - // removing the last parameter makes it compatible with 2.2.2 and earlier - sq->wakeupvm(threadVm, 0, 0, 1, 0); - } - - if(sq->getvmstate(threadVm) == SQ_VMSTATE_IDLE) { // Check to see if the thread is finished (idle again) - sq->arrayremove(v, -2, i); // Remove the task from the task array - - --tasklistSize; // Adjust the for variables to account for the removal - --i; - } - - sq->pop(v, 1); // Pop off the task - } - - // Yield to system if needed - - tasklistSize = sq->getsize(v, arrayidx); // Get the task - - } - - } while(tasklistSize > 0); // Loop until we have no more pending tasks -} - -// -// Script interface functions -// - -static SQInteger sqratbase_sleep(HSQUIRRELVM v) { - SQFloat timeout; - sq->getfloat(v, -1, &timeout); - sqrat_sleep(v, timeout); - return 0; -} - -static SQInteger sqratbase_schedule(HSQUIRRELVM v) { - sqrat_schedule(v, -1); - return 1; -} - -static SQInteger sqratbase_run(HSQUIRRELVM v) { - sqrat_run(v); - return 0; -} - -// This is a squirrel only function, since there's really no need to -// expose a native api for it. Just use the VM that you would have passed -// in anyway! -static SQInteger sqratbase_getthread(HSQUIRRELVM v) { - // For the record, this way of doing things really sucks. - // I would love a better way of retrieving this object! - HSQOBJECT threadObj; - threadObj._type = OT_THREAD; - threadObj._unVal.pThread = v; - - sq->pushobject(v, threadObj); - sq->weakref(v, -1); - sq->remove(v, -2); - return 1; -} - -// -// Module registration -// - -SQRESULT sqmodule_load(HSQUIRRELVM v, HSQAPI api) { - - sq = api; - - sq->pushstring(v, _SC("schedule"), -1); - sq->newclosure(v, &sqratbase_schedule, 0); - sq->newslot(v, -3, 0); - - sq->pushstring(v, _SC("run"), -1); - sq->newclosure(v, &sqratbase_run, 0); - sq->newslot(v, -3, 0); - - sq->pushstring(v, _SC("getthread"), -1); - sq->newclosure(v, &sqratbase_getthread, 0); - sq->newslot(v, -3, 0); - - // Would rather do this... - /*sq->pushstring(v, _SC("sleep"), -1); - sq->newclosure(v, &sqratbase_sleep, 0); - sq->newslot(v, -3, 0);*/ - - // Than this... - sq->pushstring(v, _SC("sleep"), -1); - if(SQ_FAILED(sqrat_pushsleep(v))) { - sq->pop(v, 1); - } else { - sq->newslot(v, -3, 0); - } - - return SQ_OK; -} diff --git a/external/Sqrat/sqratimport.cpp b/external/Sqrat/sqratimport.cpp deleted file mode 100644 index 9f19b109..00000000 --- a/external/Sqrat/sqratimport.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// -// SqratImport: Supports importing of squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#include "sqratimport.h" -#include "sqmodule.h" - -//#include "sqratlib/sqratBase.h" -#include -#include - -#if defined(_WIN32) - -#include - -#elif defined(__unix) - -#include - -#endif - -typedef SQRESULT (*SQMODULELOAD)(HSQUIRRELVM v, HSQAPI sq); - -static HSQAPI sqapi = NULL; - -// Create and populate the HSQAPI structure with function pointers -// If new functions are added to the Squirrel API, they should be added here too -static HSQAPI sqrat_newapi() { - HSQAPI sq = (HSQAPI)sq_malloc(sizeof(sq_api)); - - /*vm*/ - sq->open = sq_open; - sq->newthread = sq_newthread; - sq->seterrorhandler = sq_seterrorhandler; - sq->close = sq_close; - sq->setforeignptr = sq_setforeignptr; - sq->getforeignptr = sq_getforeignptr; - sq->setprintfunc = sq_setprintfunc; - sq->getprintfunc = sq_getprintfunc; - sq->suspendvm = sq_suspendvm; - sq->wakeupvm = sq_wakeupvm; - sq->getvmstate = sq_getvmstate; - - /*compiler*/ - sq->compile = sq_compile; - sq->compilebuffer = sq_compilebuffer; - sq->enabledebuginfo = sq_enabledebuginfo; - sq->notifyallexceptions = sq_notifyallexceptions; - sq->setcompilererrorhandler = sq_setcompilererrorhandler; - - /*stack operations*/ - sq->push = sq_push; - sq->pop = sq_pop; - sq->poptop = sq_poptop; - sq->remove = sq_remove; - sq->gettop = sq_gettop; - sq->settop = sq_settop; - sq->reservestack = sq_reservestack; - sq->cmp = sq_cmp; - sq->move = sq_move; - - /*object creation handling*/ - sq->newuserdata = sq_newuserdata; - sq->newtable = sq_newtable; - sq->newarray = sq_newarray; - sq->newclosure = sq_newclosure; - sq->setparamscheck = sq_setparamscheck; - sq->bindenv = sq_bindenv; - sq->pushstring = sq_pushstring; - sq->pushfloat = sq_pushfloat; - sq->pushinteger = sq_pushinteger; - sq->pushbool = sq_pushbool; - sq->pushuserpointer = sq_pushuserpointer; - sq->pushnull = sq_pushnull; - sq->gettype = sq_gettype; - sq->getsize = sq_getsize; - sq->getbase = sq_getbase; - sq->instanceof = sq_instanceof; - sq->tostring = sq_tostring; - sq->tobool = sq_tobool; - sq->getstring = sq_getstring; - sq->getinteger = sq_getinteger; - sq->getthread = sq_getthread; - sq->getbool = sq_getbool; - sq->getuserpointer = sq_getuserpointer; - sq->getuserdata = sq_getuserdata; - sq->settypetag = sq_settypetag; - sq->gettypetag = sq_gettypetag; - sq->setreleasehook = sq_setreleasehook; - sq->getscratchpad = sq_getscratchpad; - sq->getclosureinfo = sq_getclosureinfo; - sq->setnativeclosurename = sq_setnativeclosurename; - sq->setinstanceup = sq_setinstanceup; - sq->getinstanceup = sq_getinstanceup; - sq->setclassudsize = sq_setclassudsize; - sq->newclass = sq_newclass; - sq->createinstance = sq_createinstance; - sq->setattributes = sq_setattributes; - sq->getattributes = sq_getattributes; - sq->getclass = sq_getclass; - sq->weakref = sq_weakref; - sq->getdefaultdelegate = sq_getdefaultdelegate; - - /*object manipulation*/ - sq->pushroottable = sq_pushroottable; - sq->pushregistrytable = sq_pushregistrytable; - sq->pushconsttable = sq_pushconsttable; - sq->setroottable = sq_setroottable; - sq->setconsttable = sq_setconsttable; - sq->newslot = sq_newslot; - sq->deleteslot = sq_deleteslot; - sq->set = sq_set; - sq->get = sq_get; - sq->rawset = sq_rawset; - sq->rawget = sq_rawget; - sq->rawdeleteslot = sq_rawdeleteslot; - sq->arrayappend = sq_arrayappend; - sq->arraypop = sq_arraypop; - sq->arrayresize = sq_arrayresize; - sq->arrayreverse = sq_arrayreverse; - sq->arrayremove = sq_arrayremove; - sq->arrayinsert = sq_arrayinsert; - sq->setdelegate = sq_setdelegate; - sq->getdelegate = sq_getdelegate; - sq->clone = sq_clone; - sq->setfreevariable = sq_setfreevariable; - sq->next = sq_next; - sq->getweakrefval = sq_getweakrefval; - sq->clear = sq_clear; - - /*calls*/ - sq->call = sq_call; - sq->resume = sq_resume; - sq->getlocal = sq_getlocal; - sq->getfreevariable = sq_getfreevariable; - sq->throwerror = sq_throwerror; - sq->reseterror = sq_reseterror; - sq->getlasterror = sq_getlasterror; - - /*raw object handling*/ - sq->getstackobj = sq_getstackobj; - sq->pushobject = sq_pushobject; - sq->addref = sq_addref; - sq->release = sq_release; - sq->resetobject = sq_resetobject; - sq->objtostring = sq_objtostring; - sq->objtobool = sq_objtobool; - sq->objtointeger = sq_objtointeger; - sq->objtofloat = sq_objtofloat; - sq->getobjtypetag = sq_getobjtypetag; - - /*GC*/ - sq->collectgarbage = sq_collectgarbage; - - /*serialization*/ - sq->writeclosure = sq_writeclosure; - sq->readclosure = sq_readclosure; - - /*mem allocation*/ - sq->malloc = sq_malloc; - sq->realloc = sq_realloc; - sq->free = sq_free; - - /*debug*/ - sq->stackinfos = sq_stackinfos; - sq->setdebughook = sq_setdebughook; - - return sq; -} - - -static SQRESULT sqrat_importscript(HSQUIRRELVM v, const SQChar* moduleName) { - std::basic_string filename(moduleName); - filename += _SC(".nut"); - if(SQ_FAILED(sqstd_loadfile(v, moduleName, true))) { - if(SQ_FAILED(sqstd_loadfile(v, filename.c_str(), true))) { - return SQ_ERROR; - } - } - sq_push(v, -2); - sq_call(v, 1, false, true); - return SQ_OK; -} - -static SQRESULT sqrat_importbin(HSQUIRRELVM v, const SQChar* moduleName) { -#ifdef SQUNICODE -#warning sqrat_importbin() Not Implemented - return SQ_ERROR; -#else - SQMODULELOAD modLoad = 0; - -#if defined(_WIN32) - HMODULE mod; - mod = GetModuleHandle(moduleName); - if(mod == NULL) { - mod = LoadLibrary(moduleName); - if(mod == NULL) { - return SQ_ERROR; - } - } - - modLoad = (SQMODULELOAD)GetProcAddress(mod, "sqmodule_load"); - if(modLoad == NULL) { - FreeLibrary(mod); - return SQ_ERROR; - } -#elif defined(__unix) - /* adding .so to moduleName? */ - void *mod = dlopen(moduleName, RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD); //RTLD_NOLOAD flag is not specified in POSIX.1-2001..so not the best solution :( - if (mod == NULL) { - mod = dlopen(moduleName, RTLD_NOW | RTLD_LOCAL); - if (mod == NULL) - return SQ_ERROR; - } - modLoad = (SQMODULELOAD) dlsym(mod, "sqmodule_load"); - if (modLoad == NULL) { - dlclose(mod); - return SQ_ERROR; - } -#endif - - if(sqapi == NULL) { - sqapi = sqrat_newapi(); // Caching this for multiple imports is probably a very good idea - } - - SQRESULT res = modLoad(v, sqapi); - - return res; -#endif -} - -SQRESULT sqrat_import(HSQUIRRELVM v) { - const SQChar* moduleName; - HSQOBJECT table; - SQRESULT res = SQ_OK; - - - sq_getstring(v, -2, &moduleName); - sq_getstackobj(v, -1, &table); - sq_addref(v, &table); - - sq_settop(v, 0); // Clear Stack - sq_pushobject(v, table); // Push the target table onto the stack - - if(SQ_FAILED(sqrat_importscript(v, moduleName))) { - res = sqrat_importbin(v, moduleName); - } - - sq_settop(v, 0); // Clean up the stack (just in case the module load leaves it messy) - sq_pushobject(v, table); // return the target table - sq_release(v, &table); - - return res; -} - -static SQInteger sqratbase_import(HSQUIRRELVM v) { - SQInteger args = sq_gettop(v); - switch(args) { - case 2: - sq_pushroottable(v); - break; - case 3: - // should already have the desired table pushed onto the stack - break; - default: - // Error, unexpected number of arguments - break; - } - - sqrat_import(v); - - return 1; -} - -SQRESULT sqrat_register_importlib(HSQUIRRELVM v) { - sq_pushroottable(v); - - sq_pushstring(v, _SC("import"), -1); - sq_newclosure(v, &sqratbase_import, 0); - sq_newslot(v, -3, 0); - - sq_pop(v, 1); // pop sqrat table - - return SQ_OK; -} diff --git a/include/sqmod.h b/include/sqmod.h deleted file mode 100644 index 7f1670eb..00000000 --- a/include/sqmod.h +++ /dev/null @@ -1,199 +0,0 @@ -// -// SqModule: API used to communicate with and register squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQ_MODULE_H_) -#define _SQ_MODULE_H_ - -#include "squirrel.h" - -#ifdef __cplusplus -extern "C" { -#endif - - /* HSQAPI */ - /* - Allows modules to interface with squirrel's C api without linking to the squirrel library - If new functions are added to the Squirrel API, they should be added here too - */ - typedef struct { - /*vm*/ - HSQUIRRELVM (*open)(SQInteger initialstacksize); - HSQUIRRELVM (*newthread)(HSQUIRRELVM friendvm, SQInteger initialstacksize); - void (*seterrorhandler)(HSQUIRRELVM v); - void (*close)(HSQUIRRELVM v); - void (*setforeignptr)(HSQUIRRELVM v,SQUserPointer p); - SQUserPointer (*getforeignptr)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc, SQPRINTFUNCTION); -#else - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc); -#endif - SQPRINTFUNCTION (*getprintfunc)(HSQUIRRELVM v); - SQRESULT (*suspendvm)(HSQUIRRELVM v); - SQRESULT (*wakeupvm)(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror); - SQInteger (*getvmstate)(HSQUIRRELVM v); - - /*compiler*/ - SQRESULT (*compile)(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror); - SQRESULT (*compilebuffer)(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror); - void (*enabledebuginfo)(HSQUIRRELVM v, SQBool enable); - void (*notifyallexceptions)(HSQUIRRELVM v, SQBool enable); - void (*setcompilererrorhandler)(HSQUIRRELVM v,SQCOMPILERERROR f); - - /*stack operations*/ - void (*push)(HSQUIRRELVM v,SQInteger idx); - void (*pop)(HSQUIRRELVM v,SQInteger nelemstopop); - void (*poptop)(HSQUIRRELVM v); - void (*remove)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*gettop)(HSQUIRRELVM v); - void (*settop)(HSQUIRRELVM v,SQInteger newtop); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#else - void (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#endif - SQInteger (*cmp)(HSQUIRRELVM v); - void (*move)(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx); - - /*object creation handling*/ - SQUserPointer (*newuserdata)(HSQUIRRELVM v,SQUnsignedInteger size); - void (*newtable)(HSQUIRRELVM v); - void (*newarray)(HSQUIRRELVM v,SQInteger size); - void (*newclosure)(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); - SQRESULT (*setparamscheck)(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); - SQRESULT (*bindenv)(HSQUIRRELVM v,SQInteger idx); - void (*pushstring)(HSQUIRRELVM v,const SQChar *s,SQInteger len); - void (*pushfloat)(HSQUIRRELVM v,SQFloat f); - void (*pushinteger)(HSQUIRRELVM v,SQInteger n); - void (*pushbool)(HSQUIRRELVM v,SQBool b); - void (*pushuserpointer)(HSQUIRRELVM v,SQUserPointer p); - void (*pushnull)(HSQUIRRELVM v); - SQObjectType (*gettype)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*getsize)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getbase)(HSQUIRRELVM v,SQInteger idx); - SQBool (*instanceof)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*tostring)(HSQUIRRELVM v,SQInteger idx); -#else - void (*tostring)(HSQUIRRELVM v,SQInteger idx); -#endif - void (*tobool)(HSQUIRRELVM v, SQInteger idx, SQBool *b); - SQRESULT (*getstring)(HSQUIRRELVM v,SQInteger idx,const SQChar **c); - SQRESULT (*getinteger)(HSQUIRRELVM v,SQInteger idx,SQInteger *i); - SQRESULT (*getfloat)(HSQUIRRELVM v,SQInteger idx,SQFloat *f); - SQRESULT (*getbool)(HSQUIRRELVM v,SQInteger idx,SQBool *b); - SQRESULT (*getthread)(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread); - SQRESULT (*getuserpointer)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p); - SQRESULT (*getuserdata)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag); - SQRESULT (*settypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag); - SQRESULT (*gettypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag); - void (*setreleasehook)(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook); - SQChar* (*getscratchpad)(HSQUIRRELVM v,SQInteger minsize); - SQRESULT (*getclosureinfo)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars); - SQRESULT (*setnativeclosurename)(HSQUIRRELVM v,SQInteger idx,const SQChar *name); - SQRESULT (*setinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer p); - SQRESULT (*getinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag); - SQRESULT (*setclassudsize)(HSQUIRRELVM v, SQInteger idx, SQInteger udsize); - SQRESULT (*newclass)(HSQUIRRELVM v,SQBool hasbase); - SQRESULT (*createinstance)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getclass)(HSQUIRRELVM v,SQInteger idx); - void (*weakref)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdefaultdelegate)(HSQUIRRELVM v,SQObjectType t); - - /*object manipulation*/ - void (*pushroottable)(HSQUIRRELVM v); - void (*pushregistrytable)(HSQUIRRELVM v); - void (*pushconsttable)(HSQUIRRELVM v); - SQRESULT (*setroottable)(HSQUIRRELVM v); - SQRESULT (*setconsttable)(HSQUIRRELVM v); - SQRESULT (*newslot)(HSQUIRRELVM v, SQInteger idx, SQBool bstatic); - SQRESULT (*deleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*set)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*get)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawget)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawset)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawdeleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayappend)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arraypop)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayresize)(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); - SQRESULT (*arrayreverse)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arrayremove)(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx); - SQRESULT (*arrayinsert)(HSQUIRRELVM v,SQInteger idx,SQInteger destpos); - SQRESULT (*setdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clone)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*next)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getweakrefval)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clear)(HSQUIRRELVM v,SQInteger idx); - - /*calls*/ - SQRESULT (*call)(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror); - SQRESULT (*resume)(HSQUIRRELVM v,SQBool retval,SQBool raiseerror); - const SQChar* (*getlocal)(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx); - const SQChar* (*getfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*throwerror)(HSQUIRRELVM v,const SQChar *err); - void (*reseterror)(HSQUIRRELVM v); - void (*getlasterror)(HSQUIRRELVM v); - - /*raw object handling*/ - SQRESULT (*getstackobj)(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po); - void (*pushobject)(HSQUIRRELVM v,HSQOBJECT obj); - void (*addref)(HSQUIRRELVM v,HSQOBJECT *po); - SQBool (*release)(HSQUIRRELVM v,HSQOBJECT *po); - void (*resetobject)(HSQOBJECT *po); - const SQChar* (*objtostring)(const HSQOBJECT *o); - SQBool (*objtobool)(const HSQOBJECT *o); - SQInteger (*objtointeger)(const HSQOBJECT *o); - SQFloat (*objtofloat)(const HSQOBJECT *o); - SQRESULT (*getobjtypetag)(const HSQOBJECT *o,SQUserPointer * typetag); - - /*GC*/ - SQInteger (*collectgarbage)(HSQUIRRELVM v); - - /*serialization*/ - SQRESULT (*writeclosure)(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up); - SQRESULT (*readclosure)(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up); - - /*mem allocation*/ - void* (*malloc)(SQUnsignedInteger size); - void* (*realloc)(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize); - void (*free)(void *p,SQUnsignedInteger size); - - /*debug*/ - SQRESULT (*stackinfos)(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); - void (*setdebughook)(HSQUIRRELVM v); - } sq_api; - typedef sq_api* HSQAPI; - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQ_MODULE_H_*/ diff --git a/include/sqmodule.h b/include/sqmodule.h deleted file mode 100644 index 7a87104c..00000000 --- a/include/sqmodule.h +++ /dev/null @@ -1,200 +0,0 @@ -// -// SqModule: API used to communicate with and register squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQ_MODULE_H_) -#define _SQ_MODULE_H_ - -#include "squirrel.h" - -#ifdef __cplusplus -extern "C" { -#endif - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// @cond DEV - /// Allows modules to interface with Squirrel's C api without linking to the squirrel library - /// If new functions are added to the Squirrel API, they should be added here too - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - typedef struct { - /*vm*/ - HSQUIRRELVM (*open)(SQInteger initialstacksize); - HSQUIRRELVM (*newthread)(HSQUIRRELVM friendvm, SQInteger initialstacksize); - void (*seterrorhandler)(HSQUIRRELVM v); - void (*close)(HSQUIRRELVM v); - void (*setforeignptr)(HSQUIRRELVM v,SQUserPointer p); - SQUserPointer (*getforeignptr)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc, SQPRINTFUNCTION); -#else - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc); -#endif - SQPRINTFUNCTION (*getprintfunc)(HSQUIRRELVM v); - SQRESULT (*suspendvm)(HSQUIRRELVM v); - SQRESULT (*wakeupvm)(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror); - SQInteger (*getvmstate)(HSQUIRRELVM v); - - /*compiler*/ - SQRESULT (*compile)(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror); - SQRESULT (*compilebuffer)(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror); - void (*enabledebuginfo)(HSQUIRRELVM v, SQBool enable); - void (*notifyallexceptions)(HSQUIRRELVM v, SQBool enable); - void (*setcompilererrorhandler)(HSQUIRRELVM v,SQCOMPILERERROR f); - - /*stack operations*/ - void (*push)(HSQUIRRELVM v,SQInteger idx); - void (*pop)(HSQUIRRELVM v,SQInteger nelemstopop); - void (*poptop)(HSQUIRRELVM v); - void (*remove)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*gettop)(HSQUIRRELVM v); - void (*settop)(HSQUIRRELVM v,SQInteger newtop); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#else - void (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#endif - SQInteger (*cmp)(HSQUIRRELVM v); - void (*move)(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx); - - /*object creation handling*/ - SQUserPointer (*newuserdata)(HSQUIRRELVM v,SQUnsignedInteger size); - void (*newtable)(HSQUIRRELVM v); - void (*newarray)(HSQUIRRELVM v,SQInteger size); - void (*newclosure)(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); - SQRESULT (*setparamscheck)(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); - SQRESULT (*bindenv)(HSQUIRRELVM v,SQInteger idx); - void (*pushstring)(HSQUIRRELVM v,const SQChar *s,SQInteger len); - void (*pushfloat)(HSQUIRRELVM v,SQFloat f); - void (*pushinteger)(HSQUIRRELVM v,SQInteger n); - void (*pushbool)(HSQUIRRELVM v,SQBool b); - void (*pushuserpointer)(HSQUIRRELVM v,SQUserPointer p); - void (*pushnull)(HSQUIRRELVM v); - SQObjectType (*gettype)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*getsize)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getbase)(HSQUIRRELVM v,SQInteger idx); - SQBool (*instanceof)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*tostring)(HSQUIRRELVM v,SQInteger idx); -#else - void (*tostring)(HSQUIRRELVM v,SQInteger idx); -#endif - void (*tobool)(HSQUIRRELVM v, SQInteger idx, SQBool *b); - SQRESULT (*getstring)(HSQUIRRELVM v,SQInteger idx,const SQChar **c); - SQRESULT (*getinteger)(HSQUIRRELVM v,SQInteger idx,SQInteger *i); - SQRESULT (*getfloat)(HSQUIRRELVM v,SQInteger idx,SQFloat *f); - SQRESULT (*getbool)(HSQUIRRELVM v,SQInteger idx,SQBool *b); - SQRESULT (*getthread)(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread); - SQRESULT (*getuserpointer)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p); - SQRESULT (*getuserdata)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag); - SQRESULT (*settypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag); - SQRESULT (*gettypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag); - void (*setreleasehook)(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook); - SQChar* (*getscratchpad)(HSQUIRRELVM v,SQInteger minsize); - SQRESULT (*getclosureinfo)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars); - SQRESULT (*setnativeclosurename)(HSQUIRRELVM v,SQInteger idx,const SQChar *name); - SQRESULT (*setinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer p); - SQRESULT (*getinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag); - SQRESULT (*setclassudsize)(HSQUIRRELVM v, SQInteger idx, SQInteger udsize); - SQRESULT (*newclass)(HSQUIRRELVM v,SQBool hasbase); - SQRESULT (*createinstance)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getclass)(HSQUIRRELVM v,SQInteger idx); - void (*weakref)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdefaultdelegate)(HSQUIRRELVM v,SQObjectType t); - - /*object manipulation*/ - void (*pushroottable)(HSQUIRRELVM v); - void (*pushregistrytable)(HSQUIRRELVM v); - void (*pushconsttable)(HSQUIRRELVM v); - SQRESULT (*setroottable)(HSQUIRRELVM v); - SQRESULT (*setconsttable)(HSQUIRRELVM v); - SQRESULT (*newslot)(HSQUIRRELVM v, SQInteger idx, SQBool bstatic); - SQRESULT (*deleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*set)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*get)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawget)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawset)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawdeleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayappend)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arraypop)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayresize)(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); - SQRESULT (*arrayreverse)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arrayremove)(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx); - SQRESULT (*arrayinsert)(HSQUIRRELVM v,SQInteger idx,SQInteger destpos); - SQRESULT (*setdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clone)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*next)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getweakrefval)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clear)(HSQUIRRELVM v,SQInteger idx); - - /*calls*/ - SQRESULT (*call)(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror); - SQRESULT (*resume)(HSQUIRRELVM v,SQBool retval,SQBool raiseerror); - const SQChar* (*getlocal)(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx); - const SQChar* (*getfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*throwerror)(HSQUIRRELVM v,const SQChar *err); - void (*reseterror)(HSQUIRRELVM v); - void (*getlasterror)(HSQUIRRELVM v); - - /*raw object handling*/ - SQRESULT (*getstackobj)(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po); - void (*pushobject)(HSQUIRRELVM v,HSQOBJECT obj); - void (*addref)(HSQUIRRELVM v,HSQOBJECT *po); - SQBool (*release)(HSQUIRRELVM v,HSQOBJECT *po); - void (*resetobject)(HSQOBJECT *po); - const SQChar* (*objtostring)(const HSQOBJECT *o); - SQBool (*objtobool)(const HSQOBJECT *o); - SQInteger (*objtointeger)(const HSQOBJECT *o); - SQFloat (*objtofloat)(const HSQOBJECT *o); - SQRESULT (*getobjtypetag)(const HSQOBJECT *o,SQUserPointer * typetag); - - /*GC*/ - SQInteger (*collectgarbage)(HSQUIRRELVM v); - - /*serialization*/ - SQRESULT (*writeclosure)(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up); - SQRESULT (*readclosure)(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up); - - /*mem allocation*/ - void* (*malloc)(SQUnsignedInteger size); - void* (*realloc)(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize); - void (*free)(void *p,SQUnsignedInteger size); - - /*debug*/ - SQRESULT (*stackinfos)(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); - void (*setdebughook)(HSQUIRRELVM v); - } sq_api; - typedef sq_api* HSQAPI; - /// @endcond - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQ_MODULE_H_*/ diff --git a/include/sqrat.h b/include/sqrat.h index 81efc501..2f964676 100644 --- a/include/sqrat.h +++ b/include/sqrat.h @@ -56,7 +56,11 @@ #if !defined(_SCRAT_MAIN_H_) #define _SCRAT_MAIN_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API #include "sqrat/sqratTable.h" #include "sqrat/sqratClass.h" diff --git a/include/sqrat/sqratAllocator.h b/include/sqrat/sqratAllocator.h index 1eb7c15b..994a51e2 100644 --- a/include/sqrat/sqratAllocator.h +++ b/include/sqrat/sqratAllocator.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_ALLOCATOR_H_) #define _SCRAT_ALLOCATOR_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratObject.h" diff --git a/include/sqrat/sqratArray.h b/include/sqrat/sqratArray.h index 1de05d11..4d2c6ec2 100644 --- a/include/sqrat/sqratArray.h +++ b/include/sqrat/sqratArray.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_ARRAY_H_) #define _SCRAT_ARRAY_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratObject.h" diff --git a/include/sqrat/sqratClass.h b/include/sqrat/sqratClass.h index ca863e0e..9082a0ac 100644 --- a/include/sqrat/sqratClass.h +++ b/include/sqrat/sqratClass.h @@ -28,9 +28,14 @@ #if !defined(_SCRAT_CLASS_H_) #define _SCRAT_CLASS_H_ +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include -#include #include "sqratObject.h" #include "sqratClassType.h" diff --git a/include/sqrat/sqratClassType.h b/include/sqrat/sqratClassType.h index f1a62ae6..f2bda7a6 100644 --- a/include/sqrat/sqratClassType.h +++ b/include/sqrat/sqratClassType.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_CLASSTYPE_H_) #define _SCRAT_CLASSTYPE_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratUtil.h" diff --git a/include/sqrat/sqratConst.h b/include/sqrat/sqratConst.h index f0b43a96..406bd7f8 100644 --- a/include/sqrat/sqratConst.h +++ b/include/sqrat/sqratConst.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_CONST_H_) #define _SCRAT_CONST_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratObject.h" diff --git a/include/sqrat/sqratFunction.h b/include/sqrat/sqratFunction.h index 833ffa32..d66cdef4 100644 --- a/include/sqrat/sqratFunction.h +++ b/include/sqrat/sqratFunction.h @@ -29,7 +29,12 @@ #if !defined(_SCRAT_SQFUNC_H_) #define _SCRAT_SQFUNC_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include "sqratObject.h" namespace Sqrat { diff --git a/include/sqrat/sqratGlobalMethods.h b/include/sqrat/sqratGlobalMethods.h index a60ceb6f..5fd0f9a8 100644 --- a/include/sqrat/sqratGlobalMethods.h +++ b/include/sqrat/sqratGlobalMethods.h @@ -29,7 +29,12 @@ #if !defined(_SCRAT_GLOBAL_METHODS_H_) #define _SCRAT_GLOBAL_METHODS_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include "sqratTypes.h" namespace Sqrat { diff --git a/include/sqrat/sqratMemberMethods.h b/include/sqrat/sqratMemberMethods.h index f8bcf6d1..b52703b5 100644 --- a/include/sqrat/sqratMemberMethods.h +++ b/include/sqrat/sqratMemberMethods.h @@ -29,7 +29,12 @@ #if !defined(_SCRAT_MEMBER_METHODS_H_) #define _SCRAT_MEMBER_METHODS_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include "sqratTypes.h" namespace Sqrat { diff --git a/include/sqrat/sqratObject.h b/include/sqrat/sqratObject.h index bde64bb6..0f9197a9 100644 --- a/include/sqrat/sqratObject.h +++ b/include/sqrat/sqratObject.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_OBJECT_H_) #define _SCRAT_OBJECT_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratAllocator.h" diff --git a/include/sqrat/sqratOverloadMethods.h b/include/sqrat/sqratOverloadMethods.h index 655275f4..3acfd19a 100644 --- a/include/sqrat/sqratOverloadMethods.h +++ b/include/sqrat/sqratOverloadMethods.h @@ -28,8 +28,12 @@ #if !defined(_SQRAT_OVERLOAD_METHODS_H_) #define _SQRAT_OVERLOAD_METHODS_H_ -#include -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratTypes.h" #include "sqratUtil.h" diff --git a/include/sqrat/sqratScript.h b/include/sqrat/sqratScript.h index f0a3b001..6450f1ff 100644 --- a/include/sqrat/sqratScript.h +++ b/include/sqrat/sqratScript.h @@ -28,8 +28,13 @@ #if !defined(_SCRAT_SCRIPT_H_) #define _SCRAT_SCRIPT_H_ -#include -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratObject.h" diff --git a/include/sqrat/sqratTable.h b/include/sqrat/sqratTable.h index 169729f0..3da9a435 100644 --- a/include/sqrat/sqratTable.h +++ b/include/sqrat/sqratTable.h @@ -28,7 +28,12 @@ #if !defined(_SCRAT_TABLE_H_) #define _SCRAT_TABLE_H_ -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratObject.h" diff --git a/include/sqrat/sqratThread.h b/include/sqrat/sqratThread.h deleted file mode 100644 index 0c8b922c..00000000 --- a/include/sqrat/sqratThread.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// SqratThread: Sqrat threading module -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQRAT_THREAD_H_) -#define _SQRAT_THREAD_H_ - -#include "sqmodule.h" - -#ifdef __cplusplus -extern "C" { -#endif - - __declspec(dllexport) SQRESULT sqmodule_load(HSQUIRRELVM v, HSQAPI api); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQRAT_THREAD_H_*/ diff --git a/include/sqrat/sqratTypes.h b/include/sqrat/sqratTypes.h index 80c6bbe1..64942414 100644 --- a/include/sqrat/sqratTypes.h +++ b/include/sqrat/sqratTypes.h @@ -33,7 +33,12 @@ #include #endif -#include +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include "sqratClassType.h" diff --git a/include/sqrat/sqratUtil.h b/include/sqrat/sqratUtil.h index a2f44a48..5d536466 100644 --- a/include/sqrat/sqratUtil.h +++ b/include/sqrat/sqratUtil.h @@ -28,9 +28,14 @@ #if !defined(_SCRAT_UTIL_H_) #define _SCRAT_UTIL_H_ +#ifdef SQMOD_PLUGIN_API + #include +#else + #include +#endif // SQMOD_PLUGIN_API + #include #include -#include #include #if defined(SCRAT_USE_CXX11_OPTIMIZATIONS) diff --git a/include/sqrat/sqratVM.h b/include/sqrat/sqratVM.h deleted file mode 100644 index f01a2b70..00000000 --- a/include/sqrat/sqratVM.h +++ /dev/null @@ -1,348 +0,0 @@ -// -// wrapper for the Squirrel VM under Sqrat -// - -// -// Copyright (c) 2011 Alston Chen -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_VM_H_) -#define _SCRAT_VM_H_ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace Sqrat -{ - -#ifdef SQUNICODE -#define scvprintf vwprintf -#else -#define scvprintf vprintf -#endif - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/// Helper class that wraps a Squirrel virtual machine in a C++ API -/// -/// \remarks -/// This class is not currently thread-safe for the case of different VMs running in different threads (all others are) -/// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class SqratVM -{ -private: - - HSQUIRRELVM m_vm; - Sqrat::RootTable* m_rootTable; - Sqrat::Script* m_script; - Sqrat::string m_lastErrorMsg; - - static void s_addVM(HSQUIRRELVM vm, SqratVM* sqratvm) - { - // TODO for user: use mutex to lock ms_sqratVMs if necessary for your uses - ms_sqratVMs().insert(std::make_pair(vm, sqratvm)); - } - - static void s_deleteVM(HSQUIRRELVM vm) - { - // TODO for user: use mutex to lock ms_sqratVMs if necessary for your uses - ms_sqratVMs().erase(vm); - } - - static SqratVM* s_getVM(HSQUIRRELVM vm) - { - // TODO for user: use mutex to lock ms_sqratVMs if necessary for your uses - return ms_sqratVMs()[vm]; - } - -private: - - static SQRAT_API unordered_map::type& ms_sqratVMs(); - - static void printFunc(HSQUIRRELVM /*v*/, const SQChar *s, ...) - { - va_list vl; - va_start(vl, s); - scvprintf(s, vl); - va_end(vl); - } - - static SQInteger runtimeErrorHandler(HSQUIRRELVM v) - { - const SQChar *sErr = 0; - if(sq_gettop(v) >= 1) - { - Sqrat::string& errStr = s_getVM(v)->m_lastErrorMsg; - if(SQ_SUCCEEDED(sq_getstring(v, 2, &sErr))) - { - errStr = sErr; - } - else - { - errStr = _SC("an unknown runtime error has occured"); - } - } - return 0; - } - - static void compilerErrorHandler(HSQUIRRELVM v, - const SQChar* desc, - const SQChar* source, - SQInteger line, - SQInteger column) - { - SQChar buf[512]; - scsprintf(buf, 512, _SC("%s:%d:%d: %s"), source, (int) line, (int) column, desc); - buf[sizeof(buf) - 1] = 0; - s_getVM(v)->m_lastErrorMsg = buf; - } - -public: - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Enumeration representing the different types of errors that may occur within a SqratVM - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - enum ERROR_STATE - { - SQRAT_NO_ERROR, ///< For when no error has occurred - SQRAT_COMPILE_ERROR, ///< For when a script compiling error has occurred - SQRAT_RUNTIME_ERROR ///< For when a script running error has occurred - }; - - static const unsigned char LIB_IO = 0x01; ///< Input/Output library - static const unsigned char LIB_BLOB = 0x02; ///< Blob library - static const unsigned char LIB_MATH = 0x04; ///< Math library - static const unsigned char LIB_SYST = 0x08; ///< System library - static const unsigned char LIB_STR = 0x10; ///< String library - static const unsigned char LIB_ALL = LIB_IO | LIB_BLOB | LIB_MATH | LIB_SYST | LIB_STR; ///< All libraries - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Default constructor - /// - /// \param initialStackSize Initial size of the execution stack (if the stack is too small it will automatically grow) - /// \param libsToLoad Specifies what standard Squirrel libraries should be loaded - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SqratVM(int initialStackSize = 1024, unsigned char libsToLoad = LIB_ALL): m_vm(sq_open(initialStackSize)) - , m_rootTable(new Sqrat::RootTable(m_vm)) - , m_script(new Sqrat::Script(m_vm)) - , m_lastErrorMsg() - { - s_addVM(m_vm, this); - //register std libs - sq_pushroottable(m_vm); - if (libsToLoad & LIB_IO) - sqstd_register_iolib(m_vm); - if (libsToLoad & LIB_BLOB) - sqstd_register_bloblib(m_vm); - if (libsToLoad & LIB_MATH) - sqstd_register_mathlib(m_vm); - if (libsToLoad & LIB_SYST) - sqstd_register_systemlib(m_vm); - if (libsToLoad & LIB_STR) - sqstd_register_stringlib(m_vm); - sq_pop(m_vm, 1); - SetPrintFunc(printFunc, printFunc); - SetErrorHandler(runtimeErrorHandler, compilerErrorHandler); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Destructor - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ~SqratVM() - { - s_deleteVM(m_vm); - delete m_script; - delete m_rootTable; - sq_close(m_vm); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Gets the underlying Squirrel VM - /// - /// \return Underlying Squirrel VM - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - HSQUIRRELVM GetVM() - { - return m_vm; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Gets the root table for this VM - /// - /// \return RootTable for the VM - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Sqrat::RootTable& GetRootTable() - { - return *m_rootTable; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Gets the associated Script for this VM - /// - /// \return Script for the VM - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Sqrat::Script& GetScript() - { - return *m_script; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Gets the error message for the most recent Squirrel error with the VM - /// - /// \return String containing a nice error message - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Sqrat::string GetLastErrorMsg() - { - return m_lastErrorMsg; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Overwrites the most recent Squirrel error for this VM - /// - /// \param str A nice error message - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetLastErrorMsg(const Sqrat::string& str) - { - m_lastErrorMsg = str; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Sets the print function of the virtual machine (a default one is set in the constructor) - /// - /// \param printFunc A pointer to the print func or NULL to disable the output - /// \param errFunc A pointer to the error func or NULL to disable the output - /// - /// \remarks - /// The print function is used by the built-in Squirrel print function to output text. - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetPrintFunc(SQPRINTFUNCTION printFunc, SQPRINTFUNCTION errFunc) - { - sq_setprintfunc(m_vm, printFunc, errFunc); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Sets the Squirrel error handlers (both are set to defaults in the constructor) - /// - /// \param runErr A pointer to the runtime error handler func - /// \param comErr A pointer to the compile error handler func - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetErrorHandler(SQFUNCTION runErr, SQCOMPILERERROR comErr) - { - sq_newclosure(m_vm, runErr, 0); - sq_seterrorhandler(m_vm); - sq_setcompilererrorhandler(m_vm, comErr); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Runs a string containing a Squirrel script - /// - /// \param str String containing a Squirrel script - /// - /// \return An ERROR_STATE representing what happened - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ERROR_STATE DoString(const Sqrat::string& str) - { - Sqrat::string msg; - m_lastErrorMsg.clear(); - if(!m_script->CompileString(str, msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return SQRAT_COMPILE_ERROR; - } - if(!m_script->Run(msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return SQRAT_RUNTIME_ERROR; - } - return SQRAT_NO_ERROR; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Runs a file containing a Squirrel script - /// - /// \param file File path containing a Squirrel script - /// - /// \return An ERROR_STATE representing what happened - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ERROR_STATE DoFile(const Sqrat::string& file) - { - Sqrat::string msg; - m_lastErrorMsg.clear(); - if(!m_script->CompileFile(file, msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return SQRAT_COMPILE_ERROR; - } - if(!m_script->Run(msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return SQRAT_RUNTIME_ERROR; - } - return SQRAT_NO_ERROR; - } - -}; - -#if !defined(SCRAT_IMPORT) -inline unordered_map::type& SqratVM::ms_sqratVMs() { - static unordered_map::type ms; - return ms; -} -#endif - -} - -#endif diff --git a/include/sqratimport.h b/include/sqratimport.h deleted file mode 100644 index 1dd7cb32..00000000 --- a/include/sqratimport.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// SqImport: Supports importing of squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQ_IMPORT_H_) -#define _SQ_IMPORT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// To be documented... - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SQUIRREL_API SQRESULT sqrat_import(HSQUIRRELVM v); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// To be documented... - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - SQUIRREL_API SQRESULT sqrat_register_importlib(HSQUIRRELVM v); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQ_IMPORT_H_*/ diff --git a/include/squirrel.h b/include/squirrel.h index f29d6989..25c959e5 100644 --- a/include/squirrel.h +++ b/include/squirrel.h @@ -194,6 +194,7 @@ typedef struct tagSQFunctionInfo { SQInteger line; }SQFunctionInfo; +#ifndef SQMOD_PLUGIN_API /*vm*/ SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize); SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize); @@ -361,6 +362,7 @@ SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size); SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v); SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook); +#endif // SQMOD_PLUGIN_API /*UTILITY MACRO*/ #define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC) diff --git a/sample/Module.cpp b/sample/Module.cpp new file mode 100644 index 00000000..3cc17dd0 --- /dev/null +++ b/sample/Module.cpp @@ -0,0 +1,229 @@ +// -------------------------------------------------------------------------------------------- +#include "Module.hpp" +#include "sq_mod.h" + +// -------------------------------------------------------------------------------------------- +#include + +// -------------------------------------------------------------------------------------------- +#include +#include +#include + +// -------------------------------------------------------------------------------------------- +#if defined(WIN32) || defined(_WIN32) + #include +#endif + +// -------------------------------------------------------------------------------------------- +PluginFuncs* _Func = NULL; +PluginCallbacks* _Clbk = NULL; +PluginInfo* _Info = NULL; + +// -------------------------------------------------------------------------------------------- +HSQAPI _SqAPI = NULL; +HSQUIRRELVM _SqVm = NULL; + +// ------------------------------------------------------------------------------------------------ +void BindCallbacks(); +void UnbindCallbacks(); + +// -------------------------------------------------------------------------------------------- +void RegisterAPI(HSQUIRRELVM vm); + +// -------------------------------------------------------------------------------------------- +void OnSquirrelInitialize() +{ + HSQEXPORTS exp = sq_api_import(_Func); + // Did we failed to obtain the plugin exports? + if(!exp) + OutputMessage("Failed to attach to %s", SQMOD_HOST_NAME); + else + { + // Obtain the Squirrel API and VM + _SqAPI = exp->GetSquirrelAPI(); + _SqVm = exp->GetSquirrelVM(); + // Expand the API into global functions + sq_api_expand(_SqAPI); + // Register functions + RegisterAPI(_SqVm); + } +} + +// -------------------------------------------------------------------------------------------- +void OnSquirrelTerminate() +{ + OutputMessage("Terminating sample plugin..."); + // The server may still send callbacks + UnbindCallbacks(); + // Release squirrel resources... +} + +// -------------------------------------------------------------------------------------------- +int OnInternalCommand(unsigned int type, const char * text) +{ + switch(type) + { + case SQMOD_INITIALIZE_CMD: + OnSquirrelInitialize(); + break; + case SQMOD_TERMINATE_CMD: + OnSquirrelTerminate(); + break; + default: break; + } + return 1; +} + +// -------------------------------------------------------------------------------------------- +int OnInitServer() +{ + puts(""); + OutputMessage("Loaded Sample Squirrel Plugin"); + return 1; +} + +// -------------------------------------------------------------------------------------------- +SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info) +{ + // Store server proxies + _Func = functions; + _Clbk = callbacks; + _Info = info; + // Assign plugin information + _Info->uPluginVer = 0x1000; // 1.0.00 + strcpy(_Info->szName, "SampleSquirrelPlugin"); + // Expand the API into global functions + vc_api_expand(_Func); + // Bind callbacks + BindCallbacks(); + // Done! + return 1; +} + +// ------------------------------------------------------------------------------------------------ +void BindCallbacks() +{ + _Clbk->OnInitServer = OnInitServer; + _Clbk->OnInternalCommand = OnInternalCommand; +} + +// ------------------------------------------------------------------------------------------------ +void UnbindCallbacks() +{ + _Clbk->OnInitServer = NULL; + _Clbk->OnInternalCommand = NULL; +} + +// -------------------------------------------------------------------------------------------- +void OutputMessageImpl(const char * msg, va_list args) +{ +#if defined(WIN32) || defined(_WIN32) + HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE); + + CONSOLE_SCREEN_BUFFER_INFO csb_before; + GetConsoleScreenBufferInfo( hstdout, &csb_before); + SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN); + printf("[MODULE] "); + + SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); + vprintf(msg, args); + puts(""); + + SetConsoleTextAttribute(hstdout, csb_before.wAttributes); +#else + printf("%c[0;32m[MODULE]%c[0;37m", 27, 27, msg); + vprintf(msg, args); + puts(""); +#endif +} + +// -------------------------------------------------------------------------------------------- +void OutputDebug(const char * msg, ...) +{ +#ifdef _DEBUG + // Initialize the arguments list + va_list args; + va_start(args, msg); + // Call the output function + OutputMessageImpl(msg, args); + // Finalize the arguments list + va_end(args); +#endif +} + +// -------------------------------------------------------------------------------------------- +void OutputMessage(const char * msg, ...) +{ + // Initialize the arguments list + va_list args; + va_start(args, msg); + // Call the output function + OutputMessageImpl(msg, args); + // Finalize the arguments list + va_end(args); +} + +/* -------------------------------------------------------------------------------------------- + * Sample Plugin API +*/ + +int SampleFunction() +{ + OutputMessage("Hello from the sample plugin function!"); + return rand(); +} + +class SampleType +{ +private: + + int m_MyVal; + +public: + + int mMyNum; + + SampleType() + : m_MyVal(0), mMyNum(0) + { + + } + + SampleType(int num) + : m_MyVal(num * 2), mMyNum(num) + { + + } + + int GetMyVal() const + { + return m_MyVal; + } + + void SetMyVal(int val) + { + m_MyVal = val; + } + + void SampleMethod() const + { + OutputMessage("I have the values %d and %d", m_MyVal, mMyNum); + } +}; + +// -------------------------------------------------------------------------------------------- +void RegisterAPI(HSQUIRRELVM vm) +{ + using namespace Sqrat; + + RootTable(vm).Bind(_SC("SampleType"), Class< SampleType >(vm, _SC("SampleType")) + .Ctor() + .Ctor< int >() + .Var(_SC("MyNum"), &SampleType::mMyNum) + .Prop(_SC("MyVal"), &SampleType::GetMyVal, &SampleType::SetMyVal) + .Func(_SC("SampleMethod"), &SampleType::SampleMethod) + ); + + RootTable(vm).Func(_SC("SampleFunction"), &SampleFunction); +} diff --git a/sample/Module.hpp b/sample/Module.hpp new file mode 100644 index 00000000..41402995 --- /dev/null +++ b/sample/Module.hpp @@ -0,0 +1,31 @@ +#ifndef _SQMOD_MODULE_HPP_ +#define _SQMOD_MODULE_HPP_ + +// ------------------------------------------------------------------------------------------------ +#include "sq_api.h" +#include "vcmp.h" + +/* ------------------------------------------------------------------------------------------------ + * Proxies to comunicate with the server. +*/ +extern PluginFuncs* _Func; +extern PluginCallbacks* _Clbk; +extern PluginInfo* _Info; + +/* ------------------------------------------------------------------------------------------------ + * Proxies to comunicate with the Squirrel plugin. +*/ +extern HSQAPI _SqAPI; +extern HSQUIRRELVM _SqVm; + +/* ------------------------------------------------------------------------------------------------ + * Output a message only if the _DEBUG was defined. +*/ +void OutputDebug(const char * msg, ...); + +/* ------------------------------------------------------------------------------------------------ + * Output a formatted message to the console. +*/ +void OutputMessage(const char * msg, ...); + +#endif // _SQMOD_MODULE_HPP_ diff --git a/shared/sq_api.h b/shared/sq_api.h new file mode 100644 index 00000000..f539ec5c --- /dev/null +++ b/shared/sq_api.h @@ -0,0 +1,594 @@ +// +// SqModule: API used to communicate with and register squirrel modules +// + +// +// Copyright (c) 2015 Sandu Liviu Catalin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// + +#if !defined(_SQ_API_H_) +#define _SQ_API_H_ + +#include "squirrel.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /*vm*/ + typedef HSQUIRRELVM (*sqapi_open)(SQInteger initialstacksize); + typedef HSQUIRRELVM (*sqapi_newthread)(HSQUIRRELVM friendvm, SQInteger initialstacksize); + typedef void (*sqapi_seterrorhandler)(HSQUIRRELVM v); + typedef void (*sqapi_close)(HSQUIRRELVM v); + typedef void (*sqapi_setforeignptr)(HSQUIRRELVM v,SQUserPointer p); + typedef SQUserPointer (*sqapi_getforeignptr)(HSQUIRRELVM v); + typedef void (*sqapi_setsharedforeignptr)(HSQUIRRELVM v,SQUserPointer p); + typedef SQUserPointer (*sqapi_getsharedforeignptr)(HSQUIRRELVM v); + typedef void (*sqapi_setvmreleasehook)(HSQUIRRELVM v,SQRELEASEHOOK hook); + typedef SQRELEASEHOOK (*sqapi_getvmreleasehook)(HSQUIRRELVM v); + typedef void (*sqapi_setsharedreleasehook)(HSQUIRRELVM v,SQRELEASEHOOK hook); + typedef SQRELEASEHOOK (*sqapi_getsharedreleasehook)(HSQUIRRELVM v); + typedef void (*sqapi_setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc); + typedef SQPRINTFUNCTION (*sqapi_getprintfunc)(HSQUIRRELVM v); + typedef SQPRINTFUNCTION (*sqapi_geterrorfunc)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_suspendvm)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_wakeupvm)(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror); + typedef SQInteger (*sqapi_getvmstate)(HSQUIRRELVM v); + typedef SQInteger (*sqapi_getversion)(); + + /*compiler*/ + typedef SQRESULT (*sqapi_compile)(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror); + typedef SQRESULT (*sqapi_compilebuffer)(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror); + typedef void (*sqapi_enabledebuginfo)(HSQUIRRELVM v, SQBool enable); + typedef void (*sqapi_notifyallexceptions)(HSQUIRRELVM v, SQBool enable); + typedef void (*sqapi_setcompilererrorhandler)(HSQUIRRELVM v,SQCOMPILERERROR f); + + /*stack operations*/ + typedef void (*sqapi_push)(HSQUIRRELVM v,SQInteger idx); + typedef void (*sqapi_pop)(HSQUIRRELVM v,SQInteger nelemstopop); + typedef void (*sqapi_poptop)(HSQUIRRELVM v); + typedef void (*sqapi_remove)(HSQUIRRELVM v,SQInteger idx); + typedef SQInteger (*sqapi_gettop)(HSQUIRRELVM v); + typedef void (*sqapi_settop)(HSQUIRRELVM v,SQInteger newtop); + typedef SQRESULT (*sqapi_reservestack)(HSQUIRRELVM v,SQInteger nsize); + typedef SQInteger (*sqapi_cmp)(HSQUIRRELVM v); + typedef void (*sqapi_move)(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx); + + /*object creation handling*/ + typedef SQUserPointer (*sqapi_newuserdata)(HSQUIRRELVM v,SQUnsignedInteger size); + typedef void (*sqapi_newtable)(HSQUIRRELVM v); + typedef void (*sqapi_newtableex)(HSQUIRRELVM v,SQInteger initialcapacity); + typedef void (*sqapi_newarray)(HSQUIRRELVM v,SQInteger size); + typedef void (*sqapi_newclosure)(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); + typedef SQRESULT (*sqapi_setparamscheck)(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); + typedef SQRESULT (*sqapi_bindenv)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_setclosureroot)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getclosureroot)(HSQUIRRELVM v,SQInteger idx); + typedef void (*sqapi_pushstring)(HSQUIRRELVM v,const SQChar *s,SQInteger len); + typedef void (*sqapi_pushfloat)(HSQUIRRELVM v,SQFloat f); + typedef void (*sqapi_pushinteger)(HSQUIRRELVM v,SQInteger n); + typedef void (*sqapi_pushbool)(HSQUIRRELVM v,SQBool b); + typedef void (*sqapi_pushuserpointer)(HSQUIRRELVM v,SQUserPointer p); + typedef void (*sqapi_pushnull)(HSQUIRRELVM v); + typedef void (*sqapi_pushthread)(HSQUIRRELVM v, HSQUIRRELVM thread); + typedef SQObjectType (*sqapi_gettype)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_typeof)(HSQUIRRELVM v,SQInteger idx); + typedef SQInteger (*sqapi_getsize)(HSQUIRRELVM v,SQInteger idx); + typedef SQHash (*sqapi_gethash)(HSQUIRRELVM v, SQInteger idx); + typedef SQRESULT (*sqapi_getbase)(HSQUIRRELVM v,SQInteger idx); + typedef SQBool (*sqapi_instanceof)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_tostring)(HSQUIRRELVM v,SQInteger idx); + typedef void (*sqapi_tobool)(HSQUIRRELVM v, SQInteger idx, SQBool *b); + typedef SQRESULT (*sqapi_getstring)(HSQUIRRELVM v,SQInteger idx,const SQChar **c); + typedef SQRESULT (*sqapi_getinteger)(HSQUIRRELVM v,SQInteger idx,SQInteger *i); + typedef SQRESULT (*sqapi_getfloat)(HSQUIRRELVM v,SQInteger idx,SQFloat *f); + typedef SQRESULT (*sqapi_getbool)(HSQUIRRELVM v,SQInteger idx,SQBool *b); + typedef SQRESULT (*sqapi_getthread)(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread); + typedef SQRESULT (*sqapi_getuserpointer)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p); + typedef SQRESULT (*sqapi_getuserdata)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag); + typedef SQRESULT (*sqapi_settypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag); + typedef SQRESULT (*sqapi_gettypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag); + typedef void (*sqapi_setreleasehook)(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook); + typedef SQRELEASEHOOK (*sqapi_getreleasehook)(HSQUIRRELVM v,SQInteger idx); + typedef SQChar* (*sqapi_getscratchpad)(HSQUIRRELVM v,SQInteger minsize); + typedef SQRESULT (*sqapi_getfunctioninfo)(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi); + typedef SQRESULT (*sqapi_getclosureinfo)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars); + typedef SQRESULT (*sqapi_getclosurename)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_setnativeclosurename)(HSQUIRRELVM v,SQInteger idx,const SQChar *name); + typedef SQRESULT (*sqapi_setinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer p); + typedef SQRESULT (*sqapi_getinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag); + typedef SQRESULT (*sqapi_setclassudsize)(HSQUIRRELVM v, SQInteger idx, SQInteger udsize); + typedef SQRESULT (*sqapi_newclass)(HSQUIRRELVM v,SQBool hasbase); + typedef SQRESULT (*sqapi_createinstance)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_setattributes)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getattributes)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getclass)(HSQUIRRELVM v,SQInteger idx); + typedef void (*sqapi_weakref)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getdefaultdelegate)(HSQUIRRELVM v,SQObjectType t); + typedef SQRESULT (*sqapi_getmemberhandle)(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle); + typedef SQRESULT (*sqapi_getbyhandle)(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle); + typedef SQRESULT (*sqapi_setbyhandle)(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle); + + /*object manipulation*/ + typedef void (*sqapi_pushroottable)(HSQUIRRELVM v); + typedef void (*sqapi_pushregistrytable)(HSQUIRRELVM v); + typedef void (*sqapi_pushconsttable)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_setroottable)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_setconsttable)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_newslot)(HSQUIRRELVM v, SQInteger idx, SQBool bstatic); + typedef SQRESULT (*sqapi_deleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); + typedef SQRESULT (*sqapi_set)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_get)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_rawget)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_rawset)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_rawdeleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); + typedef SQRESULT (*sqapi_newmember)(HSQUIRRELVM v,SQInteger idx,SQBool bstatic); + typedef SQRESULT (*sqapi_rawnewmember)(HSQUIRRELVM v,SQInteger idx,SQBool bstatic); + typedef SQRESULT (*sqapi_arrayappend)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_arraypop)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); + typedef SQRESULT (*sqapi_arrayresize)(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); + typedef SQRESULT (*sqapi_arrayreverse)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_arrayremove)(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx); + typedef SQRESULT (*sqapi_arrayinsert)(HSQUIRRELVM v,SQInteger idx,SQInteger destpos); + typedef SQRESULT (*sqapi_setdelegate)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getdelegate)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_clone)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_setfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); + typedef SQRESULT (*sqapi_next)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_getweakrefval)(HSQUIRRELVM v,SQInteger idx); + typedef SQRESULT (*sqapi_clear)(HSQUIRRELVM v,SQInteger idx); + + /*calls*/ + typedef SQRESULT (*sqapi_call)(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror); + typedef SQRESULT (*sqapi_resume)(HSQUIRRELVM v,SQBool retval,SQBool raiseerror); + typedef const SQChar* (*sqapi_getlocal)(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx); + typedef SQRESULT (*sqapi_getcallee)(HSQUIRRELVM v); + typedef const SQChar* (*sqapi_getfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); + typedef SQRESULT (*sqapi_throwerror)(HSQUIRRELVM v,const SQChar *err); + typedef SQRESULT (*sqapi_throwobject)(HSQUIRRELVM v); + typedef void (*sqapi_reseterror)(HSQUIRRELVM v); + typedef void (*sqapi_getlasterror)(HSQUIRRELVM v); + + /*raw object handling*/ + typedef SQRESULT (*sqapi_getstackobj)(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po); + typedef void (*sqapi_pushobject)(HSQUIRRELVM v,HSQOBJECT obj); + typedef void (*sqapi_addref)(HSQUIRRELVM v,HSQOBJECT *po); + typedef SQBool (*sqapi_release)(HSQUIRRELVM v,HSQOBJECT *po); + typedef SQUnsignedInteger (*sqapi_getrefcount)(HSQUIRRELVM v,HSQOBJECT *po); + typedef void (*sqapi_resetobject)(HSQOBJECT *po); + typedef const SQChar* (*sqapi_objtostring)(const HSQOBJECT *o); + typedef SQBool (*sqapi_objtobool)(const HSQOBJECT *o); + typedef SQInteger (*sqapi_objtointeger)(const HSQOBJECT *o); + typedef SQFloat (*sqapi_objtofloat)(const HSQOBJECT *o); + typedef SQUserPointer (*sqapi_objtouserpointer)(const HSQOBJECT *o); + typedef SQRESULT (*sqapi_getobjtypetag)(const HSQOBJECT *o,SQUserPointer * typetag); + typedef SQUnsignedInteger (*sqapi_getvmrefcount)(HSQUIRRELVM v, const HSQOBJECT *po); + + + /*GC*/ + typedef SQInteger (*sqapi_collectgarbage)(HSQUIRRELVM v); + typedef SQRESULT (*sqapi_resurrectunreachable)(HSQUIRRELVM v); + + /*serialization*/ + typedef SQRESULT (*sqapi_writeclosure)(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up); + typedef SQRESULT (*sqapi_readclosure)(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up); + + /*mem allocation*/ + typedef void* (*sqapi_malloc)(SQUnsignedInteger size); + typedef void* (*sqapi_realloc)(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize); + typedef void (*sqapi_free)(void *p,SQUnsignedInteger size); + + /*debug*/ + typedef SQRESULT (*sqapi_stackinfos)(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); + typedef void (*sqapi_setdebughook)(HSQUIRRELVM v); + typedef void (*sqapi_setnativedebughook)(HSQUIRRELVM v,SQDEBUGHOOK hook); + + /*compiler helpers*/ + typedef SQRESULT (*sqapi_loadfile)(HSQUIRRELVM v,const SQChar *filename,SQBool printerror); + typedef SQRESULT (*sqapi_dofile)(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror); + typedef SQRESULT (*sqapi_writeclosuretofile)(HSQUIRRELVM v,const SQChar *filename); + + /*blob*/ + typedef SQUserPointer (*sqapi_createblob)(HSQUIRRELVM v, SQInteger size); + typedef SQRESULT (*sqapi_getblob)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr); + typedef SQInteger (*sqapi_getblobsize)(HSQUIRRELVM v,SQInteger idx); + + /*string*/ + typedef SQRESULT (*sqapi_format)(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @cond DEV + /// Allows modules to interface with Squirrel's C api without linking to the squirrel library + /// If new functions are added to the Squirrel API, they should be added here too + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + typedef struct { + /*vm*/ + sqapi_open open; + sqapi_newthread newthread; + sqapi_seterrorhandler seterrorhandler; + sqapi_close close; + sqapi_setforeignptr setforeignptr; + sqapi_getforeignptr getforeignptr; + sqapi_setsharedforeignptr setsharedforeignptr; + sqapi_getsharedforeignptr getsharedforeignptr; + sqapi_setvmreleasehook setvmreleasehook; + sqapi_getvmreleasehook getvmreleasehook; + sqapi_setsharedreleasehook setsharedreleasehook; + sqapi_getsharedreleasehook getsharedreleasehook; + sqapi_setprintfunc setprintfunc; + sqapi_getprintfunc getprintfunc; + sqapi_geterrorfunc geterrorfunc; + sqapi_suspendvm suspendvm; + sqapi_wakeupvm wakeupvm; + sqapi_getvmstate getvmstate; + sqapi_getversion getversion; + + /*compiler*/ + sqapi_compile compile; + sqapi_compilebuffer compilebuffer; + sqapi_enabledebuginfo enabledebuginfo; + sqapi_notifyallexceptions notifyallexceptions; + sqapi_setcompilererrorhandler setcompilererrorhandler; + + /*stack operations*/ + sqapi_push push; + sqapi_pop pop; + sqapi_poptop poptop; + sqapi_remove remove; + sqapi_gettop gettop; + sqapi_settop settop; + sqapi_reservestack reservestack; + sqapi_cmp cmp; + sqapi_move move; + + /*object creation handling*/ + sqapi_newuserdata newuserdata; + sqapi_newtable newtable; + sqapi_newtableex newtableex; + sqapi_newarray newarray; + sqapi_newclosure newclosure; + sqapi_setparamscheck setparamscheck; + sqapi_bindenv bindenv; + sqapi_setclosureroot setclosureroot; + sqapi_getclosureroot getclosureroot; + sqapi_pushstring pushstring; + sqapi_pushfloat pushfloat; + sqapi_pushinteger pushinteger; + sqapi_pushbool pushbool; + sqapi_pushuserpointer pushuserpointer; + sqapi_pushnull pushnull; + sqapi_pushthread pushthread; + sqapi_gettype gettype; + sqapi_typeof typeof_; + sqapi_getsize getsize; + sqapi_gethash gethash; + sqapi_getbase getbase; + sqapi_instanceof instanceof; + sqapi_tostring tostring; + sqapi_tobool tobool; + sqapi_getstring getstring; + sqapi_getinteger getinteger; + sqapi_getfloat getfloat; + sqapi_getbool getbool; + sqapi_getthread getthread; + sqapi_getuserpointer getuserpointer; + sqapi_getuserdata getuserdata; + sqapi_settypetag settypetag; + sqapi_gettypetag gettypetag; + sqapi_setreleasehook setreleasehook; + sqapi_getreleasehook getreleasehook; + sqapi_getscratchpad getscratchpad; + sqapi_getfunctioninfo getfunctioninfo; + sqapi_getclosureinfo getclosureinfo; + sqapi_getclosurename getclosurename; + sqapi_setnativeclosurename setnativeclosurename; + sqapi_setinstanceup setinstanceup; + sqapi_getinstanceup getinstanceup; + sqapi_setclassudsize setclassudsize; + sqapi_newclass newclass; + sqapi_createinstance createinstance; + sqapi_setattributes setattributes; + sqapi_getattributes getattributes; + sqapi_getclass getclass; + sqapi_weakref weakref; + sqapi_getdefaultdelegate getdefaultdelegate; + sqapi_getmemberhandle getmemberhandle; + sqapi_getbyhandle getbyhandle; + sqapi_setbyhandle setbyhandle; + + /*object manipulation*/ + sqapi_pushroottable pushroottable; + sqapi_pushregistrytable pushregistrytable; + sqapi_pushconsttable pushconsttable; + sqapi_setroottable setroottable; + sqapi_setconsttable setconsttable; + sqapi_newslot newslot; + sqapi_deleteslot deleteslot; + sqapi_set set; + sqapi_get get; + sqapi_rawget rawget; + sqapi_rawset rawset; + sqapi_rawdeleteslot rawdeleteslot; + sqapi_newmember newmember; + sqapi_rawnewmember rawnewmember; + sqapi_arrayappend arrayappend; + sqapi_arraypop arraypop; + sqapi_arrayresize arrayresize; + sqapi_arrayreverse arrayreverse; + sqapi_arrayremove arrayremove; + sqapi_arrayinsert arrayinsert; + sqapi_setdelegate setdelegate; + sqapi_getdelegate getdelegate; + sqapi_clone clone; + sqapi_setfreevariable setfreevariable; + sqapi_next next; + sqapi_getweakrefval getweakrefval; + sqapi_clear clear; + + /*calls*/ + sqapi_call call; + sqapi_resume resume; + sqapi_getlocal getlocal; + sqapi_getcallee getcallee; + sqapi_getfreevariable getfreevariable; + sqapi_throwerror throwerror; + sqapi_throwobject throwobject; + sqapi_reseterror reseterror; + sqapi_getlasterror getlasterror; + + /*raw object handling*/ + sqapi_getstackobj getstackobj; + sqapi_pushobject pushobject; + sqapi_addref addref; + sqapi_release release; + sqapi_getrefcount getrefcount; + sqapi_resetobject resetobject; + sqapi_objtostring objtostring; + sqapi_objtobool objtobool; + sqapi_objtointeger objtointeger; + sqapi_objtofloat objtofloat; + sqapi_objtouserpointer objtouserpointer; + sqapi_getobjtypetag getobjtypetag; + sqapi_getvmrefcount getvmrefcount; + + /*GC*/ + sqapi_collectgarbage collectgarbage; + sqapi_resurrectunreachable resurrectunreachable; + + /*serialization*/ + sqapi_writeclosure writeclosure; + sqapi_readclosure readclosure; + + /*mem allocation*/ + sqapi_malloc malloc; + sqapi_realloc realloc; + sqapi_free free; + + /*debug*/ + sqapi_stackinfos stackinfos; + sqapi_setdebughook setdebughook; + sqapi_setnativedebughook setnativedebughook; + + /*compiler helpers*/ + sqapi_loadfile loadfile; + sqapi_dofile dofile; + sqapi_writeclosuretofile writeclosuretofile; + + /*blob*/ + sqapi_createblob createblob; + sqapi_getblob getblob; + sqapi_getblobsize getblobsize; + + /*string*/ + sqapi_format format; + } sq_api, SQAPI, *HSQAPI; + /// @endcond + +#ifdef SQMOD_PLUGIN_API + + /*vm*/ + extern sqapi_open sq_open; + extern sqapi_newthread sq_newthread; + extern sqapi_seterrorhandler sq_seterrorhandler; + extern sqapi_close sq_close; + extern sqapi_setforeignptr sq_setforeignptr; + extern sqapi_getforeignptr sq_getforeignptr; + extern sqapi_setsharedforeignptr sq_setsharedforeignptr; + extern sqapi_getsharedforeignptr sq_getsharedforeignptr; + extern sqapi_setvmreleasehook sq_setvmreleasehook; + extern sqapi_getvmreleasehook sq_getvmreleasehook; + extern sqapi_setsharedreleasehook sq_setsharedreleasehook; + extern sqapi_getsharedreleasehook sq_getsharedreleasehook; + extern sqapi_setprintfunc sq_setprintfunc; + extern sqapi_getprintfunc sq_getprintfunc; + extern sqapi_geterrorfunc sq_geterrorfunc; + extern sqapi_suspendvm sq_suspendvm; + extern sqapi_wakeupvm sq_wakeupvm; + extern sqapi_getvmstate sq_getvmstate; + extern sqapi_getversion sq_getversion; + + /*compiler*/ + extern sqapi_compile sq_compile; + extern sqapi_compilebuffer sq_compilebuffer; + extern sqapi_enabledebuginfo sq_enabledebuginfo; + extern sqapi_notifyallexceptions sq_notifyallexceptions; + extern sqapi_setcompilererrorhandler sq_setcompilererrorhandler; + + /*stack operations*/ + extern sqapi_push sq_push; + extern sqapi_pop sq_pop; + extern sqapi_poptop sq_poptop; + extern sqapi_remove sq_remove; + extern sqapi_gettop sq_gettop; + extern sqapi_settop sq_settop; + extern sqapi_reservestack sq_reservestack; + extern sqapi_cmp sq_cmp; + extern sqapi_move sq_move; + + /*object creation handling*/ + extern sqapi_newuserdata sq_newuserdata; + extern sqapi_newtable sq_newtable; + extern sqapi_newtableex sq_newtableex; + extern sqapi_newarray sq_newarray; + extern sqapi_newclosure sq_newclosure; + extern sqapi_setparamscheck sq_setparamscheck; + extern sqapi_bindenv sq_bindenv; + extern sqapi_setclosureroot sq_setclosureroot; + extern sqapi_getclosureroot sq_getclosureroot; + extern sqapi_pushstring sq_pushstring; + extern sqapi_pushfloat sq_pushfloat; + extern sqapi_pushinteger sq_pushinteger; + extern sqapi_pushbool sq_pushbool; + extern sqapi_pushuserpointer sq_pushuserpointer; + extern sqapi_pushnull sq_pushnull; + extern sqapi_pushthread sq_pushthread; + extern sqapi_gettype sq_gettype; + extern sqapi_typeof sq_typeof; + extern sqapi_getsize sq_getsize; + extern sqapi_gethash sq_gethash; + extern sqapi_getbase sq_getbase; + extern sqapi_instanceof sq_instanceof; + extern sqapi_tostring sq_tostring; + extern sqapi_tobool sq_tobool; + extern sqapi_getstring sq_getstring; + extern sqapi_getinteger sq_getinteger; + extern sqapi_getfloat sq_getfloat; + extern sqapi_getbool sq_getbool; + extern sqapi_getthread sq_getthread; + extern sqapi_getuserpointer sq_getuserpointer; + extern sqapi_getuserdata sq_getuserdata; + extern sqapi_settypetag sq_settypetag; + extern sqapi_gettypetag sq_gettypetag; + extern sqapi_setreleasehook sq_setreleasehook; + extern sqapi_getreleasehook sq_getreleasehook; + extern sqapi_getscratchpad sq_getscratchpad; + extern sqapi_getfunctioninfo sq_getfunctioninfo; + extern sqapi_getclosureinfo sq_getclosureinfo; + extern sqapi_getclosurename sq_getclosurename; + extern sqapi_setnativeclosurename sq_setnativeclosurename; + extern sqapi_setinstanceup sq_setinstanceup; + extern sqapi_getinstanceup sq_getinstanceup; + extern sqapi_setclassudsize sq_setclassudsize; + extern sqapi_newclass sq_newclass; + extern sqapi_createinstance sq_createinstance; + extern sqapi_setattributes sq_setattributes; + extern sqapi_getattributes sq_getattributes; + extern sqapi_getclass sq_getclass; + extern sqapi_weakref sq_weakref; + extern sqapi_getdefaultdelegate sq_getdefaultdelegate; + extern sqapi_getmemberhandle sq_getmemberhandle; + extern sqapi_getbyhandle sq_getbyhandle; + extern sqapi_setbyhandle sq_setbyhandle; + + /*object manipulation*/ + extern sqapi_pushroottable sq_pushroottable; + extern sqapi_pushregistrytable sq_pushregistrytable; + extern sqapi_pushconsttable sq_pushconsttable; + extern sqapi_setroottable sq_setroottable; + extern sqapi_setconsttable sq_setconsttable; + extern sqapi_newslot sq_newslot; + extern sqapi_deleteslot sq_deleteslot; + extern sqapi_set sq_set; + extern sqapi_get sq_get; + extern sqapi_rawget sq_rawget; + extern sqapi_rawset sq_rawset; + extern sqapi_rawdeleteslot sq_rawdeleteslot; + extern sqapi_newmember sq_newmember; + extern sqapi_rawnewmember sq_rawnewmember; + extern sqapi_arrayappend sq_arrayappend; + extern sqapi_arraypop sq_arraypop; + extern sqapi_arrayresize sq_arrayresize; + extern sqapi_arrayreverse sq_arrayreverse; + extern sqapi_arrayremove sq_arrayremove; + extern sqapi_arrayinsert sq_arrayinsert; + extern sqapi_setdelegate sq_setdelegate; + extern sqapi_getdelegate sq_getdelegate; + extern sqapi_clone sq_clone; + extern sqapi_setfreevariable sq_setfreevariable; + extern sqapi_next sq_next; + extern sqapi_getweakrefval sq_getweakrefval; + extern sqapi_clear sq_clear; + + /*calls*/ + extern sqapi_call sq_call; + extern sqapi_resume sq_resume; + extern sqapi_getlocal sq_getlocal; + extern sqapi_getcallee sq_getcallee; + extern sqapi_getfreevariable sq_getfreevariable; + extern sqapi_throwerror sq_throwerror; + extern sqapi_throwobject sq_throwobject; + extern sqapi_reseterror sq_reseterror; + extern sqapi_getlasterror sq_getlasterror; + + /*raw object handling*/ + extern sqapi_getstackobj sq_getstackobj; + extern sqapi_pushobject sq_pushobject; + extern sqapi_addref sq_addref; + extern sqapi_release sq_release; + extern sqapi_getrefcount sq_getrefcount; + extern sqapi_resetobject sq_resetobject; + extern sqapi_objtostring sq_objtostring; + extern sqapi_objtobool sq_objtobool; + extern sqapi_objtointeger sq_objtointeger; + extern sqapi_objtofloat sq_objtofloat; + extern sqapi_objtouserpointer sq_objtouserpointer; + extern sqapi_getobjtypetag sq_getobjtypetag; + extern sqapi_getvmrefcount sq_getvmrefcount; + + /*GC*/ + extern sqapi_collectgarbage sq_collectgarbage; + extern sqapi_resurrectunreachable sq_resurrectunreachable; + + /*serialization*/ + extern sqapi_writeclosure sq_writeclosure; + extern sqapi_readclosure sq_readclosure; + + /*mem allocation*/ + extern sqapi_malloc sq_malloc; + extern sqapi_realloc sq_realloc; + extern sqapi_free sq_free; + + /*debug*/ + extern sqapi_stackinfos sq_stackinfos; + extern sqapi_setdebughook sq_setdebughook; + extern sqapi_setnativedebughook sq_setnativedebughook; + + /*compiler helpers*/ + extern sqapi_loadfile sqstd_loadfile; + extern sqapi_dofile sqstd_dofile; + extern sqapi_writeclosuretofile sqstd_writeclosuretofile; + + /*blob*/ + extern sqapi_createblob sqstd_createblob; + extern sqapi_getblob sqstd_getblob; + extern sqapi_getblobsize sqstd_getblobsize; + + /*string*/ + extern sqapi_format sqstd_format; + +#endif // SQMOD_PLUGIN_API + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*_SQ_API_H_*/ diff --git a/shared/sq_mod.c b/shared/sq_mod.c new file mode 100644 index 00000000..00ada16c --- /dev/null +++ b/shared/sq_mod.c @@ -0,0 +1,4 @@ +// //////////////////////////////////////////////////////////////////////////////////////////////// +#include "sq_mod.h" +#include "sq_mod.inl" +/* This method is used toa void compilers warning about C++ flags on C files and viceversa. */ \ No newline at end of file diff --git a/shared/sq_mod.cpp b/shared/sq_mod.cpp new file mode 100644 index 00000000..00ada16c --- /dev/null +++ b/shared/sq_mod.cpp @@ -0,0 +1,4 @@ +// //////////////////////////////////////////////////////////////////////////////////////////////// +#include "sq_mod.h" +#include "sq_mod.inl" +/* This method is used toa void compilers warning about C++ flags on C files and viceversa. */ \ No newline at end of file diff --git a/shared/sq_mod.h b/shared/sq_mod.h new file mode 100644 index 00000000..06cc96fd --- /dev/null +++ b/shared/sq_mod.h @@ -0,0 +1,579 @@ +// +// SqModule: API used to communicate with and register squirrel modules +// + +// +// Copyright (c) 2009 Sandu Liviu Catalin (aka. S.L.C) +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// + +#if !defined(_SQ_MOD_H_) +#define _SQ_MOD_H_ + +#include "sq_api.h" +#include "vcmp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + #if defined(_MSC_VER) + #define SQMOD_API_EXPORT extern "C" __declspec(dllexport) + #elif defined(__GNUC__) + #define SQMOD_API_EXPORT extern "C" + #else + #define SQMOD_API_EXPORT extern "C" + #endif + + #define SQMOD_HOST_NAME "SqModHost" + #define SQMOD_INITIALIZE_CMD 0xDABBAD00 + #define SQMOD_TERMINATE_CMD 0xDEADC0DE + + /* -------------------------------------------------------------------------------------------- + * Allows modules to interface with the plugin API without linking of any sorts + */ + typedef struct + { + unsigned int uStructSize; + HSQAPI (*GetSquirrelAPI) ( void ); + HSQUIRRELVM (*GetSquirrelVM) (void); + } sq_exports, SQEXPORTS, *HSQEXPORTS; + + /* ------------------------------------------------------------------------------------------------ + * PLUGIN SYSTEM + */ + extern SDK_GetServerVersion SqVC_GetServerVersion; + extern SDK_GetServerSettings SqVC_GetServerSettings; + extern SDK_ExportFunctions SqVC_ExportFunctions; + extern SDK_GetNumberOfPlugins SqVC_GetNumberOfPlugins; + extern SDK_GetPluginInfo SqVC_GetPluginInfo; + extern SDK_FindPlugin SqVC_FindPlugin; + extern SDK_GetPluginExports SqVC_GetPluginExports; + extern SDK_GetTime SqVC_GetTime; + + /* ------------------------------------------------------------------------------------------------ + * MESSAGES + */ + extern SDK_printf SqVC_printf; + extern SDK_SendCustomCommand SqVC_SendCustomCommand; + extern SDK_SendClientMessage SqVC_SendClientMessage; + extern SDK_SendGameMessage SqVC_SendGameMessage; + + /* ------------------------------------------------------------------------------------------------ + * SERVER SETTINGS + */ + extern SDK_SetServerName SqVC_SetServerName; + extern SDK_GetServerName SqVC_GetServerName; + extern SDK_SetMaxPlayers SqVC_SetMaxPlayers; + extern SDK_GetMaxPlayers SqVC_GetMaxPlayers; + extern SDK_SetServerPassword SqVC_SetServerPassword; + extern SDK_GetServerPassword SqVC_GetServerPassword; + extern SDK_SetGameModeText SqVC_SetGameModeText; + extern SDK_GetGameModeText SqVC_GetGameModeText; + extern SDK_ShutdownServer SqVC_ShutdownServer; + + /* ------------------------------------------------------------------------------------------------ + * WORLD: settings + */ + extern SDK_SetWorldBounds SqVC_SetWorldBounds; + extern SDK_GetWorldBounds SqVC_GetWorldBounds; + extern SDK_SetWastedSettings SqVC_SetWastedSettings; + extern SDK_GetWastedSettings SqVC_GetWastedSettings; + extern SDK_SetTimeRate SqVC_SetTimeRate; + extern SDK_GetTimeRate SqVC_GetTimeRate; + extern SDK_SetHour SqVC_SetHour; + extern SDK_GetHour SqVC_GetHour; + extern SDK_SetMinute SqVC_SetMinute; + extern SDK_GetMinute SqVC_GetMinute; + extern SDK_SetWeather SqVC_SetWeather; + extern SDK_GetWeather SqVC_GetWeather; + extern SDK_SetGravity SqVC_SetGravity; + extern SDK_GetGravity SqVC_GetGravity; + extern SDK_SetGamespeed SqVC_SetGamespeed; + extern SDK_GetGamespeed SqVC_GetGamespeed; + extern SDK_SetWaterLevel SqVC_SetWaterLevel; + extern SDK_GetWaterLevel SqVC_GetWaterLevel; + extern SDK_SetMaxHeight SqVC_SetMaxHeight; + extern SDK_GetMaxHeight SqVC_GetMaxHeight; + extern SDK_SetKillCmdDelay SqVC_SetKillCmdDelay; + extern SDK_GetKillCmdDelay SqVC_GetKillCmdDelay; + extern SDK_SetVehiclesForcedRespawnHeight SqVC_SetVehiclesForcedRespawnHeight; + extern SDK_GetVehiclesForcedRespawnHeight SqVC_GetVehiclesForcedRespawnHeight; + + /* ------------------------------------------------------------------------------------------------ + * WORLD: toggles + */ + extern SDK_ToggleSyncFrameLimiter SqVC_ToggleSyncFrameLimiter; + extern SDK_EnabledSyncFrameLimiter SqVC_EnabledSyncFrameLimiter; + extern SDK_ToggleFrameLimiter SqVC_ToggleFrameLimiter; + extern SDK_EnabledFrameLimiter SqVC_EnabledFrameLimiter; + extern SDK_ToggleTaxiBoostJump SqVC_ToggleTaxiBoostJump; + extern SDK_EnabledTaxiBoostJump SqVC_EnabledTaxiBoostJump; + extern SDK_ToggleDriveOnWater SqVC_ToggleDriveOnWater; + extern SDK_EnabledDriveOnWater SqVC_EnabledDriveOnWater; + extern SDK_ToggleFastSwitch SqVC_ToggleFastSwitch; + extern SDK_EnabledFastSwitch SqVC_EnabledFastSwitch; + extern SDK_ToggleFriendlyFire SqVC_ToggleFriendlyFire; + extern SDK_EnabledFriendlyFire SqVC_EnabledFriendlyFire; + extern SDK_ToggleDisableDriveby SqVC_ToggleDisableDriveby; + extern SDK_EnabledDisableDriveby SqVC_EnabledDisableDriveby; + extern SDK_TogglePerfectHandling SqVC_TogglePerfectHandling; + extern SDK_EnabledPerfectHandling SqVC_EnabledPerfectHandling; + extern SDK_ToggleFlyingCars SqVC_ToggleFlyingCars; + extern SDK_EnabledFlyingCars SqVC_EnabledFlyingCars; + extern SDK_ToggleJumpSwitch SqVC_ToggleJumpSwitch; + extern SDK_EnabledJumpSwitch SqVC_EnabledJumpSwitch; + extern SDK_ToggleShowMarkers SqVC_ToggleShowMarkers; + extern SDK_EnabledShowMarkers SqVC_EnabledShowMarkers; + extern SDK_ToggleOnlyShowTeamMarkers SqVC_ToggleOnlyShowTeamMarkers; + extern SDK_EnabledOnlyShowTeamMarkers SqVC_EnabledOnlyShowTeamMarkers; + extern SDK_ToggleStuntBike SqVC_ToggleStuntBike; + extern SDK_EnabledStuntBike SqVC_EnabledStuntBike; + extern SDK_ToggleShootInAir SqVC_ToggleShootInAir; + extern SDK_EnabledShootInAir SqVC_EnabledShootInAir; + extern SDK_ToggleShowNametags SqVC_ToggleShowNametags; + extern SDK_EnabledShowNametags SqVC_EnabledShowNametags; + extern SDK_ToggleJoinMessages SqVC_ToggleJoinMessages; + extern SDK_EnabledJoinMessages SqVC_EnabledJoinMessages; + extern SDK_ToggleDeathMessages SqVC_ToggleDeathMessages; + extern SDK_EnabledDeathMessages SqVC_EnabledDeathMessages; + extern SDK_ToggleChatTagsByDefaultEnabled SqVC_ToggleChatTagsByDefaultEnabled; + extern SDK_EnabledChatTagsByDefault SqVC_EnabledChatTagsByDefault; + + /* ------------------------------------------------------------------------------------------------ + * MISC + */ + extern SDK_CreateExplosion SqVC_CreateExplosion; + extern SDK_PlaySound SqVC_PlaySound; + extern SDK_HideMapObject SqVC_HideMapObject; + extern SDK_ShowMapObject SqVC_ShowMapObject; + extern SDK_ShowAllMapObjects SqVC_ShowAllMapObjects; + + /* ------------------------------------------------------------------------------------------------ + * WEAPONDATA + */ + extern SDK_SetWeaponDataValue SqVC_SetWeaponDataValue; + extern SDK_GetWeaponDataValue SqVC_GetWeaponDataValue; + extern SDK_ResetWeaponDataValue SqVC_ResetWeaponDataValue; + extern SDK_IsWeaponDataValueModified SqVC_IsWeaponDataValueModified; + extern SDK_ResetWeaponData SqVC_ResetWeaponData; + extern SDK_ResetAllWeaponData SqVC_ResetAllWeaponData; + + /* ------------------------------------------------------------------------------------------------ + * KEYBINDS + */ + extern SDK_GetKeyBindUnusedSlot SqVC_GetKeyBindUnusedSlot; + extern SDK_GetKeyBindData SqVC_GetKeyBindData; + extern SDK_RegisterKeyBind SqVC_RegisterKeyBind; + extern SDK_RemoveKeyBind SqVC_RemoveKeyBind; + extern SDK_RemoveAllKeyBinds SqVC_RemoveAllKeyBinds; + + /* ------------------------------------------------------------------------------------------------ + * BLIPS + */ + extern SDK_CreateCoordBlip SqVC_CreateCoordBlip; + extern SDK_DestroyCoordBlip SqVC_DestroyCoordBlip; + extern SDK_GetCoordBlipInfo SqVC_GetCoordBlipInfo; + + /* ------------------------------------------------------------------------------------------------ + * SPRITES + */ + extern SDK_CreateSprite SqVC_CreateSprite; + extern SDK_DestroySprite SqVC_DestroySprite; + extern SDK_ShowSprite SqVC_ShowSprite; + extern SDK_HideSprite SqVC_HideSprite; + extern SDK_MoveSprite SqVC_MoveSprite; + extern SDK_SetSpriteCenter SqVC_SetSpriteCenter; + extern SDK_RotateSprite SqVC_RotateSprite; + extern SDK_SetSpriteAlpha SqVC_SetSpriteAlpha; + extern SDK_SetSpriteRelativity SqVC_SetSpriteRelativity; + + /* ------------------------------------------------------------------------------------------------ + * TEXTDRAWS + */ + extern SDK_CreateTextdraw SqVC_CreateTextdraw; + extern SDK_DestroyTextdraw SqVC_DestroyTextdraw; + extern SDK_ShowTextdraw SqVC_ShowTextdraw; + extern SDK_HideTextdraw SqVC_HideTextdraw; + extern SDK_MoveTextdraw SqVC_MoveTextdraw; + extern SDK_SetTextdrawColour SqVC_SetTextdrawColour; + extern SDK_SetTextdrawRelativity SqVC_SetTextdrawRelativity; + + /* ------------------------------------------------------------------------------------------------ + * RADIOS + */ + extern SDK_AddRadioStream SqVC_AddRadioStream; + extern SDK_RemoveRadioStream SqVC_RemoveRadioStream; + + /* ------------------------------------------------------------------------------------------------ + * CLASSES + */ + extern SDK_SetUseClasses SqVC_SetUseClasses; + extern SDK_GetUseClasses SqVC_GetUseClasses; + extern SDK_GetPlayerClass SqVC_GetPlayerClass; + extern SDK_AddPlayerClass SqVC_AddPlayerClass; + extern SDK_SetSpawnPlayerPos SqVC_SetSpawnPlayerPos; + extern SDK_SetSpawnCameraPos SqVC_SetSpawnCameraPos; + extern SDK_SetSpawnCameraLookAt SqVC_SetSpawnCameraLookAt; + + /* ------------------------------------------------------------------------------------------------ + * ADMIN + */ + extern SDK_IsPlayerAdmin SqVC_IsPlayerAdmin; + extern SDK_SetPlayerAdmin SqVC_SetPlayerAdmin; + extern SDK_GetPlayerIP SqVC_GetPlayerIP; + extern SDK_KickPlayer SqVC_KickPlayer; + extern SDK_BanPlayer SqVC_BanPlayer; + extern SDK_BanIP SqVC_BanIP; + extern SDK_UnbanIP SqVC_UnbanIP; + extern SDK_IsIPBanned SqVC_IsIPBanned; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: basic + */ + extern SDK_GetPlayerIDFromName SqVC_GetPlayerIDFromName; + extern SDK_IsPlayerConnected SqVC_IsPlayerConnected; + extern SDK_IsPlayerSpawned SqVC_IsPlayerSpawned; + extern SDK_IsPlayerStreamedForPlayer SqVC_IsPlayerStreamedForPlayer; + extern SDK_GetPlayerKey SqVC_GetPlayerKey; + extern SDK_SetPlayerWorld SqVC_SetPlayerWorld; + extern SDK_GetPlayerWorld SqVC_GetPlayerWorld; + extern SDK_SetPlayerSecWorld SqVC_SetPlayerSecWorld; + extern SDK_GetPlayerSecWorld SqVC_GetPlayerSecWorld; + extern SDK_GetPlayerUniqueWorld SqVC_GetPlayerUniqueWorld; + extern SDK_IsPlayerWorldCompatible SqVC_IsPlayerWorldCompatible; + extern SDK_GetPlayerState SqVC_GetPlayerState; + extern SDK_GetPlayerName SqVC_GetPlayerName; + extern SDK_SetPlayerName SqVC_SetPlayerName; + extern SDK_SetPlayerTeam SqVC_SetPlayerTeam; + extern SDK_GetPlayerTeam SqVC_GetPlayerTeam; + extern SDK_SetPlayerSkin SqVC_SetPlayerSkin; + extern SDK_GetPlayerSkin SqVC_GetPlayerSkin; + extern SDK_SetPlayerColour SqVC_SetPlayerColour; + extern SDK_GetPlayerColour SqVC_GetPlayerColour; + extern SDK_ForcePlayerSpawn SqVC_ForcePlayerSpawn; + extern SDK_ForcePlayerSelect SqVC_ForcePlayerSelect; + extern SDK_ForceAllSelect SqVC_ForceAllSelect; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: score, ping, money, typing + */ + extern SDK_GivePlayerMoney SqVC_GivePlayerMoney; + extern SDK_SetPlayerMoney SqVC_SetPlayerMoney; + extern SDK_GetPlayerMoney SqVC_GetPlayerMoney; + extern SDK_SetPlayerScore SqVC_SetPlayerScore; + extern SDK_GetPlayerScore SqVC_GetPlayerScore; + extern SDK_GetPlayerPing SqVC_GetPlayerPing; + extern SDK_IsPlayerTyping SqVC_IsPlayerTyping; + extern SDK_GetPlayerFPS SqVC_GetPlayerFPS; + extern SDK_GetPlayerUID SqVC_GetPlayerUID; + extern SDK_GetPlayerWantedLevel SqVC_GetPlayerWantedLevel; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: health and location + */ + extern SDK_SetPlayerHealth SqVC_SetPlayerHealth; + extern SDK_GetPlayerHealth SqVC_GetPlayerHealth; + extern SDK_SetPlayerArmour SqVC_SetPlayerArmour; + extern SDK_GetPlayerArmour SqVC_GetPlayerArmour; + extern SDK_SetPlayerImmunityFlags SqVC_SetPlayerImmunityFlags; + extern SDK_GetPlayerImmunityFlags SqVC_GetPlayerImmunityFlags; + extern SDK_SetPlayerPos SqVC_SetPlayerPos; + extern SDK_GetPlayerPos SqVC_GetPlayerPos; + extern SDK_SetPlayerSpeed SqVC_SetPlayerSpeed; + extern SDK_GetPlayerSpeed SqVC_GetPlayerSpeed; + extern SDK_AddPlayerSpeed SqVC_AddPlayerSpeed; + extern SDK_SetPlayerHeading SqVC_SetPlayerHeading; + extern SDK_GetPlayerHeading SqVC_GetPlayerHeading; + extern SDK_SetPlayerAlpha SqVC_SetPlayerAlpha; + extern SDK_GetPlayerAlpha SqVC_GetPlayerAlpha; + extern SDK_GetPlayerOnFireStatus SqVC_GetPlayerOnFireStatus; + extern SDK_GetPlayerCrouchStatus SqVC_GetPlayerCrouchStatus; + extern SDK_GetPlayerAction SqVC_GetPlayerAction; + extern SDK_GetPlayerGameKeys SqVC_GetPlayerGameKeys; + extern SDK_GetPlayerAimPos SqVC_GetPlayerAimPos; + extern SDK_GetPlayerAimDir SqVC_GetPlayerAimDir; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: vehicle + */ + extern SDK_PutPlayerInVehicle SqVC_PutPlayerInVehicle; + extern SDK_RemovePlayerFromVehicle SqVC_RemovePlayerFromVehicle; + extern SDK_GetPlayerInVehicleStatus SqVC_GetPlayerInVehicleStatus; + extern SDK_GetPlayerInVehicleSlot SqVC_GetPlayerInVehicleSlot; + extern SDK_GetPlayerVehicleID SqVC_GetPlayerVehicleID; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: toggles + */ + extern SDK_TogglePlayerControllable SqVC_TogglePlayerControllable; + extern SDK_EnabledPlayerControllable SqVC_EnabledPlayerControllable; + extern SDK_TogglePlayerDriveby SqVC_TogglePlayerDriveby; + extern SDK_EnabledPlayerDriveby SqVC_EnabledPlayerDriveby; + extern SDK_TogglePlayerWhiteScanlines SqVC_TogglePlayerWhiteScanlines; + extern SDK_EnabledPlayerWhiteScanlines SqVC_EnabledPlayerWhiteScanlines; + extern SDK_TogglePlayerGreenScanlines SqVC_TogglePlayerGreenScanlines; + extern SDK_EnabledPlayerGreenScanlines SqVC_EnabledPlayerGreenScanlines; + extern SDK_TogglePlayerWidescreen SqVC_TogglePlayerWidescreen; + extern SDK_EnabledPlayerWidescreen SqVC_EnabledPlayerWidescreen; + extern SDK_TogglePlayerShowMarkers SqVC_TogglePlayerShowMarkers; + extern SDK_EnabledPlayerShowMarkers SqVC_EnabledPlayerShowMarkers; + extern SDK_TogglePlayerAttackPriv SqVC_TogglePlayerAttackPriv; + extern SDK_EnabledPlayerAttackPriv SqVC_EnabledPlayerAttackPriv; + extern SDK_TogglePlayerHasMarker SqVC_TogglePlayerHasMarker; + extern SDK_EnabledPlayerHasMarker SqVC_EnabledPlayerHasMarker; + extern SDK_TogglePlayerChatTagsEnabled SqVC_TogglePlayerChatTagsEnabled; + extern SDK_EnabledPlayerChatTags SqVC_EnabledPlayerChatTags; + extern SDK_TogglePlayerDrunkEffects SqVC_TogglePlayerDrunkEffects; + extern SDK_EnabledPlayerDrunkEffects SqVC_EnabledPlayerDrunkEffects; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: weapons + */ + extern SDK_GivePlayerWeapon SqVC_GivePlayerWeapon; + extern SDK_SetPlayerWeapon SqVC_SetPlayerWeapon; + extern SDK_GetPlayerWeapon SqVC_GetPlayerWeapon; + extern SDK_GetPlayerWeaponAmmo SqVC_GetPlayerWeaponAmmo; + extern SDK_SetPlayerWeaponSlot SqVC_SetPlayerWeaponSlot; + extern SDK_GetPlayerWeaponSlot SqVC_GetPlayerWeaponSlot; + extern SDK_GetPlayerWeaponAtSlot SqVC_GetPlayerWeaponAtSlot; + extern SDK_GetPlayerAmmoAtSlot SqVC_GetPlayerAmmoAtSlot; + extern SDK_RemovePlayerWeapon SqVC_RemovePlayerWeapon; + extern SDK_RemoveAllWeapons SqVC_RemoveAllWeapons; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: camera + */ + extern SDK_SetCameraPosition SqVC_SetCameraPosition; + extern SDK_RestoreCamera SqVC_RestoreCamera; + extern SDK_IsCameraLocked SqVC_IsCameraLocked; + + /* ------------------------------------------------------------------------------------------------ + * PLAYERS: misc + */ + extern SDK_SetPlayerAnimation SqVC_SetPlayerAnimation; + extern SDK_SetPlayerWantedLevel SqVC_SetPlayerWantedLevel; + extern SDK_GetPlayerStandingOnVehicle SqVC_GetPlayerStandingOnVehicle; + extern SDK_GetPlayerStandingOnObject SqVC_GetPlayerStandingOnObject; + extern SDK_IsPlayerAway SqVC_IsPlayerAway; + extern SDK_GetPlayerSpectateTarget SqVC_GetPlayerSpectateTarget; + extern SDK_SetPlayerSpectateTarget SqVC_SetPlayerSpectateTarget; + extern SDK_RedirectPlayerToServer SqVC_RedirectPlayerToServer; + + /* ------------------------------------------------------------------------------------------------ + * VEHICLES + */ + extern SDK_CreateVehicle SqVC_CreateVehicle; + extern SDK_DeleteVehicle SqVC_DeleteVehicle; + extern SDK_GetVehicleSyncSource SqVC_GetVehicleSyncSource; + extern SDK_GetVehicleSyncType SqVC_GetVehicleSyncType; + extern SDK_IsVehicleStreamedForPlayer SqVC_IsVehicleStreamedForPlayer; + extern SDK_SetVehicleWorld SqVC_SetVehicleWorld; + extern SDK_GetVehicleWorld SqVC_GetVehicleWorld; + extern SDK_GetVehicleModel SqVC_GetVehicleModel; + extern SDK_GetVehicleOccupant SqVC_GetVehicleOccupant; + extern SDK_RespawnVehicle SqVC_RespawnVehicle; + extern SDK_SetVehicleImmunityFlags SqVC_SetVehicleImmunityFlags; + extern SDK_GetVehicleImmunityFlags SqVC_GetVehicleImmunityFlags; + extern SDK_KillVehicle SqVC_KillVehicle; + extern SDK_IsVehicleWrecked SqVC_IsVehicleWrecked; + extern SDK_SetVehiclePos SqVC_SetVehiclePos; + extern SDK_GetVehiclePos SqVC_GetVehiclePos; + extern SDK_SetVehicleRot SqVC_SetVehicleRot; + extern SDK_SetVehicleRotEuler SqVC_SetVehicleRotEuler; + extern SDK_GetVehicleRot SqVC_GetVehicleRot; + extern SDK_GetVehicleRotEuler SqVC_GetVehicleRotEuler; + extern SDK_SetVehicleSpeed SqVC_SetVehicleSpeed; + extern SDK_GetVehicleSpeed SqVC_GetVehicleSpeed; + extern SDK_AddVehicleSpeed SqVC_AddVehicleSpeed; + extern SDK_SetVehicleRelSpeed SqVC_SetVehicleRelSpeed; + extern SDK_GetVehicleRelSpeed SqVC_GetVehicleRelSpeed; + extern SDK_AddVehicleRelSpeed SqVC_AddVehicleRelSpeed; + extern SDK_SetVehicleTurnSpeed SqVC_SetVehicleTurnSpeed; + extern SDK_GetVehicleTurnSpeed SqVC_GetVehicleTurnSpeed; + extern SDK_AddVehicleTurnSpeed SqVC_AddVehicleTurnSpeed; + extern SDK_SetVehicleRelTurnSpeed SqVC_SetVehicleRelTurnSpeed; + extern SDK_GetVehicleRelTurnSpeed SqVC_GetVehicleRelTurnSpeed; + extern SDK_AddVehicleRelTurnSpeed SqVC_AddVehicleRelTurnSpeed; + extern SDK_SetVehicleSpawnPos SqVC_SetVehicleSpawnPos; + extern SDK_GetVehicleSpawnPos SqVC_GetVehicleSpawnPos; + extern SDK_SetVehicleSpawnRot SqVC_SetVehicleSpawnRot; + extern SDK_SetVehicleSpawnRotEuler SqVC_SetVehicleSpawnRotEuler; + extern SDK_GetVehicleSpawnRot SqVC_GetVehicleSpawnRot; + extern SDK_GetVehicleSpawnRotEuler SqVC_GetVehicleSpawnRotEuler; + extern SDK_SetVehicleIdleRespawnTimer SqVC_SetVehicleIdleRespawnTimer; + extern SDK_GetVehicleIdleRespawnTimer SqVC_GetVehicleIdleRespawnTimer; + extern SDK_SetVehicleHealth SqVC_SetVehicleHealth; + extern SDK_GetVehicleHealth SqVC_GetVehicleHealth; + extern SDK_SetVehicleColour SqVC_SetVehicleColour; + extern SDK_GetVehicleColour SqVC_GetVehicleColour; + extern SDK_SetVehicleDoorsLocked SqVC_SetVehicleDoorsLocked; + extern SDK_GetVehicleDoorsLocked SqVC_GetVehicleDoorsLocked; + extern SDK_SetVehiclePartStatus SqVC_SetVehiclePartStatus; + extern SDK_GetVehiclePartStatus SqVC_GetVehiclePartStatus; + extern SDK_SetVehicleTyreStatus SqVC_SetVehicleTyreStatus; + extern SDK_GetVehicleTyreStatus SqVC_GetVehicleTyreStatus; + extern SDK_SetVehicleDamageData SqVC_SetVehicleDamageData; + extern SDK_GetVehicleDamageData SqVC_GetVehicleDamageData; + extern SDK_SetVehicleAlarm SqVC_SetVehicleAlarm; + extern SDK_GetVehicleAlarm SqVC_GetVehicleAlarm; + extern SDK_SetVehicleLights SqVC_SetVehicleLights; + extern SDK_GetVehicleLights SqVC_GetVehicleLights; + extern SDK_SetVehicleRadio SqVC_SetVehicleRadio; + extern SDK_GetVehicleRadio SqVC_GetVehicleRadio; + extern SDK_SetVehicleRadioLocked SqVC_SetVehicleRadioLocked; + extern SDK_IsVehicleRadioLocked SqVC_IsVehicleRadioLocked; + extern SDK_GetVehicleGhostState SqVC_GetVehicleGhostState; + extern SDK_SetVehicleGhostState SqVC_SetVehicleGhostState; + extern SDK_GetVehicleTurretRotation SqVC_GetVehicleTurretRotation; + + /* ------------------------------------------------------------------------------------------------ + * VEHICLES: handling + */ + extern SDK_ResetAllVehicleHandlings SqVC_ResetAllVehicleHandlings; + extern SDK_ExistsHandlingRule SqVC_ExistsHandlingRule; + extern SDK_SetHandlingRule SqVC_SetHandlingRule; + extern SDK_GetHandlingRule SqVC_GetHandlingRule; + extern SDK_ResetHandlingRule SqVC_ResetHandlingRule; + extern SDK_ResetHandling SqVC_ResetHandling; + extern SDK_ExistsInstHandlingRule SqVC_ExistsInstHandlingRule; + extern SDK_SetInstHandlingRule SqVC_SetInstHandlingRule; + extern SDK_GetInstHandlingRule SqVC_GetInstHandlingRule; + extern SDK_ResetInstHandlingRule SqVC_ResetInstHandlingRule; + extern SDK_ResetInstHandling SqVC_ResetInstHandling; + + /* ------------------------------------------------------------------------------------------------ + * PICKUPS + */ + extern SDK_CreatePickup SqVC_CreatePickup; + extern SDK_DeletePickup SqVC_DeletePickup; + extern SDK_IsPickupStreamedForPlayer SqVC_IsPickupStreamedForPlayer; + extern SDK_SetPickupWorld SqVC_SetPickupWorld; + extern SDK_GetPickupWorld SqVC_GetPickupWorld; + extern SDK_PickupGetAlpha SqVC_PickupGetAlpha; + extern SDK_PickupSetAlpha SqVC_PickupSetAlpha; + extern SDK_PickupIsAutomatic SqVC_PickupIsAutomatic; + extern SDK_PickupSetAutomatic SqVC_PickupSetAutomatic; + extern SDK_SetPickupAutoTimer SqVC_SetPickupAutoTimer; + extern SDK_GetPickupAutoTimer SqVC_GetPickupAutoTimer; + extern SDK_PickupRefresh SqVC_PickupRefresh; + extern SDK_PickupGetPos SqVC_PickupGetPos; + extern SDK_PickupSetPos SqVC_PickupSetPos; + extern SDK_PickupGetModel SqVC_PickupGetModel; + extern SDK_PickupGetQuantity SqVC_PickupGetQuantity; + + /* ------------------------------------------------------------------------------------------------ + * OBJECTS + */ + extern SDK_CreateObject SqVC_CreateObject; + extern SDK_DeleteObject SqVC_DeleteObject; + extern SDK_IsObjectStreamedForPlayer SqVC_IsObjectStreamedForPlayer; + extern SDK_GetObjectModel SqVC_GetObjectModel; + extern SDK_SetObjectWorld SqVC_SetObjectWorld; + extern SDK_GetObjectWorld SqVC_GetObjectWorld; + extern SDK_SetObjectAlpha SqVC_SetObjectAlpha; + extern SDK_GetObjectAlpha SqVC_GetObjectAlpha; + extern SDK_MoveObjectTo SqVC_MoveObjectTo; + extern SDK_MoveObjectBy SqVC_MoveObjectBy; + extern SDK_SetObjectPos SqVC_SetObjectPos; + extern SDK_GetObjectPos SqVC_GetObjectPos; + extern SDK_RotObjectTo SqVC_RotObjectTo; + extern SDK_RotObjectToEuler SqVC_RotObjectToEuler; + extern SDK_RotObjectBy SqVC_RotObjectBy; + extern SDK_RotObjectByEuler SqVC_RotObjectByEuler; + extern SDK_GetObjectRot SqVC_GetObjectRot; + extern SDK_GetObjectRotEuler SqVC_GetObjectRotEuler; + extern SDK_SetObjectShotReport SqVC_SetObjectShotReport; + extern SDK_IsObjectShotReport SqVC_IsObjectShotReport; + extern SDK_SetObjectBumpReport SqVC_SetObjectBumpReport; + extern SDK_IsObjectBumpReport SqVC_IsObjectBumpReport; + + /* ------------------------------------------------------------------------------------------------ + * + */ + extern SDK_ToggleWallglitch SqVC_ToggleWallglitch; + extern SDK_EnabledWallglitch SqVC_EnabledWallglitch; + extern SDK_SetVehicleSiren SqVC_SetVehicleSiren; + extern SDK_GetVehicleSiren SqVC_GetVehicleSiren; + extern SDK_GetPlayerUID2 SqVC_GetPlayerUID2; + + /* ------------------------------------------------------------------------------------------------ + * + */ + extern SDK_CreateCheckpoint SqVC_CreateCheckpoint; + extern SDK_DeleteCheckpoint SqVC_DeleteCheckpoint; + extern SDK_IsCheckpointStreamedForPlayer SqVC_IsCheckpointStreamedForPlayer; + extern SDK_SetCheckpointWorld SqVC_SetCheckpointWorld; + extern SDK_GetCheckpointWorld SqVC_GetCheckpointWorld; + extern SDK_SetCheckpointColor SqVC_SetCheckpointColor; + extern SDK_GetCheckpointColor SqVC_GetCheckpointColor; + extern SDK_SetCheckpointPos SqVC_SetCheckpointPos; + extern SDK_GetCheckpointPos SqVC_GetCheckpointPos; + extern SDK_SetCheckpointRadius SqVC_SetCheckpointRadius; + extern SDK_GetCheckpointRadius SqVC_GetCheckpointRadius; + extern SDK_GetCheckpointOwner SqVC_GetCheckpointOwner; + + /* ------------------------------------------------------------------------------------------------ + * + */ + extern SDK_CreateSphere SqVC_CreateSphere; + extern SDK_DeleteSphere SqVC_DeleteSphere; + extern SDK_IsSphereStreamedForPlayer SqVC_IsSphereStreamedForPlayer; + extern SDK_SetSphereWorld SqVC_SetSphereWorld; + extern SDK_GetSphereWorld SqVC_GetSphereWorld; + extern SDK_SetSphereColor SqVC_SetSphereColor; + extern SDK_GetSphereColor SqVC_GetSphereColor; + extern SDK_SetSpherePos SqVC_SetSpherePos; + extern SDK_GetSpherePos SqVC_GetSpherePos; + extern SDK_SetSphereRadius SqVC_SetSphereRadius; + extern SDK_GetSphereRadius SqVC_GetSphereRadius; + extern SDK_GetSphereOwner SqVC_GetSphereOwner; + + /* -------------------------------------------------------------------------------------------- + * Import the functions from the main squirrel plugin. + */ + SQUIRREL_API HSQEXPORTS sq_api_import(PluginFuncs * vcapi); + + /* -------------------------------------------------------------------------------------------- + * Assign the functions from the specified API structure into the global functions. + */ + SQUIRREL_API SQRESULT sq_api_expand(HSQAPI sqapi); + + /* -------------------------------------------------------------------------------------------- + * Undo changes done by sq_api_expand. + */ + SQUIRREL_API void sq_api_collapse(); + + /* -------------------------------------------------------------------------------------------- + * Assign the functions from the specified API structure into the global functions. + */ + SQUIRREL_API SQRESULT vc_api_expand(PluginFuncs * vcapi); + + /* -------------------------------------------------------------------------------------------- + * Undo changes done by vc_api_expand. + */ + SQUIRREL_API void vc_api_collapse(); + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*_SQ_API_H_*/ diff --git a/shared/sq_mod.inl b/shared/sq_mod.inl new file mode 100644 index 00000000..7283ded0 --- /dev/null +++ b/shared/sq_mod.inl @@ -0,0 +1,1968 @@ +// ------------------------------------------------------------------------------------------------ +#ifdef SQMOD_PLUGIN_API + +/*vm*/ +sqapi_open sq_open = NULL; +sqapi_newthread sq_newthread = NULL; +sqapi_seterrorhandler sq_seterrorhandler = NULL; +sqapi_close sq_close = NULL; +sqapi_setforeignptr sq_setforeignptr = NULL; +sqapi_getforeignptr sq_getforeignptr = NULL; +sqapi_setsharedforeignptr sq_setsharedforeignptr = NULL; +sqapi_getsharedforeignptr sq_getsharedforeignptr = NULL; +sqapi_setvmreleasehook sq_setvmreleasehook = NULL; +sqapi_getvmreleasehook sq_getvmreleasehook = NULL; +sqapi_setsharedreleasehook sq_setsharedreleasehook = NULL; +sqapi_getsharedreleasehook sq_getsharedreleasehook = NULL; +sqapi_setprintfunc sq_setprintfunc = NULL; +sqapi_getprintfunc sq_getprintfunc = NULL; +sqapi_geterrorfunc sq_geterrorfunc = NULL; +sqapi_suspendvm sq_suspendvm = NULL; +sqapi_wakeupvm sq_wakeupvm = NULL; +sqapi_getvmstate sq_getvmstate = NULL; +sqapi_getversion sq_getversion = NULL; + +/*compiler*/ +sqapi_compile sq_compile = NULL; +sqapi_compilebuffer sq_compilebuffer = NULL; +sqapi_enabledebuginfo sq_enabledebuginfo = NULL; +sqapi_notifyallexceptions sq_notifyallexceptions = NULL; +sqapi_setcompilererrorhandler sq_setcompilererrorhandler = NULL; + +/*stack operations*/ +sqapi_push sq_push = NULL; +sqapi_pop sq_pop = NULL; +sqapi_poptop sq_poptop = NULL; +sqapi_remove sq_remove = NULL; +sqapi_gettop sq_gettop = NULL; +sqapi_settop sq_settop = NULL; +sqapi_reservestack sq_reservestack = NULL; +sqapi_cmp sq_cmp = NULL; +sqapi_move sq_move = NULL; + +/*object creation handling*/ +sqapi_newuserdata sq_newuserdata = NULL; +sqapi_newtable sq_newtable = NULL; +sqapi_newtableex sq_newtableex = NULL; +sqapi_newarray sq_newarray = NULL; +sqapi_newclosure sq_newclosure = NULL; +sqapi_setparamscheck sq_setparamscheck = NULL; +sqapi_bindenv sq_bindenv = NULL; +sqapi_setclosureroot sq_setclosureroot = NULL; +sqapi_getclosureroot sq_getclosureroot = NULL; +sqapi_pushstring sq_pushstring = NULL; +sqapi_pushfloat sq_pushfloat = NULL; +sqapi_pushinteger sq_pushinteger = NULL; +sqapi_pushbool sq_pushbool = NULL; +sqapi_pushuserpointer sq_pushuserpointer = NULL; +sqapi_pushnull sq_pushnull = NULL; +sqapi_pushthread sq_pushthread = NULL; +sqapi_gettype sq_gettype = NULL; +sqapi_typeof sq_typeof = NULL; +sqapi_getsize sq_getsize = NULL; +sqapi_gethash sq_gethash = NULL; +sqapi_getbase sq_getbase = NULL; +sqapi_instanceof sq_instanceof = NULL; +sqapi_tostring sq_tostring = NULL; +sqapi_tobool sq_tobool = NULL; +sqapi_getstring sq_getstring = NULL; +sqapi_getinteger sq_getinteger = NULL; +sqapi_getfloat sq_getfloat = NULL; +sqapi_getbool sq_getbool = NULL; +sqapi_getthread sq_getthread = NULL; +sqapi_getuserpointer sq_getuserpointer = NULL; +sqapi_getuserdata sq_getuserdata = NULL; +sqapi_settypetag sq_settypetag = NULL; +sqapi_gettypetag sq_gettypetag = NULL; +sqapi_setreleasehook sq_setreleasehook = NULL; +sqapi_getreleasehook sq_getreleasehook = NULL; +sqapi_getscratchpad sq_getscratchpad = NULL; +sqapi_getfunctioninfo sq_getfunctioninfo = NULL; +sqapi_getclosureinfo sq_getclosureinfo = NULL; +sqapi_getclosurename sq_getclosurename = NULL; +sqapi_setnativeclosurename sq_setnativeclosurename = NULL; +sqapi_setinstanceup sq_setinstanceup = NULL; +sqapi_getinstanceup sq_getinstanceup = NULL; +sqapi_setclassudsize sq_setclassudsize = NULL; +sqapi_newclass sq_newclass = NULL; +sqapi_createinstance sq_createinstance = NULL; +sqapi_setattributes sq_setattributes = NULL; +sqapi_getattributes sq_getattributes = NULL; +sqapi_getclass sq_getclass = NULL; +sqapi_weakref sq_weakref = NULL; +sqapi_getdefaultdelegate sq_getdefaultdelegate = NULL; +sqapi_getmemberhandle sq_getmemberhandle = NULL; +sqapi_getbyhandle sq_getbyhandle = NULL; +sqapi_setbyhandle sq_setbyhandle = NULL; + +/*object manipulation*/ +sqapi_pushroottable sq_pushroottable = NULL; +sqapi_pushregistrytable sq_pushregistrytable = NULL; +sqapi_pushconsttable sq_pushconsttable = NULL; +sqapi_setroottable sq_setroottable = NULL; +sqapi_setconsttable sq_setconsttable = NULL; +sqapi_newslot sq_newslot = NULL; +sqapi_deleteslot sq_deleteslot = NULL; +sqapi_set sq_set = NULL; +sqapi_get sq_get = NULL; +sqapi_rawget sq_rawget = NULL; +sqapi_rawset sq_rawset = NULL; +sqapi_rawdeleteslot sq_rawdeleteslot = NULL; +sqapi_newmember sq_newmember = NULL; +sqapi_rawnewmember sq_rawnewmember = NULL; +sqapi_arrayappend sq_arrayappend = NULL; +sqapi_arraypop sq_arraypop = NULL; +sqapi_arrayresize sq_arrayresize = NULL; +sqapi_arrayreverse sq_arrayreverse = NULL; +sqapi_arrayremove sq_arrayremove = NULL; +sqapi_arrayinsert sq_arrayinsert = NULL; +sqapi_setdelegate sq_setdelegate = NULL; +sqapi_getdelegate sq_getdelegate = NULL; +sqapi_clone sq_clone = NULL; +sqapi_setfreevariable sq_setfreevariable = NULL; +sqapi_next sq_next = NULL; +sqapi_getweakrefval sq_getweakrefval = NULL; +sqapi_clear sq_clear = NULL; + +/*calls*/ +sqapi_call sq_call = NULL; +sqapi_resume sq_resume = NULL; +sqapi_getlocal sq_getlocal = NULL; +sqapi_getcallee sq_getcallee = NULL; +sqapi_getfreevariable sq_getfreevariable = NULL; +sqapi_throwerror sq_throwerror = NULL; +sqapi_throwobject sq_throwobject = NULL; +sqapi_reseterror sq_reseterror = NULL; +sqapi_getlasterror sq_getlasterror = NULL; + +/*raw object handling*/ +sqapi_getstackobj sq_getstackobj = NULL; +sqapi_pushobject sq_pushobject = NULL; +sqapi_addref sq_addref = NULL; +sqapi_release sq_release = NULL; +sqapi_getrefcount sq_getrefcount = NULL; +sqapi_resetobject sq_resetobject = NULL; +sqapi_objtostring sq_objtostring = NULL; +sqapi_objtobool sq_objtobool = NULL; +sqapi_objtointeger sq_objtointeger = NULL; +sqapi_objtofloat sq_objtofloat = NULL; +sqapi_objtouserpointer sq_objtouserpointer = NULL; +sqapi_getobjtypetag sq_getobjtypetag = NULL; +sqapi_getvmrefcount sq_getvmrefcount = NULL; + +/*GC*/ +sqapi_collectgarbage sq_collectgarbage = NULL; +sqapi_resurrectunreachable sq_resurrectunreachable = NULL; + +/*serialization*/ +sqapi_writeclosure sq_writeclosure = NULL; +sqapi_readclosure sq_readclosure = NULL; + +/*mem allocation*/ +sqapi_malloc sq_malloc = NULL; +sqapi_realloc sq_realloc = NULL; +sqapi_free sq_free = NULL; + +/*debug*/ +sqapi_stackinfos sq_stackinfos = NULL; +sqapi_setdebughook sq_setdebughook = NULL; +sqapi_setnativedebughook sq_setnativedebughook = NULL; + +/*compiler helpers*/ +sqapi_loadfile sq_loadfile = NULL; +sqapi_dofile sq_dofile = NULL; +sqapi_writeclosuretofile sq_writeclosuretofile = NULL; + +/*blob*/ +sqapi_createblob sq_createblob = NULL; +sqapi_getblob sq_getblob = NULL; +sqapi_getblobsize sq_getblobsize = NULL; + +/*string*/ +sqapi_format sq_format = NULL; + +#endif // SQMOD_PLUGIN_API + +// ------------------------------------------------------------------------------------------------ +HSQEXPORTS sq_api_import(PluginFuncs * vcapi) +{ + // Make sure a valid plugin api and reference to exports structure pointer was specified + if (!vcapi) + { + return NULL; + } + unsigned int struct_size; + // Attempt to find the main plugin ID + int plugin_id = vcapi->FindPlugin((char *)(SQMOD_HOST_NAME)); + // Attempt to retrieve the plugin exports + void ** plugin_exports = vcapi->GetPluginExports(plugin_id, &struct_size); + // See if we have any imports from Squirrel + if (plugin_exports == NULL || struct_size <= 0) + { + return NULL; + } + // Simply return the obtain poiner to the exports structure + return *(sq_exports **)plugin_exports; +} + +// ------------------------------------------------------------------------------------------------ +SQRESULT sq_api_expand(HSQAPI sqapi) +{ + if (!sqapi) + return SQ_ERROR; + +#ifdef SQMOD_PLUGIN_API + + /*vm*/ + sq_open = sqapi->open; + sq_newthread = sqapi->newthread; + sq_seterrorhandler = sqapi->seterrorhandler; + sq_close = sqapi->close; + sq_setforeignptr = sqapi->setforeignptr; + sq_getforeignptr = sqapi->getforeignptr; + sq_setsharedforeignptr = sqapi->setsharedforeignptr; + sq_getsharedforeignptr = sqapi->getsharedforeignptr; + sq_setvmreleasehook = sqapi->setvmreleasehook; + sq_getvmreleasehook = sqapi->getvmreleasehook; + sq_setsharedreleasehook = sqapi->setsharedreleasehook; + sq_getsharedreleasehook = sqapi->getsharedreleasehook; + sq_setprintfunc = sqapi->setprintfunc; + sq_getprintfunc = sqapi->getprintfunc; + sq_geterrorfunc = sqapi->geterrorfunc; + sq_suspendvm = sqapi->suspendvm; + sq_wakeupvm = sqapi->wakeupvm; + sq_getvmstate = sqapi->getvmstate; + sq_getversion = sqapi->getversion; + + /*compiler*/ + sq_compile = sqapi->compile; + sq_compilebuffer = sqapi->compilebuffer; + sq_enabledebuginfo = sqapi->enabledebuginfo; + sq_notifyallexceptions = sqapi->notifyallexceptions; + sq_setcompilererrorhandler = sqapi->setcompilererrorhandler; + + /*stack operations*/ + sq_push = sqapi->push; + sq_pop = sqapi->pop; + sq_poptop = sqapi->poptop; + sq_remove = sqapi->remove; + sq_gettop = sqapi->gettop; + sq_settop = sqapi->settop; + sq_reservestack = sqapi->reservestack; + sq_cmp = sqapi->cmp; + sq_move = sqapi->move; + + /*object creation handling*/ + sq_newuserdata = sqapi->newuserdata; + sq_newtable = sqapi->newtable; + sq_newtableex = sqapi->newtableex; + sq_newarray = sqapi->newarray; + sq_newclosure = sqapi->newclosure; + sq_setparamscheck = sqapi->setparamscheck; + sq_bindenv = sqapi->bindenv; + sq_setclosureroot = sqapi->setclosureroot; + sq_getclosureroot = sqapi->getclosureroot; + sq_pushstring = sqapi->pushstring; + sq_pushfloat = sqapi->pushfloat; + sq_pushinteger = sqapi->pushinteger; + sq_pushbool = sqapi->pushbool; + sq_pushuserpointer = sqapi->pushuserpointer; + sq_pushnull = sqapi->pushnull; + sq_pushthread = sqapi->pushthread; + sq_gettype = sqapi->gettype; + sq_typeof = sqapi->typeof_; + sq_getsize = sqapi->getsize; + sq_gethash = sqapi->gethash; + sq_getbase = sqapi->getbase; + sq_instanceof = sqapi->instanceof; + sq_tostring = sqapi->tostring; + sq_tobool = sqapi->tobool; + sq_getstring = sqapi->getstring; + sq_getinteger = sqapi->getinteger; + sq_getfloat = sqapi->getfloat; + sq_getbool = sqapi->getbool; + sq_getthread = sqapi->getthread; + sq_getuserpointer = sqapi->getuserpointer; + sq_getuserdata = sqapi->getuserdata; + sq_settypetag = sqapi->settypetag; + sq_gettypetag = sqapi->gettypetag; + sq_setreleasehook = sqapi->setreleasehook; + sq_getreleasehook = sqapi->getreleasehook; + sq_getscratchpad = sqapi->getscratchpad; + sq_getfunctioninfo = sqapi->getfunctioninfo; + sq_getclosureinfo = sqapi->getclosureinfo; + sq_getclosurename = sqapi->getclosurename; + sq_setnativeclosurename = sqapi->setnativeclosurename; + sq_setinstanceup = sqapi->setinstanceup; + sq_getinstanceup = sqapi->getinstanceup; + sq_setclassudsize = sqapi->setclassudsize; + sq_newclass = sqapi->newclass; + sq_createinstance = sqapi->createinstance; + sq_setattributes = sqapi->setattributes; + sq_getattributes = sqapi->getattributes; + sq_getclass = sqapi->getclass; + sq_weakref = sqapi->weakref; + sq_getdefaultdelegate = sqapi->getdefaultdelegate; + sq_getmemberhandle = sqapi->getmemberhandle; + sq_getbyhandle = sqapi->getbyhandle; + sq_setbyhandle = sqapi->setbyhandle; + + /*object manipulation*/ + sq_pushroottable = sqapi->pushroottable; + sq_pushregistrytable = sqapi->pushregistrytable; + sq_pushconsttable = sqapi->pushconsttable; + sq_setroottable = sqapi->setroottable; + sq_setconsttable = sqapi->setconsttable; + sq_newslot = sqapi->newslot; + sq_deleteslot = sqapi->deleteslot; + sq_set = sqapi->set; + sq_get = sqapi->get; + sq_rawget = sqapi->rawget; + sq_rawset = sqapi->rawset; + sq_rawdeleteslot = sqapi->rawdeleteslot; + sq_newmember = sqapi->newmember; + sq_rawnewmember = sqapi->rawnewmember; + sq_arrayappend = sqapi->arrayappend; + sq_arraypop = sqapi->arraypop; + sq_arrayresize = sqapi->arrayresize; + sq_arrayreverse = sqapi->arrayreverse; + sq_arrayremove = sqapi->arrayremove; + sq_arrayinsert = sqapi->arrayinsert; + sq_setdelegate = sqapi->setdelegate; + sq_getdelegate = sqapi->getdelegate; + sq_clone = sqapi->clone; + sq_setfreevariable = sqapi->setfreevariable; + sq_next = sqapi->next; + sq_getweakrefval = sqapi->getweakrefval; + sq_clear = sqapi->clear; + + /*calls*/ + sq_call = sqapi->call; + sq_resume = sqapi->resume; + sq_getlocal = sqapi->getlocal; + sq_getcallee = sqapi->getcallee; + sq_getfreevariable = sqapi->getfreevariable; + sq_throwerror = sqapi->throwerror; + sq_throwobject = sqapi->throwobject; + sq_reseterror = sqapi->reseterror; + sq_getlasterror = sqapi->getlasterror; + + /*raw object handling*/ + sq_getstackobj = sqapi->getstackobj; + sq_pushobject = sqapi->pushobject; + sq_addref = sqapi->addref; + sq_release = sqapi->release; + sq_getrefcount = sqapi->getrefcount; + sq_resetobject = sqapi->resetobject; + sq_objtostring = sqapi->objtostring; + sq_objtobool = sqapi->objtobool; + sq_objtointeger = sqapi->objtointeger; + sq_objtofloat = sqapi->objtofloat; + sq_objtouserpointer = sqapi->objtouserpointer; + sq_getobjtypetag = sqapi->getobjtypetag; + sq_getvmrefcount = sqapi->getvmrefcount; + + /*GC*/ + sq_collectgarbage = sqapi->collectgarbage; + sq_resurrectunreachable = sqapi->resurrectunreachable; + + /*serialization*/ + sq_writeclosure = sqapi->writeclosure; + sq_readclosure = sqapi->readclosure; + + /*mem allocation*/ + sq_malloc = sqapi->malloc; + sq_realloc = sqapi->realloc; + sq_free = sqapi->free; + + /*debug*/ + sq_stackinfos = sqapi->stackinfos; + sq_setdebughook = sqapi->setdebughook; + sq_setnativedebughook = sqapi->setnativedebughook; + + /*compiler helpers*/ + sq_loadfile = sqapi->loadfile; + sq_dofile = sqapi->dofile; + sq_writeclosuretofile = sqapi->writeclosuretofile; + + /*blob*/ + sq_createblob = sqapi->createblob; + sq_getblob = sqapi->getblob; + sq_getblobsize = sqapi->getblobsize; + + /*string*/ + sq_format = sqapi->format; + +#endif // SQMOD_PLUGIN_API + + return SQ_OK; +} + +// ------------------------------------------------------------------------------------------------ +void sq_api_collapse() +{ +#ifdef SQMOD_PLUGIN_API + + /*vm*/ + sq_open = NULL; + sq_newthread = NULL; + sq_seterrorhandler = NULL; + sq_close = NULL; + sq_setforeignptr = NULL; + sq_getforeignptr = NULL; + sq_setsharedforeignptr = NULL; + sq_getsharedforeignptr = NULL; + sq_setvmreleasehook = NULL; + sq_getvmreleasehook = NULL; + sq_setsharedreleasehook = NULL; + sq_getsharedreleasehook = NULL; + sq_setprintfunc = NULL; + sq_getprintfunc = NULL; + sq_geterrorfunc = NULL; + sq_suspendvm = NULL; + sq_wakeupvm = NULL; + sq_getvmstate = NULL; + sq_getversion = NULL; + + /*compiler*/ + sq_compile = NULL; + sq_compilebuffer = NULL; + sq_enabledebuginfo = NULL; + sq_notifyallexceptions = NULL; + sq_setcompilererrorhandler = NULL; + + /*stack operations*/ + sq_push = NULL; + sq_pop = NULL; + sq_poptop = NULL; + sq_remove = NULL; + sq_gettop = NULL; + sq_settop = NULL; + sq_reservestack = NULL; + sq_cmp = NULL; + sq_move = NULL; + + /*object creation handling*/ + sq_newuserdata = NULL; + sq_newtable = NULL; + sq_newtableex = NULL; + sq_newarray = NULL; + sq_newclosure = NULL; + sq_setparamscheck = NULL; + sq_bindenv = NULL; + sq_setclosureroot = NULL; + sq_getclosureroot = NULL; + sq_pushstring = NULL; + sq_pushfloat = NULL; + sq_pushinteger = NULL; + sq_pushbool = NULL; + sq_pushuserpointer = NULL; + sq_pushnull = NULL; + sq_pushthread = NULL; + sq_gettype = NULL; + sq_typeof = NULL; + sq_getsize = NULL; + sq_gethash = NULL; + sq_getbase = NULL; + sq_instanceof = NULL; + sq_tostring = NULL; + sq_tobool = NULL; + sq_getstring = NULL; + sq_getinteger = NULL; + sq_getfloat = NULL; + sq_getbool = NULL; + sq_getthread = NULL; + sq_getuserpointer = NULL; + sq_getuserdata = NULL; + sq_settypetag = NULL; + sq_gettypetag = NULL; + sq_setreleasehook = NULL; + sq_getreleasehook = NULL; + sq_getscratchpad = NULL; + sq_getfunctioninfo = NULL; + sq_getclosureinfo = NULL; + sq_getclosurename = NULL; + sq_setnativeclosurename = NULL; + sq_setinstanceup = NULL; + sq_getinstanceup = NULL; + sq_setclassudsize = NULL; + sq_newclass = NULL; + sq_createinstance = NULL; + sq_setattributes = NULL; + sq_getattributes = NULL; + sq_getclass = NULL; + sq_weakref = NULL; + sq_getdefaultdelegate = NULL; + sq_getmemberhandle = NULL; + sq_getbyhandle = NULL; + sq_setbyhandle = NULL; + + /*object manipulation*/ + sq_pushroottable = NULL; + sq_pushregistrytable = NULL; + sq_pushconsttable = NULL; + sq_setroottable = NULL; + sq_setconsttable = NULL; + sq_newslot = NULL; + sq_deleteslot = NULL; + sq_set = NULL; + sq_get = NULL; + sq_rawget = NULL; + sq_rawset = NULL; + sq_rawdeleteslot = NULL; + sq_newmember = NULL; + sq_rawnewmember = NULL; + sq_arrayappend = NULL; + sq_arraypop = NULL; + sq_arrayresize = NULL; + sq_arrayreverse = NULL; + sq_arrayremove = NULL; + sq_arrayinsert = NULL; + sq_setdelegate = NULL; + sq_getdelegate = NULL; + sq_clone = NULL; + sq_setfreevariable = NULL; + sq_next = NULL; + sq_getweakrefval = NULL; + sq_clear = NULL; + + /*calls*/ + sq_call = NULL; + sq_resume = NULL; + sq_getlocal = NULL; + sq_getcallee = NULL; + sq_getfreevariable = NULL; + sq_throwerror = NULL; + sq_throwobject = NULL; + sq_reseterror = NULL; + sq_getlasterror = NULL; + + /*raw object handling*/ + sq_getstackobj = NULL; + sq_pushobject = NULL; + sq_addref = NULL; + sq_release = NULL; + sq_getrefcount = NULL; + sq_resetobject = NULL; + sq_objtostring = NULL; + sq_objtobool = NULL; + sq_objtointeger = NULL; + sq_objtofloat = NULL; + sq_objtouserpointer = NULL; + sq_getobjtypetag = NULL; + sq_getvmrefcount = NULL; + + /*GC*/ + sq_collectgarbage = NULL; + sq_resurrectunreachable = NULL; + + /*serialization*/ + sq_writeclosure = NULL; + sq_readclosure = NULL; + + /*mem allocation*/ + sq_malloc = NULL; + sq_realloc = NULL; + sq_free = NULL; + + /*debug*/ + sq_stackinfos = NULL; + sq_setdebughook = NULL; + sq_setnativedebughook = NULL; + + /*compiler helpers*/ + sq_loadfile = NULL; + sq_dofile = NULL; + sq_writeclosuretofile = NULL; + + /*blob*/ + sq_createblob = NULL; + sq_getblob = NULL; + sq_getblobsize = NULL; + + /*string*/ + sq_format = NULL; + +#endif // SQMOD_PLUGIN_API +} + +// -------------------------------------------------------------------------------------------- +//PLUGIN SYSTEM +SDK_GetServerVersion SqVC_GetServerVersion = NULL; +SDK_GetServerSettings SqVC_GetServerSettings = NULL; +SDK_ExportFunctions SqVC_ExportFunctions = NULL; +SDK_GetNumberOfPlugins SqVC_GetNumberOfPlugins = NULL; +SDK_GetPluginInfo SqVC_GetPluginInfo = NULL; +SDK_FindPlugin SqVC_FindPlugin = NULL; +SDK_GetPluginExports SqVC_GetPluginExports = NULL; +SDK_GetTime SqVC_GetTime = NULL; + +// -------------------------------------------------------------------------------------------- +//MESSAGES +SDK_printf SqVC_printf = NULL; +SDK_SendCustomCommand SqVC_SendCustomCommand = NULL; +SDK_SendClientMessage SqVC_SendClientMessage = NULL; +SDK_SendGameMessage SqVC_SendGameMessage = NULL; + +// -------------------------------------------------------------------------------------------- +//SERVER SETTINGS +SDK_SetServerName SqVC_SetServerName = NULL; +SDK_GetServerName SqVC_GetServerName = NULL; +SDK_SetMaxPlayers SqVC_SetMaxPlayers = NULL; +SDK_GetMaxPlayers SqVC_GetMaxPlayers = NULL; +SDK_SetServerPassword SqVC_SetServerPassword = NULL; +SDK_GetServerPassword SqVC_GetServerPassword = NULL; +SDK_SetGameModeText SqVC_SetGameModeText = NULL; +SDK_GetGameModeText SqVC_GetGameModeText = NULL; +SDK_ShutdownServer SqVC_ShutdownServer = NULL; + +// -------------------------------------------------------------------------------------------- +//WORLD: settings +SDK_SetWorldBounds SqVC_SetWorldBounds = NULL; +SDK_GetWorldBounds SqVC_GetWorldBounds = NULL; +SDK_SetWastedSettings SqVC_SetWastedSettings = NULL; +SDK_GetWastedSettings SqVC_GetWastedSettings = NULL; +SDK_SetTimeRate SqVC_SetTimeRate = NULL; +SDK_GetTimeRate SqVC_GetTimeRate = NULL; +SDK_SetHour SqVC_SetHour = NULL; +SDK_GetHour SqVC_GetHour = NULL; +SDK_SetMinute SqVC_SetMinute = NULL; +SDK_GetMinute SqVC_GetMinute = NULL; +SDK_SetWeather SqVC_SetWeather = NULL; +SDK_GetWeather SqVC_GetWeather = NULL; +SDK_SetGravity SqVC_SetGravity = NULL; +SDK_GetGravity SqVC_GetGravity = NULL; +SDK_SetGamespeed SqVC_SetGamespeed = NULL; +SDK_GetGamespeed SqVC_GetGamespeed = NULL; +SDK_SetWaterLevel SqVC_SetWaterLevel = NULL; +SDK_GetWaterLevel SqVC_GetWaterLevel = NULL; +SDK_SetMaxHeight SqVC_SetMaxHeight = NULL; +SDK_GetMaxHeight SqVC_GetMaxHeight = NULL; +SDK_SetKillCmdDelay SqVC_SetKillCmdDelay = NULL; +SDK_GetKillCmdDelay SqVC_GetKillCmdDelay = NULL; +SDK_SetVehiclesForcedRespawnHeight SqVC_SetVehiclesForcedRespawnHeight = NULL; +SDK_GetVehiclesForcedRespawnHeight SqVC_GetVehiclesForcedRespawnHeight = NULL; + +// -------------------------------------------------------------------------------------------- +//WORLD: toggles +SDK_ToggleSyncFrameLimiter SqVC_ToggleSyncFrameLimiter = NULL; +SDK_EnabledSyncFrameLimiter SqVC_EnabledSyncFrameLimiter = NULL; +SDK_ToggleFrameLimiter SqVC_ToggleFrameLimiter = NULL; +SDK_EnabledFrameLimiter SqVC_EnabledFrameLimiter = NULL; +SDK_ToggleTaxiBoostJump SqVC_ToggleTaxiBoostJump = NULL; +SDK_EnabledTaxiBoostJump SqVC_EnabledTaxiBoostJump = NULL; +SDK_ToggleDriveOnWater SqVC_ToggleDriveOnWater = NULL; +SDK_EnabledDriveOnWater SqVC_EnabledDriveOnWater = NULL; +SDK_ToggleFastSwitch SqVC_ToggleFastSwitch = NULL; +SDK_EnabledFastSwitch SqVC_EnabledFastSwitch = NULL; +SDK_ToggleFriendlyFire SqVC_ToggleFriendlyFire = NULL; +SDK_EnabledFriendlyFire SqVC_EnabledFriendlyFire = NULL; +SDK_ToggleDisableDriveby SqVC_ToggleDisableDriveby = NULL; +SDK_EnabledDisableDriveby SqVC_EnabledDisableDriveby = NULL; +SDK_TogglePerfectHandling SqVC_TogglePerfectHandling = NULL; +SDK_EnabledPerfectHandling SqVC_EnabledPerfectHandling = NULL; +SDK_ToggleFlyingCars SqVC_ToggleFlyingCars = NULL; +SDK_EnabledFlyingCars SqVC_EnabledFlyingCars = NULL; +SDK_ToggleJumpSwitch SqVC_ToggleJumpSwitch = NULL; +SDK_EnabledJumpSwitch SqVC_EnabledJumpSwitch = NULL; +SDK_ToggleShowMarkers SqVC_ToggleShowMarkers = NULL; +SDK_EnabledShowMarkers SqVC_EnabledShowMarkers = NULL; +SDK_ToggleOnlyShowTeamMarkers SqVC_ToggleOnlyShowTeamMarkers = NULL; +SDK_EnabledOnlyShowTeamMarkers SqVC_EnabledOnlyShowTeamMarkers = NULL; +SDK_ToggleStuntBike SqVC_ToggleStuntBike = NULL; +SDK_EnabledStuntBike SqVC_EnabledStuntBike = NULL; +SDK_ToggleShootInAir SqVC_ToggleShootInAir = NULL; +SDK_EnabledShootInAir SqVC_EnabledShootInAir = NULL; +SDK_ToggleShowNametags SqVC_ToggleShowNametags = NULL; +SDK_EnabledShowNametags SqVC_EnabledShowNametags = NULL; +SDK_ToggleJoinMessages SqVC_ToggleJoinMessages = NULL; +SDK_EnabledJoinMessages SqVC_EnabledJoinMessages = NULL; +SDK_ToggleDeathMessages SqVC_ToggleDeathMessages = NULL; +SDK_EnabledDeathMessages SqVC_EnabledDeathMessages = NULL; +SDK_ToggleChatTagsByDefaultEnabled SqVC_ToggleChatTagsByDefaultEnabled = NULL; +SDK_EnabledChatTagsByDefault SqVC_EnabledChatTagsByDefault = NULL; + +// -------------------------------------------------------------------------------------------- +//MISC +SDK_CreateExplosion SqVC_CreateExplosion = NULL; +SDK_PlaySound SqVC_PlaySound = NULL; +SDK_HideMapObject SqVC_HideMapObject = NULL; +SDK_ShowMapObject SqVC_ShowMapObject = NULL; +SDK_ShowAllMapObjects SqVC_ShowAllMapObjects = NULL; + +//WEAPONDATA +SDK_SetWeaponDataValue SqVC_SetWeaponDataValue = NULL; +SDK_GetWeaponDataValue SqVC_GetWeaponDataValue = NULL; +SDK_ResetWeaponDataValue SqVC_ResetWeaponDataValue = NULL; +SDK_IsWeaponDataValueModified SqVC_IsWeaponDataValueModified = NULL; +SDK_ResetWeaponData SqVC_ResetWeaponData = NULL; +SDK_ResetAllWeaponData SqVC_ResetAllWeaponData = NULL; + +// -------------------------------------------------------------------------------------------- +//KEYBINDS +SDK_GetKeyBindUnusedSlot SqVC_GetKeyBindUnusedSlot = NULL; +SDK_GetKeyBindData SqVC_GetKeyBindData = NULL; +SDK_RegisterKeyBind SqVC_RegisterKeyBind = NULL; +SDK_RemoveKeyBind SqVC_RemoveKeyBind = NULL; +SDK_RemoveAllKeyBinds SqVC_RemoveAllKeyBinds = NULL; + +//BLIPS +SDK_CreateCoordBlip SqVC_CreateCoordBlip = NULL; +SDK_DestroyCoordBlip SqVC_DestroyCoordBlip = NULL; +SDK_GetCoordBlipInfo SqVC_GetCoordBlipInfo = NULL; + +// -------------------------------------------------------------------------------------------- +//SPRITES +SDK_CreateSprite SqVC_CreateSprite = NULL; +SDK_DestroySprite SqVC_DestroySprite = NULL; +SDK_ShowSprite SqVC_ShowSprite = NULL; +SDK_HideSprite SqVC_HideSprite = NULL; +SDK_MoveSprite SqVC_MoveSprite = NULL; +SDK_SetSpriteCenter SqVC_SetSpriteCenter = NULL; +SDK_RotateSprite SqVC_RotateSprite = NULL; +SDK_SetSpriteAlpha SqVC_SetSpriteAlpha = NULL; +SDK_SetSpriteRelativity SqVC_SetSpriteRelativity = NULL; + +//TEXTDRAWS +SDK_CreateTextdraw SqVC_CreateTextdraw = NULL; +SDK_DestroyTextdraw SqVC_DestroyTextdraw = NULL; +SDK_ShowTextdraw SqVC_ShowTextdraw = NULL; +SDK_HideTextdraw SqVC_HideTextdraw = NULL; +SDK_MoveTextdraw SqVC_MoveTextdraw = NULL; +SDK_SetTextdrawColour SqVC_SetTextdrawColour = NULL; +SDK_SetTextdrawRelativity SqVC_SetTextdrawRelativity = NULL; + +// -------------------------------------------------------------------------------------------- +//RADIOS +SDK_AddRadioStream SqVC_AddRadioStream = NULL; +SDK_RemoveRadioStream SqVC_RemoveRadioStream = NULL; + +// -------------------------------------------------------------------------------------------- +//CLASSES +SDK_SetUseClasses SqVC_SetUseClasses = NULL; +SDK_GetUseClasses SqVC_GetUseClasses = NULL; +SDK_GetPlayerClass SqVC_GetPlayerClass = NULL; +SDK_AddPlayerClass SqVC_AddPlayerClass = NULL; +SDK_SetSpawnPlayerPos SqVC_SetSpawnPlayerPos = NULL; +SDK_SetSpawnCameraPos SqVC_SetSpawnCameraPos = NULL; +SDK_SetSpawnCameraLookAt SqVC_SetSpawnCameraLookAt = NULL; + +// -------------------------------------------------------------------------------------------- +//ADMIN +SDK_IsPlayerAdmin SqVC_IsPlayerAdmin = NULL; +SDK_SetPlayerAdmin SqVC_SetPlayerAdmin = NULL; +SDK_GetPlayerIP SqVC_GetPlayerIP = NULL; +SDK_KickPlayer SqVC_KickPlayer = NULL; +SDK_BanPlayer SqVC_BanPlayer = NULL; +SDK_BanIP SqVC_BanIP = NULL; +SDK_UnbanIP SqVC_UnbanIP = NULL; +SDK_IsIPBanned SqVC_IsIPBanned = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: basic +SDK_GetPlayerIDFromName SqVC_GetPlayerIDFromName = NULL; +SDK_IsPlayerConnected SqVC_IsPlayerConnected = NULL; +SDK_IsPlayerSpawned SqVC_IsPlayerSpawned = NULL; +SDK_IsPlayerStreamedForPlayer SqVC_IsPlayerStreamedForPlayer = NULL; +SDK_GetPlayerKey SqVC_GetPlayerKey = NULL; +SDK_SetPlayerWorld SqVC_SetPlayerWorld = NULL; +SDK_GetPlayerWorld SqVC_GetPlayerWorld = NULL; +SDK_SetPlayerSecWorld SqVC_SetPlayerSecWorld = NULL; +SDK_GetPlayerSecWorld SqVC_GetPlayerSecWorld = NULL; +SDK_GetPlayerUniqueWorld SqVC_GetPlayerUniqueWorld = NULL; +SDK_IsPlayerWorldCompatible SqVC_IsPlayerWorldCompatible = NULL; +SDK_GetPlayerState SqVC_GetPlayerState = NULL; +SDK_GetPlayerName SqVC_GetPlayerName = NULL; +SDK_SetPlayerName SqVC_SetPlayerName = NULL; +SDK_SetPlayerTeam SqVC_SetPlayerTeam = NULL; +SDK_GetPlayerTeam SqVC_GetPlayerTeam = NULL; +SDK_SetPlayerSkin SqVC_SetPlayerSkin = NULL; +SDK_GetPlayerSkin SqVC_GetPlayerSkin = NULL; +SDK_SetPlayerColour SqVC_SetPlayerColour = NULL; +SDK_GetPlayerColour SqVC_GetPlayerColour = NULL; +SDK_ForcePlayerSpawn SqVC_ForcePlayerSpawn = NULL; +SDK_ForcePlayerSelect SqVC_ForcePlayerSelect = NULL; +SDK_ForceAllSelect SqVC_ForceAllSelect = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: score, ping, money, typing +SDK_GivePlayerMoney SqVC_GivePlayerMoney = NULL; +SDK_SetPlayerMoney SqVC_SetPlayerMoney = NULL; +SDK_GetPlayerMoney SqVC_GetPlayerMoney = NULL; +SDK_SetPlayerScore SqVC_SetPlayerScore = NULL; +SDK_GetPlayerScore SqVC_GetPlayerScore = NULL; +SDK_GetPlayerPing SqVC_GetPlayerPing = NULL; +SDK_IsPlayerTyping SqVC_IsPlayerTyping = NULL; +SDK_GetPlayerFPS SqVC_GetPlayerFPS = NULL; +SDK_GetPlayerUID SqVC_GetPlayerUID = NULL; +SDK_GetPlayerWantedLevel SqVC_GetPlayerWantedLevel = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: health and location +SDK_SetPlayerHealth SqVC_SetPlayerHealth = NULL; +SDK_GetPlayerHealth SqVC_GetPlayerHealth = NULL; +SDK_SetPlayerArmour SqVC_SetPlayerArmour = NULL; +SDK_GetPlayerArmour SqVC_GetPlayerArmour = NULL; +SDK_SetPlayerImmunityFlags SqVC_SetPlayerImmunityFlags = NULL; +SDK_GetPlayerImmunityFlags SqVC_GetPlayerImmunityFlags = NULL; +SDK_SetPlayerPos SqVC_SetPlayerPos = NULL; +SDK_GetPlayerPos SqVC_GetPlayerPos = NULL; +SDK_SetPlayerSpeed SqVC_SetPlayerSpeed = NULL; +SDK_GetPlayerSpeed SqVC_GetPlayerSpeed = NULL; +SDK_AddPlayerSpeed SqVC_AddPlayerSpeed = NULL; +SDK_SetPlayerHeading SqVC_SetPlayerHeading = NULL; +SDK_GetPlayerHeading SqVC_GetPlayerHeading = NULL; +SDK_SetPlayerAlpha SqVC_SetPlayerAlpha = NULL; +SDK_GetPlayerAlpha SqVC_GetPlayerAlpha = NULL; +SDK_GetPlayerOnFireStatus SqVC_GetPlayerOnFireStatus = NULL; +SDK_GetPlayerCrouchStatus SqVC_GetPlayerCrouchStatus = NULL; +SDK_GetPlayerAction SqVC_GetPlayerAction = NULL; +SDK_GetPlayerGameKeys SqVC_GetPlayerGameKeys = NULL; +SDK_GetPlayerAimPos SqVC_GetPlayerAimPos = NULL; +SDK_GetPlayerAimDir SqVC_GetPlayerAimDir = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: vehicle +SDK_PutPlayerInVehicle SqVC_PutPlayerInVehicle = NULL; +SDK_RemovePlayerFromVehicle SqVC_RemovePlayerFromVehicle = NULL; +SDK_GetPlayerInVehicleStatus SqVC_GetPlayerInVehicleStatus = NULL; +SDK_GetPlayerInVehicleSlot SqVC_GetPlayerInVehicleSlot = NULL; +SDK_GetPlayerVehicleID SqVC_GetPlayerVehicleID = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: toggles +SDK_TogglePlayerControllable SqVC_TogglePlayerControllable = NULL; +SDK_EnabledPlayerControllable SqVC_EnabledPlayerControllable = NULL; +SDK_TogglePlayerDriveby SqVC_TogglePlayerDriveby = NULL; +SDK_EnabledPlayerDriveby SqVC_EnabledPlayerDriveby = NULL; +SDK_TogglePlayerWhiteScanlines SqVC_TogglePlayerWhiteScanlines = NULL; +SDK_EnabledPlayerWhiteScanlines SqVC_EnabledPlayerWhiteScanlines = NULL; +SDK_TogglePlayerGreenScanlines SqVC_TogglePlayerGreenScanlines = NULL; +SDK_EnabledPlayerGreenScanlines SqVC_EnabledPlayerGreenScanlines = NULL; +SDK_TogglePlayerWidescreen SqVC_TogglePlayerWidescreen = NULL; +SDK_EnabledPlayerWidescreen SqVC_EnabledPlayerWidescreen = NULL; +SDK_TogglePlayerShowMarkers SqVC_TogglePlayerShowMarkers = NULL; +SDK_EnabledPlayerShowMarkers SqVC_EnabledPlayerShowMarkers = NULL; +SDK_TogglePlayerAttackPriv SqVC_TogglePlayerAttackPriv = NULL; +SDK_EnabledPlayerAttackPriv SqVC_EnabledPlayerAttackPriv = NULL; +SDK_TogglePlayerHasMarker SqVC_TogglePlayerHasMarker = NULL; +SDK_EnabledPlayerHasMarker SqVC_EnabledPlayerHasMarker = NULL; +SDK_TogglePlayerChatTagsEnabled SqVC_TogglePlayerChatTagsEnabled = NULL; +SDK_EnabledPlayerChatTags SqVC_EnabledPlayerChatTags = NULL; +SDK_TogglePlayerDrunkEffects SqVC_TogglePlayerDrunkEffects = NULL; +SDK_EnabledPlayerDrunkEffects SqVC_EnabledPlayerDrunkEffects = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: weapons +SDK_GivePlayerWeapon SqVC_GivePlayerWeapon = NULL; +SDK_SetPlayerWeapon SqVC_SetPlayerWeapon = NULL; +SDK_GetPlayerWeapon SqVC_GetPlayerWeapon = NULL; +SDK_GetPlayerWeaponAmmo SqVC_GetPlayerWeaponAmmo = NULL; +SDK_SetPlayerWeaponSlot SqVC_SetPlayerWeaponSlot = NULL; +SDK_GetPlayerWeaponSlot SqVC_GetPlayerWeaponSlot = NULL; +SDK_GetPlayerWeaponAtSlot SqVC_GetPlayerWeaponAtSlot = NULL; +SDK_GetPlayerAmmoAtSlot SqVC_GetPlayerAmmoAtSlot = NULL; +SDK_RemovePlayerWeapon SqVC_RemovePlayerWeapon = NULL; +SDK_RemoveAllWeapons SqVC_RemoveAllWeapons = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: camera +SDK_SetCameraPosition SqVC_SetCameraPosition = NULL; +SDK_RestoreCamera SqVC_RestoreCamera = NULL; +SDK_IsCameraLocked SqVC_IsCameraLocked = NULL; + +// -------------------------------------------------------------------------------------------- +//PLAYERS: misc +SDK_SetPlayerAnimation SqVC_SetPlayerAnimation = NULL; +SDK_SetPlayerWantedLevel SqVC_SetPlayerWantedLevel = NULL; +SDK_GetPlayerStandingOnVehicle SqVC_GetPlayerStandingOnVehicle = NULL; +SDK_GetPlayerStandingOnObject SqVC_GetPlayerStandingOnObject = NULL; +SDK_IsPlayerAway SqVC_IsPlayerAway = NULL; +SDK_GetPlayerSpectateTarget SqVC_GetPlayerSpectateTarget = NULL; +SDK_SetPlayerSpectateTarget SqVC_SetPlayerSpectateTarget = NULL; +SDK_RedirectPlayerToServer SqVC_RedirectPlayerToServer = NULL; + +// -------------------------------------------------------------------------------------------- +//VEHICLES +SDK_CreateVehicle SqVC_CreateVehicle = NULL; +SDK_DeleteVehicle SqVC_DeleteVehicle = NULL; +SDK_GetVehicleSyncSource SqVC_GetVehicleSyncSource = NULL; +SDK_GetVehicleSyncType SqVC_GetVehicleSyncType = NULL; +SDK_IsVehicleStreamedForPlayer SqVC_IsVehicleStreamedForPlayer = NULL; +SDK_SetVehicleWorld SqVC_SetVehicleWorld = NULL; +SDK_GetVehicleWorld SqVC_GetVehicleWorld = NULL; +SDK_GetVehicleModel SqVC_GetVehicleModel = NULL; +SDK_GetVehicleOccupant SqVC_GetVehicleOccupant = NULL; +SDK_RespawnVehicle SqVC_RespawnVehicle = NULL; +SDK_SetVehicleImmunityFlags SqVC_SetVehicleImmunityFlags = NULL; +SDK_GetVehicleImmunityFlags SqVC_GetVehicleImmunityFlags = NULL; +SDK_KillVehicle SqVC_KillVehicle = NULL; +SDK_IsVehicleWrecked SqVC_IsVehicleWrecked = NULL; +SDK_SetVehiclePos SqVC_SetVehiclePos = NULL; +SDK_GetVehiclePos SqVC_GetVehiclePos = NULL; +SDK_SetVehicleRot SqVC_SetVehicleRot = NULL; +SDK_SetVehicleRotEuler SqVC_SetVehicleRotEuler = NULL; +SDK_GetVehicleRot SqVC_GetVehicleRot = NULL; +SDK_GetVehicleRotEuler SqVC_GetVehicleRotEuler = NULL; +SDK_SetVehicleSpeed SqVC_SetVehicleSpeed = NULL; +SDK_GetVehicleSpeed SqVC_GetVehicleSpeed = NULL; +SDK_AddVehicleSpeed SqVC_AddVehicleSpeed = NULL; +SDK_SetVehicleRelSpeed SqVC_SetVehicleRelSpeed = NULL; +SDK_GetVehicleRelSpeed SqVC_GetVehicleRelSpeed = NULL; +SDK_AddVehicleRelSpeed SqVC_AddVehicleRelSpeed = NULL; +SDK_SetVehicleTurnSpeed SqVC_SetVehicleTurnSpeed = NULL; +SDK_GetVehicleTurnSpeed SqVC_GetVehicleTurnSpeed = NULL; +SDK_AddVehicleTurnSpeed SqVC_AddVehicleTurnSpeed = NULL; +SDK_SetVehicleRelTurnSpeed SqVC_SetVehicleRelTurnSpeed = NULL; +SDK_GetVehicleRelTurnSpeed SqVC_GetVehicleRelTurnSpeed = NULL; +SDK_AddVehicleRelTurnSpeed SqVC_AddVehicleRelTurnSpeed = NULL; +SDK_SetVehicleSpawnPos SqVC_SetVehicleSpawnPos = NULL; +SDK_GetVehicleSpawnPos SqVC_GetVehicleSpawnPos = NULL; +SDK_SetVehicleSpawnRot SqVC_SetVehicleSpawnRot = NULL; +SDK_SetVehicleSpawnRotEuler SqVC_SetVehicleSpawnRotEuler = NULL; +SDK_GetVehicleSpawnRot SqVC_GetVehicleSpawnRot = NULL; +SDK_GetVehicleSpawnRotEuler SqVC_GetVehicleSpawnRotEuler = NULL; +SDK_SetVehicleIdleRespawnTimer SqVC_SetVehicleIdleRespawnTimer = NULL; +SDK_GetVehicleIdleRespawnTimer SqVC_GetVehicleIdleRespawnTimer = NULL; +SDK_SetVehicleHealth SqVC_SetVehicleHealth = NULL; +SDK_GetVehicleHealth SqVC_GetVehicleHealth = NULL; +SDK_SetVehicleColour SqVC_SetVehicleColour = NULL; +SDK_GetVehicleColour SqVC_GetVehicleColour = NULL; +SDK_SetVehicleDoorsLocked SqVC_SetVehicleDoorsLocked = NULL; +SDK_GetVehicleDoorsLocked SqVC_GetVehicleDoorsLocked = NULL; +SDK_SetVehiclePartStatus SqVC_SetVehiclePartStatus = NULL; +SDK_GetVehiclePartStatus SqVC_GetVehiclePartStatus = NULL; +SDK_SetVehicleTyreStatus SqVC_SetVehicleTyreStatus = NULL; +SDK_GetVehicleTyreStatus SqVC_GetVehicleTyreStatus = NULL; +SDK_SetVehicleDamageData SqVC_SetVehicleDamageData = NULL; +SDK_GetVehicleDamageData SqVC_GetVehicleDamageData = NULL; +SDK_SetVehicleAlarm SqVC_SetVehicleAlarm = NULL; +SDK_GetVehicleAlarm SqVC_GetVehicleAlarm = NULL; +SDK_SetVehicleLights SqVC_SetVehicleLights = NULL; +SDK_GetVehicleLights SqVC_GetVehicleLights = NULL; +SDK_SetVehicleRadio SqVC_SetVehicleRadio = NULL; +SDK_GetVehicleRadio SqVC_GetVehicleRadio = NULL; +SDK_SetVehicleRadioLocked SqVC_SetVehicleRadioLocked = NULL; +SDK_IsVehicleRadioLocked SqVC_IsVehicleRadioLocked = NULL; +SDK_GetVehicleGhostState SqVC_GetVehicleGhostState = NULL; +SDK_SetVehicleGhostState SqVC_SetVehicleGhostState = NULL; +SDK_GetVehicleTurretRotation SqVC_GetVehicleTurretRotation = NULL; + +// -------------------------------------------------------------------------------------------- +//VEHICLES: handling +SDK_ResetAllVehicleHandlings SqVC_ResetAllVehicleHandlings = NULL; +SDK_ExistsHandlingRule SqVC_ExistsHandlingRule = NULL; +SDK_SetHandlingRule SqVC_SetHandlingRule = NULL; +SDK_GetHandlingRule SqVC_GetHandlingRule = NULL; +SDK_ResetHandlingRule SqVC_ResetHandlingRule = NULL; +SDK_ResetHandling SqVC_ResetHandling = NULL; +SDK_ExistsInstHandlingRule SqVC_ExistsInstHandlingRule = NULL; +SDK_SetInstHandlingRule SqVC_SetInstHandlingRule = NULL; +SDK_GetInstHandlingRule SqVC_GetInstHandlingRule = NULL; +SDK_ResetInstHandlingRule SqVC_ResetInstHandlingRule = NULL; +SDK_ResetInstHandling SqVC_ResetInstHandling = NULL; + +// -------------------------------------------------------------------------------------------- +//PICKUPS +SDK_CreatePickup SqVC_CreatePickup = NULL; +SDK_DeletePickup SqVC_DeletePickup = NULL; +SDK_IsPickupStreamedForPlayer SqVC_IsPickupStreamedForPlayer = NULL; +SDK_SetPickupWorld SqVC_SetPickupWorld = NULL; +SDK_GetPickupWorld SqVC_GetPickupWorld = NULL; +SDK_PickupGetAlpha SqVC_PickupGetAlpha = NULL; +SDK_PickupSetAlpha SqVC_PickupSetAlpha = NULL; +SDK_PickupIsAutomatic SqVC_PickupIsAutomatic = NULL; +SDK_PickupSetAutomatic SqVC_PickupSetAutomatic = NULL; +SDK_SetPickupAutoTimer SqVC_SetPickupAutoTimer = NULL; +SDK_GetPickupAutoTimer SqVC_GetPickupAutoTimer = NULL; +SDK_PickupRefresh SqVC_PickupRefresh = NULL; +SDK_PickupGetPos SqVC_PickupGetPos = NULL; +SDK_PickupSetPos SqVC_PickupSetPos = NULL; +SDK_PickupGetModel SqVC_PickupGetModel = NULL; +SDK_PickupGetQuantity SqVC_PickupGetQuantity = NULL; + +// -------------------------------------------------------------------------------------------- +//OBJECTS +SDK_CreateObject SqVC_CreateObject = NULL; +SDK_DeleteObject SqVC_DeleteObject = NULL; +SDK_IsObjectStreamedForPlayer SqVC_IsObjectStreamedForPlayer = NULL; +SDK_GetObjectModel SqVC_GetObjectModel = NULL; +SDK_SetObjectWorld SqVC_SetObjectWorld = NULL; +SDK_GetObjectWorld SqVC_GetObjectWorld = NULL; +SDK_SetObjectAlpha SqVC_SetObjectAlpha = NULL; +SDK_GetObjectAlpha SqVC_GetObjectAlpha = NULL; +SDK_MoveObjectTo SqVC_MoveObjectTo = NULL; +SDK_MoveObjectBy SqVC_MoveObjectBy = NULL; +SDK_SetObjectPos SqVC_SetObjectPos = NULL; +SDK_GetObjectPos SqVC_GetObjectPos = NULL; +SDK_RotObjectTo SqVC_RotObjectTo = NULL; +SDK_RotObjectToEuler SqVC_RotObjectToEuler = NULL; +SDK_RotObjectBy SqVC_RotObjectBy = NULL; +SDK_RotObjectByEuler SqVC_RotObjectByEuler = NULL; +SDK_GetObjectRot SqVC_GetObjectRot = NULL; +SDK_GetObjectRotEuler SqVC_GetObjectRotEuler = NULL; +SDK_SetObjectShotReport SqVC_SetObjectShotReport = NULL; +SDK_IsObjectShotReport SqVC_IsObjectShotReport = NULL; +SDK_SetObjectBumpReport SqVC_SetObjectBumpReport = NULL; +SDK_IsObjectBumpReport SqVC_IsObjectBumpReport = NULL; + +// -------------------------------------------------------------------------------------------- +// TODO: Move these functions to proper sections on major plugin update +SDK_ToggleWallglitch SqVC_ToggleWallglitch = NULL; +SDK_EnabledWallglitch SqVC_EnabledWallglitch = NULL; +SDK_SetVehicleSiren SqVC_SetVehicleSiren = NULL; +SDK_GetVehicleSiren SqVC_GetVehicleSiren = NULL; +SDK_GetPlayerUID2 SqVC_GetPlayerUID2 = NULL; + +// -------------------------------------------------------------------------------------------- +SDK_CreateCheckpoint SqVC_CreateCheckpoint = NULL; +SDK_DeleteCheckpoint SqVC_DeleteCheckpoint = NULL; +SDK_IsCheckpointStreamedForPlayer SqVC_IsCheckpointStreamedForPlayer = NULL; +SDK_SetCheckpointWorld SqVC_SetCheckpointWorld = NULL; +SDK_GetCheckpointWorld SqVC_GetCheckpointWorld = NULL; +SDK_SetCheckpointColor SqVC_SetCheckpointColor = NULL; +SDK_GetCheckpointColor SqVC_GetCheckpointColor = NULL; +SDK_SetCheckpointPos SqVC_SetCheckpointPos = NULL; +SDK_GetCheckpointPos SqVC_GetCheckpointPos = NULL; +SDK_SetCheckpointRadius SqVC_SetCheckpointRadius = NULL; +SDK_GetCheckpointRadius SqVC_GetCheckpointRadius = NULL; +SDK_GetCheckpointOwner SqVC_GetCheckpointOwner = NULL; + +// -------------------------------------------------------------------------------------------- +SDK_CreateSphere SqVC_CreateSphere = NULL; +SDK_DeleteSphere SqVC_DeleteSphere = NULL; +SDK_IsSphereStreamedForPlayer SqVC_IsSphereStreamedForPlayer = NULL; +SDK_SetSphereWorld SqVC_SetSphereWorld = NULL; +SDK_GetSphereWorld SqVC_GetSphereWorld = NULL; +SDK_SetSphereColor SqVC_SetSphereColor = NULL; +SDK_GetSphereColor SqVC_GetSphereColor = NULL; +SDK_SetSpherePos SqVC_SetSpherePos = NULL; +SDK_GetSpherePos SqVC_GetSpherePos = NULL; +SDK_SetSphereRadius SqVC_SetSphereRadius = NULL; +SDK_GetSphereRadius SqVC_GetSphereRadius = NULL; +SDK_GetSphereOwner SqVC_GetSphereOwner = NULL; + +// ------------------------------------------------------------------------------------------------ +SQRESULT vc_api_expand(PluginFuncs * vcapi) +{ + if (!vcapi) + return SQ_ERROR; + + // -------------------------------------------------------------------------------------------- + //PLUGIN SYSTEM + SqVC_GetServerVersion = vcapi->GetServerVersion; + SqVC_GetServerSettings = vcapi->GetServerSettings; + SqVC_ExportFunctions = vcapi->ExportFunctions; + SqVC_GetNumberOfPlugins = vcapi->GetNumberOfPlugins; + SqVC_GetPluginInfo = vcapi->GetPluginInfo; + SqVC_FindPlugin = vcapi->FindPlugin; + SqVC_GetPluginExports = vcapi->GetPluginExports; + SqVC_GetTime = vcapi->GetTime; + + // -------------------------------------------------------------------------------------------- + //MESSAGES + SqVC_printf = vcapi->printf; + SqVC_SendCustomCommand = vcapi->SendCustomCommand; + SqVC_SendClientMessage = vcapi->SendClientMessage; + SqVC_SendGameMessage = vcapi->SendGameMessage; + + // -------------------------------------------------------------------------------------------- + //SERVER SETTINGS + SqVC_SetServerName = vcapi->SetServerName; + SqVC_GetServerName = vcapi->GetServerName; + SqVC_SetMaxPlayers = vcapi->SetMaxPlayers; + SqVC_GetMaxPlayers = vcapi->GetMaxPlayers; + SqVC_SetServerPassword = vcapi->SetServerPassword; + SqVC_GetServerPassword = vcapi->GetServerPassword; + SqVC_SetGameModeText = vcapi->SetGameModeText; + SqVC_GetGameModeText = vcapi->GetGameModeText; + SqVC_ShutdownServer = vcapi->ShutdownServer; + + // -------------------------------------------------------------------------------------------- + //WORLD: settings + SqVC_SetWorldBounds = vcapi->SetWorldBounds; + SqVC_GetWorldBounds = vcapi->GetWorldBounds; + SqVC_SetWastedSettings = vcapi->SetWastedSettings; + SqVC_GetWastedSettings = vcapi->GetWastedSettings; + SqVC_SetTimeRate = vcapi->SetTimeRate; + SqVC_GetTimeRate = vcapi->GetTimeRate; + SqVC_SetHour = vcapi->SetHour; + SqVC_GetHour = vcapi->GetHour; + SqVC_SetMinute = vcapi->SetMinute; + SqVC_GetMinute = vcapi->GetMinute; + SqVC_SetWeather = vcapi->SetWeather; + SqVC_GetWeather = vcapi->GetWeather; + SqVC_SetGravity = vcapi->SetGravity; + SqVC_GetGravity = vcapi->GetGravity; + SqVC_SetGamespeed = vcapi->SetGamespeed; + SqVC_GetGamespeed = vcapi->GetGamespeed; + SqVC_SetWaterLevel = vcapi->SetWaterLevel; + SqVC_GetWaterLevel = vcapi->GetWaterLevel; + SqVC_SetMaxHeight = vcapi->SetMaxHeight; + SqVC_GetMaxHeight = vcapi->GetMaxHeight; + SqVC_SetKillCmdDelay = vcapi->SetKillCmdDelay; + SqVC_GetKillCmdDelay = vcapi->GetKillCmdDelay; + SqVC_SetVehiclesForcedRespawnHeight = vcapi->SetVehiclesForcedRespawnHeight; + SqVC_GetVehiclesForcedRespawnHeight = vcapi->GetVehiclesForcedRespawnHeight; + + // -------------------------------------------------------------------------------------------- + //WORLD: toggles + SqVC_ToggleSyncFrameLimiter = vcapi->ToggleSyncFrameLimiter; + SqVC_EnabledSyncFrameLimiter = vcapi->EnabledSyncFrameLimiter; + SqVC_ToggleFrameLimiter = vcapi->ToggleFrameLimiter; + SqVC_EnabledFrameLimiter = vcapi->EnabledFrameLimiter; + SqVC_ToggleTaxiBoostJump = vcapi->ToggleTaxiBoostJump; + SqVC_EnabledTaxiBoostJump = vcapi->EnabledTaxiBoostJump; + SqVC_ToggleDriveOnWater = vcapi->ToggleDriveOnWater; + SqVC_EnabledDriveOnWater = vcapi->EnabledDriveOnWater; + SqVC_ToggleFastSwitch = vcapi->ToggleFastSwitch; + SqVC_EnabledFastSwitch = vcapi->EnabledFastSwitch; + SqVC_ToggleFriendlyFire = vcapi->ToggleFriendlyFire; + SqVC_EnabledFriendlyFire = vcapi->EnabledFriendlyFire; + SqVC_ToggleDisableDriveby = vcapi->ToggleDisableDriveby; + SqVC_EnabledDisableDriveby = vcapi->EnabledDisableDriveby; + SqVC_TogglePerfectHandling = vcapi->TogglePerfectHandling; + SqVC_EnabledPerfectHandling = vcapi->EnabledPerfectHandling; + SqVC_ToggleFlyingCars = vcapi->ToggleFlyingCars; + SqVC_EnabledFlyingCars = vcapi->EnabledFlyingCars; + SqVC_ToggleJumpSwitch = vcapi->ToggleJumpSwitch; + SqVC_EnabledJumpSwitch = vcapi->EnabledJumpSwitch; + SqVC_ToggleShowMarkers = vcapi->ToggleShowMarkers; + SqVC_EnabledShowMarkers = vcapi->EnabledShowMarkers; + SqVC_ToggleOnlyShowTeamMarkers = vcapi->ToggleOnlyShowTeamMarkers; + SqVC_EnabledOnlyShowTeamMarkers = vcapi->EnabledOnlyShowTeamMarkers; + SqVC_ToggleStuntBike = vcapi->ToggleStuntBike; + SqVC_EnabledStuntBike = vcapi->EnabledStuntBike; + SqVC_ToggleShootInAir = vcapi->ToggleShootInAir; + SqVC_EnabledShootInAir = vcapi->EnabledShootInAir; + SqVC_ToggleShowNametags = vcapi->ToggleShowNametags; + SqVC_EnabledShowNametags = vcapi->EnabledShowNametags; + SqVC_ToggleJoinMessages = vcapi->ToggleJoinMessages; + SqVC_EnabledJoinMessages = vcapi->EnabledJoinMessages; + SqVC_ToggleDeathMessages = vcapi->ToggleDeathMessages; + SqVC_EnabledDeathMessages = vcapi->EnabledDeathMessages; + SqVC_ToggleChatTagsByDefaultEnabled = vcapi->ToggleChatTagsByDefaultEnabled; + SqVC_EnabledChatTagsByDefault = vcapi->EnabledChatTagsByDefault; + + // -------------------------------------------------------------------------------------------- + //MISC + SqVC_CreateExplosion = vcapi->CreateExplosion; + SqVC_PlaySound = vcapi->PlaySound; + SqVC_HideMapObject = vcapi->HideMapObject; + SqVC_ShowMapObject = vcapi->ShowMapObject; + SqVC_ShowAllMapObjects = vcapi->ShowAllMapObjects; + + //WEAPONDATA + SqVC_SetWeaponDataValue = vcapi->SetWeaponDataValue; + SqVC_GetWeaponDataValue = vcapi->GetWeaponDataValue; + SqVC_ResetWeaponDataValue = vcapi->ResetWeaponDataValue; + SqVC_IsWeaponDataValueModified = vcapi->IsWeaponDataValueModified; + SqVC_ResetWeaponData = vcapi->ResetWeaponData; + SqVC_ResetAllWeaponData = vcapi->ResetAllWeaponData; + + // -------------------------------------------------------------------------------------------- + //KEYBINDS + SqVC_GetKeyBindUnusedSlot = vcapi->GetKeyBindUnusedSlot; + SqVC_GetKeyBindData = vcapi->GetKeyBindData; + SqVC_RegisterKeyBind = vcapi->RegisterKeyBind; + SqVC_RemoveKeyBind = vcapi->RemoveKeyBind; + SqVC_RemoveAllKeyBinds = vcapi->RemoveAllKeyBinds; + + //BLIPS + SqVC_CreateCoordBlip = vcapi->CreateCoordBlip; + SqVC_DestroyCoordBlip = vcapi->DestroyCoordBlip; + SqVC_GetCoordBlipInfo = vcapi->GetCoordBlipInfo; + + // -------------------------------------------------------------------------------------------- + //SPRITES + SqVC_CreateSprite = vcapi->CreateSprite; + SqVC_DestroySprite = vcapi->DestroySprite; + SqVC_ShowSprite = vcapi->ShowSprite; + SqVC_HideSprite = vcapi->HideSprite; + SqVC_MoveSprite = vcapi->MoveSprite; + SqVC_SetSpriteCenter = vcapi->SetSpriteCenter; + SqVC_RotateSprite = vcapi->RotateSprite; + SqVC_SetSpriteAlpha = vcapi->SetSpriteAlpha; + SqVC_SetSpriteRelativity = vcapi->SetSpriteRelativity; + + //TEXTDRAWS + SqVC_CreateTextdraw = vcapi->CreateTextdraw; + SqVC_DestroyTextdraw = vcapi->DestroyTextdraw; + SqVC_ShowTextdraw = vcapi->ShowTextdraw; + SqVC_HideTextdraw = vcapi->HideTextdraw; + SqVC_MoveTextdraw = vcapi->MoveTextdraw; + SqVC_SetTextdrawColour = vcapi->SetTextdrawColour; + SqVC_SetTextdrawRelativity = vcapi->SetTextdrawRelativity; + + // -------------------------------------------------------------------------------------------- + //RADIOS + SqVC_AddRadioStream = vcapi->AddRadioStream; + SqVC_RemoveRadioStream = vcapi->RemoveRadioStream; + + // -------------------------------------------------------------------------------------------- + //CLASSES + SqVC_SetUseClasses = vcapi->SetUseClasses; + SqVC_GetUseClasses = vcapi->GetUseClasses; + SqVC_GetPlayerClass = vcapi->GetPlayerClass; + SqVC_AddPlayerClass = vcapi->AddPlayerClass; + SqVC_SetSpawnPlayerPos = vcapi->SetSpawnPlayerPos; + SqVC_SetSpawnCameraPos = vcapi->SetSpawnCameraPos; + SqVC_SetSpawnCameraLookAt = vcapi->SetSpawnCameraLookAt; + + // -------------------------------------------------------------------------------------------- + //ADMIN + SqVC_IsPlayerAdmin = vcapi->IsPlayerAdmin; + SqVC_SetPlayerAdmin = vcapi->SetPlayerAdmin; + SqVC_GetPlayerIP = vcapi->GetPlayerIP; + SqVC_KickPlayer = vcapi->KickPlayer; + SqVC_BanPlayer = vcapi->BanPlayer; + SqVC_BanIP = vcapi->BanIP; + SqVC_UnbanIP = vcapi->UnbanIP; + SqVC_IsIPBanned = vcapi->IsIPBanned; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: basic + SqVC_GetPlayerIDFromName = vcapi->GetPlayerIDFromName; + SqVC_IsPlayerConnected = vcapi->IsPlayerConnected; + SqVC_IsPlayerSpawned = vcapi->IsPlayerSpawned; + SqVC_IsPlayerStreamedForPlayer = vcapi->IsPlayerStreamedForPlayer; + SqVC_GetPlayerKey = vcapi->GetPlayerKey; + SqVC_SetPlayerWorld = vcapi->SetPlayerWorld; + SqVC_GetPlayerWorld = vcapi->GetPlayerWorld; + SqVC_SetPlayerSecWorld = vcapi->SetPlayerSecWorld; + SqVC_GetPlayerSecWorld = vcapi->GetPlayerSecWorld; + SqVC_GetPlayerUniqueWorld = vcapi->GetPlayerUniqueWorld; + SqVC_IsPlayerWorldCompatible = vcapi->IsPlayerWorldCompatible; + SqVC_GetPlayerState = vcapi->GetPlayerState; + SqVC_GetPlayerName = vcapi->GetPlayerName; + SqVC_SetPlayerName = vcapi->SetPlayerName; + SqVC_SetPlayerTeam = vcapi->SetPlayerTeam; + SqVC_GetPlayerTeam = vcapi->GetPlayerTeam; + SqVC_SetPlayerSkin = vcapi->SetPlayerSkin; + SqVC_GetPlayerSkin = vcapi->GetPlayerSkin; + SqVC_SetPlayerColour = vcapi->SetPlayerColour; + SqVC_GetPlayerColour = vcapi->GetPlayerColour; + SqVC_ForcePlayerSpawn = vcapi->ForcePlayerSpawn; + SqVC_ForcePlayerSelect = vcapi->ForcePlayerSelect; + SqVC_ForceAllSelect = vcapi->ForceAllSelect; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: score, ping, money, typing + SqVC_GivePlayerMoney = vcapi->GivePlayerMoney; + SqVC_SetPlayerMoney = vcapi->SetPlayerMoney; + SqVC_GetPlayerMoney = vcapi->GetPlayerMoney; + SqVC_SetPlayerScore = vcapi->SetPlayerScore; + SqVC_GetPlayerScore = vcapi->GetPlayerScore; + SqVC_GetPlayerPing = vcapi->GetPlayerPing; + SqVC_IsPlayerTyping = vcapi->IsPlayerTyping; + SqVC_GetPlayerFPS = vcapi->GetPlayerFPS; + SqVC_GetPlayerUID = vcapi->GetPlayerUID; + SqVC_GetPlayerWantedLevel = vcapi->GetPlayerWantedLevel; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: health and location + SqVC_SetPlayerHealth = vcapi->SetPlayerHealth; + SqVC_GetPlayerHealth = vcapi->GetPlayerHealth; + SqVC_SetPlayerArmour = vcapi->SetPlayerArmour; + SqVC_GetPlayerArmour = vcapi->GetPlayerArmour; + SqVC_SetPlayerImmunityFlags = vcapi->SetPlayerImmunityFlags; + SqVC_GetPlayerImmunityFlags = vcapi->GetPlayerImmunityFlags; + SqVC_SetPlayerPos = vcapi->SetPlayerPos; + SqVC_GetPlayerPos = vcapi->GetPlayerPos; + SqVC_SetPlayerSpeed = vcapi->SetPlayerSpeed; + SqVC_GetPlayerSpeed = vcapi->GetPlayerSpeed; + SqVC_AddPlayerSpeed = vcapi->AddPlayerSpeed; + SqVC_SetPlayerHeading = vcapi->SetPlayerHeading; + SqVC_GetPlayerHeading = vcapi->GetPlayerHeading; + SqVC_SetPlayerAlpha = vcapi->SetPlayerAlpha; + SqVC_GetPlayerAlpha = vcapi->GetPlayerAlpha; + SqVC_GetPlayerOnFireStatus = vcapi->GetPlayerOnFireStatus; + SqVC_GetPlayerCrouchStatus = vcapi->GetPlayerCrouchStatus; + SqVC_GetPlayerAction = vcapi->GetPlayerAction; + SqVC_GetPlayerGameKeys = vcapi->GetPlayerGameKeys; + SqVC_GetPlayerAimPos = vcapi->GetPlayerAimPos; + SqVC_GetPlayerAimDir = vcapi->GetPlayerAimDir; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: vehicle + SqVC_PutPlayerInVehicle = vcapi->PutPlayerInVehicle; + SqVC_RemovePlayerFromVehicle = vcapi->RemovePlayerFromVehicle; + SqVC_GetPlayerInVehicleStatus = vcapi->GetPlayerInVehicleStatus; + SqVC_GetPlayerInVehicleSlot = vcapi->GetPlayerInVehicleSlot; + SqVC_GetPlayerVehicleID = vcapi->GetPlayerVehicleID; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: toggles + SqVC_TogglePlayerControllable = vcapi->TogglePlayerControllable; + SqVC_EnabledPlayerControllable = vcapi->EnabledPlayerControllable; + SqVC_TogglePlayerDriveby = vcapi->TogglePlayerDriveby; + SqVC_EnabledPlayerDriveby = vcapi->EnabledPlayerDriveby; + SqVC_TogglePlayerWhiteScanlines = vcapi->TogglePlayerWhiteScanlines; + SqVC_EnabledPlayerWhiteScanlines = vcapi->EnabledPlayerWhiteScanlines; + SqVC_TogglePlayerGreenScanlines = vcapi->TogglePlayerGreenScanlines; + SqVC_EnabledPlayerGreenScanlines = vcapi->EnabledPlayerGreenScanlines; + SqVC_TogglePlayerWidescreen = vcapi->TogglePlayerWidescreen; + SqVC_EnabledPlayerWidescreen = vcapi->EnabledPlayerWidescreen; + SqVC_TogglePlayerShowMarkers = vcapi->TogglePlayerShowMarkers; + SqVC_EnabledPlayerShowMarkers = vcapi->EnabledPlayerShowMarkers; + SqVC_TogglePlayerAttackPriv = vcapi->TogglePlayerAttackPriv; + SqVC_EnabledPlayerAttackPriv = vcapi->EnabledPlayerAttackPriv; + SqVC_TogglePlayerHasMarker = vcapi->TogglePlayerHasMarker; + SqVC_EnabledPlayerHasMarker = vcapi->EnabledPlayerHasMarker; + SqVC_TogglePlayerChatTagsEnabled = vcapi->TogglePlayerChatTagsEnabled; + SqVC_EnabledPlayerChatTags = vcapi->EnabledPlayerChatTags; + SqVC_TogglePlayerDrunkEffects = vcapi->TogglePlayerDrunkEffects; + SqVC_EnabledPlayerDrunkEffects = vcapi->EnabledPlayerDrunkEffects; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: weapons + SqVC_GivePlayerWeapon = vcapi->GivePlayerWeapon; + SqVC_SetPlayerWeapon = vcapi->SetPlayerWeapon; + SqVC_GetPlayerWeapon = vcapi->GetPlayerWeapon; + SqVC_GetPlayerWeaponAmmo = vcapi->GetPlayerWeaponAmmo; + SqVC_SetPlayerWeaponSlot = vcapi->SetPlayerWeaponSlot; + SqVC_GetPlayerWeaponSlot = vcapi->GetPlayerWeaponSlot; + SqVC_GetPlayerWeaponAtSlot = vcapi->GetPlayerWeaponAtSlot; + SqVC_GetPlayerAmmoAtSlot = vcapi->GetPlayerAmmoAtSlot; + SqVC_RemovePlayerWeapon = vcapi->RemovePlayerWeapon; + SqVC_RemoveAllWeapons = vcapi->RemoveAllWeapons; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: camera + SqVC_SetCameraPosition = vcapi->SetCameraPosition; + SqVC_RestoreCamera = vcapi->RestoreCamera; + SqVC_IsCameraLocked = vcapi->IsCameraLocked; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: misc + SqVC_SetPlayerAnimation = vcapi->SetPlayerAnimation; + SqVC_SetPlayerWantedLevel = vcapi->SetPlayerWantedLevel; + SqVC_GetPlayerStandingOnVehicle = vcapi->GetPlayerStandingOnVehicle; + SqVC_GetPlayerStandingOnObject = vcapi->GetPlayerStandingOnObject; + SqVC_IsPlayerAway = vcapi->IsPlayerAway; + SqVC_GetPlayerSpectateTarget = vcapi->GetPlayerSpectateTarget; + SqVC_SetPlayerSpectateTarget = vcapi->SetPlayerSpectateTarget; + SqVC_RedirectPlayerToServer = vcapi->RedirectPlayerToServer; + + // -------------------------------------------------------------------------------------------- + //VEHICLES + SqVC_CreateVehicle = vcapi->CreateVehicle; + SqVC_DeleteVehicle = vcapi->DeleteVehicle; + SqVC_GetVehicleSyncSource = vcapi->GetVehicleSyncSource; + SqVC_GetVehicleSyncType = vcapi->GetVehicleSyncType; + SqVC_IsVehicleStreamedForPlayer = vcapi->IsVehicleStreamedForPlayer; + SqVC_SetVehicleWorld = vcapi->SetVehicleWorld; + SqVC_GetVehicleWorld = vcapi->GetVehicleWorld; + SqVC_GetVehicleModel = vcapi->GetVehicleModel; + SqVC_GetVehicleOccupant = vcapi->GetVehicleOccupant; + SqVC_RespawnVehicle = vcapi->RespawnVehicle; + SqVC_SetVehicleImmunityFlags = vcapi->SetVehicleImmunityFlags; + SqVC_GetVehicleImmunityFlags = vcapi->GetVehicleImmunityFlags; + SqVC_KillVehicle = vcapi->KillVehicle; + SqVC_IsVehicleWrecked = vcapi->IsVehicleWrecked; + SqVC_SetVehiclePos = vcapi->SetVehiclePos; + SqVC_GetVehiclePos = vcapi->GetVehiclePos; + SqVC_SetVehicleRot = vcapi->SetVehicleRot; + SqVC_SetVehicleRotEuler = vcapi->SetVehicleRotEuler; + SqVC_GetVehicleRot = vcapi->GetVehicleRot; + SqVC_GetVehicleRotEuler = vcapi->GetVehicleRotEuler; + SqVC_SetVehicleSpeed = vcapi->SetVehicleSpeed; + SqVC_GetVehicleSpeed = vcapi->GetVehicleSpeed; + SqVC_AddVehicleSpeed = vcapi->AddVehicleSpeed; + SqVC_SetVehicleRelSpeed = vcapi->SetVehicleRelSpeed; + SqVC_GetVehicleRelSpeed = vcapi->GetVehicleRelSpeed; + SqVC_AddVehicleRelSpeed = vcapi->AddVehicleRelSpeed; + SqVC_SetVehicleTurnSpeed = vcapi->SetVehicleTurnSpeed; + SqVC_GetVehicleTurnSpeed = vcapi->GetVehicleTurnSpeed; + SqVC_AddVehicleTurnSpeed = vcapi->AddVehicleTurnSpeed; + SqVC_SetVehicleRelTurnSpeed = vcapi->SetVehicleRelTurnSpeed; + SqVC_GetVehicleRelTurnSpeed = vcapi->GetVehicleRelTurnSpeed; + SqVC_AddVehicleRelTurnSpeed = vcapi->AddVehicleRelTurnSpeed; + SqVC_SetVehicleSpawnPos = vcapi->SetVehicleSpawnPos; + SqVC_GetVehicleSpawnPos = vcapi->GetVehicleSpawnPos; + SqVC_SetVehicleSpawnRot = vcapi->SetVehicleSpawnRot; + SqVC_SetVehicleSpawnRotEuler = vcapi->SetVehicleSpawnRotEuler; + SqVC_GetVehicleSpawnRot = vcapi->GetVehicleSpawnRot; + SqVC_GetVehicleSpawnRotEuler = vcapi->GetVehicleSpawnRotEuler; + SqVC_SetVehicleIdleRespawnTimer = vcapi->SetVehicleIdleRespawnTimer; + SqVC_GetVehicleIdleRespawnTimer = vcapi->GetVehicleIdleRespawnTimer; + SqVC_SetVehicleHealth = vcapi->SetVehicleHealth; + SqVC_GetVehicleHealth = vcapi->GetVehicleHealth; + SqVC_SetVehicleColour = vcapi->SetVehicleColour; + SqVC_GetVehicleColour = vcapi->GetVehicleColour; + SqVC_SetVehicleDoorsLocked = vcapi->SetVehicleDoorsLocked; + SqVC_GetVehicleDoorsLocked = vcapi->GetVehicleDoorsLocked; + SqVC_SetVehiclePartStatus = vcapi->SetVehiclePartStatus; + SqVC_GetVehiclePartStatus = vcapi->GetVehiclePartStatus; + SqVC_SetVehicleTyreStatus = vcapi->SetVehicleTyreStatus; + SqVC_GetVehicleTyreStatus = vcapi->GetVehicleTyreStatus; + SqVC_SetVehicleDamageData = vcapi->SetVehicleDamageData; + SqVC_GetVehicleDamageData = vcapi->GetVehicleDamageData; + SqVC_SetVehicleAlarm = vcapi->SetVehicleAlarm; + SqVC_GetVehicleAlarm = vcapi->GetVehicleAlarm; + SqVC_SetVehicleLights = vcapi->SetVehicleLights; + SqVC_GetVehicleLights = vcapi->GetVehicleLights; + SqVC_SetVehicleRadio = vcapi->SetVehicleRadio; + SqVC_GetVehicleRadio = vcapi->GetVehicleRadio; + SqVC_SetVehicleRadioLocked = vcapi->SetVehicleRadioLocked; + SqVC_IsVehicleRadioLocked = vcapi->IsVehicleRadioLocked; + SqVC_GetVehicleGhostState = vcapi->GetVehicleGhostState; + SqVC_SetVehicleGhostState = vcapi->SetVehicleGhostState; + SqVC_GetVehicleTurretRotation = vcapi->GetVehicleTurretRotation; + + // -------------------------------------------------------------------------------------------- + //VEHICLES: handling + SqVC_ResetAllVehicleHandlings = vcapi->ResetAllVehicleHandlings; + SqVC_ExistsHandlingRule = vcapi->ExistsHandlingRule; + SqVC_SetHandlingRule = vcapi->SetHandlingRule; + SqVC_GetHandlingRule = vcapi->GetHandlingRule; + SqVC_ResetHandlingRule = vcapi->ResetHandlingRule; + SqVC_ResetHandling = vcapi->ResetHandling; + SqVC_ExistsInstHandlingRule = vcapi->ExistsInstHandlingRule; + SqVC_SetInstHandlingRule = vcapi->SetInstHandlingRule; + SqVC_GetInstHandlingRule = vcapi->GetInstHandlingRule; + SqVC_ResetInstHandlingRule = vcapi->ResetInstHandlingRule; + SqVC_ResetInstHandling = vcapi->ResetInstHandling; + + // -------------------------------------------------------------------------------------------- + //PICKUPS + SqVC_CreatePickup = vcapi->CreatePickup; + SqVC_DeletePickup = vcapi->DeletePickup; + SqVC_IsPickupStreamedForPlayer = vcapi->IsPickupStreamedForPlayer; + SqVC_SetPickupWorld = vcapi->SetPickupWorld; + SqVC_GetPickupWorld = vcapi->GetPickupWorld; + SqVC_PickupGetAlpha = vcapi->PickupGetAlpha; + SqVC_PickupSetAlpha = vcapi->PickupSetAlpha; + SqVC_PickupIsAutomatic = vcapi->PickupIsAutomatic; + SqVC_PickupSetAutomatic = vcapi->PickupSetAutomatic; + SqVC_SetPickupAutoTimer = vcapi->SetPickupAutoTimer; + SqVC_GetPickupAutoTimer = vcapi->GetPickupAutoTimer; + SqVC_PickupRefresh = vcapi->PickupRefresh; + SqVC_PickupGetPos = vcapi->PickupGetPos; + SqVC_PickupSetPos = vcapi->PickupSetPos; + SqVC_PickupGetModel = vcapi->PickupGetModel; + SqVC_PickupGetQuantity = vcapi->PickupGetQuantity; + + // -------------------------------------------------------------------------------------------- + //OBJECTS + SqVC_CreateObject = vcapi->CreateObject; + SqVC_DeleteObject = vcapi->DeleteObject; + SqVC_IsObjectStreamedForPlayer = vcapi->IsObjectStreamedForPlayer; + SqVC_GetObjectModel = vcapi->GetObjectModel; + SqVC_SetObjectWorld = vcapi->SetObjectWorld; + SqVC_GetObjectWorld = vcapi->GetObjectWorld; + SqVC_SetObjectAlpha = vcapi->SetObjectAlpha; + SqVC_GetObjectAlpha = vcapi->GetObjectAlpha; + SqVC_MoveObjectTo = vcapi->MoveObjectTo; + SqVC_MoveObjectBy = vcapi->MoveObjectBy; + SqVC_SetObjectPos = vcapi->SetObjectPos; + SqVC_GetObjectPos = vcapi->GetObjectPos; + SqVC_RotObjectTo = vcapi->RotObjectTo; + SqVC_RotObjectToEuler = vcapi->RotObjectToEuler; + SqVC_RotObjectBy = vcapi->RotObjectBy; + SqVC_RotObjectByEuler = vcapi->RotObjectByEuler; + SqVC_GetObjectRot = vcapi->GetObjectRot; + SqVC_GetObjectRotEuler = vcapi->GetObjectRotEuler; + SqVC_SetObjectShotReport = vcapi->SetObjectShotReport; + SqVC_IsObjectShotReport = vcapi->IsObjectShotReport; + SqVC_SetObjectBumpReport = vcapi->SetObjectBumpReport; + SqVC_IsObjectBumpReport = vcapi->IsObjectBumpReport; + + // -------------------------------------------------------------------------------------------- + // TODO: Move these functions to proper sections on major plugin update + SqVC_ToggleWallglitch = vcapi->ToggleWallglitch; + SqVC_EnabledWallglitch = vcapi->EnabledWallglitch; + SqVC_SetVehicleSiren = vcapi->SetVehicleSiren; + SqVC_GetVehicleSiren = vcapi->GetVehicleSiren; + SqVC_GetPlayerUID2 = vcapi->GetPlayerUID2; + + // -------------------------------------------------------------------------------------------- + SqVC_CreateCheckpoint = vcapi->CreateCheckpoint; + SqVC_DeleteCheckpoint = vcapi->DeleteCheckpoint; + SqVC_IsCheckpointStreamedForPlayer = vcapi->IsCheckpointStreamedForPlayer; + SqVC_SetCheckpointWorld = vcapi->SetCheckpointWorld; + SqVC_GetCheckpointWorld = vcapi->GetCheckpointWorld; + SqVC_SetCheckpointColor = vcapi->SetCheckpointColor; + SqVC_GetCheckpointColor = vcapi->GetCheckpointColor; + SqVC_SetCheckpointPos = vcapi->SetCheckpointPos; + SqVC_GetCheckpointPos = vcapi->GetCheckpointPos; + SqVC_SetCheckpointRadius = vcapi->SetCheckpointRadius; + SqVC_GetCheckpointRadius = vcapi->GetCheckpointRadius; + SqVC_GetCheckpointOwner = vcapi->GetCheckpointOwner; + + // -------------------------------------------------------------------------------------------- + SqVC_CreateSphere = vcapi->CreateSphere; + SqVC_DeleteSphere = vcapi->DeleteSphere; + SqVC_IsSphereStreamedForPlayer = vcapi->IsSphereStreamedForPlayer; + SqVC_SetSphereWorld = vcapi->SetSphereWorld; + SqVC_GetSphereWorld = vcapi->GetSphereWorld; + SqVC_SetSphereColor = vcapi->SetSphereColor; + SqVC_GetSphereColor = vcapi->GetSphereColor; + SqVC_SetSpherePos = vcapi->SetSpherePos; + SqVC_GetSpherePos = vcapi->GetSpherePos; + SqVC_SetSphereRadius = vcapi->SetSphereRadius; + SqVC_GetSphereRadius = vcapi->GetSphereRadius; + SqVC_GetSphereOwner = vcapi->GetSphereOwner; + + return SQ_OK; +} + +// ------------------------------------------------------------------------------------------------ +void vc_api_collapse() +{ + // -------------------------------------------------------------------------------------------- + //PLUGIN SYSTEM + SqVC_GetServerVersion = NULL; + SqVC_GetServerSettings = NULL; + SqVC_ExportFunctions = NULL; + SqVC_GetNumberOfPlugins = NULL; + SqVC_GetPluginInfo = NULL; + SqVC_FindPlugin = NULL; + SqVC_GetPluginExports = NULL; + SqVC_GetTime = NULL; + + // -------------------------------------------------------------------------------------------- + //MESSAGES + SqVC_printf = NULL; + SqVC_SendCustomCommand = NULL; + SqVC_SendClientMessage = NULL; + SqVC_SendGameMessage = NULL; + + // -------------------------------------------------------------------------------------------- + //SERVER SETTINGS + SqVC_SetServerName = NULL; + SqVC_GetServerName = NULL; + SqVC_SetMaxPlayers = NULL; + SqVC_GetMaxPlayers = NULL; + SqVC_SetServerPassword = NULL; + SqVC_GetServerPassword = NULL; + SqVC_SetGameModeText = NULL; + SqVC_GetGameModeText = NULL; + SqVC_ShutdownServer = NULL; + + // -------------------------------------------------------------------------------------------- + //WORLD: settings + SqVC_SetWorldBounds = NULL; + SqVC_GetWorldBounds = NULL; + SqVC_SetWastedSettings = NULL; + SqVC_GetWastedSettings = NULL; + SqVC_SetTimeRate = NULL; + SqVC_GetTimeRate = NULL; + SqVC_SetHour = NULL; + SqVC_GetHour = NULL; + SqVC_SetMinute = NULL; + SqVC_GetMinute = NULL; + SqVC_SetWeather = NULL; + SqVC_GetWeather = NULL; + SqVC_SetGravity = NULL; + SqVC_GetGravity = NULL; + SqVC_SetGamespeed = NULL; + SqVC_GetGamespeed = NULL; + SqVC_SetWaterLevel = NULL; + SqVC_GetWaterLevel = NULL; + SqVC_SetMaxHeight = NULL; + SqVC_GetMaxHeight = NULL; + SqVC_SetKillCmdDelay = NULL; + SqVC_GetKillCmdDelay = NULL; + SqVC_SetVehiclesForcedRespawnHeight = NULL; + SqVC_GetVehiclesForcedRespawnHeight = NULL; + + // -------------------------------------------------------------------------------------------- + //WORLD: toggles + SqVC_ToggleSyncFrameLimiter = NULL; + SqVC_EnabledSyncFrameLimiter = NULL; + SqVC_ToggleFrameLimiter = NULL; + SqVC_EnabledFrameLimiter = NULL; + SqVC_ToggleTaxiBoostJump = NULL; + SqVC_EnabledTaxiBoostJump = NULL; + SqVC_ToggleDriveOnWater = NULL; + SqVC_EnabledDriveOnWater = NULL; + SqVC_ToggleFastSwitch = NULL; + SqVC_EnabledFastSwitch = NULL; + SqVC_ToggleFriendlyFire = NULL; + SqVC_EnabledFriendlyFire = NULL; + SqVC_ToggleDisableDriveby = NULL; + SqVC_EnabledDisableDriveby = NULL; + SqVC_TogglePerfectHandling = NULL; + SqVC_EnabledPerfectHandling = NULL; + SqVC_ToggleFlyingCars = NULL; + SqVC_EnabledFlyingCars = NULL; + SqVC_ToggleJumpSwitch = NULL; + SqVC_EnabledJumpSwitch = NULL; + SqVC_ToggleShowMarkers = NULL; + SqVC_EnabledShowMarkers = NULL; + SqVC_ToggleOnlyShowTeamMarkers = NULL; + SqVC_EnabledOnlyShowTeamMarkers = NULL; + SqVC_ToggleStuntBike = NULL; + SqVC_EnabledStuntBike = NULL; + SqVC_ToggleShootInAir = NULL; + SqVC_EnabledShootInAir = NULL; + SqVC_ToggleShowNametags = NULL; + SqVC_EnabledShowNametags = NULL; + SqVC_ToggleJoinMessages = NULL; + SqVC_EnabledJoinMessages = NULL; + SqVC_ToggleDeathMessages = NULL; + SqVC_EnabledDeathMessages = NULL; + SqVC_ToggleChatTagsByDefaultEnabled = NULL; + SqVC_EnabledChatTagsByDefault = NULL; + + // -------------------------------------------------------------------------------------------- + //MISC + SqVC_CreateExplosion = NULL; + SqVC_PlaySound = NULL; + SqVC_HideMapObject = NULL; + SqVC_ShowMapObject = NULL; + SqVC_ShowAllMapObjects = NULL; + + //WEAPONDATA + SqVC_SetWeaponDataValue = NULL; + SqVC_GetWeaponDataValue = NULL; + SqVC_ResetWeaponDataValue = NULL; + SqVC_IsWeaponDataValueModified = NULL; + SqVC_ResetWeaponData = NULL; + SqVC_ResetAllWeaponData = NULL; + + // -------------------------------------------------------------------------------------------- + //KEYBINDS + SqVC_GetKeyBindUnusedSlot = NULL; + SqVC_GetKeyBindData = NULL; + SqVC_RegisterKeyBind = NULL; + SqVC_RemoveKeyBind = NULL; + SqVC_RemoveAllKeyBinds = NULL; + + //BLIPS + SqVC_CreateCoordBlip = NULL; + SqVC_DestroyCoordBlip = NULL; + SqVC_GetCoordBlipInfo = NULL; + + // -------------------------------------------------------------------------------------------- + //SPRITES + SqVC_CreateSprite = NULL; + SqVC_DestroySprite = NULL; + SqVC_ShowSprite = NULL; + SqVC_HideSprite = NULL; + SqVC_MoveSprite = NULL; + SqVC_SetSpriteCenter = NULL; + SqVC_RotateSprite = NULL; + SqVC_SetSpriteAlpha = NULL; + SqVC_SetSpriteRelativity = NULL; + + //TEXTDRAWS + SqVC_CreateTextdraw = NULL; + SqVC_DestroyTextdraw = NULL; + SqVC_ShowTextdraw = NULL; + SqVC_HideTextdraw = NULL; + SqVC_MoveTextdraw = NULL; + SqVC_SetTextdrawColour = NULL; + SqVC_SetTextdrawRelativity = NULL; + + // -------------------------------------------------------------------------------------------- + //RADIOS + SqVC_AddRadioStream = NULL; + SqVC_RemoveRadioStream = NULL; + + // -------------------------------------------------------------------------------------------- + //CLASSES + SqVC_SetUseClasses = NULL; + SqVC_GetUseClasses = NULL; + SqVC_GetPlayerClass = NULL; + SqVC_AddPlayerClass = NULL; + SqVC_SetSpawnPlayerPos = NULL; + SqVC_SetSpawnCameraPos = NULL; + SqVC_SetSpawnCameraLookAt = NULL; + + // -------------------------------------------------------------------------------------------- + //ADMIN + SqVC_IsPlayerAdmin = NULL; + SqVC_SetPlayerAdmin = NULL; + SqVC_GetPlayerIP = NULL; + SqVC_KickPlayer = NULL; + SqVC_BanPlayer = NULL; + SqVC_BanIP = NULL; + SqVC_UnbanIP = NULL; + SqVC_IsIPBanned = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: basic + SqVC_GetPlayerIDFromName = NULL; + SqVC_IsPlayerConnected = NULL; + SqVC_IsPlayerSpawned = NULL; + SqVC_IsPlayerStreamedForPlayer = NULL; + SqVC_GetPlayerKey = NULL; + SqVC_SetPlayerWorld = NULL; + SqVC_GetPlayerWorld = NULL; + SqVC_SetPlayerSecWorld = NULL; + SqVC_GetPlayerSecWorld = NULL; + SqVC_GetPlayerUniqueWorld = NULL; + SqVC_IsPlayerWorldCompatible = NULL; + SqVC_GetPlayerState = NULL; + SqVC_GetPlayerName = NULL; + SqVC_SetPlayerName = NULL; + SqVC_SetPlayerTeam = NULL; + SqVC_GetPlayerTeam = NULL; + SqVC_SetPlayerSkin = NULL; + SqVC_GetPlayerSkin = NULL; + SqVC_SetPlayerColour = NULL; + SqVC_GetPlayerColour = NULL; + SqVC_ForcePlayerSpawn = NULL; + SqVC_ForcePlayerSelect = NULL; + SqVC_ForceAllSelect = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: score, ping, money, typing + SqVC_GivePlayerMoney = NULL; + SqVC_SetPlayerMoney = NULL; + SqVC_GetPlayerMoney = NULL; + SqVC_SetPlayerScore = NULL; + SqVC_GetPlayerScore = NULL; + SqVC_GetPlayerPing = NULL; + SqVC_IsPlayerTyping = NULL; + SqVC_GetPlayerFPS = NULL; + SqVC_GetPlayerUID = NULL; + SqVC_GetPlayerWantedLevel = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: health and location + SqVC_SetPlayerHealth = NULL; + SqVC_GetPlayerHealth = NULL; + SqVC_SetPlayerArmour = NULL; + SqVC_GetPlayerArmour = NULL; + SqVC_SetPlayerImmunityFlags = NULL; + SqVC_GetPlayerImmunityFlags = NULL; + SqVC_SetPlayerPos = NULL; + SqVC_GetPlayerPos = NULL; + SqVC_SetPlayerSpeed = NULL; + SqVC_GetPlayerSpeed = NULL; + SqVC_AddPlayerSpeed = NULL; + SqVC_SetPlayerHeading = NULL; + SqVC_GetPlayerHeading = NULL; + SqVC_SetPlayerAlpha = NULL; + SqVC_GetPlayerAlpha = NULL; + SqVC_GetPlayerOnFireStatus = NULL; + SqVC_GetPlayerCrouchStatus = NULL; + SqVC_GetPlayerAction = NULL; + SqVC_GetPlayerGameKeys = NULL; + SqVC_GetPlayerAimPos = NULL; + SqVC_GetPlayerAimDir = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: vehicle + SqVC_PutPlayerInVehicle = NULL; + SqVC_RemovePlayerFromVehicle = NULL; + SqVC_GetPlayerInVehicleStatus = NULL; + SqVC_GetPlayerInVehicleSlot = NULL; + SqVC_GetPlayerVehicleID = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: toggles + SqVC_TogglePlayerControllable = NULL; + SqVC_EnabledPlayerControllable = NULL; + SqVC_TogglePlayerDriveby = NULL; + SqVC_EnabledPlayerDriveby = NULL; + SqVC_TogglePlayerWhiteScanlines = NULL; + SqVC_EnabledPlayerWhiteScanlines = NULL; + SqVC_TogglePlayerGreenScanlines = NULL; + SqVC_EnabledPlayerGreenScanlines = NULL; + SqVC_TogglePlayerWidescreen = NULL; + SqVC_EnabledPlayerWidescreen = NULL; + SqVC_TogglePlayerShowMarkers = NULL; + SqVC_EnabledPlayerShowMarkers = NULL; + SqVC_TogglePlayerAttackPriv = NULL; + SqVC_EnabledPlayerAttackPriv = NULL; + SqVC_TogglePlayerHasMarker = NULL; + SqVC_EnabledPlayerHasMarker = NULL; + SqVC_TogglePlayerChatTagsEnabled = NULL; + SqVC_EnabledPlayerChatTags = NULL; + SqVC_TogglePlayerDrunkEffects = NULL; + SqVC_EnabledPlayerDrunkEffects = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: weapons + SqVC_GivePlayerWeapon = NULL; + SqVC_SetPlayerWeapon = NULL; + SqVC_GetPlayerWeapon = NULL; + SqVC_GetPlayerWeaponAmmo = NULL; + SqVC_SetPlayerWeaponSlot = NULL; + SqVC_GetPlayerWeaponSlot = NULL; + SqVC_GetPlayerWeaponAtSlot = NULL; + SqVC_GetPlayerAmmoAtSlot = NULL; + SqVC_RemovePlayerWeapon = NULL; + SqVC_RemoveAllWeapons = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: camera + SqVC_SetCameraPosition = NULL; + SqVC_RestoreCamera = NULL; + SqVC_IsCameraLocked = NULL; + + // -------------------------------------------------------------------------------------------- + //PLAYERS: misc + SqVC_SetPlayerAnimation = NULL; + SqVC_SetPlayerWantedLevel = NULL; + SqVC_GetPlayerStandingOnVehicle = NULL; + SqVC_GetPlayerStandingOnObject = NULL; + SqVC_IsPlayerAway = NULL; + SqVC_GetPlayerSpectateTarget = NULL; + SqVC_SetPlayerSpectateTarget = NULL; + SqVC_RedirectPlayerToServer = NULL; + + // -------------------------------------------------------------------------------------------- + //VEHICLES + SqVC_CreateVehicle = NULL; + SqVC_DeleteVehicle = NULL; + SqVC_GetVehicleSyncSource = NULL; + SqVC_GetVehicleSyncType = NULL; + SqVC_IsVehicleStreamedForPlayer = NULL; + SqVC_SetVehicleWorld = NULL; + SqVC_GetVehicleWorld = NULL; + SqVC_GetVehicleModel = NULL; + SqVC_GetVehicleOccupant = NULL; + SqVC_RespawnVehicle = NULL; + SqVC_SetVehicleImmunityFlags = NULL; + SqVC_GetVehicleImmunityFlags = NULL; + SqVC_KillVehicle = NULL; + SqVC_IsVehicleWrecked = NULL; + SqVC_SetVehiclePos = NULL; + SqVC_GetVehiclePos = NULL; + SqVC_SetVehicleRot = NULL; + SqVC_SetVehicleRotEuler = NULL; + SqVC_GetVehicleRot = NULL; + SqVC_GetVehicleRotEuler = NULL; + SqVC_SetVehicleSpeed = NULL; + SqVC_GetVehicleSpeed = NULL; + SqVC_AddVehicleSpeed = NULL; + SqVC_SetVehicleRelSpeed = NULL; + SqVC_GetVehicleRelSpeed = NULL; + SqVC_AddVehicleRelSpeed = NULL; + SqVC_SetVehicleTurnSpeed = NULL; + SqVC_GetVehicleTurnSpeed = NULL; + SqVC_AddVehicleTurnSpeed = NULL; + SqVC_SetVehicleRelTurnSpeed = NULL; + SqVC_GetVehicleRelTurnSpeed = NULL; + SqVC_AddVehicleRelTurnSpeed = NULL; + SqVC_SetVehicleSpawnPos = NULL; + SqVC_GetVehicleSpawnPos = NULL; + SqVC_SetVehicleSpawnRot = NULL; + SqVC_SetVehicleSpawnRotEuler = NULL; + SqVC_GetVehicleSpawnRot = NULL; + SqVC_GetVehicleSpawnRotEuler = NULL; + SqVC_SetVehicleIdleRespawnTimer = NULL; + SqVC_GetVehicleIdleRespawnTimer = NULL; + SqVC_SetVehicleHealth = NULL; + SqVC_GetVehicleHealth = NULL; + SqVC_SetVehicleColour = NULL; + SqVC_GetVehicleColour = NULL; + SqVC_SetVehicleDoorsLocked = NULL; + SqVC_GetVehicleDoorsLocked = NULL; + SqVC_SetVehiclePartStatus = NULL; + SqVC_GetVehiclePartStatus = NULL; + SqVC_SetVehicleTyreStatus = NULL; + SqVC_GetVehicleTyreStatus = NULL; + SqVC_SetVehicleDamageData = NULL; + SqVC_GetVehicleDamageData = NULL; + SqVC_SetVehicleAlarm = NULL; + SqVC_GetVehicleAlarm = NULL; + SqVC_SetVehicleLights = NULL; + SqVC_GetVehicleLights = NULL; + SqVC_SetVehicleRadio = NULL; + SqVC_GetVehicleRadio = NULL; + SqVC_SetVehicleRadioLocked = NULL; + SqVC_IsVehicleRadioLocked = NULL; + SqVC_GetVehicleGhostState = NULL; + SqVC_SetVehicleGhostState = NULL; + SqVC_GetVehicleTurretRotation = NULL; + + // -------------------------------------------------------------------------------------------- + //VEHICLES: handling + SqVC_ResetAllVehicleHandlings = NULL; + SqVC_ExistsHandlingRule = NULL; + SqVC_SetHandlingRule = NULL; + SqVC_GetHandlingRule = NULL; + SqVC_ResetHandlingRule = NULL; + SqVC_ResetHandling = NULL; + SqVC_ExistsInstHandlingRule = NULL; + SqVC_SetInstHandlingRule = NULL; + SqVC_GetInstHandlingRule = NULL; + SqVC_ResetInstHandlingRule = NULL; + SqVC_ResetInstHandling = NULL; + + // -------------------------------------------------------------------------------------------- + //PICKUPS + SqVC_CreatePickup = NULL; + SqVC_DeletePickup = NULL; + SqVC_IsPickupStreamedForPlayer = NULL; + SqVC_SetPickupWorld = NULL; + SqVC_GetPickupWorld = NULL; + SqVC_PickupGetAlpha = NULL; + SqVC_PickupSetAlpha = NULL; + SqVC_PickupIsAutomatic = NULL; + SqVC_PickupSetAutomatic = NULL; + SqVC_SetPickupAutoTimer = NULL; + SqVC_GetPickupAutoTimer = NULL; + SqVC_PickupRefresh = NULL; + SqVC_PickupGetPos = NULL; + SqVC_PickupSetPos = NULL; + SqVC_PickupGetModel = NULL; + SqVC_PickupGetQuantity = NULL; + + // -------------------------------------------------------------------------------------------- + //OBJECTS + SqVC_CreateObject = NULL; + SqVC_DeleteObject = NULL; + SqVC_IsObjectStreamedForPlayer = NULL; + SqVC_GetObjectModel = NULL; + SqVC_SetObjectWorld = NULL; + SqVC_GetObjectWorld = NULL; + SqVC_SetObjectAlpha = NULL; + SqVC_GetObjectAlpha = NULL; + SqVC_MoveObjectTo = NULL; + SqVC_MoveObjectBy = NULL; + SqVC_SetObjectPos = NULL; + SqVC_GetObjectPos = NULL; + SqVC_RotObjectTo = NULL; + SqVC_RotObjectToEuler = NULL; + SqVC_RotObjectBy = NULL; + SqVC_RotObjectByEuler = NULL; + SqVC_GetObjectRot = NULL; + SqVC_GetObjectRotEuler = NULL; + SqVC_SetObjectShotReport = NULL; + SqVC_IsObjectShotReport = NULL; + SqVC_SetObjectBumpReport = NULL; + SqVC_IsObjectBumpReport = NULL; + + // -------------------------------------------------------------------------------------------- + // TODO: Move these functions to proper sections on major plugin update + SqVC_ToggleWallglitch = NULL; + SqVC_EnabledWallglitch = NULL; + SqVC_SetVehicleSiren = NULL; + SqVC_GetVehicleSiren = NULL; + SqVC_GetPlayerUID2 = NULL; + + // -------------------------------------------------------------------------------------------- + SqVC_CreateCheckpoint = NULL; + SqVC_DeleteCheckpoint = NULL; + SqVC_IsCheckpointStreamedForPlayer = NULL; + SqVC_SetCheckpointWorld = NULL; + SqVC_GetCheckpointWorld = NULL; + SqVC_SetCheckpointColor = NULL; + SqVC_GetCheckpointColor = NULL; + SqVC_SetCheckpointPos = NULL; + SqVC_GetCheckpointPos = NULL; + SqVC_SetCheckpointRadius = NULL; + SqVC_GetCheckpointRadius = NULL; + SqVC_GetCheckpointOwner = NULL; + + // -------------------------------------------------------------------------------------------- + SqVC_CreateSphere = NULL; + SqVC_DeleteSphere = NULL; + SqVC_IsSphereStreamedForPlayer = NULL; + SqVC_SetSphereWorld = NULL; + SqVC_GetSphereWorld = NULL; + SqVC_SetSphereColor = NULL; + SqVC_GetSphereColor = NULL; + SqVC_SetSpherePos = NULL; + SqVC_GetSpherePos = NULL; + SqVC_SetSphereRadius = NULL; + SqVC_GetSphereRadius = NULL; + SqVC_GetSphereOwner = NULL; +} \ No newline at end of file diff --git a/source/Core.cpp b/source/Core.cpp index 7a60e55f..a06885f7 100644 --- a/source/Core.cpp +++ b/source/Core.cpp @@ -229,26 +229,33 @@ bool Core::Init() { // Get the file path as a string String path(itr->pItem); - // See if it wasn't already loaded - if (m_Scripts.find(path) != m_Scripts.end()) + // See if the specified script path is valid + if (path.empty()) { - LogWrn("Script was already loaded: %s", path.c_str()); + // Simply ignore it + continue; + } + // See if it wasn't already loaded + else if (m_Scripts.find(path) != m_Scripts.end()) + { + LogWrn("Script was specified before: %s", path.c_str()); // No point in loading it again continue; } - // Attempt to compile it - else if (!Compile(path)) + // Create a new script container and insert it into the script pool + std::pair< Scripts::iterator, bool > res = m_Scripts.insert(Scripts::value_type(path, Script(m_VM))); + // We don't compile the scripts yet. We just store their path and prepare the objects. + if (!res.second) { - // Plug-in shouldn't load + LogErr("Unable to queue script: %s", path.c_str()); + // Drop all previous scripts + m_Scripts.clear(); + // Failed to compile the specified script return false; } - else - { - LogScs("Successfully compiled script: %s", path.c_str()); - } } // See if any script could be compiled - if (m_Scripts.empty()) + if (m_Scripts.empty() && !conf.GetBoolValue("Config", "EmptyInit", false)) { LogErr("No scripts compiled. No reason to load the plug-in"); // No point in loading the plug-in @@ -303,25 +310,27 @@ bool Core::Load() { // Are there any scripts to execute? if (cLogErr(m_Scripts.empty(), "No scripts to execute. Plug-in has no purpose")) - { return false; - } + LogDbg("Signaling outside plugins to register their API"); + // Signal outside plugins to do their monkey business + _Func->SendCustomCommand(0xDABBAD00, ""); LogDbg("Attempting to execute the specified scripts"); - // Go through each loaded script + // Go through each specified script for (Scripts::iterator itr = m_Scripts.begin(); itr != m_Scripts.end(); ++itr) { + // Attempt to load and compile the script file + itr->second.CompileFile(itr->first); + // See if any compile time error occurred during compilation + if (Error::Occurred(m_VM)) + return false; /* Failed to load properly */ // Attempt to execute the script itr->second.Run(); // See if the executed script had any errors if (Error::Occurred(m_VM)) - { // Failed to execute scripts - return false; - } + return false; /* Failed to load properly */ else - { LogScs("Successfully executed script: %s", itr->first.c_str()); - } } // Successfully loaded return true; @@ -363,42 +372,6 @@ void Core::Terminate() } } -bool Core::Compile(const string & name) -{ - // See if the specified script path is valid - if (name.empty()) - { - LogErr("Cannot compile script without a valid name"); - // Failed to compile the specified script - return false; - } - // Create a new script container and insert it into the script pool - std::pair< Scripts::iterator, bool > res = m_Scripts.insert(Scripts::value_type(name, Script(m_VM))); - // See if the script container could be created and inserted - if (res.second) - { - // Attempt to load and compile the specified script file - res.first->second.CompileFile(name); - // See if any compile time error occurred in the compiled script - if (Error::Occurred(m_VM)) - { - // Release the script container - m_Scripts.erase(res.first); - // Failed to compile the specified script - return false; - } - } - // Failed to create the script container - else - { - LogErr("Unable to queue script: %s", name.c_str()); - // Failed to compile the specified script - return false; - } - // At this point everything went as it should - return true; -} - // ------------------------------------------------------------------------------------------------ CSStr Core::GetOption(const String & name) const { diff --git a/source/Core.hpp b/source/Core.hpp index d5b7d2d3..fb0af1ee 100644 --- a/source/Core.hpp +++ b/source/Core.hpp @@ -499,11 +499,6 @@ public: protected: - /* -------------------------------------------------------------------------------------------- - * Compile the specified file as a script. - */ - bool Compile(const string & name); - /* -------------------------------------------------------------------------------------------- * Script output handlers. */ diff --git a/source/Exports.cpp b/source/Exports.cpp new file mode 100644 index 00000000..2ededa29 --- /dev/null +++ b/source/Exports.cpp @@ -0,0 +1,227 @@ +// ------------------------------------------------------------------------------------------------ +#include "Core.hpp" + +// ------------------------------------------------------------------------------------------------ +#include +#include + +// ------------------------------------------------------------------------------------------------ +#include +#include +#include +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +static SQAPI g_SqAPI; +static SQEXPORTS g_SqExports; + +// ------------------------------------------------------------------------------------------------ +static HSQAPI GetSquirrelAPI() +{ + return &g_SqAPI; +} + +// ------------------------------------------------------------------------------------------------ +static HSQUIRRELVM GetSquirrelVM() +{ + if (_Core) + return _Core->GetVM(); + return NULL; +} + +// ------------------------------------------------------------------------------------------------ +void InitExports() +{ + static HSQEXPORTS sqexports = &g_SqExports; + + // Assign the functions that should be exported + g_SqExports.uStructSize = sizeof(SQEXPORTS); + g_SqExports.GetSquirrelAPI = GetSquirrelAPI; + g_SqExports.GetSquirrelVM = GetSquirrelVM; + // Export them to the server + _Func->ExportFunctions(_Info->nPluginId, (void **)(&sqexports), sizeof(SQEXPORTS)); + /*vm*/ + g_SqAPI.open = sq_open; + g_SqAPI.newthread = sq_newthread; + g_SqAPI.seterrorhandler = sq_seterrorhandler; + g_SqAPI.close = sq_close; + g_SqAPI.setforeignptr = sq_setforeignptr; + g_SqAPI.getforeignptr = sq_getforeignptr; + g_SqAPI.setsharedforeignptr = sq_setsharedforeignptr; + g_SqAPI.getsharedforeignptr = sq_getsharedforeignptr; + g_SqAPI.setvmreleasehook = sq_setvmreleasehook; + g_SqAPI.getvmreleasehook = sq_getvmreleasehook; + g_SqAPI.setsharedreleasehook = sq_setsharedreleasehook; + g_SqAPI.getsharedreleasehook = sq_getsharedreleasehook; + g_SqAPI.setprintfunc = sq_setprintfunc; + g_SqAPI.getprintfunc = sq_getprintfunc; + g_SqAPI.geterrorfunc = sq_geterrorfunc; + g_SqAPI.suspendvm = sq_suspendvm; + g_SqAPI.wakeupvm = sq_wakeupvm; + g_SqAPI.getvmstate = sq_getvmstate; + g_SqAPI.getversion = sq_getversion; + + /*compiler*/ + g_SqAPI.compile = sq_compile; + g_SqAPI.compilebuffer = sq_compilebuffer; + g_SqAPI.enabledebuginfo = sq_enabledebuginfo; + g_SqAPI.notifyallexceptions = sq_notifyallexceptions; + g_SqAPI.setcompilererrorhandler = sq_setcompilererrorhandler; + + /*stack operations*/ + g_SqAPI.push = sq_push; + g_SqAPI.pop = sq_pop; + g_SqAPI.poptop = sq_poptop; + g_SqAPI.remove = sq_remove; + g_SqAPI.gettop = sq_gettop; + g_SqAPI.settop = sq_settop; + g_SqAPI.reservestack = sq_reservestack; + g_SqAPI.cmp = sq_cmp; + g_SqAPI.move = sq_move; + + /*object creation handling*/ + g_SqAPI.newuserdata = sq_newuserdata; + g_SqAPI.newtable = sq_newtable; + g_SqAPI.newtableex = sq_newtableex; + g_SqAPI.newarray = sq_newarray; + g_SqAPI.newclosure = sq_newclosure; + g_SqAPI.setparamscheck = sq_setparamscheck; + g_SqAPI.bindenv = sq_bindenv; + g_SqAPI.setclosureroot = sq_setclosureroot; + g_SqAPI.getclosureroot = sq_getclosureroot; + g_SqAPI.pushstring = sq_pushstring; + g_SqAPI.pushfloat = sq_pushfloat; + g_SqAPI.pushinteger = sq_pushinteger; + g_SqAPI.pushbool = sq_pushbool; + g_SqAPI.pushuserpointer = sq_pushuserpointer; + g_SqAPI.pushnull = sq_pushnull; + g_SqAPI.pushthread = sq_pushthread; + g_SqAPI.gettype = sq_gettype; + g_SqAPI.typeof_ = sq_typeof; + g_SqAPI.getsize = sq_getsize; + g_SqAPI.gethash = sq_gethash; + g_SqAPI.getbase = sq_getbase; + g_SqAPI.instanceof = sq_instanceof; + g_SqAPI.tostring = sq_tostring; + g_SqAPI.tobool = sq_tobool; + g_SqAPI.getstring = sq_getstring; + g_SqAPI.getinteger = sq_getinteger; + g_SqAPI.getfloat = sq_getfloat; + g_SqAPI.getbool = sq_getbool; + g_SqAPI.getthread = sq_getthread; + g_SqAPI.getuserpointer = sq_getuserpointer; + g_SqAPI.getuserdata = sq_getuserdata; + g_SqAPI.settypetag = sq_settypetag; + g_SqAPI.gettypetag = sq_gettypetag; + g_SqAPI.setreleasehook = sq_setreleasehook; + g_SqAPI.getreleasehook = sq_getreleasehook; + g_SqAPI.getscratchpad = sq_getscratchpad; + g_SqAPI.getfunctioninfo = sq_getfunctioninfo; + g_SqAPI.getclosureinfo = sq_getclosureinfo; + g_SqAPI.getclosurename = sq_getclosurename; + g_SqAPI.setnativeclosurename = sq_setnativeclosurename; + g_SqAPI.setinstanceup = sq_setinstanceup; + g_SqAPI.getinstanceup = sq_getinstanceup; + g_SqAPI.setclassudsize = sq_setclassudsize; + g_SqAPI.newclass = sq_newclass; + g_SqAPI.createinstance = sq_createinstance; + g_SqAPI.setattributes = sq_setattributes; + g_SqAPI.getattributes = sq_getattributes; + g_SqAPI.getclass = sq_getclass; + g_SqAPI.weakref = sq_weakref; + g_SqAPI.getdefaultdelegate = sq_getdefaultdelegate; + g_SqAPI.getmemberhandle = sq_getmemberhandle; + g_SqAPI.getbyhandle = sq_getbyhandle; + g_SqAPI.setbyhandle = sq_setbyhandle; + + /*object manipulation*/ + g_SqAPI.pushroottable = sq_pushroottable; + g_SqAPI.pushregistrytable = sq_pushregistrytable; + g_SqAPI.pushconsttable = sq_pushconsttable; + g_SqAPI.setroottable = sq_setroottable; + g_SqAPI.setconsttable = sq_setconsttable; + g_SqAPI.newslot = sq_newslot; + g_SqAPI.deleteslot = sq_deleteslot; + g_SqAPI.set = sq_set; + g_SqAPI.get = sq_get; + g_SqAPI.rawget = sq_rawget; + g_SqAPI.rawset = sq_rawset; + g_SqAPI.rawdeleteslot = sq_rawdeleteslot; + g_SqAPI.newmember = sq_newmember; + g_SqAPI.rawnewmember = sq_rawnewmember; + g_SqAPI.arrayappend = sq_arrayappend; + g_SqAPI.arraypop = sq_arraypop; + g_SqAPI.arrayresize = sq_arrayresize; + g_SqAPI.arrayreverse = sq_arrayreverse; + g_SqAPI.arrayremove = sq_arrayremove; + g_SqAPI.arrayinsert = sq_arrayinsert; + g_SqAPI.setdelegate = sq_setdelegate; + g_SqAPI.getdelegate = sq_getdelegate; + g_SqAPI.clone = sq_clone; + g_SqAPI.setfreevariable = sq_setfreevariable; + g_SqAPI.next = sq_next; + g_SqAPI.getweakrefval = sq_getweakrefval; + g_SqAPI.clear = sq_clear; + + /*calls*/ + g_SqAPI.call = sq_call; + g_SqAPI.resume = sq_resume; + g_SqAPI.getlocal = sq_getlocal; + g_SqAPI.getcallee = sq_getcallee; + g_SqAPI.getfreevariable = sq_getfreevariable; + g_SqAPI.throwerror = sq_throwerror; + g_SqAPI.throwobject = sq_throwobject; + g_SqAPI.reseterror = sq_reseterror; + g_SqAPI.getlasterror = sq_getlasterror; + + /*raw object handling*/ + g_SqAPI.getstackobj = sq_getstackobj; + g_SqAPI.pushobject = sq_pushobject; + g_SqAPI.addref = sq_addref; + g_SqAPI.release = sq_release; + g_SqAPI.getrefcount = sq_getrefcount; + g_SqAPI.resetobject = sq_resetobject; + g_SqAPI.objtostring = sq_objtostring; + g_SqAPI.objtobool = sq_objtobool; + g_SqAPI.objtointeger = sq_objtointeger; + g_SqAPI.objtofloat = sq_objtofloat; + g_SqAPI.objtouserpointer = sq_objtouserpointer; + g_SqAPI.getobjtypetag = sq_getobjtypetag; + g_SqAPI.getvmrefcount = sq_getvmrefcount; + + /*GC*/ + g_SqAPI.collectgarbage = sq_collectgarbage; + g_SqAPI.resurrectunreachable = sq_resurrectunreachable; + + /*serialization*/ + g_SqAPI.writeclosure = sq_writeclosure; + g_SqAPI.readclosure = sq_readclosure; + + /*mem allocation*/ + g_SqAPI.malloc = sq_malloc; + g_SqAPI.realloc = sq_realloc; + g_SqAPI.free = sq_free; + + /*debug*/ + g_SqAPI.stackinfos = sq_stackinfos; + g_SqAPI.setdebughook = sq_setdebughook; + g_SqAPI.setnativedebughook = sq_setnativedebughook; + + /*compiler helpers*/ + g_SqAPI.loadfile = sqstd_loadfile; + g_SqAPI.dofile = sqstd_dofile; + g_SqAPI.writeclosuretofile = sqstd_writeclosuretofile; + + /*blob*/ + g_SqAPI.createblob = sqstd_createblob; + g_SqAPI.getblob = sqstd_getblob; + g_SqAPI.getblobsize = sqstd_getblobsize; + + /*string*/ + g_SqAPI.format = sqstd_format; +} + +} // Namespace:: SqMod diff --git a/source/Main.cpp b/source/Main.cpp index 0b2846de..e4f453a2 100644 --- a/source/Main.cpp +++ b/source/Main.cpp @@ -10,6 +10,11 @@ #include #endif // _WIN32 +// ------------------------------------------------------------------------------------------------ +namespace SqMod { +extern void InitExports(); +} // Namespace:: SqMod + // ------------------------------------------------------------------------------------------------ using namespace SqMod; @@ -17,6 +22,29 @@ using namespace SqMod; void BindCallbacks(); void UnbindCallbacks(); +// ------------------------------------------------------------------------------------------------ +void DestroyComponents() +{ + // Destroy command component + if (_Cmd) + { + delete _Cmd; + _Cmd = NULL; + } + // Destroy core component + if (_Core) + { + delete _Core; + _Core = NULL; + } + // Destroy logger component + if (_Log) + { + delete _Log; + _Log = NULL; + } +} + // ------------------------------------------------------------------------------------------------ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallbacks * calls, PluginInfo * info) { @@ -24,23 +52,31 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback WSADATA wsaData; #endif // _WIN32 _Log = Logger::Get(); - _Core = Core::Get(); - _Cmd = CmdManager::Get(); // Verify that core components are working if (!_Log) { puts("[SQMOD] Unable to start because the logging class could not be instantiated"); return SQMOD_FAILURE; } - else if (!_Core) + _Core = Core::Get(); + if (!_Core) { + DestroyComponents(); puts("[SQMOD] Unable to start because the central core class could not be instantiated"); return SQMOD_FAILURE; } + _Cmd = CmdManager::Get(); + if (!_Cmd) + { + DestroyComponents(); + puts("[SQMOD] Unable to start because the command class could not be instantiated"); + return SQMOD_FAILURE; + } #if defined(_WIN32) // Initialize the sockets on windows - else if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) + if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { + DestroyComponents(); puts("[SQMOD] Unable to start because the windows sockets could not be initialized"); return SQMOD_FAILURE; } @@ -51,12 +87,13 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback _Info = info; _Info->uPluginVer = SQMOD_VERSION; - strcpy(_Info->szName, SQMOD_NAME); + strcpy(_Info->szName, SQMOD_HOST_NAME); if (!_Core->Init()) { LogFtl("The plugin failed to initialize"); _Core->Terminate(); + DestroyComponents(); return SQMOD_FAILURE; } else if (_Clbk) @@ -65,15 +102,23 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback } else { + _Core->Terminate(); + DestroyComponents(); LogFtl("Unable to start because the server callbacks are missing"); + return SQMOD_FAILURE; } - + // Attempt to initialize the plugin exports + InitExports(); + // Initialization was successful return SQMOD_SUCCESS; } // -------------------------------------------------------------------------------------------- static int VC_InitServer(void) { + if (!_Core) + return SQMOD_FAILURE; + _Core->SetState(1); if (_Core->Load()) @@ -86,18 +131,16 @@ static int VC_InitServer(void) static void VC_ShutdownServer(void) { + if (!_Core) + return; + _Core->EmitServerShutdown(); // Deallocate and release everything obtained at startup _Core->Terminate(); // The server still triggers callbacks and we deallocated everything! UnbindCallbacks(); - // Destroy core components - delete _Cmd; - delete _Core; - delete _Log; - _Cmd = NULL; - _Core = NULL; - _Log = NULL; + // Destroy components + DestroyComponents(); } static void VC_Frame(float delta) diff --git a/source/SqBase.hpp b/source/SqBase.hpp index 9e821d8f..ea268b75 100644 --- a/source/SqBase.hpp +++ b/source/SqBase.hpp @@ -112,6 +112,7 @@ #define SQMOD_NAME "Squirrel Module" #define SQMOD_AUTHOR "Sandu Liviu Catalin" #define SQMOD_COPYRIGHT "Copyright (C) 2015 Sandu Liviu Catalin" +#define SQMOD_HOST_NAME "SqModHost" #define SQMOD_VERSION 001 #define SQMOD_VERSION_STR "0.0.1" #define SQMOD_VERSION_MAJOR 0 @@ -444,6 +445,8 @@ enum CmdError #define SQMOD_API_EXPORT extern "C" __declspec(dllexport) #elif defined(__GNUC__) #define SQMOD_API_EXPORT extern "C" +#else + #define SQMOD_API_EXPORT extern "C" #endif /* ------------------------------------------------------------------------------------------------