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

Function Info_SetValueForKey

code/qcommon/q_shared.cpp:883–914  ·  view source on GitHub ↗

================== Info_SetValueForKey Changes or adds a key/value pair ================== */

Source from the content-addressed store, hash-verified

881==================
882*/
883void Info_SetValueForKey( char *s, const char *key, const char *value ) {
884 char newi[MAX_INFO_STRING];
885 const char* blacklist = "\\;\"";
886
887 if ( strlen( s ) >= MAX_INFO_STRING ) {
888 Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
889 }
890
891 for(; *blacklist; ++blacklist)
892 {
893 if (strchr (key, *blacklist) || strchr (value, *blacklist))
894 {
895 Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value);
896 return;
897 }
898 }
899
900 Info_RemoveKey (s, key);
901 if (!value || !strlen(value))
902 return;
903
904 Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
905
906 if (strlen(newi) + strlen(s) >= MAX_INFO_STRING)
907 {
908 Com_Printf ("Info string length exceeded\n");
909 return;
910 }
911
912 strcat (newi, s);
913 strcpy (s, newi);
914}
915
916/*
917==================

Callers 5

Cvar_InfoStringFunction · 0.70
CL_CheckForResendFunction · 0.50
SV_DirectConnectFunction · 0.50
SVC_StatusFunction · 0.50
SVC_InfoFunction · 0.50

Calls 4

Com_ErrorFunction · 0.70
Com_PrintfFunction · 0.70
Info_RemoveKeyFunction · 0.70
Com_sprintfFunction · 0.70

Tested by

no test coverage detected