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

Function Item_EnableShowViaCvar

code/ui/ui_shared.cpp:6103–6171  ·  view source on GitHub ↗

================= Item_EnableShowViaCvar ================= */

Source from the content-addressed store, hash-verified

6101=================
6102*/
6103qboolean Item_EnableShowViaCvar(itemDef_t *item, int flag)
6104{
6105 if (item && item->enableCvar && *item->enableCvar && item->cvarTest && *item->cvarTest)
6106 {
6107 char script[1024];
6108 const char *p;
6109 char buff[1024];
6110 if (item->cvarFlags & CVAR_SUBSTRING)
6111 {
6112 const char *val;
6113 p = item->enableCvar;
6114 COM_BeginParseSession();
6115 if (!String_Parse(&p, &val))
6116 {//strip the quotes off
6117 COM_EndParseSession();
6118 return (item->cvarFlags & flag) ? qfalse : qtrue;
6119 }
6120
6121 COM_EndParseSession();
6122 Q_strncpyz(buff, val, sizeof(buff));
6123 DC->getCVarString(item->cvarTest, script, sizeof(script));
6124 p = script;
6125 }
6126 else
6127 {
6128 DC->getCVarString(item->cvarTest, buff, sizeof(buff));
6129 Q_strncpyz(script, item->enableCvar, sizeof(script));
6130 p = script;
6131 }
6132 COM_BeginParseSession();
6133 while (1)
6134 {
6135 const char *val;
6136 // expect value then ; or NULL, NULL ends list
6137 if (!String_Parse(&p, &val))
6138 {
6139 COM_EndParseSession();
6140 return (item->cvarFlags & flag) ? qfalse : qtrue;
6141 }
6142
6143 if (val[0] == ';' && val[1] == '\0')
6144 {
6145 continue;
6146 }
6147
6148 // enable it if any of the values are true
6149 if (item->cvarFlags & flag)
6150 {
6151 if (Q_stricmp(buff, val) == 0)
6152 {
6153 COM_EndParseSession();
6154 return qtrue;
6155 }
6156 }
6157 else
6158 {
6159 // disable it if any of the values are true
6160 if (Q_stricmp(buff, val) == 0)

Callers 6

Item_TextColorFunction · 0.70
Item_OwnerDraw_PaintFunction · 0.70
Item_PaintFunction · 0.70
Item_MouseEnterFunction · 0.70
Item_SetFocusFunction · 0.70
Menu_HandleMouseMoveFunction · 0.70

Calls 5

COM_EndParseSessionFunction · 0.85
Q_strncpyzFunction · 0.85
Q_stricmpFunction · 0.85
String_ParseFunction · 0.70
COM_BeginParseSessionFunction · 0.50

Tested by

no test coverage detected