소스 검색

- Removed sd->max_menu, sd->npc_menu is now reused to store what is the max number of valid entries and prevent clients from picking invalid options.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9690 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 18 년 전
부모
커밋
81a9313a9d
3개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 1
      src/map/clif.c
  2. 1 1
      src/map/map.h
  3. 3 3
      src/map/script.c

+ 1 - 1
src/map/clif.c

@@ -10023,7 +10023,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
 	RFIFOHEAD(fd);
 
 	select = RFIFOB(fd,6);
-	if((select > sd->max_menu && select != 0xff) || !select){
+	if((select > sd->npc_menu && select != 0xff) || !select){
 		ShowWarning("Hack on NPC Select Menu: %s (AID: %d)!\n",sd->status.name,sd->bl.id);
 		clif_GM_kick(sd,sd,0);
 	} else {

+ 1 - 1
src/map/map.h

@@ -628,7 +628,7 @@ struct map_session_data {
 	unsigned int client_tick;
 	int npc_id,areanpc_id,npc_shopid;
 	int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
-	int npc_menu, max_menu;
+	int npc_menu;
 	int npc_amount;
 	struct script_state *st;
 	char npc_str[256];

+ 3 - 3
src/map/script.c

@@ -4403,7 +4403,7 @@ int buildin_menu(struct script_state *st)
 			if(buf[i] == ':')
 				max++;
 		}
-		sd->max_menu = max;
+		sd->npc_menu = max; //Reuse to store max menu entries. Avoids the need of an extra variable.
 		clif_scriptmenu(sd,st->oid,buf);
 		aFree(buf);
 	} else if(sd->npc_menu==0xff){	// cancel
@@ -10637,7 +10637,7 @@ int buildin_select(struct script_state *st)
 			if(buf[i] == ':')
 				max++;
 		}
-		sd->max_menu = max;
+		sd->npc_menu = max; //Reuse to store max menu entries. Avoids the need of an extra variable.
 		clif_scriptmenu(sd,st->oid,buf);
 		aFree(buf);
 	} else if(sd->npc_menu==0xff){
@@ -10683,7 +10683,7 @@ int buildin_prompt(struct script_state *st)
 			if(buf[i] == ':')
 				max++;
 		}
-		sd->max_menu = max;
+		sd->npc_menu = max; //Reuse to store max menu entries. Avoids the need of an extra variable.
 		clif_scriptmenu(sd,st->oid,buf);
 		aFree(buf);
 	} else {