================= Item_EnableShowViaCvar ================= */
| 6101 | ================= |
| 6102 | */ |
| 6103 | qboolean 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) |
no test coverage detected