Skip to content

Commit c972a0f

Browse files
committed
removed nearly all code except GAME_INIT and G_LOCATE_GAME_DATA calls so that it is a true "stub" plugin which does nearly nothing except load. bumped version to v2.4.2
1 parent e191f6b commit c972a0f

2 files changed

Lines changed: 11 additions & 58 deletions

File tree

include/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Created By:
1717

1818
#define STUB_QMM_VERSION_MAJOR 2
1919
#define STUB_QMM_VERSION_MINOR 4
20-
#define STUB_QMM_VERSION_REV 1
20+
#define STUB_QMM_VERSION_REV 2
2121

2222
#define STUB_QMM_VERSION STRINGIFY(STUB_QMM_VERSION_MAJOR) "." STRINGIFY(STUB_QMM_VERSION_MINOR) "." STRINGIFY(STUB_QMM_VERSION_REV)
2323

src/main.cpp

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ C_DLLEXPORT void QMM_Query(plugininfo_t** pinfo) {
6262
- modfunc = pointer to the mod's vmMain function
6363
- presult = pointer to plugin result variable
6464
- pluginfuncs = pointer to table of plugin helper function pointers
65-
- vmbase = value to add to pointers passed to the engine from a QVM mod (0 if DLL mod)
6665
- pluginvars = pointer to table of plugin helper variables
6766
6867
return:
@@ -97,51 +96,11 @@ C_DLLEXPORT void QMM_Detach() {
9796
*/
9897
C_DLLEXPORT intptr_t QMM_vmMain(intptr_t cmd, intptr_t* args) {
9998
if (cmd == GAME_INIT) {
100-
// example showing writing to QMM log
99+
// example showing writing to QMM log on initialization
101100
QMM_WRITEQMMLOG(PLID, QMM_VARARGS(PLID, "Stub_QMM loaded! Game engine: %s\n", QMM_GETGAMEENGINE(PLID)), QMMLOG_INFO);
102101
}
103-
else if (cmd == GAME_CLIENT_COMMAND) {
104-
char buf[16] = "";
105-
intptr_t clientnum = args[0];
106-
107-
// some engines use this arg/buf/buflen syntax for G_ARGV while others return
108-
// the char*, so we use QMM_ARGV to handle both methods automatically
109-
QMM_ARGV(PLID, 0, buf, sizeof(buf));
110-
111-
// example showing how to use infostrings
112-
if (!strcmp(buf, "myinfo")) {
113-
char userinfo[MAX_INFO_STRING];
114-
g_syscall(G_GET_USERINFO, clientnum, userinfo, sizeof(userinfo));
115-
const char* name = QMM_INFOVALUEFORKEY(PLID, userinfo, "name");
116-
#if defined(GAME_Q2_ENGINE)
117-
g_syscall(G_CLIENT_PRINT, clientnum, PRINT_HIGH, QMM_VARARGS(PLID, "[STUB_QMM] Your name is: '%s'\n", name));
118-
#else
119-
g_syscall(G_SEND_SERVER_COMMAND, clientnum, QMM_VARARGS(PLID, "print \"[STUB_QMM] Your name is: '%s'\"\n", name));
120-
#endif
121-
QMM_RET_SUPERCEDE(1);
122-
}
123-
#if !defined(GAME_Q2_ENGINE)
124-
// purely an example to show entity/client access and how it might be different per-game
125-
else if (!strcmp(buf, "myweapon")) {
126-
gclient_t* client = CLIENT_FROM_NUM(clientnum);
127-
#if defined(GAME_STEF2)
128-
int left = client->ps.activeItems[ITEM_NAME_WEAPON_LEFT];
129-
int right = client->ps.activeItems[ITEM_NAME_WEAPON_RIGHT];
130-
g_syscall(G_SEND_SERVER_COMMAND, clientnum, QMM_VARARGS(PLID, "print \"[STUB_QMM] Your weapons are: %d %d\"\n", left, right));
131-
#else
132-
#if defined(GAME_MOHAA) || defined(GAME_MOHSH) || defined(GAME_MOHBT)
133-
int item = client->ps.activeItems[ITEM_WEAPON];
134-
#else
135-
int item = client->ps.weapon;
136-
#endif // MOHAA, MOHSH, MOHBT
137-
g_syscall(G_SEND_SERVER_COMMAND, clientnum, QMM_VARARGS(PLID, "print \"[STUB_QMM] Your weapon is: %d\"\n", item));
138-
#endif // GAME_STEF2
139-
QMM_RET_SUPERCEDE(1);
140-
}
141-
#endif // !GAME_Q2R && !GAME_QUAKE2
142-
}
143102

144-
QMM_RET_IGNORED(1);
103+
QMM_RET_IGNORED(0);
145104
}
146105

147106

@@ -152,9 +111,9 @@ C_DLLEXPORT intptr_t QMM_vmMain(intptr_t cmd, intptr_t* args) {
152111
- args = arguments to cmd
153112
*/
154113
C_DLLEXPORT intptr_t QMM_syscall(intptr_t cmd, intptr_t* args) {
155-
// this is fairly common to store entity/client data. the second argument (num gentities) changes
156-
// every time a new entity is spawned, so this gets called a lot. no other args should change after
157-
// the first call. for QUAKE2, Q2R and JK2SP, this is a QMM polyfill call
114+
// this is fairly common to store entity/client data. the second argument (num gentities) changes every time
115+
// a new entity is spawned, so this gets called a lot. no other args should change after the first call.
116+
// for QUAKE2, Q2R, SIN, STVOYSP, JASP, and JK2SP engines, this is a QMM polyfill call when it detects changes
158117
if (cmd == G_LOCATE_GAME_DATA) {
159118
g_gents = (gentity_t*)(args[0]);
160119
g_numgents = args[1];
@@ -163,7 +122,7 @@ C_DLLEXPORT intptr_t QMM_syscall(intptr_t cmd, intptr_t* args) {
163122
g_clientsize = args[4];
164123
}
165124

166-
QMM_RET_IGNORED(1);
125+
QMM_RET_IGNORED(0);
167126
}
168127

169128

@@ -177,10 +136,8 @@ C_DLLEXPORT intptr_t QMM_syscall(intptr_t cmd, intptr_t* args) {
177136
In QMM_vmMain_Post functions, you can access *g_pluginvars->preturn to get the return value of the vmMain call that will be returned back to the engine
178137
*/
179138
C_DLLEXPORT intptr_t QMM_vmMain_Post(intptr_t cmd, intptr_t* args) {
180-
// example of broadcasting a message to other plugins
181-
if (cmd == GAME_SHUTDOWN)
182-
QMM_PLUGIN_BROADCAST(PLID, "BYE", nullptr, 0);
183-
QMM_RET_IGNORED(1);
139+
140+
QMM_RET_IGNORED(0);
184141
}
185142

186143

@@ -189,21 +146,17 @@ C_DLLEXPORT intptr_t QMM_vmMain_Post(intptr_t cmd, intptr_t* args) {
189146
- cmd = command like G_PRINT, G_LOCATE_GAME_DATA, etc. (game-specific)
190147
- args = arguments to cmd
191148
192-
In QMM_syscall_Post functions, you can access *g_pluginvars->preturn / QMM_GET_RETURN to get the return value of the syscall call that will be returned
149+
In QMM_syscall_Post functions, you can access *g_pluginvars->preturn / QMM_VAR_RETURN to get the return value of the syscall call that will be returned
193150
back to the mod
194151
*/
195152
C_DLLEXPORT intptr_t QMM_syscall_Post(intptr_t cmd, intptr_t* args) {
196-
if (cmd == G_ARGC) {
197-
QMM_WRITEQMMLOG(PLID, QMM_VARARGS(PLID, "G_ARGC return value: %d\n", QMM_VAR_RETURN(intptr_t)), QMMLOG_INFO);
198-
}
199153

200-
QMM_RET_IGNORED(1);
154+
QMM_RET_IGNORED(0);
201155
}
202156

203157

204158
/* QMM_PluginMessage
205159
This is called by other plugins using the QMM_PLUGIN_BROADCAST helper
206160
*/
207161
C_DLLEXPORT void QMM_PluginMessage(plid_t from_plid, const char* message, void* buf, intptr_t buflen) {
208-
QMM_WRITEQMMLOG(PLID, QMM_VARARGS(PLID, "Received plugin message \"%s\" with a %d-byte buffer", message, buflen), QMMLOG_INFO);
209162
}

0 commit comments

Comments
 (0)