1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Restructure the whole plugin development kit.

This commit is contained in:
Sandu Liviu Catalin 2020-05-28 20:59:29 +03:00
parent acbca01e7a
commit 47f71625d8
17 changed files with 74 additions and 2717 deletions

View File

@ -7,7 +7,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Several plugin options # Several plugin options
option(BUILTIN_RUNTIMES "Include the MinGW runtime into the binary itself." ON) option(BUILTIN_RUNTIMES "Include the MinGW runtime into the binary itself." ON)
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF) option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
option(PLUGIN_DEVEL "Switch to plugin development." OFF)
option(ENABLE_MYSQL "Enable the MySQL library." OFF) option(ENABLE_MYSQL "Enable the MySQL library." OFF)
option(ENABLE_API21 "Build for 2.1 API." OFF) option(ENABLE_API21 "Build for 2.1 API." OFF)
@ -40,18 +39,7 @@ endif()
if(UNIX) if(UNIX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif() endif()
# Include VCMP library
add_subdirectory(vcmp)
# Include Squirrel library
add_subdirectory(squirrel)
# Include Squat library
add_subdirectory(sqrat)
# Include SDK library # Include SDK library
add_subdirectory(sdk) add_subdirectory(sdk)
if(PLUGIN_DEVEL)
# Include Sample module
add_subdirectory(hello)
else()
# Include Module library # Include Module library
add_subdirectory(module) add_subdirectory(module)
endif()

View File

@ -1,34 +0,0 @@
# Create the Squirrel module
add_library(SqHello MODULE Module.cpp
Common.hpp Common.cpp
)
# Compile definitions
target_compile_definitions(SqHello PUBLIC SQMOD_PLUGIN_API=1)
# Determine if build mode
if(CMAKE_BUILD_TYPE MATCHES Release)
target_compile_definitions(SqHello PRIVATE NDEBUG=1)
else()
target_compile_definitions(SqHello PRIVATE _DEBUG=1 SQMOD_EXCEPTLOC=1)
endif()
# Link to base libraries
target_link_libraries(SqHello VCMP SquirrelAPI Sqrat SqSDK)
# Don't prefix the module binary.
set_target_properties(SqHello PROPERTIES PREFIX "")
# Custmize module binary name/
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT FORCE_32BIT_BIN)
set_target_properties(SqHello PROPERTIES OUTPUT_NAME "mod_hello_64")
else()
set_target_properties(SqHello PROPERTIES OUTPUT_NAME "mod_hello_32")
endif()
else(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT FORCE_32BIT_BIN)
set_target_properties(SqHello PROPERTIES OUTPUT_NAME "mod_hello_64")
else()
set_target_properties(SqHello PROPERTIES OUTPUT_NAME "mod_hello_32")
endif()
endif(WIN32)
# Include current directory in the search path
target_include_directories(SqHello PRIVATE ${CMAKE_CURRENT_LIST_DIR})
# Copy module into the plugins folder
add_custom_command(TARGET SqHello POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:SqHello> "${PROJECT_SOURCE_DIR}/bin/plugins")

View File

@ -1,273 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
#ifdef SQMOD_OS_WINDOWS
#include <windows.h>
#endif // SQMOD_OS_WINDOWS
// ------------------------------------------------------------------------------------------------
#include <cstdarg>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
PluginFuncs* _Func = nullptr;
PluginCallbacks* _Clbk = nullptr;
PluginInfo* _Info = nullptr;
/* ------------------------------------------------------------------------------------------------
* Common buffers to reduce memory allocations. To be immediately copied upon return!
*/
static SQChar g_Buffer[4096];
// ------------------------------------------------------------------------------------------------
void SqThrowF(const SQChar * str, ...)
{
// Initialize the argument list
va_list args;
va_start (args, str);
// Write the requested contents
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
{
// Write a generic message at least
std::strcpy(g_Buffer, "Unknown error has occurred");
}
// Finalize the argument list
va_end(args);
// Throw the exception with the resulted message
throw Sqrat::Exception(g_Buffer); // NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
}
/* ------------------------------------------------------------------------------------------------
* Raw console message output.
*/
static inline void OutputMessageImpl(const SQChar * msg, va_list args)
{
#ifdef SQMOD_OS_WINDOWS
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csb_before;
GetConsoleScreenBufferInfo( hstdout, &csb_before);
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::vprintf(msg, args);
std::puts("");
SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
#else
std::printf("\033[21;32m[SQMOD]\033[0m");
std::vprintf(msg, args);
std::puts("");
#endif // SQMOD_OS_WINDOWS
}
/* ------------------------------------------------------------------------------------------------
* Raw console error output.
*/
static inline void OutputErrorImpl(const SQChar * msg, va_list args)
{
#ifdef SQMOD_OS_WINDOWS
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csb_before;
GetConsoleScreenBufferInfo( hstdout, &csb_before);
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::vprintf(msg, args);
std::puts("");
SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
#else
std::printf("\033[21;91m[SQMOD]\033[0m");
std::vprintf(msg, args);
std::puts("");
#endif // SQMOD_OS_WINDOWS
}
// ------------------------------------------------------------------------------------------------
void OutputDebug(const SQChar * 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);
#else
SQMOD_UNUSED_VAR(msg);
#endif
}
// ------------------------------------------------------------------------------------------------
void OutputMessage(const SQChar * 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);
}
// ------------------------------------------------------------------------------------------------
void OutputError(const SQChar * msg, ...)
{
// Initialize the arguments list
va_list args;
va_start(args, msg);
// Call the output function
OutputErrorImpl(msg, args);
// Finalize the arguments list
va_end(args);
}
// ------------------------------------------------------------------------------------------------
bool CheckModuleAPIVer(const SQChar * ver, const SQChar * mod)
{
// Obtain the numeric representation of the API version
const long int vernum = std::strtol(ver, nullptr, 10);
// Check against version mismatch
if (vernum == SQMOD_API_VER)
{
return true;
}
// Log the incident
OutputError("API version mismatch on %s", mod);
OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
// Invoker should not attempt to communicate through the module API
return false;
}
// ------------------------------------------------------------------------------------------------
bool CheckModuleOrder(PluginFuncs * vcapi, uint32_t mod_id, const SQChar * mod)
{
// Make sure a valid server API was provided
if (!vcapi)
{
OutputError("Invalid pointer to server API structure");
// Validation failed!
return false;
}
// Attempt to find the host plug-in identifier
const int plugin_id = vcapi->FindPlugin(SQMOD_HOST_NAME);
// See if our module was loaded after the host plug-in
if (plugin_id < 0)
{
OutputError("%s: could find the host plug-in", mod);
// Validation failed!
return false;
}
// Should never reach this point but just in case
else if (static_cast< uint32_t >(plugin_id) > mod_id)
{
OutputError("%s: loaded after the host plug-in", mod);
// Validation failed!
return false;
}
// Loaded in the correct order
return true;
}
// ------------------------------------------------------------------------------------------------
void ImportModuleAPI(PluginFuncs * vcapi, const SQChar * mod)
{
// Make sure a valid server API was provided
if (!vcapi)
{
STHROWF("%s: Invalid pointer to server API structure", mod);
}
size_t exports_struct_size;
// Attempt to find the host plug-in identifier
int plugin_id = vcapi->FindPlugin(SQMOD_HOST_NAME);
// Validate the obtained plug-in identifier
if (plugin_id < 0)
{
STHROWF("%s: Unable to obtain the host plug-in identifier", mod);
}
// Attempt to retrieve the host plug-in exports
const void ** raw_plugin_exports = vcapi->GetPluginExports(plugin_id, &exports_struct_size);
// See if the size of the exports structure matches
if (exports_struct_size <= 0)
{
STHROWF("%s: Incompatible host plug-in exports structure", mod);
}
// See if we have any exports from the host plug-in
else if (raw_plugin_exports == nullptr)
{
STHROWF("%s: Unable to obtain pointer host plug-in exports", mod);
}
// Obtain pointer to the exports structure
const SQMODEXPORTS * plugin_exports = *reinterpret_cast< const SQMODEXPORTS ** >(raw_plugin_exports);
// See if we have a valid pointer to the exports structure
if (plugin_exports == nullptr)
{
STHROWF("%s: Invalid pointer to host plug-in exports structure", mod);
}
else if (plugin_exports->PopulateModuleAPI == nullptr || plugin_exports->PopulateSquirrelAPI == nullptr)
{
STHROWF("%s: Invalid pointer to host plug-in import functions", mod);
}
// Prepare a structure to obtain the module API
SQMODAPI sqmodapi;
// Attempt to populate the structure
switch (plugin_exports->PopulateModuleAPI(&sqmodapi, sizeof(SQMODAPI)))
{
case -1: STHROWF("%s: Incompatible module API structure", mod);
// fall through
case 0: STHROWF("%s: Invalid pointer to module API structure", mod);
}
// Prepare a structure to obtain the squirrel API
SQLIBAPI sqlibapi;
// Attempt to populate the structure
switch (plugin_exports->PopulateSquirrelAPI(&sqlibapi, sizeof(SQLIBAPI)))
{
case -1: STHROWF("%s: Incompatible squirrel API structure", mod);
// fall through
case 0: STHROWF("%s: Invalid pointer to squirrel API structure", mod);
}
// Attempt to expand the obtained API
if (!sqmod_api_expand(&sqmodapi))
{
// Collapse the API first
sqmod_api_collapse();
// Now it's safe to throw the exception
STHROWF("%s: Unable to expand module API structure", mod);
}
else if (!sqlib_api_expand(&sqlibapi))
{
// Collapse the API first
sqmod_api_collapse();
sqlib_api_collapse();
// Now it's safe to throw the exception
STHROWF("%s: Unable to expand module API structure", mod);
}
}
// ------------------------------------------------------------------------------------------------
int SampleFunction()
{
OutputMessage("Hello from the sample plug-in function!");
return rand();
}
// ------------------------------------------------------------------------------------------------
void SampleType::SampleMethod() const
{
OutputMessage("I have the values %d and %d", m_MyVal, mMyNum);
}
} // Namespace:: SqMod

