소스 검색

- Removed the flag variable from the npc_data structure. Disabled NPCs are now handled through nd->sc.option&OPTION_INVISIBLE checks. Should fix disable/enablenpc calls not working.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5889 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 년 전
부모
커밋
de8f8cb6f7
3개의 변경된 파일15개의 추가작업 그리고 17개의 파일을 삭제
  1. 2 0
      Changelog-Trunk.txt
  2. 0 1
      src/map/map.h
  3. 13 16
      src/map/npc.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ 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/04/03
+	* Disabled NPCs are now handled through nd->sc.option&OPTION_INVISIBLE
+	  checks. Should fix disable/enablenpc calls not working. [Skotlex]
 	* Moved skill_counter_additional_effect calls to trigger right after
 	  skill_additional_effect (which means they trigger at the end of the attack
 	  motion for physical attacks instead of at the beginning of the attack

+ 0 - 1
src/map/map.h

@@ -786,7 +786,6 @@ struct npc_data {
 	unsigned char name[NAME_LENGTH];
 	unsigned char exname[NAME_LENGTH];
 	int chat_id;
-	short flag;
 	unsigned int next_walktime;
 
 	char eventqueue[MAX_EVENTQUEUE][50];

+ 13 - 16
src/map/npc.c

@@ -90,7 +90,7 @@ int npc_enable_sub( struct block_list *bl, va_list ap )
 	if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){
 		char name[50]; // need 24 + 9 for the "::OnTouch"
 
-		if (nd->flag&1)	// 無効化されている
+		if (nd->sc.option&OPTION_INVISIBLE)	// 無効化されている
 			return 1;
 
 		if(sd->areanpc_id==nd->bl.id)
@@ -110,19 +110,17 @@ int npc_enable(const char *name,int flag)
 		return 0;
 
 	if (flag&1) {	// 有効化
-		nd->flag&=~1;
-		clif_spawn(&nd->bl);
+		nd->sc.option&=~OPTION_INVISIBLE;
+		clif_changeoption(&nd->bl);
 	}else if (flag&2){
-		nd->flag&=~1;
-		nd->sc.option = 0x0000;
+		nd->sc.option&=~OPTION_HIDE;
 		clif_changeoption(&nd->bl);
 	}else if (flag&4){
-		nd->flag|=1;
-		nd->sc.option = 0x0002;
+		nd->sc.option = OPTION_HIDE;
+		clif_changeoption(&nd->bl);
+	}else{	//Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
+		nd->sc.option = OPTION_INVISIBLE;
 		clif_changeoption(&nd->bl);
-	}else{		// 無効化
-		nd->flag|=1;
-		clif_clearchar(&nd->bl,0);
 	}
 	if(flag&3 && (nd->u.scr.xs > 0 || nd->u.scr.ys >0))
 		map_foreachinarea( npc_enable_sub,nd->bl.m,nd->bl.x-nd->u.scr.xs,nd->bl.y-nd->u.scr.ys,nd->bl.x+nd->u.scr.xs,nd->bl.y+nd->u.scr.ys,BL_PC,nd);
@@ -859,7 +857,7 @@ int npc_event (struct map_session_data *sd, const unsigned char *eventname, int
 		}
 		return 1;
 	}
-	if (nd->flag&1) {	// 無効化されている
+	if (nd->sc.option&OPTION_INVISIBLE) {	// 無効化されている
 		npc_event_dequeue(sd);
 		return 0;
 	}
@@ -909,7 +907,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
 		return 1;
 
 	for(i=0;i<map[m].npc_num;i++) {
-		if (map[m].npc[i]->flag&1) {	// 無効化されている
+		if (map[m].npc[i]->sc.option&OPTION_INVISIBLE) {	// 無効化されている
 			f=0;
 			continue;
 		}
@@ -1034,7 +1032,8 @@ int npc_click(struct map_session_data *sd,int id)
 
 	nd=(struct npc_data *)map_id2bl(id);
 
-	if (nd->flag&1)	// 無効化されている
+	//Disabled npc.
+	if (nd->sc.option&OPTION_INVISIBLE)
 		return 1;
 
 	sd->npc_id=id;
@@ -1093,7 +1092,7 @@ int npc_buysellsel(struct map_session_data *sd,int id,int type)
 		sd->npc_id=0;
 		return 1;
 	}
-	if (nd->flag&1)	// 無効化されている
+	if (nd->sc.option&OPTION_INVISIBLE)	// 無効化されている
 		return 1;
 
 	sd->npc_shopid=id;
@@ -1570,7 +1569,6 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
 	nd->bl.x = x;
 	nd->bl.y = y;
 	nd->bl.id = npc_get_new_npc_id();
-	nd->flag = 0;
 	memcpy(nd->name, w3, NAME_LENGTH-1);
 	nd->name[NAME_LENGTH-1] = '\0';
 	nd->class_ = m==-1?-1:atoi(w4);
@@ -1874,7 +1872,6 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
 	nd->bl.x = x;
 	nd->bl.y = y;
 	nd->bl.id = npc_get_new_npc_id();
-//	nd->flag = 0;
 	nd->class_ = class_;
 	nd->speed = 200;
 	nd->u.scr.script = script;