Welcome to the Builder Academy

Question Trigger VNum 40603 has looped 100 times!!!

More
12 Mar 2014 02:01 #4751 by krell
Hrm, should this not be changed to the following? Would this help Parna's script not resetting properly?

Code:
static struct cmdlist_element *find_done(struct cmdlist_element *cl) { struct cmdlist_element *c; char *p; if (!cl || !(cl->next)) return cl; for (c = cl->next; c && c->next; c = c->next) { for (p = c->cmd; *p && isspace(*p); p++); if (!strn_cmp("while ", p, 6) || !strn_cmp("switch ", p, 7)) c = find_done(c); - else if (!strn_cmp("done", p, 3)) + else if (!strn_cmp("done", p, 4)) return c; } return c; }

Please Log in or Create an account to join the conversation.

More
12 Mar 2014 02:54 - 12 Mar 2014 02:55 #4752 by krell
Also in dg_scripts.c
Code:
static struct cmdlist_element * find_case(struct trig_data *trig, struct cmdlist_element *cl, void *go, struct script_data *sc, int type, char *cond) { char result[MAX_INPUT_LENGTH]; struct cmdlist_element *c; char *p, *buf; eval_expr(cond, result, go, sc, trig, type); if (!(cl->next)) return cl; for (c = cl->next; c->next; c = c->next) { for (p = c->cmd; *p && isspace(*p); p++); if (!strn_cmp("while ", p, 6) || !strn_cmp("switch", p, 6)) c = find_done(c); else if (!strn_cmp("case ", p, 5)) { buf = (char*)malloc(MAX_STRING_LENGTH); eval_op("==", result, p + 5, buf, go, sc, trig); if (*buf && *buf!='0') { free(buf); return c; } free(buf); } else if (!strn_cmp("default", p, 7)) return c; - else if (!strn_cmp("done", p, 3)) + else if (!strn_cmp("done", p, 4)) return c; } return c; }
Last edit: 12 Mar 2014 02:55 by krell.

Please Log in or Create an account to join the conversation.

More
15 Mar 2014 04:07 - 15 Mar 2014 04:16 #4755 by krell
I've reproduced the error and I get the error whether I use !strn_cmp("done", p, 3) or !strn_cmp("done", p, 4).

Code:
set a 0 set b 0 set c 0 set d 0 while %a% < 30 set a %a% + 1 done while %b% < 30 set b = %b% + 1 done while %c% < 30 set c = %c% + 1 done while %d% < 30 set d = %d% + 1 done

Is the limit on the number of loops actually on the trigger itself and not on the specific while loop?

Code:
GET_TRIG_LOOPS(trig)++; . . . } if (GET_TRIG_LOOPS(trig) >= 100) { script_log("Trigger VNum %d has looped 100 times!!!", GET_TRIG_VNUM(trig)); break; }
Last edit: 15 Mar 2014 04:16 by krell.

Please Log in or Create an account to join the conversation.

More
15 Mar 2014 16:53 #4756 by krell
Here's my reasoning (and someone else better reply to the thread soon, I'm starting to sound bonkers talking to myself. :-)) Please correct me if I'm wrong.

If the loop count for a trigger should reset after encountering a "done" in a (properly constructed) while loop then GET_TRIG_LOOPS(trig) should reset. For some reason the original code doesn't seem to do it, or it does but I'm not seeing it. I've tried adding the indicated code below on my local copy and it seems to work, though I may have broken something without realizing it.

I'm also testing for NULL though that may not be necessary.

Code:
} 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 switch statement, this ends it. */ } } + } else if (strn_cmp("done", p, 4)) { + if (cl->original == '\0' || cl->original) { + GET_TRIG_LOOPS(trig) = 0; + } }

Please Log in or Create an account to join the conversation.

More
15 Mar 2014 17:33 #4757 by Parnassus
I can't really answer since it's now gone beyond my building problems and into that fancy code stuff that I don't understand at all.

I'm just wondering, does your fix still give the message for all those times when I write the triggers wrong and they actually do loop over 100 times?

Please Log in or Create an account to join the conversation.

More
15 Mar 2014 17:47 #4758 by krell
Actually, I'm aware of that issue as I had already tried that myself. The current code I suggested doesn't catch the 100+ loops. I'll post a solution soon...I hope. :-)

Please Log in or Create an account to join the conversation.

Time to create page: 0.190 seconds