View File

@ -1,153 +0,0 @@
#ifndef _SQSAMPLE_COMMON_HPP_
#define _SQSAMPLE_COMMON_HPP_
// ------------------------------------------------------------------------------------------------
#include <SqMod.h>
#include <sqrat.h>
#include <vcmp.h>
// ------------------------------------------------------------------------------------------------
#include <cstddef>
#include <cstdint>
#include <cassert>
#include <string>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
using namespace Sqrat;
/* ------------------------------------------------------------------------------------------------
* SOFTWARE INFORMATION
*/
#define SQSAMPLE_NAME "Squirrel Sample Module"
#define SQSAMPLE_AUTHOR "Sandu Liviu Catalin (S.L.C)"
#define SQSAMPLE_COPYRIGHT "Copyright (C) 2018 Sandu Liviu Catalin"
#define SQSAMPLE_HOST_NAME "SqModSampleHost"
#define SQSAMPLE_VERSION 001
#define SQSAMPLE_VERSION_STR "0.0.1"
#define SQSAMPLE_VERSION_MAJOR 0
#define SQSAMPLE_VERSION_MINOR 0
#define SQSAMPLE_VERSION_PATCH 1
/* ------------------------------------------------------------------------------------------------
* LOGGING LOCATION
*/
#define SQMOD_TRUESTRINGIZE(x) #x
#define SQMOD_STRINGIZEWRAP(x) SQMOD_TRUESTRINGIZE(x)
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
#define SQMOD_MSGLOC(m) (m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ")
#else
#define SQMOD_MSGLOC(m) (m)
#endif // _DEBUG
/* ------------------------------------------------------------------------------------------------
* EXCEPTION THROWING
*/
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
#define STHROWF(m, ...) SqThrowF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
#define STHROWLASTF(m, ...) SqThrowLastF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
#else
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
#define STHROWF(m, ...) SqThrowF(m, ##__VA_ARGS__)
#define STHROWLASTF(m, ...) SqThrowLastF(m, ##__VA_ARGS__)
#endif // _DEBUG
/* ------------------------------------------------------------------------------------------------
* GENERAL RESPONSES
*/
#define SQMOD_SUCCESS 1
#define SQMOD_FAILURE 0
#define SQMOD_UNKNOWN (-1)
/* ------------------------------------------------------------------------------------------------
* Proxies to communicate with the server.
*/
extern PluginFuncs* _Func;
extern PluginCallbacks* _Clbk;
extern PluginInfo* _Info;
/* ------------------------------------------------------------------------------------------------
* Generate a formatted string and throw it as a sqrat exception.
*/
void SqThrowF(const char * str, ...);
/* ------------------------------------------------------------------------------------------------
* Output a message only if the _DEBUG was defined.
*/
void OutputDebug(const SQChar * msg, ...);
/* ------------------------------------------------------------------------------------------------
* Output a formatted user message to the console.
*/
void OutputMessage(const SQChar * msg, ...);
/* ------------------------------------------------------------------------------------------------
* Output a formatted error message to the console.
*/
void OutputError(const SQChar * msg, ...);
/* ------------------------------------------------------------------------------------------------
* Validate the module API to make sure we don't run into issues.
*/
bool CheckModuleAPIVer(const SQChar * ver, const SQChar * mod);
/* ------------------------------------------------------------------------------------------------
* Make sure that the module was loaded after the host plug-in.
*/
bool CheckModuleOrder(PluginFuncs * vcapi, uint32_t mod_id, const SQChar * mod);
/* ------------------------------------------------------------------------------------------------
* Used by the modules to import the API from the host plug-in.
*/
void ImportModuleAPI(PluginFuncs * vcapi, const SQChar * mod);
/* --------------------------------------------------------------------------------------------
* Sample Plug-in API
*/
int SampleFunction();
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;
};
} // Namespace:: SqMod
#endif // _SQSAMPLE_COMMON_HPP_

View File

