=============== Item_RunScript =============== */
| 5278 | =============== |
| 5279 | */ |
| 5280 | void Item_RunScript(itemDef_t *item, const char *s) |
| 5281 | { |
| 5282 | const char *p; |
| 5283 | int i; |
| 5284 | qboolean bRan; |
| 5285 | |
| 5286 | uiInfo.runScriptItem = item; |
| 5287 | |
| 5288 | if (item && s && s[0]) |
| 5289 | { |
| 5290 | p = s; |
| 5291 | COM_BeginParseSession(); |
| 5292 | while (1) |
| 5293 | { |
| 5294 | const char *command; |
| 5295 | // expect command then arguments, ; ends command, NULL ends script |
| 5296 | if (!String_Parse(&p, &command)) |
| 5297 | { |
| 5298 | break; |
| 5299 | } |
| 5300 | |
| 5301 | if (command[0] == ';' && command[1] == '\0') |
| 5302 | { |
| 5303 | continue; |
| 5304 | } |
| 5305 | |
| 5306 | bRan = qfalse; |
| 5307 | for (i = 0; i < scriptCommandCount; i++) |
| 5308 | { |
| 5309 | if (Q_stricmp(command, commandList[i].name) == 0) |
| 5310 | { |
| 5311 | if ( !(commandList[i].handler(item, &p)) ) |
| 5312 | { |
| 5313 | COM_EndParseSession(); |
| 5314 | return; |
| 5315 | } |
| 5316 | |
| 5317 | bRan = qtrue; |
| 5318 | break; |
| 5319 | } |
| 5320 | } |
| 5321 | // not in our auto list, pass to handler |
| 5322 | if (!bRan) |
| 5323 | { |
| 5324 | // Allow any script command to fail |
| 5325 | if ( !DC->runScript(&p) ) |
| 5326 | { |
| 5327 | break; |
| 5328 | } |
| 5329 | } |
| 5330 | } |
| 5331 | COM_EndParseSession(); |
| 5332 | } |
| 5333 | } |
| 5334 | |
| 5335 | |
| 5336 | /* |
no test coverage detected