Просмотр исходного кода

* Bugfix on fake npc

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6585 54d463be-8e91-2dee-dedb-b68131a5f0ec
Lance 19 лет назад
Родитель
Сommit
05736737c7
5 измененных файлов с 23 добавлено и 9 удалено
  1. 1 0
      Changelog-Trunk.txt
  2. 7 1
      src/map/clif.c
  3. 2 0
      src/map/map.h
  4. 12 7
      src/map/npc.c
  5. 1 1
      src/map/pc.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/05/12
+	* Bugfix on fake npc [Lance]
 	* Fixed mob_once_spawn not working for non-random coordinates. [blackhole89]
 	* Reverted again the change that stuns the caster on Ske, Ska, Swoo when
 	  the target is a nonplayer (rather than always) [Skotlex]

+ 7 - 1
src/map/clif.c

@@ -763,13 +763,19 @@ int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
  *------------------------------------------
  */
 int clif_clearchar_id(int id, int type, int fd) {
-	unsigned char buf[16];
+	/*unsigned char buf[16];
 
 	WBUFW(buf,0) = 0x80;
 	WBUFL(buf,2) = id;
 	WBUFB(buf,6) = type;
 	WFIFOHEAD(fd, packet_len_table[0x80]);
 	memcpy(WFIFOP(fd,0), buf, 7);
+	WFIFOSET(fd, packet_len_table[0x80]);*/
+
+	WFIFOHEAD(fd, packet_len_table[0x80]);
+	WFIFOW(fd,0)	= 0x80;
+	WFIFOL(fd,2)	= id;
+	WFIFOB(fd,6)	= (char)type; // Why use int for a char in the first place?
 	WFIFOSET(fd, packet_len_table[0x80]);
 
 	return 0;

+ 2 - 0
src/map/map.h

@@ -1412,4 +1412,6 @@ typedef struct pet_data         TBL_PET;
 extern int lowest_gm_level;
 extern char main_chat_nick[16];
 
+int fake_npc_id;
+
 #endif

+ 12 - 7
src/map/npc.c

@@ -1076,14 +1076,19 @@ int npc_scriptcont(struct map_session_data *sd,int id)
 		ShowWarning("npc_scriptcont: sd->npc_id (%d) is not id (%d).\n", sd->npc_id, id);
 		return 1;
 	}
-	if (npc_checknear(sd,id)){
-		ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
-		return 1;
-	}
 
-	nd=(struct npc_data *)map_id2bl(id);
+	if(sd->npc_id != fake_npc_id){ // Not item script
+		if (npc_checknear(sd,id)){
+			ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
+			return 1;
+		}
+
+		nd=(struct npc_data *)map_id2bl(id);
 
-	sd->npc_pos=run_script(nd->u.scr.script,sd->npc_pos,sd->bl.id,id);
+		sd->npc_pos=run_script(nd->u.scr.script,sd->npc_pos,sd->bl.id,id);
+	} else { // Item script, continue execution...
+		sd->npc_pos=run_script(sd->npc_scriptroot,sd->npc_pos,sd->bl.id,id);
+	}
 
 	return 0;
 }
@@ -2920,7 +2925,7 @@ int do_init_npc(void)
 	add_timer_func_list(npc_timerevent,"npc_timerevent");
 
 	// Init dummy NPC
-	//dummy_npc_id = npc_get_new_npc_id();
+	fake_npc_id = npc_get_new_npc_id();
 
 	return 0;
 }

+ 1 - 1
src/map/pc.c

@@ -2704,7 +2704,7 @@ int pc_useitem(struct map_session_data *sd,int n)
 	}
 
 	sd->canuseitem_tick= tick + battle_config.item_use_interval; //Update item use time.
-	run_script(script,0,sd->bl.id,0);
+	run_script(script,0,sd->bl.id,fake_npc_id);
 	potion_flag = 0;
 	return 1;
 }