summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-16 12:10:53 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-16 12:10:53 +0000
commitb7c32095864ed8ac2547507ccbe0f5eacf11664a (patch)
tree960ff64937df2bea2288f84b290b31e60ff90f0b
parent084f3b9931895aa6c7665e61617f170c9c053afd (diff)
downloadhercules-b7c32095864ed8ac2547507ccbe0f5eacf11664a.tar.gz
hercules-b7c32095864ed8ac2547507ccbe0f5eacf11664a.tar.bz2
hercules-b7c32095864ed8ac2547507ccbe0f5eacf11664a.tar.xz
hercules-b7c32095864ed8ac2547507ccbe0f5eacf11664a.zip
* Experimental npc_event_doall_sub with queue and npc_id allocation when needed.
* Added warnings to npc_scriptcont for easier debugging. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6106 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt5
-rw-r--r--src/map/npc.c70
-rw-r--r--src/map/npc.h1
3 files changed, 46 insertions, 30 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 7dc1bea46..9f1d1b499 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -5,13 +5,16 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/04/16
* Fixed wrong check of Deluge + Suiton which broke the water-requirement
- check for skills. [Skotlex\
+ check for skills. [Skotlex]
* Cleared ud->target on remove-map, it should fix the phantom mob sprite
issue. [Skotlex]
* Temperory fixed compiler warnings/errors. Please compile before commiting.
[Lance]
* Added pcre3.dll, zlib1.dll and libmysql.dll. DO NOT DELETE THEM.
(Required by systems without these DLLs preinstalled) [Lance]
+ * Experimental npc_event_doall_sub with queue and npc_id allocation when needed.
+ [Lance]
+ * Added warnings to npc_scriptcont for easier debugging. [Lance]
2006/04/15
* Fixed upgrade_svn5902.sql, thanks to Koshiro for pointing it out.
diff --git a/src/map/npc.c b/src/map/npc.c
index e50e78fa5..15cf75983 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -320,7 +320,10 @@ int npc_event_doall_sub(DBKey key,void *data,va_list ap)
rid=va_arg(ap, int);
if( (p=strchr(p,':')) && p && strcmpi(name,p)==0 ){
- run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id);
+ if(rid)
+ npc_event_sub(((struct map_session_data *)map_id2bl(rid)),ev,key.str);
+ else
+ run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id);
(*c)++;
}
@@ -794,6 +797,35 @@ int npc_settimerevent_tick(struct npc_data *nd,int newtimer)
return 0;
}
+int npc_event_sub(struct map_session_data *sd, struct event_data *ev, const unsigned char *eventname){
+
+ if ( sd->npc_id!=0) {
+// if (battle_config.error_log)
+// printf("npc_event: npc_id != 0\n");
+ int i;
+ for(i=0;i<MAX_EVENTQUEUE;i++)
+ if (!sd->eventqueue[i][0])
+ break;
+ if (i==MAX_EVENTQUEUE) {
+ if (battle_config.error_log)
+ ShowWarning("npc_event: event queue is full !\n");
+ }else{
+// if (battle_config.etc_log)
+// printf("npc_event: enqueue\n");
+ memcpy(sd->eventqueue[i],eventname,50);
+ }
+ return 1;
+ }
+ if (ev->nd->sc.option&OPTION_INVISIBLE) { // 無効化されている
+ npc_event_dequeue(sd);
+ return 0;
+ }
+
+ sd->npc_id=ev->nd->bl.id;
+ sd->npc_pos=run_script(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id);
+ return 0;
+}
+
/*==========================================
* イベント型のNPC処理
*------------------------------------------
@@ -841,32 +873,8 @@ int npc_event (struct map_session_data *sd, const unsigned char *eventname, int
return 1;
}
}
-
- if ( sd->npc_id!=0) {
-// if (battle_config.error_log)
-// printf("npc_event: npc_id != 0\n");
- int i;
- for(i=0;i<MAX_EVENTQUEUE;i++)
- if (!sd->eventqueue[i][0])
- break;
- if (i==MAX_EVENTQUEUE) {
- if (battle_config.error_log)
- ShowWarning("npc_event: event queue is full !\n");
- }else{
-// if (battle_config.etc_log)
-// printf("npc_event: enqueue\n");
- memcpy(sd->eventqueue[i],eventname,50);
- }
- return 1;
- }
- if (nd->sc.option&OPTION_INVISIBLE) { // 無効化されている
- npc_event_dequeue(sd);
- return 0;
- }
-
- sd->npc_id=nd->bl.id;
- sd->npc_pos=run_script(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id);
- return 0;
+
+ return npc_event_sub(sd,ev,eventname);
}
@@ -1062,10 +1070,14 @@ int npc_scriptcont(struct map_session_data *sd,int id)
nullpo_retr(1, sd);
- if (id!=sd->npc_id)
+ if (id!=sd->npc_id){
+ ShowWarning("npc_scriptcont: sd->npc_id is not id.\n");
return 1;
- if (npc_checknear(sd,id))
+ }
+ if (npc_checknear(sd,id)){
+ ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
return 1;
+ }
nd=(struct npc_data *)map_id2bl(id);
diff --git a/src/map/npc.h b/src/map/npc.h
index e05687969..a2c6b5ca4 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -38,6 +38,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4);
int npc_parse_mob2 (struct spawn_data*, int index); // [Wizputer]
int npc_parse_warp(char *w1,char *w2,char *w3,char *w4);
int npc_globalmessage(const char *name,char *mes);
+int npc_event_sub(struct map_session_data *sd, struct event_data *ev, const unsigned char *eventname); //[Lance]
int npc_enable(const char *name,int flag);
int npc_changename(const char *name, const char *newname, short look); // [Lance]