@ -1,201 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstdio>
#include <cstdlib>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Register the module API under the obtained virtual machine.
*/
static bool RegisterAPI(HSQUIRRELVM vm)
{
// Make sure there's a valid virtual machine before proceeding
if (!vm)
{
OutputError("%s: Cannot register API without a valid virtual machine", SQSAMPLE_NAME);
// Registration failed
return false;
}
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);
// Registration was successful
return true;
}
/* ------------------------------------------------------------------------------------------------
* Load the module on the virtual machine provided by the host module.
*/
static bool OnSquirrelLoad()
{
// Make sure that we have a valid module API
if (!SqMod_GetSquirrelVM)
{
OutputError("%s: Cannot obtain the Squirrel virtual machine without the module API", SQSAMPLE_NAME);
// Unable to proceed!
return false;
}
// Obtain the Squirrel virtual machine from the host plug-in
DefaultVM::Set(SqMod_GetSquirrelVM());
// Make sure that a valid virtual machine exists
if (!DefaultVM::Get())
{
OutputError("%s: Squirrel virtual machine obtained from the host plug-in is invalid", SQSAMPLE_NAME);
// Unable to proceed!
return false;
}
// Register the module API
if (RegisterAPI(DefaultVM::Get()))
{
OutputMessage("Registered: %s", SQSAMPLE_NAME);
}
else
{
return false;
}
// At this point, the module was successfully loaded
return true;
}
/* ------------------------------------------------------------------------------------------------
* The virtual machine is about to be terminated and script resources should be released.
*/
static void OnSquirrelTerminate()
{
OutputMessage("Terminating: %s", SQSAMPLE_NAME);
// Release script resources...
}
/* ------------------------------------------------------------------------------------------------
* The virtual machined is about to be closed. Last chance to release anything manually.
*/
static void OnSquirrelClosing()
{
// Nothing to release manually...
}
/* ------------------------------------------------------------------------------------------------
* The virtual machined was closed and all memory associated with it was released.
*/
static void OnSquirrelReleased()
{
// Release the current virtual machine, if any
DefaultVM::Set(nullptr);
}
/* ------------------------------------------------------------------------------------------------
* React to command sent by other plug-ins.
*/
static uint8_t OnPluginCommand(uint32_t command_identifier, const char * message)
{
switch(command_identifier)
{
case SQMOD_INITIALIZE_CMD:
{
if (CheckModuleAPIVer(message, SQSAMPLE_NAME))
{
try
{
ImportModuleAPI(_Func, SQSAMPLE_NAME);
}
catch (const Sqrat::Exception & e)
{
OutputError("%s", e.what());
// Failed to initialize
return 0;
}
}
} break;
case SQMOD_LOAD_CMD:
{
return OnSquirrelLoad();
} break;
case SQMOD_TERMINATE_CMD:
{
OnSquirrelTerminate();
} break;
case SQMOD_CLOSING_CMD:
{
OnSquirrelClosing();
} break;
case SQMOD_RELEASED_CMD:
{
OnSquirrelReleased();
} break;
default: break;
}
return 1;
}
/* ------------------------------------------------------------------------------------------------
* The server was initialized and this plug-in was loaded successfully.
*/
static uint8_t OnServerInitialise()
{
return 1; // Initialization was successful
}
/* ------------------------------------------------------------------------------------------------
* The server is about to shutdown gracefully.
*/
static void OnServerShutdown(void)
{
// The server may still send callbacks
_Clbk->OnServerInitialise = nullptr;
_Clbk->OnServerShutdown = nullptr;
_Clbk->OnPluginCommand = nullptr;
}
} // Namespace:: SqMod
// ------------------------------------------------------------------------------------------------
SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCallbacks * callbacks, PluginInfo * info)
{
using namespace SqMod;
// Output plug-in header
puts("");
OutputMessage("--------------------------------------------------------------------");
OutputMessage("Plug-in: %s", SQSAMPLE_NAME);
OutputMessage("Author: %s", SQSAMPLE_AUTHOR);
OutputMessage("Legal: %s", SQSAMPLE_COPYRIGHT);
OutputMessage("--------------------------------------------------------------------");
puts("");
// Make sure that the module was loaded after the host plug-in
if (!CheckModuleOrder(functions, info->pluginId, SQSAMPLE_NAME))
{
return SQMOD_FAILURE;
}
// Store server proxies
_Func = functions;
_Clbk = callbacks;
_Info = info;
// Assign plug-in version
_Info->pluginVersion = SQSAMPLE_VERSION;
_Info->apiMajorVersion = PLUGIN_API_MAJOR;
_Info->apiMinorVersion = PLUGIN_API_MINOR;
// Assign the plug-in name
std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQSAMPLE_HOST_NAME);
// Bind to the server callbacks
_Clbk->OnServerInitialise = OnServerInitialise;
_Clbk->OnServerShutdown = OnServerShutdown;
_Clbk->OnPluginCommand = OnPluginCommand;
// Notify that the plug-in was successfully loaded
OutputMessage("Successfully loaded %s", SQSAMPLE_NAME);
// Dummy spacing
puts("");
// Done!
return SQMOD_SUCCESS;
}

View File

@ -66,6 +66,30 @@ extern void LogSWrn(CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 1, 2);
extern void LogSErr(CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 1, 2); extern void LogSErr(CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 1, 2);
extern void LogSFtl(CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 1, 2); extern void LogSFtl(CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 1, 2);
/* ------------------------------------------------------------------------------------------------
* Forward declarations of the logging functions to avoid including the logger everywhere.
* Primary logging functions.
*/
extern void LogDbgV(CCStr fmt, va_list vlist);
extern void LogUsrV(CCStr fmt, va_list vlist);
extern void LogScsV(CCStr fmt, va_list vlist);
extern void LogInfV(CCStr fmt, va_list vlist);
extern void LogWrnV(CCStr fmt, va_list vlist);
extern void LogErrV(CCStr fmt, va_list vlist);
extern void LogFtlV(CCStr fmt, va_list vlist);
/* ------------------------------------------------------------------------------------------------
* Forward declarations of the logging functions to avoid including the logger everywhere.
* Secondary logging functions.
*/
extern void LogSDbgV(CCStr fmt, va_list vlist);
extern void LogSUsrV(CCStr fmt, va_list vlist);
extern void LogSScsV(CCStr fmt, va_list vlist);
extern void LogSInfV(CCStr fmt, va_list vlist);
extern void LogSWrnV(CCStr fmt, va_list vlist);
extern void LogSErrV(CCStr fmt, va_list vlist);
extern void LogSFtlV(CCStr fmt, va_list vlist);
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Forward declarations of the logging functions to avoid including the logger everywhere. * Forward declarations of the logging functions to avoid including the logger everywhere.
* Primary conditional logging functions. * Primary conditional logging functions.

View File

@ -73,10 +73,8 @@ add_library(SqModule MODULE
Misc/Vehicle.cpp Misc/Vehicle.hpp Misc/Vehicle.cpp Misc/Vehicle.hpp
Misc/Weapon.cpp Misc/Weapon.hpp Misc/Weapon.cpp Misc/Weapon.hpp
) )
# Link to base libraries # Link to libraries
target_link_libraries(SqModule VCMP Squirrel Sqrat SqSDKAPI) target_link_libraries(SqModule SqModSDK SimpleINI HashLib B64Lib AES256Lib WhirlpoolLib TinyDir PUGIXML SQLite MaxmindDB SimpleSocket)
# Link to third-party libraries
target_link_libraries(SqModule SimpleINI HashLib B64Lib AES256Lib WhirlpoolLib TinyDir PUGIXML SQLite MaxmindDB SimpleSocket)
# Link to mysql client library # Link to mysql client library
if(ENABLE_MYSQL) if(ENABLE_MYSQL)
# Include the implementation # Include the implementation

View File

