MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CL_ConfigstringModified

Function CL_ConfigstringModified

code/client/cl_cgame.cpp:283–337  ·  view source on GitHub ↗

===================== CL_ConfigstringModified ===================== */

Source from the content-addressed store, hash-verified

281=====================
282*/
283void CL_ConfigstringModified( void ) {
284 const char *s;
285 char *old;
286 int i, index;
287 const char *dup;
288 gameState_t oldGs;
289 int len;
290
291 index = atoi( Cmd_Argv(1) );
292 if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
293 Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );
294 }
295 s = Cmd_Argv(2);
296
297 old = cl.gameState.stringData + cl.gameState.stringOffsets[ index ];
298 if ( !strcmp( old, s ) ) {
299 return; // unchanged
300 }
301
302 // build the new gameState_t
303 oldGs = cl.gameState;
304
305 memset( &cl.gameState, 0, sizeof( cl.gameState ) );
306
307 // leave the first 0 for uninitialized strings
308 cl.gameState.dataCount = 1;
309
310 for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {
311 if ( i == index ) {
312 dup = s;
313 } else {
314 dup = oldGs.stringData + oldGs.stringOffsets[ i ];
315 }
316 if ( !dup[0] ) {
317 continue; // leave with the default empty string
318 }
319
320 len = strlen( dup );
321
322 if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
323 Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
324 }
325
326 // append it to the gameState string buffer
327 cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;
328 memcpy( cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1 );
329 cl.gameState.dataCount += len + 1;
330 }
331
332 if ( index == CS_SYSTEMINFO ) {
333 // parse serverId and other cvars
334 CL_SystemInfoChanged();
335 }
336
337}
338
339
340/*

Callers 1

CL_GetServerCommandFunction · 0.70

Calls 3

CL_SystemInfoChangedFunction · 0.70
Cmd_ArgvFunction · 0.50
Com_ErrorFunction · 0.50

Tested by

no test coverage detected