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

Function Item_RunScript

code/ui/ui_shared.cpp:5280–5333  ·  view source on GitHub ↗

=============== Item_RunScript =============== */

Source from the content-addressed store, hash-verified

5278===============
5279*/
5280void 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/*

Callers 15

UI_FeederSelectionFunction · 0.70
UI_ShutdownForceHelpFunction · 0.70
Menu_RunCloseScriptFunction · 0.70
Menu_ClearFocusFunction · 0.70
Script_SetFocusFunction · 0.70
Script_RunDeferredFunction · 0.70
GetCurrentFeederIndexFunction · 0.70
Menus_ActivateFunction · 0.70
Menu_PaintFunction · 0.70
Item_PaintFunction · 0.70
Item_MouseEnterFunction · 0.70
Item_SetFocusFunction · 0.70

Calls 4

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

Tested by

no test coverage detected