Issue information

Issue ID
#7965
Status
Fixed
Severity
None
Started
AnnieRuru
Jan 12, 2014 9:55
Last Post
AnnieRuru
Mar 16, 2014 18:56
Confirmation
Yes (1)
No (0)

AnnieRuru - Jan 12, 2014 9:55

[url="http://rathena.org/board/tracker/issue-8459-addtimer-command-should-report-an-error-if-it-hits-max-eventtimer/"]http://rathena.org/board/tracker/issue-8459-addtimer-command-should-report-an-error-if-it-hits-max-eventtimer/[/url]

[url="http://rathena.org/board/topic/91248-npc-event-error/"]http://rathena.org/board/topic/91248-npc-event-error/[/url]
what a long way to tackle this topic
and the reason is so simple ...
just because the *addtimer script command doesn't report an error when the MAX_EVENTTIMER is full

[url="https://github.com/HerculesWS/Hercules/blob/master/src/map/map.h#L35"]https://github.com/HerculesWS/Hercules/blob/master/src/map/map.h#L35[/url]
there is currently a hardcoded limit that addtimer command can only queue up to 32 instances
over that, addtimer command doesn't report an error
but its weird that OnxxxxEvent does !
[url="https://github.com/HerculesWS/Hercules/blob/master/src/map/npc.c#L285"]https://github.com/HerculesWS/Hercules/blob/master/src/map/npc.c#L285[/url]
so its better for the addtimer command should be report an error
suggestion, follow how rathena did[code=auto:0]BUILDIN(addtimer) { int tick = script_getnum(st,2); const char* event = script_getstr(st, 3); TBL_PC* sd; script->check_event(st, event); sd = script->rid2sd(st); if( sd == NULL ) return true; if (!pc_addeventtimer(sd,tick,event)) { ShowWarning("buildin_addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n",sd->status.char_id,event); return false; } return true; }[/code]

Ind - Jan 12, 2014 18:00

[code=auto:0] if (!pc->addeventtimer(sd,100,sd->eventqueue[0])) { //Failed to dequeue, couldn't set a timer. ShowWarning("npc_event_dequeue: event timer is full !\n"); return 0; } [/code]hmm I wonder why npc_event_dequeue sets a 100ms delay between events, I currently see no reason for them not to be run as the other finishes and so son (the mechanism for that is already existent, script_state has a bk_st pointer to the previous script_state, which allows for recursion to be endless aka as many events as you need), this would also make them stop using MAX_EVENTTIMER room.

AnnieRuru - Jan 12, 2014 20:28

[quote]
...which allows for recursion to be endless aka as many events as you need...[/quote]there is a special case

#define MAX_EVENTQUEUE 2

yes you might make it infinite IF there is no MAX_EVENTQUEUE
but I remember ultramage add it purposely to ensure the scripters use a clean way to queue up a OnxxxxEvent

there are a few ways to hit this MAX_EVENTQUEUE
use OnPCLoginEvent: and a *mes + *next, then the next OnPCLoginEvent will be waiting in a queue
if used too many, the server will print this error
[url="https://github.com/HerculesWS/Hercules/blob/master/src/map/npc.c#L774"]https://github.com/HerculesWS/Hercules/blob/master/src/map/npc.c#L774[/url][quote]
this would also make them stop using MAX_EVENTTIMER room.[/quote]I think there is a difference with
MAX_EVENTQUEUE and MAX_EVENTTIMER ...
read that topic in rathena forum =/
[url="http://rathena.org/board/topic/91248-npc-event-error/?p=239258"]http://rathena.org/board/topic/91248-npc-event-error/?p=239258[/url]


EDIT: it seems like you have some idea to improve this part, I am interested to hear it


EDIT2: are you thinking about removing the limitation of MAX_EVENTTIMER and MAX_EVENTQUEUE all-together ?
I think hercules core-developer can find a way to make this run unlimitedly

This post has been edited by AnnieRuru on Jan 12, 2014 21:57

AnnieRuru - Mar 16, 2014 18:56

( after 2 months )
fix this myself in
[url="https://github.com/HerculesWS/Hercules/commit/18278c253f08f5c8b26a1634a7c6c5efff8ee4b5"]https://github.com/HerculesWS/Hercules/commit/18278c253f08f5c8b26a1634a7c6c5efff8ee4b5[/url]