The main issue isn't the time it takes, but that - since the server is singlethreaded - it only has a limited time to perform its duties before people percieve the delay as lag.
If you loop more than 30 times in a while loop, you're broken out of it immidiately.
Code:
} else if (!strn_cmp("while ", p, 6)) {
temp = find_done(cl);
if (!temp) {
script_log("Trigger VNum %d has 'while' without 'done'.",
GET_TRIG_VNUM(trig));
return ret_val;
}
if (process_if(p + 6, go, sc, trig, type)) {
temp->original = cl;
} else {
cl = temp;
loops = 0;
}
} else if (!strn_cmp("switch ", p, 7)) {
cl = find_case(trig, cl, go, sc, type, p + 7);
} else if (!strn_cmp("end", p, 3)) {
/* If not in an if-block, ignore the extra 'end' and warn about it. */
if (GET_TRIG_DEPTH(trig) == 1) {
script_log("Trigger VNum %d has 'end' without 'if'.",
GET_TRIG_VNUM(trig));
continue;
}
GET_TRIG_DEPTH(trig)--;
} else if (!strn_cmp("done", p, 4)) {
/* if in a while loop, cl->original is non-NULL */
if (cl->original) {
char *orig_cmd = cl->original->cmd;
while (*orig_cmd && isspace(*orig_cmd)) orig_cmd++;
if (cl->original && process_if(orig_cmd + 6, go, sc, trig,
type)) {
cl = cl->original;
loops++;
GET_TRIG_LOOPS(trig)++;
if (loops == 30) {
process_wait(go, trig, type, "wait 1", cl);
depth--;
return ret_val;
}
if (GET_TRIG_LOOPS(trig) >= 100) {
script_log("Trigger VNum %d has looped 100 times!!!",
GET_TRIG_VNUM(trig));
break;
}
} else {
/* if we're falling through a
...
But your solution: start new while loops - they reset the counter.