Skip to content

Commit a72bc15

Browse files
authored
Fix configstring replacement causing the model to be referenced twice on base MOHAA clients (#779)
1 parent e47790c commit a72bc15

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

code/cgame/cg_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,12 @@ void CG_ProcessConfigString(int num, qboolean modelOnly)
358358

359359
if (hModel != hOldModel) {
360360
if (hOldModel) {
361+
assert(CG_IsHandleUnique(hOldModel));
361362
cgi.R_UnregisterServerModel(hOldModel);
362363
}
363364

364365
cgs.model_draw[num - CS_MODELS] = hModel;
366+
assert(CG_IsHandleUnique(hModel));
365367
}
366368
tiki = cgi.R_Model_GetHandle(hModel);
367369
if (tiki) {

code/server/sv_main.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,25 @@ not have future snapshot_t executed before it is executed
160160
void SV_AddServerCommand( client_t *client, const char *cmd ) {
161161
int index, i;
162162

163-
// this is very ugly but it's also a waste to for instance send multiple config string updates
164-
// for the same config string index in one snapshot
165-
if ( !strncmp(cmd, "cs ", 3) && SV_ReplacePendingServerCommands(client, cmd) ) {
166-
return;
163+
if ( com_protocol->integer >= PROTOCOL_MOHTA_MIN ) {
164+
// Added in 2.0
165+
// Requires spearhead clients.
166+
// Unfortunately in MOHAA 1.11, replacing cs can cause clients to crash
167+
// when an existing model is moved into a lower configstring.
168+
// For example:
169+
// cs 138 models/weapons/mp40.tik
170+
// cs 117 models/weapons/m1_garand.tik
171+
// 1) models/weapons/mp40.tik is already referenced by cs 117, it will cause the model handle to be referenced twice.
172+
// 2) when the client executes "cs 117", it will free up the mp40.tik model, leaving a dangling handle for cs 138.
173+
174+
// FIXME: To make it work on MOHAA clients, reorder configstrings that are sent to clients.
175+
// For example, always put "cs 117" before "cs 138".
176+
177+
// this is very ugly but it's also a waste to for instance send multiple config string updates
178+
// for the same config string index in one snapshot
179+
if ( !strncmp( cmd, "cs ", 3 ) && SV_ReplacePendingServerCommands( client, cmd ) ) {
180+
return;
181+
}
167182
}
168183

169184
// do not send commands until the gamestate has been sent

0 commit comments

Comments
 (0)