Revert "Added loop counter per while instead of global. fixes #135"

This reverts commit 59cf6a1fb2.
This commit is contained in:
welcor 2024-09-28 20:05:40 +02:00
parent 59cf6a1fb2
commit e76c603110
2 changed files with 4 additions and 5 deletions

View file

@ -2486,6 +2486,7 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
char cmd[MAX_INPUT_LENGTH], *p; char cmd[MAX_INPUT_LENGTH], *p;
struct script_data *sc = 0; struct script_data *sc = 0;
struct cmdlist_element *temp; struct cmdlist_element *temp;
unsigned long loops = 0;
void *go = NULL; void *go = NULL;
void obj_command_interpreter(obj_data *obj, char *argument); void obj_command_interpreter(obj_data *obj, char *argument);
@ -2577,8 +2578,8 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
if (process_if(p + 6, go, sc, trig, type)) { if (process_if(p + 6, go, sc, trig, type)) {
temp->original = cl; temp->original = cl;
} else { } else {
cl->loops = 0;
cl = temp; cl = temp;
loops = 0;
} }
} else if (!strn_cmp("switch ", p, 7)) { } else if (!strn_cmp("switch ", p, 7)) {
cl = find_case(trig, cl, go, sc, type, p + 7); cl = find_case(trig, cl, go, sc, type, p + 7);
@ -2598,10 +2599,9 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
if (cl->original && process_if(orig_cmd + 6, go, sc, trig, if (cl->original && process_if(orig_cmd + 6, go, sc, trig,
type)) { type)) {
cl = cl->original; cl = cl->original;
cl->loops++; loops++;
GET_TRIG_LOOPS(trig)++; GET_TRIG_LOOPS(trig)++;
if (cl->loops == 30) { if (loops == 30) {
cl->loops = 0;
process_wait(go, trig, type, "wait 1", cl); process_wait(go, trig, type, "wait 1", cl);
depth--; depth--;
return ret_val; return ret_val;

View file

@ -135,7 +135,6 @@ struct cmdlist_element {
char *cmd; /* one line of a trigger */ char *cmd; /* one line of a trigger */
struct cmdlist_element *original; struct cmdlist_element *original;
struct cmdlist_element *next; struct cmdlist_element *next;
int loops; /* for counting number of runs in a while loop */
}; };
struct trig_var_data { struct trig_var_data {