@ -16,12 +16,12 @@
#include "Entity/Vehicle.hpp" #include "Entity/Vehicle.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <SqMod.h>
#include <sqstdio.h> #include <sqstdio.h>
#include <sqstdblob.h> #include <sqstdblob.h>
#include <sqstdmath.h> #include <sqstdmath.h>
#include <sqstdsystem.h> #include <sqstdsystem.h>
#include <sqstdstring.h> #include <sqstdstring.h>
#include <sqmodapi.h>
#include <SimpleIni.h> #include <SimpleIni.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -680,6 +680,32 @@ SQMOD_LOG(LogSWrn, LOGL_WRN, true)
SQMOD_LOG(LogSErr, LOGL_ERR, true) SQMOD_LOG(LogSErr, LOGL_ERR, true)
SQMOD_LOG(LogSFtl, LOGL_FTL, true) SQMOD_LOG(LogSFtl, LOGL_FTL, true)
// ------------------------------------------------------------------------------------------------
#define SQMOD_VLOG(N_, L_, S_) /*
*/ void N_(CCStr fmt, va_list vlist) /*
*/ { /*
*/ Logger::Get().Send(L_, S_, fmt, vlist); /*
*/ } /*
*/
// ------------------------------------------------------------------------------------------------
SQMOD_VLOG(LogDbgV, LOGL_DBG, false)
SQMOD_VLOG(LogUsrV, LOGL_USR, false)
SQMOD_VLOG(LogScsV, LOGL_SCS, false)
SQMOD_VLOG(LogInfV, LOGL_INF, false)
SQMOD_VLOG(LogWrnV, LOGL_WRN, false)
SQMOD_VLOG(LogErrV, LOGL_ERR, false)
SQMOD_VLOG(LogFtlV, LOGL_FTL, false)
// ------------------------------------------------------------------------------------------------
SQMOD_VLOG(LogSDbgV, LOGL_DBG, true)
SQMOD_VLOG(LogSUsrV, LOGL_USR, true)
SQMOD_VLOG(LogSScsV, LOGL_SCS, true)
SQMOD_VLOG(LogSInfV, LOGL_INF, true)
SQMOD_VLOG(LogSWrnV, LOGL_WRN, true)
SQMOD_VLOG(LogSErrV, LOGL_ERR, true)
SQMOD_VLOG(LogSFtlV, LOGL_FTL, true)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#define SQMOD_CLOG(N_, L_, S_) /* #define SQMOD_CLOG(N_, L_, S_) /*
*/bool N_(bool c, CCStr fmt, ...) /* */bool N_(bool c, CCStr fmt, ...) /*

View File

@ -1,11 +1,13 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Logger.hpp" #include "Logger.hpp"
#include "Core.hpp" #include "Core.hpp"
#include "SqMod.h"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <cstdio> #include <cstdio>
// ------------------------------------------------------------------------------------------------
#include <sqmodapi.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#ifdef SQMOD_OS_WINDOWS #ifdef SQMOD_OS_WINDOWS
#include <Winsock2.h> #include <Winsock2.h>

View File

@ -8,7 +8,7 @@
#include <sqstdio.h> #include <sqstdio.h>
#include <sqstdblob.h> #include <sqstdblob.h>
#include <sqstdstring.h> #include <sqstdstring.h>
#include <SqMod.h> #include <sqmodapi.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
@ -61,6 +61,20 @@ static int32_t SqExport_PopulateModuleAPI(HSQMODAPI api, size_t size)
api->LogSWrn = LogSWrn; api->LogSWrn = LogSWrn;
api->LogSErr = LogSErr; api->LogSErr = LogSErr;
api->LogSFtl = LogSFtl; api->LogSFtl = LogSFtl;
api->LogDbgV = LogDbgV;
api->LogUsrV = LogUsrV;
api->LogScsV = LogScsV;
api->LogInfV = LogInfV;
api->LogWrnV = LogWrnV;
api->LogErrV = LogErrV;
api->LogFtlV = LogFtlV;
api->LogSDbgV = LogSDbgV;
api->LogSUsrV = LogSUsrV;
api->LogSScsV = LogSScsV;
api->LogSInfV = LogSInfV;
api->LogSWrnV = LogSWrnV;
api->LogSErrV = LogSErrV;
api->LogSFtlV = LogSFtlV;
//script loading //script loading
api->LoadScript = SqModImpl_LoadScript; api->LoadScript = SqModImpl_LoadScript;

2
sdk

@ -1 +1 @@
Subproject commit 7d240a80294f09e877f82ba7818103ffa2104815 Subproject commit 0d7324fda957ed56531d94e8871b8e90e8b1288a

View File

@ -1,8 +0,0 @@
# Create the VCMP library
add_library(VCMP STATIC vcmp.h vcmp.c vcmp20.h vcmp21.h)
# Checkf for API version
if (ENABLE_API21)
target_compile_definitions(VCMP PUBLIC VCMP_SDK_2_1=1)
endif()
# Library includes
target_include_directories(VCMP PUBLIC ${CMAKE_CURRENT_LIST_DIR})

View File

@ -1 +0,0 @@
#include <vcmp.h>

View File

@ -1,8 +0,0 @@
#pragma once
//#define VCMP_SDK_2_1
// Choose which SDK to use
#ifdef VCMP_SDK_2_1
#include "vcmp21.h"
#else
#include "vcmp20.h"
#endif

View File

@ -1,975 +0,0 @@
/*
Project: Vice City Multiplayer 0.4 Server / Plugin Kit
File: plugin.h
Copyright 2011-2016 Ago Allikmaa (maxorator)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <stdlib.h>
typedef struct {
uint32_t structSize;
char serverName[128];
uint32_t maxPlayers;
uint32_t port;
uint32_t flags;
} ServerSettings;
#define PLUGIN_API_MAJOR 2
#define PLUGIN_API_MINOR 0
typedef struct {
uint32_t structSize;
uint32_t pluginId;
char name[32];
uint32_t pluginVersion;
uint16_t apiMajorVersion;
uint16_t apiMinorVersion;
} PluginInfo;
typedef enum {
vcmpErrorNone = 0,
vcmpErrorNoSuchEntity = 1,
vcmpErrorBufferTooSmall = 2,
vcmpErrorTooLargeInput = 3,
vcmpErrorArgumentOutOfBounds = 4,
vcmpErrorNullArgument = 5,
vcmpErrorPoolExhausted = 6,
vcmpErrorInvalidName = 7,
vcmpErrorRequestDenied = 8,
forceSizeVcmpError = INT32_MAX
} vcmpError;
typedef enum {
vcmpEntityPoolVehicle = 1,
vcmpEntityPoolObject = 2,
vcmpEntityPoolPickup = 3,
vcmpEntityPoolRadio = 4,
vcmpEntityPoolBlip = 7,
vcmpEntityPoolCheckPoint = 8,
forceSizeVcmpEntityPool = INT32_MAX
} vcmpEntityPool;
typedef enum {
vcmpDisconnectReasonTimeout = 0,
vcmpDisconnectReasonQuit = 1,
vcmpDisconnectReasonKick = 2,
vcmpDisconnectReasonCrash = 3,
vcmpDisconnectReasonAntiCheat = 4,
forceSizeVcmpDisconnectReason = INT32_MAX
} vcmpDisconnectReason;
typedef enum {
vcmpBodyPartBody = 0,
vcmpBodyPartTorso = 1,
vcmpBodyPartLeftArm = 2,
vcmpBodyPartRightArm = 3,
vcmpBodyPartLeftLeg = 4,
vcmpBodyPartRightLeg = 5,
vcmpBodyPartHead = 6,
vcmpBodyPartInVehicle = 7,
forceSizeVcmpBodyPart = INT32_MAX
} vcmpBodyPart;
typedef enum {
vcmpPlayerStateNone = 0,
vcmpPlayerStateNormal = 1,
vcmpPlayerStateAim = 2,
vcmpPlayerStateDriver = 3,
vcmpPlayerStatePassenger = 4,
vcmpPlayerStateEnterDriver = 5,
vcmpPlayerStateEnterPassenger = 6,
vcmpPlayerStateExit = 7,
vcmpPlayerStateUnspawned = 8,
forceSizeVcmpPlayerState = INT32_MAX
} vcmpPlayerState;
typedef enum {
vcmpPlayerUpdateNormal = 0,
vcmpPlayerUpdateAiming = 1,
vcmpPlayerUpdateDriver = 2,
vcmpPlayerUpdatePassenger = 3,
forceSizeVcmpPlayerUpdate = INT32_MAX
} vcmpPlayerUpdate;
typedef enum {
vcmpPlayerVehicleOut = 0,
vcmpPlayerVehicleEntering = 1,
vcmpPlayerVehicleExiting = 2,
vcmpPlayerVehicleIn = 3,
forceSizeVcmpPlayerVehicle = INT32_MAX
} vcmpPlayerVehicle;
typedef enum {
vcmpVehicleSyncNone = 0,
vcmpVehicleSyncDriver = 1,
vcmpVehicleSyncPassenger = 3,
vcmpVehicleSyncNear = 4,
forceSizeVcmpVehicleSync = INT32_MAX
} vcmpVehicleSync;
typedef enum {
vcmpVehicleUpdateDriverSync = 0,
vcmpVehicleUpdateOtherSync = 1,
vcmpVehicleUpdatePosition = 2,
vcmpVehicleUpdateHealth = 4,
vcmpVehicleUpdateColour = 5,
vcmpVehicleUpdateRotation = 6,
forceSizeVcmpVehicleUpdate = INT32_MAX
} vcmpVehicleUpdate;
typedef enum {
vcmpServerOptionSyncFrameLimiter = 0,
vcmpServerOptionFrameLimiter = 1,
vcmpServerOptionTaxiBoostJump = 2,
vcmpServerOptionDriveOnWater = 3,
vcmpServerOptionFastSwitch = 4,
vcmpServerOptionFriendlyFire = 5,
vcmpServerOptionDisableDriveBy = 6,
vcmpServerOptionPerfectHandling = 7,
vcmpServerOptionFlyingCars = 8,
vcmpServerOptionJumpSwitch = 9,
vcmpServerOptionShowMarkers = 10,
vcmpServerOptionOnlyShowTeamMarkers = 11,
vcmpServerOptionStuntBike = 12,
vcmpServerOptionShootInAir = 13,
vcmpServerOptionShowNameTags = 14,
vcmpServerOptionJoinMessages = 15,
vcmpServerOptionDeathMessages = 16,
vcmpServerOptionChatTagsEnabled = 17,
vcmpServerOptionUseClasses = 18,
vcmpServerOptionWallGlitch = 19,
vcmpServerOptionDisableBackfaceCulling = 20,
vcmpServerOptionDisableHeliBladeDamage = 21,
forceSizeVcmpServerOption = INT32_MAX
} vcmpServerOption;
typedef enum {
vcmpPlayerOptionControllable = 0,
vcmpPlayerOptionDriveBy = 1,
vcmpPlayerOptionWhiteScanlines = 2,
vcmpPlayerOptionGreenScanlines = 3,
vcmpPlayerOptionWidescreen = 4,
vcmpPlayerOptionShowMarkers = 5,
vcmpPlayerOptionCanAttack = 6,
vcmpPlayerOptionHasMarker = 7,
vcmpPlayerOptionChatTagsEnabled = 8,
vcmpPlayerOptionDrunkEffects = 9,
forceSizeVcmpPlayerOption = INT32_MAX
} vcmpPlayerOption;
typedef enum {
vcmpVehicleOptionDoorsLocked = 0,
vcmpVehicleOptionAlarm = 1,
vcmpVehicleOptionLights = 2,
vcmpVehicleOptionRadioLocked = 3,
vcmpVehicleOptionGhost = 4,
vcmpVehicleOptionSiren = 5,
vcmpVehicleOptionSingleUse = 6,
forceSizeVcmpVehicleOption = INT32_MAX
} vcmpVehicleOption;
typedef enum {
vcmpPickupOptionSingleUse = 0,
forceSizeVcmpPickupOption = INT32_MAX
} vcmpPickupOption;
typedef struct {
uint32_t structSize;
/**
* Plugin system
*/
/* success */
uint32_t (*GetServerVersion) (void);
/* vcmpErrorNullArgument */
vcmpError (*GetServerSettings) (ServerSettings* settings);
/* vcmpErrorNoSuchEntity */
vcmpError (*ExportFunctions) (int32_t pluginId, const void** functionList, size_t size);
/* success */
uint32_t (*GetNumberOfPlugins) (void);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument */
vcmpError (*GetPluginInfo) (int32_t pluginId, PluginInfo* pluginInfo);
/* -1 == vcmpEntityNone */
int32_t (*FindPlugin) (const char* pluginName);
/* GetLastError: vcmpErrorNoSuchEntity */
const void** (*GetPluginExports) (int32_t pluginId, size_t* exportCount);
/* vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendPluginCommand) (uint32_t commandIdentifier, const char* format, ...);
/* success */
uint64_t (*GetTime) (void);
/* vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*LogMessage) (const char* format, ...);
/* success */
vcmpError (*GetLastError) (void);
/**
* Client messages
*/
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendClientScriptData) (int32_t playerId, const void* data, size_t size);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendClientMessage) (int32_t playerId, uint32_t colour, const char* format, ...);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendGameMessage) (int32_t playerId, int32_t type, const char* format, ...);
/*
* Server settings
*/
/* vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SetServerName) (const char* text);
/* vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetServerName) (char* buffer, size_t size);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*SetMaxPlayers) (uint32_t maxPlayers);
/* success */
uint32_t (*GetMaxPlayers) (void);
/* vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SetServerPassword) (const char* password);
/* vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetServerPassword) (char* buffer, size_t size);
/* vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SetGameModeText) (const char* gameMode);
/* vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetGameModeText) (char* buffer, size_t size);
/* success */
void (*ShutdownServer) (void);
/*
* Game environment settings
*/
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*SetServerOption) (vcmpServerOption option, uint8_t toggle);
/* GetLastError: vcmpErrorArgumentOutOfBounds */
uint8_t (*GetServerOption) (vcmpServerOption option);
/* success */
void (*SetWorldBounds) (float maxX, float minX, float maxY, float minY);
/* success */
void (*GetWorldBounds) (float* maxXOut, float* minXOut, float* maxYOut, float* minYOut);
/* success */
void (*SetWastedSettings) (uint32_t deathTimer, uint32_t fadeTimer, float fadeInSpeed, float fadeOutSpeed, uint32_t fadeColour, uint32_t corpseFadeStart, uint32_t corpseFadeTime);
/* success */
void (*GetWastedSettings) (uint32_t* deathTimerOut, uint32_t* fadeTimerOut, float* fadeInSpeedOut, float* fadeOutSpeedOut, uint32_t* fadeColourOut, uint32_t* corpseFadeStartOut, uint32_t* corpseFadeTimeOut);
/* success */
void (*SetTimeRate) (int32_t timeRate);
/* success */
int32_t (*GetTimeRate) (void);
/* success */
void (*SetHour) (int32_t hour);
/* success */
int32_t (*GetHour) (void);
/* success */
void (*SetMinute) (int32_t minute);
/* success */
int32_t (*GetMinute) (void);
/* success */
void (*SetWeather) (int32_t weather);
/* success */
int32_t (*GetWeather) (void);
/* success */
void (*SetGravity) (float gravity);
/* success */
float (*GetGravity) (void);
/* success */
void (*SetGameSpeed) (float gameSpeed);
/* success */
float (*GetGameSpeed) (void);
/* success */
void (*SetWaterLevel) (float waterLevel);
/* success */
float (*GetWaterLevel) (void);
/* success */
void (*SetMaximumFlightAltitude) (float height);
/* success */
float (*GetMaximumFlightAltitude) (void);
/* success */
void (*SetKillCommandDelay) (int32_t delay);
/* success */
int32_t (*GetKillCommandDelay) (void);
/* success */
void (*SetVehiclesForcedRespawnHeight) (float height);
/* success */
float (*GetVehiclesForcedRespawnHeight) (void);
/*
* Miscellaneous things
*/
/* vcmpErrorArgumentOutOfBounds, vcmpErrorNoSuchEntity */
vcmpError (*CreateExplosion) (int32_t worldId, int32_t type, float x, float y, float z, int32_t responsiblePlayerId, uint8_t atGroundLevel);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*PlaySound) (int32_t worldId, int32_t soundId, float x, float y, float z);
/* success */
void (*HideMapObject) (int32_t modelId, int16_t tenthX, int16_t tenthY, int16_t tenthZ);
/* success */
void (*ShowMapObject) (int32_t modelId, int16_t tenthX, int16_t tenthY, int16_t tenthZ);
/* success */
void (*ShowAllMapObjects) (void);
/*
* Weapon settings
*/
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*SetWeaponDataValue) (int32_t weaponId, int32_t fieldId, double value);
/* GetLastError: vcmpErrorArgumentOutOfBounds */
double (*GetWeaponDataValue) (int32_t weaponId, int32_t fieldId);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*ResetWeaponDataValue) (int32_t weaponId, int32_t fieldId);
/* GetLastError: vcmpErrorArgumentOutOfBounds */
uint8_t (*IsWeaponDataValueModified) (int32_t weaponId, int32_t fieldId);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*ResetWeaponData) (int32_t weaponId);
/* success */
void (*ResetAllWeaponData) (void);
/*
* Key binds
*/
/* -1 == vcmpEntityNone */
int32_t (*GetKeyBindUnusedSlot) (void);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetKeyBindData) (int32_t bindId, uint8_t* isCalledOnReleaseOut, int32_t* keyOneOut, int32_t* keyTwoOut, int32_t* keyThreeOut);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*RegisterKeyBind) (int32_t bindId, uint8_t isCalledOnRelease, int32_t keyOne, int32_t keyTwo, int32_t keyThree);
/* vcmpErrorNoSuchEntity */
vcmpError (*RemoveKeyBind) (int32_t bindId);
/* success */
void (*RemoveAllKeyBinds) (void);
/*
* Coordinate blips
*/
/* GetLastError: vcmpErrorPoolExhausted */
int32_t (*CreateCoordBlip) (int32_t index, int32_t world, float x, float y, float z, int32_t scale, uint32_t colour, int32_t sprite);
/* vcmpErrorNoSuchEntity */
vcmpError (*DestroyCoordBlip) (int32_t index);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetCoordBlipInfo) (int32_t index, int32_t* worldOut, float* xOut, float* yOUt, float* zOut, int32_t* scaleOut, uint32_t* colourOut, int32_t* spriteOut);
/*
* Radios
*/
/* vcmpErrorArgumentOutOfBounds, vcmpErrorNullArgument */
vcmpError (*AddRadioStream) (int32_t radioId, const char* radioName, const char* radioUrl, uint8_t isListed);
/* vcmpErrorNoSuchEntity */
vcmpError (*RemoveRadioStream) (int32_t radioId);
/*
* Spawning and classes
*/
/* GetLastError: vcmpErrorArgumentOutOfBounds, vcmpErrorPoolExhausted */
int32_t (*AddPlayerClass) (int32_t teamId, uint32_t colour, int32_t modelIndex, float x, float y, float z, float angle, int32_t weaponOne, int32_t weaponOneAmmo, int32_t weaponTwo, int32_t weaponTwoAmmo, int32_t weaponThree, int32_t weaponThreeAmmo);
/* success */
void (*SetSpawnPlayerPosition) (float x, float y, float z);
/* success */
void (*SetSpawnCameraPosition) (float x, float y, float z);
/* success */
void (*SetSpawnCameraLookAt) (float x, float y, float z);
/*
* Administration
*/
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerAdmin) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerAdmin) (int32_t playerId, uint8_t toggle);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetPlayerIP) (int32_t playerId, char* buffer, size_t size);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetPlayerUID) (int32_t playerId, char* buffer, size_t size);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetPlayerUID2) (int32_t playerId, char* buffer, size_t size);
/* vcmpErrorNoSuchEntity */
vcmpError (*KickPlayer) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*BanPlayer) (int32_t playerId);
/* success */
void (*BanIP) (char* ipAddress);
/* success */
uint8_t (*UnbanIP) (char* ipAddress);
/* success */
uint8_t (*IsIPBanned) (char* ipAddress);
/*
* Player access and basic info
*/
/* -1 == vcmpEntityNone */
int32_t (*GetPlayerIdFromName) (const char* name);
/* success */
uint8_t (*IsPlayerConnected) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerStreamedForPlayer) (int32_t checkedPlayerId, int32_t playerId);
/* vcmpErrorNoSuchEntity */
uint32_t (*GetPlayerKey) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorBufferTooSmall */
vcmpError (*GetPlayerName) (int32_t playerId, char* buffer, size_t size);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorInvalidName, vcmpErrorTooLargeInput */
vcmpError (*SetPlayerName) (int32_t playerId, const char* name);
/* GetLastError: vcmpErrorNoSuchEntity */
vcmpPlayerState (*GetPlayerState) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPlayerOption) (int32_t playerId, vcmpPlayerOption option, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
uint8_t (*GetPlayerOption) (int32_t playerId, vcmpPlayerOption option);
/*
* Player world
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerWorld) (int32_t playerId, int32_t world);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerWorld) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerSecondaryWorld) (int32_t playerId, int32_t secondaryWorld);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerSecondaryWorld) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerUniqueWorld) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerWorldCompatible) (int32_t playerId, int32_t world);
/*
* Player class, team, skin, colour
*/
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerClass) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPlayerTeam) (int32_t playerId, int32_t teamId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerTeam) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPlayerSkin) (int32_t playerId, int32_t skinId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerSkin) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerColour) (int32_t playerId, uint32_t colour);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetPlayerColour) (int32_t playerId);
/*
* Player spawn cycle
*/
/* vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerSpawned) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*ForcePlayerSpawn) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*ForcePlayerSelect) (int32_t playerId);
/* success */
void (*ForceAllSelect) (void);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerTyping) (int32_t playerId);
/*
* Player money, score, wanted level
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*GivePlayerMoney) (int32_t playerId, int32_t amount);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerMoney) (int32_t playerId, int32_t amount);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerMoney) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerScore) (int32_t playerId, int32_t score);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerScore) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerWantedLevel) (int32_t playerId, int32_t level);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerWantedLevel) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerPing) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
double (*GetPlayerFPS) (int32_t playerId);
/*
* Player health and immunity
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerHealth) (int32_t playerId, float health);
/* GetLastError: vcmpErrorNoSuchEntity */
float (*GetPlayerHealth) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerArmour) (int32_t playerId, float armour);
/* GetLastError: vcmpErrorNoSuchEntity */
float (*GetPlayerArmour) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerImmunityFlags) (int32_t playerId, uint32_t flags);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetPlayerImmunityFlags) (int32_t playerId);
/*
* Player position and rotation
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerPosition) (int32_t playerId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetPlayerPosition) (int32_t playerId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerSpeed) (int32_t playerId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetPlayerSpeed) (int32_t playerId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*AddPlayerSpeed) (int32_t playerId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerHeading) (int32_t playerId, float angle);
/* GetLastError: vcmpErrorNoSuchEntity */
float (*GetPlayerHeading) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerAlpha) (int32_t playerId, int32_t alpha, uint32_t fadeTime);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerAlpha) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetPlayerAimPosition) (int32_t playerId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetPlayerAimDirection) (int32_t playerId, float* xOut, float* yOut, float* zOut);
/*
* Player actions and keys
*/
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerOnFire) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerCrouching) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerAction) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetPlayerGameKeys) (int32_t playerId);
/*
* Player vehicle
*/
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds, vcmpErrorRequestDenied */
vcmpError (*PutPlayerInVehicle) (int32_t playerId, int32_t vehicleId, int32_t slotIndex, uint8_t makeRoom, uint8_t warp);
/* vcmpErrorNoSuchEntity */
vcmpError (*RemovePlayerFromVehicle) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
vcmpPlayerVehicle (*GetPlayerInVehicleStatus) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerInVehicleSlot) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerVehicleId) (int32_t playerId);
/*
* Player weapons
*/
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*GivePlayerWeapon) (int32_t playerId, int32_t weaponId, int32_t ammo);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPlayerWeapon) (int32_t playerId, int32_t weaponId, int32_t ammo);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerWeapon) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerWeaponAmmo) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPlayerWeaponSlot) (int32_t playerId, int32_t slot);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerWeaponSlot) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
int32_t (*GetPlayerWeaponAtSlot) (int32_t playerId, int32_t slot);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
int32_t (*GetPlayerAmmoAtSlot) (int32_t playerId, int32_t slot);
/* vcmpErrorNoSuchEntity */
vcmpError (*RemovePlayerWeapon) (int32_t playerId, int32_t weaponId);
/* vcmpErrorNoSuchEntity */
vcmpError (*RemoveAllWeapons) (int32_t playerId);
/*
* Player camera
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*SetCameraPosition) (int32_t playerId, float posX, float posY, float posZ, float lookX, float lookY, float lookZ);
/* vcmpErrorNoSuchEntity */
vcmpError (*RestoreCamera) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsCameraLocked) (int32_t playerId);
/*
* Player miscellaneous stuff
*/
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerAnimation) (int32_t playerId, int32_t groupId, int32_t animationId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerStandingOnVehicle) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPlayerStandingOnObject) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPlayerAway) (int32_t playerId);
/* vcmpErrorNoSuchEntity */
int32_t (*GetPlayerSpectateTarget) (int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
vcmpError (*SetPlayerSpectateTarget) (int32_t playerId, int32_t targetId);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument */
vcmpError (*RedirectPlayerToServer) (int32_t playerId, const char* ip, uint32_t port, const char* nick, const char* serverPassword, const char* userPassword);
/*
* All entities
*/
/* GetLastError: vcmpArgumentOutOfBounds */
uint8_t (*CheckEntityExists) (vcmpEntityPool entityPool, int32_t index);
/*
* Vehicles
*/
/* GetLastError: vcmpErrorArgumentOutOfBounds, vcmpErrorPoolExhausted */
int32_t (*CreateVehicle) (int32_t modelIndex, int32_t world, float x, float y, float z, float angle, int32_t primaryColour, int32_t secondaryColour);
/* vcmpErrorNoSuchEntity */
vcmpError (*DeleteVehicle) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetVehicleOption) (int32_t vehicleId, vcmpVehicleOption option, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
uint8_t (*GetVehicleOption) (int32_t vehicleId, vcmpVehicleOption option);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehicleSyncSource) (int32_t vehicleId);
/* GetLastError: vcmpErrorNoSuchEntity */
vcmpVehicleSync (*GetVehicleSyncType) (int32_t vehicleId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsVehicleStreamedForPlayer) (int32_t vehicleId, int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleWorld) (int32_t vehicleId, int32_t world);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehicleWorld) (int32_t vehicleId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehicleModel) (int32_t vehicleId);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
int32_t (*GetVehicleOccupant) (int32_t vehicleId, int32_t slotIndex);
/* vcmpErrorNoSuchEntity */
vcmpError (*RespawnVehicle) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleImmunityFlags) (int32_t vehicleId, uint32_t immunityFlags);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetVehicleImmunityFlags) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*ExplodeVehicle) (int32_t vehicleId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsVehicleWrecked) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehiclePosition) (int32_t vehicleId, float x, float y, float z, uint8_t removeOccupants);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehiclePosition) (int32_t vehicleId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleRotation) (int32_t vehicleId, float x, float y, float z, float w);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleRotationEuler) (int32_t vehicleId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleRotation) (int32_t vehicleId, float* xOut, float* yOut, float* zOut, float* wOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleRotationEuler) (int32_t vehicleId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleSpeed) (int32_t vehicleId, float x, float y, float z, uint8_t add, uint8_t relative);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleSpeed) (int32_t vehicleId, float* xOut, float* yOut, float* zOut, uint8_t relative);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleTurnSpeed) (int32_t vehicleId, float x, float y, float z, uint8_t add, uint8_t relative);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleTurnSpeed) (int32_t vehicleId, float* xOut, float* yOut, float* zOut, uint8_t relative);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleSpawnPosition) (int32_t vehicleId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleSpawnPosition) (int32_t vehicleId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleSpawnRotation) (int32_t vehicleId, float x, float y, float z, float w);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleSpawnRotationEuler) (int32_t vehicleId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleSpawnRotation) (int32_t vehicleId, float* xOut, float* yOut, float* zOut, float* wOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleSpawnRotationEuler) (int32_t vehicleId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleIdleRespawnTimer) (int32_t vehicleId, uint32_t millis);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetVehicleIdleRespawnTimer) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleHealth) (int32_t vehicleId, float health);
/* GetLastError: vcmpErrorNoSuchEntity */
float (*GetVehicleHealth) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleColour) (int32_t vehicleId, int32_t primaryColour, int32_t secondaryColour);
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument */
vcmpError (*GetVehicleColour) (int32_t vehicleId, int32_t* primaryColourOut, int32_t* secondaryColourOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehiclePartStatus) (int32_t vehicleId, int32_t partId, int32_t status);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehiclePartStatus) (int32_t vehicleId, int32_t partId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleTyreStatus) (int32_t vehicleId, int32_t tyreId, int32_t status);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehicleTyreStatus) (int32_t vehicleId, int32_t tyreId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleDamageData) (int32_t vehicleId, uint32_t damageData);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetVehicleDamageData) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetVehicleRadio) (int32_t vehicleId, int32_t radioId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetVehicleRadio) (int32_t vehicleId);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetVehicleTurretRotation) (int32_t vehicleId, float* horizontalOut, float* verticalOut);
/*
* Vehicle handling
*/
/* success */
void (*ResetAllVehicleHandlings) (void);
/* vcmpErrorArgumentOutOfBounds */
uint8_t (*ExistsHandlingRule) (int32_t modelIndex, int32_t ruleIndex);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*SetHandlingRule) (int32_t modelIndex, int32_t ruleIndex, double value);
/* GetLastError: vcmpErrorArgumentOutOfBounds */
double (*GetHandlingRule) (int32_t modelIndex, int32_t ruleIndex);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*ResetHandlingRule) (int32_t modelIndex, int32_t ruleIndex);
/* vcmpErrorArgumentOutOfBounds */
vcmpError (*ResetHandling) (int32_t modelIndex);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
uint8_t (*ExistsInstHandlingRule) (int32_t vehicleId, int32_t ruleIndex);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetInstHandlingRule) (int32_t vehicleId, int32_t ruleIndex, double value);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
double (*GetInstHandlingRule) (int32_t vehicleId, int32_t ruleIndex);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*ResetInstHandlingRule) (int32_t vehicleId, int32_t ruleIndex);
/* vcmpErrorNoSuchEntity */
vcmpError (*ResetInstHandling) (int32_t vehicleId);
/*
* Pickups
*/
/* vcmpErrorPoolExhausted */
int32_t (*CreatePickup) (int32_t modelIndex, int32_t world, int32_t quantity, float x, float y, float z, int32_t alpha, uint8_t isAutomatic);
/* vcmpErrorNoSuchEntity */
vcmpError (*DeletePickup) (int32_t pickupId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPickupStreamedForPlayer) (int32_t pickupId, int32_t playerId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPickupWorld) (int32_t pickupId, int32_t world);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPickupWorld) (int32_t pickupId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPickupAlpha) (int32_t pickupId, int32_t alpha);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPickupAlpha) (int32_t pickupId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPickupIsAutomatic) (int32_t pickupId, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsPickupAutomatic) (int32_t pickupId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPickupAutoTimer) (int32_t pickupId, uint32_t durationMillis);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t (*GetPickupAutoTimer) (int32_t pickupId);
/* vcmpErrorNoSuchEntity */
vcmpError (*RefreshPickup) (int32_t pickupId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetPickupPosition) (int32_t pickupId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetPickupPosition) (int32_t pickupId, float* xOut, float* yOut, float* zOut);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPickupModel) (int32_t pickupId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetPickupQuantity) (int32_t pickupId);
/*
* Checkpoints
*/
/* vcmpErrorPoolExhausted, vcmpErrorNoSuchEntity */
int32_t (*CreateCheckPoint) (int32_t playerId, int32_t world, uint8_t isSphere, float x, float y, float z, int32_t red, int32_t green, int32_t blue, int32_t alpha, float radius);
/* vcmpErrorNoSuchEntity */
vcmpError (*DeleteCheckPoint) (int32_t checkPointId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsCheckPointStreamedForPlayer) (int32_t checkPointId, int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsCheckPointSphere) (int32_t checkPointId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetCheckPointWorld) (int32_t checkPointId, int32_t world);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetCheckPointWorld) (int32_t checkPointId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetCheckPointColour) (int32_t checkPointId, int32_t red, int32_t green, int32_t blue, int32_t alpha);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetCheckPointColour) (int32_t checkPointId, int32_t* redOut, int32_t* greenOut, int32_t* blueOut, int32_t* alphaOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetCheckPointPosition) (int32_t checkPointId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetCheckPointPosition) (int32_t checkPointId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetCheckPointRadius) (int32_t checkPointId, float radius);
/* GetLastError: vcmpErrorNoSuchEntity */
float (*GetCheckPointRadius) (int32_t checkPointId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetCheckPointOwner) (int32_t checkPointId);
/*
* Objects
*/
/* GetLastError: vcmpErrorPoolExhausted */
int32_t (*CreateObject) (int32_t modelIndex, int32_t world, float x, float y, float z, int32_t alpha);
/* vcmpErrorNoSuchEntity */
vcmpError (*DeleteObject) (int32_t objectId);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsObjectStreamedForPlayer) (int32_t objectId, int32_t playerId);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetObjectModel) (int32_t objectId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetObjectWorld) (int32_t objectId, int32_t world);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetObjectWorld) (int32_t objectId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetObjectAlpha) (int32_t objectId, int32_t alpha, uint32_t duration);
/* GetLastError: vcmpErrorNoSuchEntity */
int32_t (*GetObjectAlpha) (int32_t objectId);
/* vcmpErrorNoSuchEntity */
vcmpError (*MoveObjectTo) (int32_t objectId, float x, float y, float z, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*MoveObjectBy) (int32_t objectId, float x, float y, float z, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetObjectPosition) (int32_t objectId, float x, float y, float z);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetObjectPosition) (int32_t objectId, float* xOut, float* yOut, float* zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*RotateObjectTo) (int32_t objectId, float x, float y, float z, float w, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*RotateObjectToEuler) (int32_t objectId, float x, float y, float z, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*RotateObjectBy) (int32_t objectId, float x, float y, float z, float w, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*RotateObjectByEuler) (int32_t objectId, float x, float y, float z, uint32_t duration);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetObjectRotation) (int32_t objectId, float* xOut, float* yOut, float *zOut, float *wOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*GetObjectRotationEuler) (int32_t objectId, float* xOut, float* yOut, float *zOut);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetObjectShotReportEnabled) (int32_t objectId, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsObjectShotReportEnabled) (int32_t objectId);
/* vcmpErrorNoSuchEntity */
vcmpError (*SetObjectTouchedReportEnabled) (int32_t objectId, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity */
uint8_t (*IsObjectTouchedReportEnabled) (int32_t objectId);
// TODO: MOVE LATER
vcmpError (*GetPlayerModuleList) (int32_t playerId);
/* vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
vcmpError (*SetPickupOption) (int32_t pickupId, vcmpPickupOption option, uint8_t toggle);
/* GetLastError: vcmpErrorNoSuchEntity, vcmpErrorArgumentOutOfBounds */
uint8_t (*GetPickupOption) (int32_t pickupId, vcmpPickupOption option);
/* success */
void (*SetFallTimer) (uint16_t timeRate);
/* success */
uint16_t (*GetFallTimer) (void);
/* vcmpErrorNoSuchEntity */
vcmpError(*SetVehicleLightsData) (int32_t vehicleId, uint32_t lightsData);
/* GetLastError: vcmpErrorNoSuchEntity */
uint32_t(*GetVehicleLightsData) (int32_t vehicleId);
} PluginFuncs;
typedef struct {
uint32_t structSize;
uint8_t (*OnServerInitialise) (void);
void (*OnServerShutdown) (void);
void (*OnServerFrame) (float elapsedTime);
uint8_t (*OnPluginCommand) (uint32_t commandIdentifier, const char* message);
uint8_t (*OnIncomingConnection) (char* playerName, size_t nameBufferSize, const char* userPassword, const char* ipAddress);
void (*OnClientScriptData) (int32_t playerId, const uint8_t* data, size_t size);
void (*OnPlayerConnect) (int32_t playerId);
void (*OnPlayerDisconnect) (int32_t playerId, vcmpDisconnectReason reason);
uint8_t (*OnPlayerRequestClass) (int32_t playerId, int32_t offset);
uint8_t (*OnPlayerRequestSpawn) (int32_t playerId);
void (*OnPlayerSpawn) (int32_t playerId);
void (*OnPlayerDeath) (int32_t playerId, int32_t killerId, int32_t reason, vcmpBodyPart bodyPart);
void (*OnPlayerUpdate) (int32_t playerId, vcmpPlayerUpdate updateType);
uint8_t (*OnPlayerRequestEnterVehicle) (int32_t playerId, int32_t vehicleId, int32_t slotIndex);
void (*OnPlayerEnterVehicle) (int32_t playerId, int32_t vehicleId, int32_t slotIndex);
void (*OnPlayerExitVehicle) (int32_t playerId, int32_t vehicleId);
void (*OnPlayerNameChange) (int32_t playerId, const char* oldName, const char* newName);
void (*OnPlayerStateChange) (int32_t playerId, vcmpPlayerState oldState, vcmpPlayerState newState);
void (*OnPlayerActionChange) (int32_t playerId, int32_t oldAction, int32_t newAction);
void (*OnPlayerOnFireChange) (int32_t playerId, uint8_t isOnFire);
void (*OnPlayerCrouchChange) (int32_t playerId, uint8_t isCrouching);
void (*OnPlayerGameKeysChange) (int32_t playerId, uint32_t oldKeys, uint32_t newKeys);
void (*OnPlayerBeginTyping) (int32_t playerId);
void (*OnPlayerEndTyping) (int32_t playerId);
void (*OnPlayerAwayChange) (int32_t playerId, uint8_t isAway);
uint8_t (*OnPlayerMessage) (int32_t playerId, const char* message);
uint8_t (*OnPlayerCommand) (int32_t playerId, const char* message);
uint8_t (*OnPlayerPrivateMessage) (int32_t playerId, int32_t targetPlayerId, const char* message);
void (*OnPlayerKeyBindDown) (int32_t playerId, int32_t bindId);
void (*OnPlayerKeyBindUp) (int32_t playerId, int32_t bindId);
void (*OnPlayerSpectate) (int32_t playerId, int32_t targetPlayerId);
void (*OnPlayerCrashReport) (int32_t playerId, const char* report);
void (*OnVehicleUpdate) (int32_t vehicleId, vcmpVehicleUpdate updateType);
void (*OnVehicleExplode) (int32_t vehicleId);
void (*OnVehicleRespawn) (int32_t vehicleId);
void (*OnObjectShot) (int32_t objectId, int32_t playerId, int32_t weaponId);
void (*OnObjectTouched) (int32_t objectId, int32_t playerId);
uint8_t (*OnPickupPickAttempt) (int32_t pickupId, int32_t playerId);
void (*OnPickupPicked) (int32_t pickupId, int32_t playerId);
void (*OnPickupRespawn) (int32_t pickupId);
void (*OnCheckpointEntered) (int32_t checkPointId, int32_t playerId);
void (*OnCheckpointExited) (int32_t checkPointId, int32_t playerId);
void (*OnEntityPoolChange) (vcmpEntityPool entityType, int32_t entityId, uint8_t isDeleted);
void (*OnServerPerformanceReport) (size_t entryCount, const char** descriptions, uint64_t* times);
// TODO: MOVE LATER
void(*OnPlayerModuleList) (int32_t playerId, const char* list);
} PluginCallbacks;

File diff suppressed because it is too large Load Diff