Issue information

Issue ID
#2223
Status
Working as Intended
Severity
Low
Started
Hercules Elf Bot
Sep 13, 2008 10:06
Last Post
Hercules Elf Bot
Apr 19, 2012 10:18
Confirmation
N/A

Hercules Elf Bot - Sep 13, 2008 10:06

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2223

When the special OnPC/NPC events get executed, they process simultaneously and globally. This means that when such an event occurs (say, OnPCDieEvent when you get killed), all npcs on the server that have an OnPCDieEvent label are looked up, and attempt to execute one by one:
CODE
        if(rid) // a player may only have 1 script running at the same time
            npc_event_sub(map_id2sd(rid),ev,key.str);
        else
            run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id);
But if you already have a npc conversation open at this point, all of them get force-queued instead. A simple example would be a npc with an OnPCLogoutEvent, duplicated 5 times.

The issue here is that the event queue for these events is only 2 entries long! (this is a value inherited from ancient jathena). So if you have more than 2 npcs with the same event somewhere on your server, triggering this event while talking to a npc raises an error condition
CODE
[03:02:34][Warning]: npc_event: player's event queue is full, can't add event '%s' !

The only workaround so far is to increase the MAX_EVENTQUEUE parameter to as high as the max. amount of npcs that share a npc event.


PS: a tweak to let you see exactly which npcs are causing this:
CODE
=== npc.c
==================================================================
--- npc.c    (revision 13205)
+++ npc.c    (local)
@@ -641,7 +641,13 @@
        if( i < MAX_EVENTQUEUE )
            safestrncpy(sd->eventqueue[i],eventname,50); //Event enqueued.
        else
-            ShowWarning("npc_event: player's event queue is full, can't add event '%s' !\n", eventname);
+        {
+            ShowWarning("npc_event: event queue of player '%s' is full, can't add event '%s' !\n", sd->status.name, eventname);
+            ShowDebug("Dumping event queue for player '%s':", sd->status.name);
+            for( i = 0; i < MAX_EVENTQUEUE; ++i )
+                ShowMessage(" \"%s\"", sd->eventqueue[i]);
+            ShowMessage("\n");
+        }
        
        return 1;
    }

Hercules Elf Bot - Jan 4, 2012 5:02

Originally posted by [b]Ind[/b]
nonono, the workaround is actually having a single place to your event, they're all run at once anyway. I see no benefit in having them split all over the place.