Sfoglia il codice sorgente

* 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://svn.code.sf.net/p/rathena/svn/trunk@6106 54d463be-8e91-2dee-dedb-b68131a5f0ec

Lance 19 anni fa
parent
commit
af5bdf87c3
3 ha cambiato i file con 46 aggiunte e 30 eliminazioni
  1. 4 1
      Changelog-Trunk.txt
  2. 41 29
      src/map/npc.c
  3. 1 0
      src/map/npc.h

+ 4 - 1
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.

+ 41 - 29
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);
 

+ 1 - 0
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]