Преглед на файлове

- Changed npc_click declaration to receive an npc structure rather than a generic block-list one.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7925 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex преди 19 години
родител
ревизия
8da82e0a0a
променени са 4 файла, в които са добавени 11 реда и са изтрити 19 реда
  1. 1 1
      src/map/clif.c
  2. 8 16
      src/map/npc.c
  3. 1 1
      src/map/npc.h
  4. 1 1
      src/map/unit.c

+ 1 - 1
src/map/clif.c

@@ -9353,7 +9353,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
 			clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
 			break;
 		case BL_NPC:
-			npc_click(sd,bl);
+			npc_click(sd,(TBL_NPC*)bl);
 			break;
 	}
 	return;

+ 8 - 16
src/map/npc.c

@@ -969,7 +969,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
 
 			if( npc_event(sd,name,0)>0 ) {
 				pc_stop_walking(sd,1); //Make it stop walking!
-				npc_click(sd,&(map[m].npc[i]->bl));
+				npc_click(sd,map[m].npc[i]);
 			}
 			//aFree(name);
 			break;
@@ -1082,10 +1082,8 @@ int npc_globalmessage(const char *name,char *mes)
  * ƒNƒŠƒbƒNŽž‚ÌNPC�ˆ—�
  *------------------------------------------
  */
-int npc_click(struct map_session_data *sd,struct block_list *bl)
+int npc_click(struct map_session_data *sd,struct npc_data *nd)
 {
-	struct npc_data *nd = NULL;
-
 	nullpo_retr(1, sd);
 
 	if (sd->npc_id != 0) {
@@ -1094,18 +1092,12 @@ int npc_click(struct map_session_data *sd,struct block_list *bl)
 		return 1;
 	}
 
-	if(!bl) return 1;
-	switch(bl->type){
-		case BL_NPC:
-			if ((nd = npc_checknear(sd,bl)) == NULL)
-				return 1;
-			//Hidden/Disabled npc.
-			if (nd->class_ < 0 || nd->sc.option&OPTION_INVISIBLE)
-				return 1;
-			break;
-		default:
-			return 1;
-	}
+	if(!nd) return 1;
+	if ((nd = npc_checknear(sd,&nd->bl)) == NULL)
+		return 1;
+	//Hidden/Disabled npc.
+	if (nd->class_ < 0 || nd->sc.option&OPTION_INVISIBLE)
+		return 1;
 
 	switch(nd->bl.subtype) {
 	case SHOP:

+ 1 - 1
src/map/npc.h

@@ -41,7 +41,7 @@ int npc_timer_event(const unsigned char *eventname);				// Added by RoVeRT
 int npc_command(struct map_session_data *sd,const unsigned char *npcname,char *command);
 int npc_touch_areanpc(struct map_session_data *,int,int,int);
 int npc_touch_areanpc2(struct block_list *bl); // [Skotlex]
-int npc_click(struct map_session_data *sd,struct block_list *bl);
+int npc_click(struct map_session_data *sd,struct npc_data *nd);
 int npc_scriptcont(struct map_session_data *,int);
 TBL_NPC *npc_checknear(struct map_session_data *sd,struct block_list *bl);
 int npc_checknear2(struct map_session_data *sd,struct block_list *bl);

+ 1 - 1
src/map/unit.c

@@ -1097,7 +1097,7 @@ int unit_attack(struct block_list *src,int target_id,int type)
 	}
 
 	if(src->type == BL_PC && target->type==BL_NPC) { // monster npcs [Valaris]
-		npc_click((TBL_PC*)src,target); // submitted by leinsirk10 [Celest]
+		npc_click((TBL_PC*)src,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
 		return 0;
 	}