QMM Plugin API QMM |
API version 1:0 |
Contents
|
Overview
This document explains the API for QMM plugins. If you are looking for QMM installation instructions, please go here. All plugins must include the qmmapi.h header file from the QMM source. This contains all the type definitions, global externs, and macros used by plugins. In this document, you will see the following colored boxes: Green blocks like this contain code samples Blue blocks like this contain notes Red blocks like this contain warnings Top |
Data Types
plugininfo_t typedef struct plugininfo_s { char* name; char* version; char* desc; char* author; char* url; int canpause; int loadcmd; int unloadcmd; int pifv_major; int pifv_minor; } plugininfo_t;
Top pluginfuncs_t typedef struct pluginfuncs_s { int (*pfnWriteGameLog)(const char*, int); char* (*pfnVarArgs)(char*, ...); int (*pfnIsVM)(); const char* (*pfnEngMsgName)(int); const char* (*pfnModMsgName)(int); int (*pfnGetIntCvar)(const char*); const char* (*pfnGetStrCvar)(const char*); } pluginfuncs_t; Top pluginres_t typedef enum pluginres_e { QMM_UNUSED = -2, QMM_ERROR = -1, QMM_IGNORED = 0, QMM_OVERRIDE, QMM_SUPERCEDE } pluginres_t;
Top eng_syscall_t typedef int (*eng_syscall_t)(int, ...); Top mod_vmMain_t typedef int (*mod_vmMain_t)(int, int, int, int, int, int, int, int, int, int, int, int, int); Top |
Globals
plugininfo_t g_plugininfo pluginfuncs_t* g_pluginfuncs pluginres_t* g_result eng_syscall_t g_syscall mod_vmMain_t g_vmMain int g_vmbase WARNING: g_vmbase should not be used by anything other than the GETPTR and SETPTR macros. Top |
Exported Functions
C_DLLEXPORT void QMM_Query(pluginfuncs_t** pinfo) C_DLLEXPORT void QMM_Query(plugininfo_t** pinfo) { QMM_GIVE_PINFO(); } WARNING: Nothing that requires deinitialization should be done within QMM_Query() since there is no corresponding unload function. Top C_DLLEXPORT int QMM_Attach(eng_syscall_t engfunc, mod_vmMain_t modfunc, pluginres_t* presult, pluginfuncs_t* pluginfuncs, int vmbase, int iscmd)
C_DLLEXPORT int QMM_Attach(/* ... */) { QMM_SAVE_VARS(); //...The last argument, iscmd is a boolean flag that is 0 if the plugin is being loaded on map startup from the QMM configuration file. It is 1 if the plugin is being loaded from the server console during a map. To signal to QMM that this function completed successfully, it should return 1. If this function returns 0, it will be unloaded immediately upon return. Non-game-related initializations should be done here. Top C_DLLEXPORT void QMM_Detach(int iscmd) C_DLLEXPORT int QMM_vmMain(int cmd, int arg0, /* ... */, int arg11) C_DLLEXPORT int QMM_vmMain_Post(int cmd, int arg0, /* ... */, int arg11) C_DLLEXPORT int QMM_syscall(int cmd, int arg0, /* ... */, int arg12) Note: In the mod SDK, the engine's syscall function is called behind-the-scenes by the trap_* functions. Look at g_syscalls.c in the mod SDK for more information. Top C_DLLEXPORT int QMM_syscall_Post(int cmd, int arg0, /* ... */, int arg12) Note: In the mod SDK, the engine's syscall function is called behind-the-scenes by the trap_* functions. Look at g_syscalls.c in the mod SDK for more information. Top |
QMM Plugin Functions
int QMM_ISVM() char* QMM_VARARGS(char* fmt, ...) Note: The returned char* points to 1 of 8 cycling static string buffers, so you do not have to copy the string to a local buffer as is typical with functions returning statically-stored strings. Top int QMM_WRITEGAMELOG(char* str, int len) Note: If len is -1, it will default to the length of str. Top const char* QMM_ENGMSGNAME(int msg) const char* QMM_MODMSGNAME(int msg) int QMM_GETINTCVAR(const char* cvar) const char* QMM_GETSTRCVAR(const char* cvar) Note: The returned char* points to 1 of 8 cycling static string buffers, so you do not have to copy the string to a local buffer as is typical with functions returning statically-stored strings. Top |
Miscellaneous
QMM_GIVE_PINFO() C_DLLEXPORT void QMM_Query(plugininfo_t** pinfo) { QMM_GIVE_PINFO(); } Top QMM_SAVE_VARS() C_DLLEXPORT int QMM_Attach(/* ... */) { QMM_SAVE_VARS(); //... Top QMM_PIFV_MAJOR Note: If the plugin's major API version does not match QMM's major API version, the plugin will not load and an error will appear in the console. Top QMM_PIFV_MINOR Note: If the plugin's minor API version is greater than QMM's minor API version, the plugin will not load and an error will appear in the console. If the plugin's is less than QMM's, the plugin will load, but a warning will appear in console. Top QMM_RETURN(result, return) QMM_SET_RESULT(result) QMM_RET_*(return)
Top GETPTR(pointer,type) gentity_t* entity = /* ... */; gclient_t* client = GETPTR(entity->client, gclient_t*); Top SETPTR(pointer,type) gentity_t* entity = /* ... */; entity->classname = SETPTR("someclass", char*); Top |
QMM was written by Kevin Masterson (CyberMind) <kevinm -AT- planetquake -DOT- com> <cybermind -AT- users -DOT- sourceforge -DOT- net> QMM is released under the GPL Copyright 2005 Kevin Masterson, all rights reserved. |