MCPcopy Index your code
hub / github.com/assaultcube/AC / lookup

Function lookup

source/src/command.cpp:392–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392char *lookup(char *n, int levels) // find value of ident referenced with $ in exp
393{
394 if(levels > 1) n = exchangestr(n, lookup(newstring(n), min(levels - 1, CSLIMIT_LOOKUPNESTING - 1))); // nested ("$$var"), limit to three levels
395 ident *id = idents->access(n);
396 if(id) switch(id->type)
397 {
398 case ID_VAR: { string t; itoa(t, *id->storage.i); return exchangestr(n, t); }
399 case ID_FVAR: return exchangestr(n, floatstr(*id->storage.f));
400 case ID_SVAR: { { if(id->getfun) ((void (__cdecl *)())id->getfun)(); } return exchangestr(n, *id->storage.s); }
401 case ID_ALIAS: return exchangestr(n, id->action);
402 }
403 conoutf("unknown alias lookup: %s", n);
404 scripterr();
405 return n;
406}
407
408char *parseword(const char *&p, int arg, int *infix, int rec) // parse single argument, including expressions
409{

Callers 2

parseexpFunction · 0.85
parsewordFunction · 0.85

Calls 7

exchangestrFunction · 0.85
newstringFunction · 0.85
minFunction · 0.85
floatstrFunction · 0.85
scripterrFunction · 0.85
accessMethod · 0.80
conoutfFunction · 0.70

Tested by

no test coverage detected