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

Function loopa

source/src/command.cpp:1025–1059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1023//COMMANDN(if, ifthen, "sss"); // CB seriously trips over this one ;)
1024
1025void loopa(char *var, int *times, char *body)
1026{
1027 if(*times > CSLIMIT_ITERATION) { cslimiterr("loop iterations"); return; }
1028 int t = *times;
1029 if(t<=0) return;
1030 ident *id = newident(var, execcontext);
1031 if(id->type!=ID_ALIAS) return;
1032 char *buf = newstring("0", 16);
1033 pushident(*id, buf);
1034 loop_level++;
1035 execute(body);
1036 loop_skip = false;
1037 if(loop_break) loop_break = false;
1038 else
1039 {
1040 loopi(t-1)
1041 {
1042 if(buf != id->action)
1043 {
1044 if(id->action != id->executing) delete[] id->action;
1045 id->action = buf = newstring(16);
1046 }
1047 itoa(id->action, i+1);
1048 execute(body);
1049 loop_skip = false;
1050 if(loop_break)
1051 {
1052 loop_break = false;
1053 break;
1054 }
1055 }
1056 }
1057 popident(*id);
1058 loop_level--;
1059}
1060COMMANDN(loop, loopa, "sis");
1061
1062void whilea(char *cond, char *body)

Callers

nothing calls this directly

Calls 7

cslimiterrFunction · 0.85
newidentFunction · 0.85
newstringFunction · 0.85
pushidentFunction · 0.85
executeFunction · 0.85
popidentFunction · 0.85
loopiFunction · 0.70

Tested by

no test coverage detected