Browse Source

Fixed a lot of scanf issues reported by rathena's cppcheck

Lemongrass3110 10 years ago
parent
commit
a674869113

+ 1 - 1
conf/msg_conf/map_msg.conf

@@ -423,7 +423,7 @@
 404: War of Emperium SE is currently in progress.
 404: War of Emperium SE is currently in progress.
 405: War of Emperium SE has been ended.
 405: War of Emperium SE has been ended.
 406: War of Emperium SE is currently not in progress.
 406: War of Emperium SE is currently not in progress.
-//407 free
+407: Invalid amount of parameters.
 //chrif related
 //chrif related
 408: Need disconnection to perform change-sex request...
 408: Need disconnection to perform change-sex request...
 409: Your sex has been changed (need disconnection by the server)...
 409: Your sex has been changed (need disconnection by the server)...

+ 1 - 1
conf/msg_conf/map_msg_chn.conf

@@ -412,7 +412,7 @@
 404: 攻城戰第二版正在進行中
 404: 攻城戰第二版正在進行中
 405: 攻城戰第二版結束了
 405: 攻城戰第二版結束了
 406: 攻城戰第二版尚未開始
 406: 攻城戰第二版尚未開始
-//407 free
+407: Invalid amount of parameters.
 //chrif related
 //chrif related
 408: 需要斷線以更改性別
 408: 需要斷線以更改性別
 409: 你的性別已更改(你將會被伺服器中斷連線)
 409: 你的性別已更改(你將會被伺服器中斷連線)

+ 1 - 1
conf/msg_conf/map_msg_frn.conf

@@ -420,7 +420,7 @@
 404: War of Emperium SE en cours.
 404: War of Emperium SE en cours.
 405: War of Emperium SE est terminée.
 405: War of Emperium SE est terminée.
 406: War of Emperium SE n'est pas en cours.
 406: War of Emperium SE n'est pas en cours.
-//407 free
+407: Invalid amount of parameters.
 //chrif related
 //chrif related
 408: Besoin de vous déconnecter pour effectuer la demande de changement de sexe...
 408: Besoin de vous déconnecter pour effectuer la demande de changement de sexe...
 409: Changement de sexe (le serveur a besoin de vous déconnecter)...
 409: Changement de sexe (le serveur a besoin de vous déconnecter)...

+ 1 - 1
conf/msg_conf/map_msg_grm.conf

@@ -403,7 +403,7 @@
 404: War of Emperium SE ist derzeitig im Gange.
 404: War of Emperium SE ist derzeitig im Gange.
 405: War of Emperium SE wurde Beendet.
 405: War of Emperium SE wurde Beendet.
 406: War of Emperium SE ist derzeitig nicht im Gange.
 406: War of Emperium SE ist derzeitig nicht im Gange.
-
+407: Invalid amount of parameters.
 // Homunculus messages
 // Homunculus messages
 450: Du hast bereitz ein Homunculus
 450: Du hast bereitz ein Homunculus
 
 

+ 1 - 1
conf/msg_conf/map_msg_idn.conf

@@ -423,7 +423,7 @@
 404: War of Emperium SE saat ini sedang berjalan.
 404: War of Emperium SE saat ini sedang berjalan.
 405: War of Emperium SE telah dimulai.
 405: War of Emperium SE telah dimulai.
 406: War of Emperium SE saat ini sedang tidak berjalan.
 406: War of Emperium SE saat ini sedang tidak berjalan.
-//407 kosong
+407: Invalid amount of parameters.
 //berkaitan dengan chrif
 //berkaitan dengan chrif
 408: Dibutuhkan pemutusan koneksi untuk melakukan permintaan ubah jenis kelamin ...
 408: Dibutuhkan pemutusan koneksi untuk melakukan permintaan ubah jenis kelamin ...
 409: Jenis kelaminmu telah diganti (membutuhkan pemutusan koneksi oleh server) ...
 409: Jenis kelaminmu telah diganti (membutuhkan pemutusan koneksi oleh server) ...

+ 1 - 1
conf/msg_conf/map_msg_por.conf

@@ -410,7 +410,7 @@
 404: A Guerra do Emperium SE já está em progresso.
 404: A Guerra do Emperium SE já está em progresso.
 405: A Guerra do Emperium SE terminou!
 405: A Guerra do Emperium SE terminou!
 406: A Guerra do Emperium SE ainda não foi iniciada.
 406: A Guerra do Emperium SE ainda não foi iniciada.
-//407 livre
+407: Invalid amount of parameters.
 //Mensagens relacionadas ao chrif
 //Mensagens relacionadas ao chrif
 408: É preciso desconectar-se para que o pedido de mudança de sexo seja processado...
 408: É preciso desconectar-se para que o pedido de mudança de sexo seja processado...
 409: O seu sexo foi alterado (é preciso desconectar-se do servidor)...
 409: O seu sexo foi alterado (é preciso desconectar-se do servidor)...

+ 1 - 1
conf/msg_conf/map_msg_rus.conf

@@ -420,7 +420,7 @@
 404: Война за Империум 2.0 уже идёт.
 404: Война за Империум 2.0 уже идёт.
 405: Война за Империум 2.0 окончена.
 405: Война за Империум 2.0 окончена.
 406: Война за Империум 2.0 в текущее время не идёт.
 406: Война за Империум 2.0 в текущее время не идёт.
-//407 НЕ ИСПОЛЬЗУЕТСЯ
+407: Invalid amount of parameters.
 //chrif related
 //chrif related
 408: Необходимо отключение для выполнения запроса на смену пола...
 408: Необходимо отключение для выполнения запроса на смену пола...
 409: Ваш пол был изменен (необходимо отключение от сервера)...
 409: Ваш пол был изменен (необходимо отключение от сервера)...

+ 1 - 1
conf/msg_conf/map_msg_spn.conf

@@ -411,7 +411,7 @@
 404: Hay una Guerra del Emperium de la 2ª edición en marcha.
 404: Hay una Guerra del Emperium de la 2ª edición en marcha.
 405: Ha finalizado la Guerra del Emperium de la 2ª edición.
 405: Ha finalizado la Guerra del Emperium de la 2ª edición.
 406: No hay ninguna Guerra del Emperium de la 2ª edición en marcha.
 406: No hay ninguna Guerra del Emperium de la 2ª edición en marcha.
-//407 vacío
+407: Invalid amount of parameters.
 //Mensajes de chrif
 //Mensajes de chrif
 408: Necesitas desconectarte para realizar el cambio de sexo.
 408: Necesitas desconectarte para realizar el cambio de sexo.
 409: Has cambiado de sexo (necesitas desconectarte y volver a entrar)
 409: Has cambiado de sexo (necesitas desconectarte y volver a entrar)

+ 1 - 1
conf/msg_conf/map_msg_tha.conf

@@ -418,7 +418,7 @@
 404: War of Emperium SE ∂턺㎎彖拈睾撫尸∏橘旅.
 404: War of Emperium SE ∂턺㎎彖拈睾撫尸∏橘旅.
 405: War of Emperium SE 芽蟯뵀�.
 405: War of Emperium SE 芽蟯뵀�.
 406: War of Emperium SE 幄巍닻롭㎾믹쬔嵬묄넓밌�.
 406: War of Emperium SE 幄巍닻롭㎾믹쬔嵬묄넓밌�.
-//407 free
+407: Invalid amount of parameters.
 //chrif related
 //chrif related
 408: 들系둘뇟櫓夕羸皐듣滾묀櫓닒仙瀆⌒창梱뼜㏅안 ...
 408: 들系둘뇟櫓夕羸皐듣滾묀櫓닒仙瀆⌒창梱뼜㏅안 ...
 409: ㅨ념닻沼큘宣휸촹쨘췌睾 (들系둘뇟櫓夕羸皐듣繫納奭惇荑璿稿�)...
 409: ㅨ념닻沼큘宣휸촹쨘췌睾 (들系둘뇟櫓夕羸皐듣繫納奭惇荑璿稿�)...

+ 4 - 2
src/char/char.c

@@ -2631,9 +2631,11 @@ bool char_config_read(const char* cfgName, bool normal){
 			charserv_config.save_log = config_switch(w2);
 			charserv_config.save_log = config_switch(w2);
 		} else if (strcmpi(w1, "start_point") == 0) {
 		} else if (strcmpi(w1, "start_point") == 0) {
 			char map[MAP_NAME_LENGTH_EXT];
 			char map[MAP_NAME_LENGTH_EXT];
-			int x, y;
-			if (sscanf(w2, "%15[^,],%d,%d", map, &x, &y) < 3)
+			short x, y;
+			if (sscanf(w2, "%15[^,],%6hd,%6hd", map, &x, &y) < 3){
+				ShowWarning( "Specified start_point has an invalid format.\n" );
 				continue;
 				continue;
+			}
 			charserv_config.start_point.map = mapindex_name2id(map);
 			charserv_config.start_point.map = mapindex_name2id(map);
 			if (!charserv_config.start_point.map)
 			if (!charserv_config.start_point.map)
 				ShowError("Specified start_point %s not found in map-index cache.\n", map);
 				ShowError("Specified start_point %s not found in map-index cache.\n", map);

+ 1 - 1
src/common/core.c

@@ -218,7 +218,7 @@ const char* get_svn_revision(void) {
 				// XML File format
 				// XML File format
 				while (fgets(line,sizeof(line),fp))
 				while (fgets(line,sizeof(line),fp))
 					if (strstr(line,"revision=")) break;
 					if (strstr(line,"revision=")) break;
-				if (sscanf(line," %*[^\"]\"%d%*[^\n]", &rev) == 1) {
+				if (sscanf(line," %*[^\"]\"%11d%*[^\n]", &rev) == 1) {
 					snprintf(svn_version_buffer, sizeof(svn_version_buffer), "%d", rev);
 					snprintf(svn_version_buffer, sizeof(svn_version_buffer), "%d", rev);
 				}
 				}
 			}
 			}

+ 72 - 66
src/map/atcommand.c

@@ -140,8 +140,8 @@ ACMD_FUNC(send)
 	int len=0,type;
 	int len=0,type;
 	// read message type as hex number (without the 0x)
 	// read message type as hex number (without the 0x)
 	if(!message || !*message ||
 	if(!message || !*message ||
-			!((sscanf(message, "len %x", &type)==1 && (len=1))
-			|| sscanf(message, "%x", &type)==1) )
+			!((sscanf(message, "len %8x", &type)==1 && (len=1))
+			|| sscanf(message, "%8x", &type)==1) )
 	{
 	{
 		int i;
 		int i;
 		for (i = 900; i <= 903; ++i)
 		for (i = 900; i <= 903; ++i)
@@ -173,7 +173,7 @@ ACMD_FUNC(send)
 
 
 #define GET_VALUE(p,num) \
 #define GET_VALUE(p,num) \
 	{\
 	{\
-		if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
+		if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
 			PARSE_ERROR("Invalid number in:",(p));\
 			PARSE_ERROR("Invalid number in:",(p));\
 			return -1;\
 			return -1;\
 		}\
 		}\
@@ -449,8 +449,8 @@ ACMD_FUNC(mapmove)
 	memset(map_name, '\0', sizeof(map_name));
 	memset(map_name, '\0', sizeof(map_name));
 
 
 	if (!message || !*message ||
 	if (!message || !*message ||
-		(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
-		 sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
+		(sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
+		 sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
 			clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
 			clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
 			return -1;
 			return -1;
 	}
 	}
@@ -577,7 +577,10 @@ ACMD_FUNC(jump)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	sscanf(message, "%hd %hd", &x, &y);
+	if (sscanf(message, "%6hd %6hd", &x, &y) != 2) {
+		clif_displaymessage(fd, msg_txt(sd,407));
+		return -1;
+	}
 
 
 	if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
 	if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
 		clif_displaymessage(fd, msg_txt(sd,248));	// You are not authorized to warp from your current map.
 		clif_displaymessage(fd, msg_txt(sd,248));	// You are not authorized to warp from your current map.
@@ -844,13 +847,13 @@ ACMD_FUNC(load)
  *------------------------------------------*/
  *------------------------------------------*/
 ACMD_FUNC(speed)
 ACMD_FUNC(speed)
 {
 {
-	int speed;
+	short speed;
 
 
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
+	if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
 		sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
 		sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
 		return -1;
 		return -1;
@@ -934,7 +937,7 @@ ACMD_FUNC(option)
 	int param1 = 0, param2 = 0, param3 = 0;
 	int param1 = 0, param2 = 0, param3 = 0;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
+	if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
 	{// failed to match the parameters so inform the user of the options
 	{// failed to match the parameters so inform the user of the options
 		const char* text;
 		const char* text;
 
 
@@ -1012,7 +1015,7 @@ ACMD_FUNC(jobchange)
 	const char* text;
 	const char* text;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-    if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
+    if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
 		int i;
 		int i;
 		bool found = false;
 		bool found = false;
 
 
@@ -1119,7 +1122,7 @@ ACMD_FUNC(kami)
 		else
 		else
 			intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
 			intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
 	} else {
 	} else {
-		if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
+		if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
 			clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
 			clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
 			return -1;
 			return -1;
 		}
 		}
@@ -1141,7 +1144,10 @@ ACMD_FUNC(heal)
 	int hp = 0, sp = 0; // [Valaris] thanks to fov
 	int hp = 0, sp = 0; // [Valaris] thanks to fov
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	sscanf(message, "%d %d", &hp, &sp);
+	if (sscanf(message, "%11d %11d", &hp, &sp) != 2) {
+		clif_displaymessage(fd, msg_txt(sd,407));
+		return -1;
+	}
 
 
 	// some overflow checks
 	// some overflow checks
 	if( hp == INT_MIN ) hp++;
 	if( hp == INT_MIN ) hp++;
@@ -1212,8 +1218,8 @@ ACMD_FUNC(item)
 
 
 	if (!strcmpi(parent_cmd,"itembound")) {
 	if (!strcmpi(parent_cmd,"itembound")) {
 		if (!message || !*message || (
 		if (!message || !*message || (
-			sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 3 &&
-			sscanf(message, "%99s %d %d", item_name, &number, &bound) < 3))
+			sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
+			sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
 		{
 		{
 			clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
 			clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
 			clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
 			clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
@@ -1224,8 +1230,8 @@ ACMD_FUNC(item)
 			return -1;
 			return -1;
 		}
 		}
 	} else if (!message || !*message || (
 	} else if (!message || !*message || (
-		sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
-		sscanf(message, "%99s %d", item_name, &number) < 1
+		sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
+		sscanf(message, "%99s %11d", item_name, &number) < 1
 	)) {
 	)) {
 		clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
 		clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
 		return -1;
 		return -1;
@@ -1289,8 +1295,8 @@ ACMD_FUNC(item2)
 
 
 	if (!strcmpi(parent_cmd+1,"itembound2")) {
 	if (!strcmpi(parent_cmd+1,"itembound2")) {
 		if (!message || !*message || (
 		if (!message || !*message || (
-			sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
-			sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
+			sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
+			sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
 		{
 		{
 			clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
 			clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
 			clif_displaymessage(fd, msg_txt(sd,297)); //   <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
 			clif_displaymessage(fd, msg_txt(sd,297)); //   <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
@@ -1302,8 +1308,8 @@ ACMD_FUNC(item2)
 			return -1;
 			return -1;
 		}
 		}
 	} else if ( !message || !*message || (
 	} else if ( !message || !*message || (
-		sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
-		sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
+		sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
+		sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
 		)) {
 		)) {
 		clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
 		clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
 		clif_displaymessage(fd, msg_txt(sd,985)); //   <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
 		clif_displaymessage(fd, msg_txt(sd,985)); //   <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
@@ -1704,7 +1710,7 @@ ACMD_FUNC(model)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
+	if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
 		sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
 		sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
 		        MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
 		        MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
@@ -1736,7 +1742,7 @@ ACMD_FUNC(dye)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
+	if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
 		sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
 		sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
 		return -1;
 		return -1;
@@ -1763,7 +1769,7 @@ ACMD_FUNC(hair_style)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
+	if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
 		sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
 		sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
 		return -1;
 		return -1;
@@ -1790,7 +1796,7 @@ ACMD_FUNC(hair_color)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
+	if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
 		sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
 		sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
 		return -1;
 		return -1;
@@ -1815,7 +1821,6 @@ ACMD_FUNC(go)
 	int i;
 	int i;
 	int town;
 	int town;
 	char map_name[MAP_NAME_LENGTH];
 	char map_name[MAP_NAME_LENGTH];
-	int16 m;
 
 
 	const struct {
 	const struct {
 		char map[MAP_NAME_LENGTH];
 		char map[MAP_NAME_LENGTH];
@@ -1984,7 +1989,7 @@ ACMD_FUNC(go)
 
 
 	if (town >= 0 && town < ARRAYLENGTH(data))
 	if (town >= 0 && town < ARRAYLENGTH(data))
 	{
 	{
-		m = map_mapname2mapid(data[town].map);
+		int16 m = map_mapname2mapid(data[town].map);
 		if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
 		if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
 			clif_displaymessage(fd, msg_txt(sd,247));
 			clif_displaymessage(fd, msg_txt(sd,247));
 			return -1;
 			return -1;
@@ -2031,14 +2036,14 @@ ACMD_FUNC(monster)
 			clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
 			clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
 			return -1;
 			return -1;
 	}
 	}
-	if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
-		sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
+	if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
+		sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
 		//All data can be left as it is.
 		//All data can be left as it is.
-	} else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
+	} else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
 		//Here, it is possible name was not given and we are using monster for it.
 		//Here, it is possible name was not given and we are using monster for it.
 		if (count < 3) //Blank mob's name.
 		if (count < 3) //Blank mob's name.
 			name[0] = '\0';
 			name[0] = '\0';
-	} else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
+	} else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
 		//All data can be left as it is.
 		//All data can be left as it is.
 	} else if (sscanf(message, "%23s", monster) > 0) {
 	} else if (sscanf(message, "%23s", monster) > 0) {
 		//As before, name may be already filled.
 		//As before, name may be already filled.
@@ -2168,7 +2173,7 @@ ACMD_FUNC(refine)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
+	if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
 		clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
 		clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
 		sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
 		sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
@@ -2250,8 +2255,8 @@ ACMD_FUNC(produce)
 	memset(item_name, '\0', sizeof(item_name));
 	memset(item_name, '\0', sizeof(item_name));
 
 
 	if (!message || !*message || (
 	if (!message || !*message || (
-		sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
-		sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
+		sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
+		sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
 	)) {
 	)) {
 		clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
 		clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
 		return -1;
 		return -1;
@@ -2304,7 +2309,7 @@ ACMD_FUNC(memo)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if( !message || !*message || sscanf(message, "%d", &position) < 1 )
+	if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
 	{
 	{
 		int i;
 		int i;
 		clif_displaymessage(sd->fd,  msg_txt(sd,668));
 		clif_displaymessage(sd->fd,  msg_txt(sd,668));
@@ -2362,7 +2367,7 @@ ACMD_FUNC(displaystatus)
 	int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
 	int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
+	if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
 		clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
 		clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
 		return -1;
 		return -1;
 	}
 	}
@@ -2511,7 +2516,7 @@ ACMD_FUNC(param)
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 
 
-	if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
+	if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
 		clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
 		clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
 		return -1;
 		return -1;
 	}
 	}
@@ -2583,7 +2588,7 @@ ACMD_FUNC(stat_all)
 	status[4] = &sd->status.dex;
 	status[4] = &sd->status.dex;
 	status[5] = &sd->status.luk;
 	status[5] = &sd->status.luk;
 
 
-	if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
+	if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
 		max_status[0] = pc_maxparameter(sd,PARAM_STR);
 		max_status[0] = pc_maxparameter(sd,PARAM_STR);
 		max_status[1] = pc_maxparameter(sd,PARAM_AGI);
 		max_status[1] = pc_maxparameter(sd,PARAM_AGI);
 		max_status[2] = pc_maxparameter(sd,PARAM_VIT);
 		max_status[2] = pc_maxparameter(sd,PARAM_VIT);
@@ -2645,7 +2650,7 @@ ACMD_FUNC(guildlevelup) {
 	struct guild *guild_info;
 	struct guild *guild_info;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
+	if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
 		clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
 		clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
 		return -1;
 		return -1;
 	}
 	}
@@ -3887,7 +3892,7 @@ ACMD_FUNC(mapinfo) {
 	memset(mapname, '\0', sizeof(mapname));
 	memset(mapname, '\0', sizeof(mapname));
 	memset(direction, '\0', sizeof(direction));
 	memset(direction, '\0', sizeof(direction));
 
 
-	sscanf(message, "%d %23[^\n]", &list, mapname);
+	sscanf(message, "%11d %23[^\n]", &list, mapname);
 
 
 	if (list < 0 || list > 3) {
 	if (list < 0 || list > 3) {
 		clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
 		clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
@@ -5134,7 +5139,7 @@ ACMD_FUNC(effect)
 	int type = 0, flag = 0;
 	int type = 0, flag = 0;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%d", &type) < 1) {
+	if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
 		clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
 		clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
 		return -1;
 		return -1;
 	}
 	}
@@ -5210,12 +5215,12 @@ ACMD_FUNC(skilloff)
  *------------------------------------------*/
  *------------------------------------------*/
 ACMD_FUNC(npcmove)
 ACMD_FUNC(npcmove)
 {
 {
-	int x = 0, y = 0, m;
+	short x = 0, y = 0, m;
 	struct npc_data *nd = 0;
 	struct npc_data *nd = 0;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 	memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
 	memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
 
 
-	if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
+	if (!message || !*message || sscanf(message, "%6hd %6hd %23[^\n]", &x, &y, atcmd_player_name) < 3) {
 		clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
 		clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
 		return -1;
 		return -1;
 	}
 	}
@@ -5248,15 +5253,15 @@ ACMD_FUNC(npcmove)
  *------------------------------------------*/
  *------------------------------------------*/
 ACMD_FUNC(addwarp)
 ACMD_FUNC(addwarp)
 {
 {
-	char mapname[32], warpname[NAME_LENGTH+1];
-	int x,y;
+	char mapname[32], warpname[MAP_NAME_LENGTH_EXT];
+	short x,y;
 	unsigned short m;
 	unsigned short m;
 	struct npc_data* nd;
 	struct npc_data* nd;
 
 
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 	memset(warpname, '\0', sizeof(warpname));
 	memset(warpname, '\0', sizeof(warpname));
 
 
-	if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
+	if (!message || !*message || sscanf(message, "%31s %6hd %6hd %23[^\n]", mapname, &x, &y, warpname) < 4) {
 		clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
 		clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
 		return -1;
 		return -1;
 	}
 	}
@@ -5543,7 +5548,7 @@ ACMD_FUNC(useskill)
 	char target[100];
 	char target[100];
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
+	if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
 		clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
 		clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
 		return -1;
 		return -1;
 	}
 	}
@@ -5587,7 +5592,7 @@ ACMD_FUNC(displayskill)
 	uint16 skill_lv = 1;
 	uint16 skill_lv = 1;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
+	if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
 	{
 	{
 		clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
 		clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
 		return -1;
 		return -1;
@@ -5613,7 +5618,7 @@ ACMD_FUNC(skilltree)
 	struct skill_tree_entry *ent;
 	struct skill_tree_entry *ent;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
+	if(!message || !*message || sscanf(message, "%6hu %23[^\r\n]", &skill_id, target) != 2) {
 		clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
 		clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
 		return -1;
 		return -1;
 	}
 	}
@@ -5737,7 +5742,7 @@ ACMD_FUNC(changelook)
 	int i, j = 0, k = 0;
 	int i, j = 0, k = 0;
 	int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
 	int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
 
 
-	if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
+	if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
 		clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
 		clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
 		clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
 		clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
 		return -1;
 		return -1;
@@ -6046,7 +6051,7 @@ ACMD_FUNC(autolootitem)
  *------------------------------------------*/
  *------------------------------------------*/
 ACMD_FUNC(autoloottype)
 ACMD_FUNC(autoloottype)
 {
 {
-	uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
+	uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
 	enum item_types type = -1;
 	enum item_types type = -1;
 	int ITEM_MAX = 1533;
 	int ITEM_MAX = 1533;
 
 
@@ -6120,6 +6125,7 @@ ACMD_FUNC(autoloottype)
 			if (sd->state.autoloottype == 0)
 			if (sd->state.autoloottype == 0)
 				clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
 				clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
 			else {
 			else {
+				uint8 i = 0;
 				clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
 				clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
 				while (i < IT_MAX) {
 				while (i < IT_MAX) {
 					if (sd->state.autoloottype&(1<<i)) {
 					if (sd->state.autoloottype&(1<<i)) {
@@ -6411,15 +6417,15 @@ ACMD_FUNC(cleanmap)
 
 
 ACMD_FUNC(cleanarea)
 ACMD_FUNC(cleanarea)
 {
 {
-	int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
+	short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
 
 
-	if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
+	if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
 	}
 	}
-	else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
+	else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
 	}
 	}
-	else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
+	else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
 		map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
 	}
 	}
 
 
@@ -6448,7 +6454,7 @@ ACMD_FUNC(npctalk)
 		}
 		}
 	}
 	}
 	else {
 	else {
-		if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
+		if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
 			clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
 			clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
 			return -1;
 			return -1;
 		}
 		}
@@ -6601,7 +6607,7 @@ ACMD_FUNC(summon)
 
 
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
+	if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
 	{
 	{
 		clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
 		clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
 		return -1;
 		return -1;
@@ -6647,7 +6653,7 @@ ACMD_FUNC(adjgroup)
 	int new_group = 0;
 	int new_group = 0;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
+	if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
 		clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
 		clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
 		return -1;
 		return -1;
 	}
 	}
@@ -6792,7 +6798,7 @@ ACMD_FUNC(mute)
 	int manner;
 	int manner;
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
+	if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
 		clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
 		clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
 		return -1;
 		return -1;
 	}
 	}
@@ -6933,7 +6939,7 @@ ACMD_FUNC(misceffect)
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 	if (!message || !*message)
 	if (!message || !*message)
 		return -1;
 		return -1;
-	if (sscanf(message, "%d", &effect) < 1)
+	if (sscanf(message, "%11d", &effect) < 1)
 		return -1;
 		return -1;
 	clif_misceffect(&sd->bl,effect);
 	clif_misceffect(&sd->bl,effect);
 
 
@@ -7819,7 +7825,7 @@ ACMD_FUNC(sizeguild)
 
 
 	memset(guild, '\0', sizeof(guild));
 	memset(guild, '\0', sizeof(guild));
 
 
-	if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
+	if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
 		clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
 		clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
 		return -1;
 		return -1;
 	}
 	}
@@ -7924,7 +7930,7 @@ ACMD_FUNC(mapflag) {
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 	memset(flag_name, '\0', sizeof(flag_name));
 	memset(flag_name, '\0', sizeof(flag_name));
 
 
-	if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
+	if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
 		clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
 		clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
 		clif_displaymessage(sd->fd,"----------------------------------");
 		clif_displaymessage(sd->fd,"----------------------------------");
 		checkflag(town);				checkflag(autotrade);			checkflag(allowks);				checkflag(nomemo);
 		checkflag(town);				checkflag(autotrade);			checkflag(allowks);				checkflag(nomemo);
@@ -8109,7 +8115,7 @@ ACMD_FUNC(duel)
 	}
 	}
 
 
 	if( message[0] ) {
 	if( message[0] ) {
-		if(sscanf(message, "%u", &maxpl) >= 1) {
+		if(sscanf(message, "%11u", &maxpl) >= 1) {
 			if(maxpl < 2 || maxpl > 65535) {
 			if(maxpl < 2 || maxpl > 65535) {
 				clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
 				clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
 				return 0;
 				return 0;
@@ -8700,7 +8706,7 @@ ACMD_FUNC(delitem)
 
 
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
-	if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
+	if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
 	{
 	{
 		clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
 		clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
 		return -1;
 		return -1;
@@ -8906,7 +8912,7 @@ ACMD_FUNC(accinfo) {
 	char type = 0; // type = 1, get only account name
 	char type = 0; // type = 1, get only account name
 
 
 	if (!message || !*message || strlen(message) > NAME_LENGTH
 	if (!message || !*message || strlen(message) > NAME_LENGTH
-		|| ( sscanf(message, "%31s %c", query, &type) < 1))
+		|| ( sscanf(message, "%23s %c", query, &type) < 1))
 	{
 	{
 		clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
 		clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
 		clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
 		clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
@@ -9551,7 +9557,7 @@ ACMD_FUNC(cloneequip) {
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
-	if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
+	if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
 		clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
 		clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
 		return -1;
 		return -1;
 	}
 	}
@@ -9627,7 +9633,7 @@ ACMD_FUNC(clonestat) {
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 
 
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
-	if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
+	if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
 		clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
 		clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
 		return -1;
 		return -1;
 	}
 	}

+ 2 - 2
src/map/battle.c

@@ -2529,7 +2529,6 @@ static int battle_get_weapon_element(struct Damage wd, struct block_list *src, s
 	struct map_session_data *sd = BL_CAST(BL_PC, src);
 	struct map_session_data *sd = BL_CAST(BL_PC, src);
 	struct status_change *sc = status_get_sc(src);
 	struct status_change *sc = status_get_sc(src);
 	struct status_data *sstatus = status_get_status_data(src);
 	struct status_data *sstatus = status_get_status_data(src);
-	uint8 i;
 	int element = skill_get_ele(skill_id, skill_lv);
 	int element = skill_get_ele(skill_id, skill_lv);
 
 
 	//Take weapon's element
 	//Take weapon's element
@@ -2542,6 +2541,7 @@ static int battle_get_weapon_element(struct Damage wd, struct block_list *src, s
 			element = sd->bonus.arrow_ele;
 			element = sd->bonus.arrow_ele;
 		// on official endows override all other elements [helvetica]
 		// on official endows override all other elements [helvetica]
 		if (sd) { //Summoning 10 talisman will endow your weapon.
 		if (sd) { //Summoning 10 talisman will endow your weapon.
+			uint8 i;
 			ARR_FIND(1, 6, i, sd->talisman[i] >= 10);
 			ARR_FIND(1, 6, i, sd->talisman[i] >= 10);
 			if (i < 5)
 			if (i < 5)
 				element = i;
 				element = i;
@@ -3101,7 +3101,7 @@ static struct Damage battle_calc_multi_attack(struct Damage wd, struct block_lis
 			}
 			}
 		}
 		}
 		else if( ((sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0) //Normal Chain Action effect
 		else if( ((sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0) //Normal Chain Action effect
-			|| (sd && sc->count && sc->data[SC_E_CHAIN] && (skill_lv = sc->data[SC_E_CHAIN]->val2) > 0)) //Chain Action of ETERNAL_CHAIN
+			|| (sd && sc && sc->count && sc->data[SC_E_CHAIN] && (skill_lv = sc->data[SC_E_CHAIN]->val2) > 0)) //Chain Action of ETERNAL_CHAIN
 			&& rnd()%100 < 5*skill_lv ) //Success rate
 			&& rnd()%100 < 5*skill_lv ) //Success rate
 		{
 		{
 			wd.div_ = skill_get_num(GS_CHAINACTION,skill_lv);
 			wd.div_ = skill_get_num(GS_CHAINACTION,skill_lv);

+ 1 - 1
src/map/battleground.h

@@ -7,7 +7,7 @@
 #include "../common/mmo.h" // struct party
 #include "../common/mmo.h" // struct party
 #include "guild.h"
 #include "guild.h"
 
 
-#define MAX_BG_MEMBERS 30
+#define MAX_BG_MEMBERS 20
 
 
 struct battleground_member_data {
 struct battleground_member_data {
 	unsigned short x, y;
 	unsigned short x, y;

+ 1 - 1
src/map/channel.c

@@ -382,7 +382,7 @@ int channel_chk(char *chname, char *chpass, int type){
 			return -4;
 			return -4;
 		}
 		}
 	}
 	}
-	if (type&4 && (chpass != '\0' && strlen(chpass) > CHAN_NAME_LENGTH ) ) {
+	if (type&4 && (chpass[0] != '\0' && strlen(chpass) > CHAN_NAME_LENGTH ) ) {
 		return -3;
 		return -3;
 	}
 	}
 
 

+ 2 - 1
src/map/clif.c

@@ -8818,12 +8818,13 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m
 
 
 void clif_messagecolor2(struct map_session_data *sd, unsigned long color, const char* msg)
 void clif_messagecolor2(struct map_session_data *sd, unsigned long color, const char* msg)
 {
 {
-	int fd;
 	unsigned short msg_len = strlen(msg) + 1;
 	unsigned short msg_len = strlen(msg) + 1;
 
 
 	nullpo_retv(sd);
 	nullpo_retv(sd);
 
 
 	if(msg_len > 0) {
 	if(msg_len > 0) {
+		int fd;
+
 		color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR
 		color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR
 
 
 		fd = sd->fd;
 		fd = sd->fd;

+ 2 - 3
src/map/map.c

@@ -3490,14 +3490,13 @@ int parse_console(const char* buf){
 	char mapname[64];
 	char mapname[64];
 	int16 x = 0;
 	int16 x = 0;
 	int16 y = 0;
 	int16 y = 0;
-	int16 m;
 	int n;
 	int n;
 	struct map_session_data sd;
 	struct map_session_data sd;
 
 
 	memset(&sd, 0, sizeof(struct map_session_data));
 	memset(&sd, 0, sizeof(struct map_session_data));
 	strcpy(sd.status.name, "console");
 	strcpy(sd.status.name, "console");
 
 
-	if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %hd %hd[^\n]", type, command, mapname, &x, &y) ) < 5 ){
+	if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %6hd %6hd[^\n]", type, command, mapname, &x, &y) ) < 5 ){
 		if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 )		{
 		if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 )		{
 			if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
 			if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
 		}
 		}
@@ -3519,7 +3518,7 @@ int parse_console(const char* buf){
 
 
 	if(strcmpi("admin",type) == 0 ) {
 	if(strcmpi("admin",type) == 0 ) {
 		if(strcmpi("map",command) == 0){
 		if(strcmpi("map",command) == 0){
-			m = map_mapname2mapid(mapname);
+			int16 m = map_mapname2mapid(mapname);
 			if( m < 0 ){
 			if( m < 0 ){
 				ShowWarning("Console: Unknown map.\n");
 				ShowWarning("Console: Unknown map.\n");
 				return 0;
 				return 0;

+ 59 - 40
src/map/npc.c

@@ -502,7 +502,7 @@ int npc_timerevent_export(struct npc_data *nd, int i)
 	int t = 0, k = 0;
 	int t = 0, k = 0;
 	char *lname = nd->u.scr.label_list[i].name;
 	char *lname = nd->u.scr.label_list[i].name;
 	int pos = nd->u.scr.label_list[i].pos;
 	int pos = nd->u.scr.label_list[i].pos;
-	if (sscanf(lname, "OnTimer%d%n", &t, &k) == 1 && lname[k] == '\0') {
+	if (sscanf(lname, "OnTimer%11d%n", &t, &k) == 1 && lname[k] == '\0') {
 		// Timer event
 		// Timer event
 		struct npc_timerevent_list *te = nd->u.scr.timer_event;
 		struct npc_timerevent_list *te = nd->u.scr.timer_event;
 		int j, k2 = nd->u.scr.timeramount;
 		int j, k2 = nd->u.scr.timeramount;
@@ -2342,15 +2342,16 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
  */
  */
 static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 {
 {
-	int x, y, xs, ys, to_x, to_y, m;
+	int m;
+	short x, y, xs, ys, to_x, to_y;
 	unsigned short i;
 	unsigned short i;
-	char mapname[32], to_mapname[32];
+	char mapname[MAP_NAME_LENGTH_EXT], to_mapname[MAP_NAME_LENGTH_EXT];
 	struct npc_data *nd;
 	struct npc_data *nd;
 
 
 	// w1=<from map name>,<fromX>,<fromY>,<facing>
 	// w1=<from map name>,<fromX>,<fromY>,<facing>
 	// w4=<spanx>,<spany>,<to map name>,<toX>,<toY>
 	// w4=<spanx>,<spany>,<to map name>,<toX>,<toY>
-	if( sscanf(w1, "%31[^,],%d,%d", mapname, &x, &y) != 3
-	||	sscanf(w4, "%d,%d,%31[^,],%d,%d", &xs, &ys, to_mapname, &to_x, &to_y) != 5 )
+	if( sscanf(w1, "%15[^,],%6hd,%6hd", mapname, &x, &y) != 3
+	||	sscanf(w4, "%6hd,%6hd,%15[^,],%6hd,%6hd", &xs, &ys, to_mapname, &to_x, &to_y) != 5 )
 	{
 	{
 		ShowError("npc_parse_warp: Invalid warp definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		ShowError("npc_parse_warp: Invalid warp definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		return strchr(start,'\n');// skip and continue
 		return strchr(start,'\n');// skip and continue
@@ -2425,7 +2426,9 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
 static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 {
 {
 	char *p, point_str[32];
 	char *p, point_str[32];
-	int x, y, dir, m, is_discount = 0;
+	int m, is_discount = 0;
+	uint16 dir;
+	short x, y;
 	unsigned short nameid = 0;
 	unsigned short nameid = 0;
 	struct npc_data *nd;
 	struct npc_data *nd;
 	enum npc_subtype type;
 	enum npc_subtype type;
@@ -2437,8 +2440,8 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 	}
 	}
 	else
 	else
 	{// w1=<map name>,<x>,<y>,<facing>
 	{// w1=<map name>,<x>,<y>,<facing>
-		char mapname[32];
-		if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4
+		char mapname[MAP_NAME_LENGTH_EXT];
+		if( sscanf(w1, "%15[^,],%6hd,%6hd,%4hd", mapname, &x, &y, &dir) != 4
 		||	strchr(w4, ',') == NULL )
 		||	strchr(w4, ',') == NULL )
 		{
 		{
 			ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
@@ -2468,7 +2471,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 
 
 	switch(type) {
 	switch(type) {
 		case NPCTYPE_ITEMSHOP: {
 		case NPCTYPE_ITEMSHOP: {
-			if (sscanf(p,",%hu:%d,",&nameid,&is_discount) < 1) {
+			if (sscanf(p,",%5hu:%11d,",&nameid,&is_discount) < 1) {
 				ShowError("npc_parse_shop: Invalid item cost definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 				ShowError("npc_parse_shop: Invalid item cost definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 				return strchr(start,'\n'); // skip and continue
 				return strchr(start,'\n'); // skip and continue
 			}
 			}
@@ -2480,7 +2483,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 			break;
 			break;
 		}
 		}
 		case NPCTYPE_POINTSHOP: {
 		case NPCTYPE_POINTSHOP: {
-			if (sscanf(p, ",%32[^,:]:%d,",point_str,&is_discount) < 1) {
+			if (sscanf(p, ",%32[^,:]:%11d,",point_str,&is_discount) < 1) {
 				ShowError("npc_parse_shop: Invalid item cost definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 				ShowError("npc_parse_shop: Invalid item cost definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 				return strchr(start,'\n'); // skip and continue
 				return strchr(start,'\n'); // skip and continue
 			}
 			}
@@ -2526,14 +2529,14 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 		switch(type) {
 		switch(type) {
 			case NPCTYPE_MARKETSHOP:
 			case NPCTYPE_MARKETSHOP:
 #if PACKETVER >= 20131223
 #if PACKETVER >= 20131223
-				if (sscanf(p, ",%hu:%d:%hu", &nameid2, &value, &qty) != 3) {
+				if (sscanf(p, ",%6hu:%11d:%6hu", &nameid2, &value, &qty) != 3) {
 					ShowError("npc_parse_shop: (MARKETSHOP) Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4);
 					ShowError("npc_parse_shop: (MARKETSHOP) Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4);
 					skip = true;
 					skip = true;
 				}
 				}
 #endif
 #endif
 				break;
 				break;
 			default:
 			default:
-				if (sscanf(p, ",%hu:%d", &nameid2, &value) != 2) {
+				if (sscanf(p, ",%6hu:%11d", &nameid2, &value) != 2) {
 					ShowError("npc_parse_shop: Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4);
 					ShowError("npc_parse_shop: Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4);
 					skip = true;
 					skip = true;
 				}
 				}
@@ -2782,7 +2785,8 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
  * @return new index for next parsing
  * @return new index for next parsing
  */
  */
 static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) {
 static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) {
-	int x, y, dir = 0, m, xs = 0, ys = 0;	// [Valaris] thanks to fov
+	int16 dir = 0;
+	short m, x, y, xs = 0, ys = 0; // [Valaris] thanks to fov
 	struct script_code *script;
 	struct script_code *script;
 	int i;
 	int i;
 	const char* end;
 	const char* end;
@@ -2800,9 +2804,9 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
 	}
 	}
 	else
 	else
 	{// npc in a map
 	{// npc in a map
-		char mapname[32];
+		char mapname[MAP_NAME_LENGTH_EXT];
 
 
-		if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 )
+		if( sscanf(w1, "%15[^,],%6hd,%6hd,%4hd", mapname, &x, &y, &dir) != 4 )
 		{
 		{
 			ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			return NULL;// unknown format, don't continue
 			return NULL;// unknown format, don't continue
@@ -2835,7 +2839,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
 
 
 	CREATE(nd, struct npc_data, 1);
 	CREATE(nd, struct npc_data, 1);
 
 
-	if( sscanf(w4, "%*[^,],%d,%d", &xs, &ys) == 2 )
+	if( sscanf(w4, "%*[^,],%6hd,%6hd", &xs, &ys) == 2 )
 	{// OnTouch area defined
 	{// OnTouch area defined
 		nd->u.scr.xs = xs;
 		nd->u.scr.xs = xs;
 		nd->u.scr.ys = ys;
 		nd->u.scr.ys = ys;
@@ -2922,7 +2926,8 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
 /// npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
 /// npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
 const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 {
 {
-	int x, y, dir, m, xs = -1, ys = -1;
+	short x, y, m, xs = -1, ys = -1;
+	int16 dir;
 	char srcname[128];
 	char srcname[128];
 	int i;
 	int i;
 	const char* end;
 	const char* end;
@@ -2957,9 +2962,9 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
 		x = y = dir = 0;
 		x = y = dir = 0;
 		m = -1;
 		m = -1;
 	} else {
 	} else {
-		char mapname[32];
+		char mapname[MAP_NAME_LENGTH_EXT];
 
 
-		if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ) { // <map name>,<x>,<y>,<facing>
+		if( sscanf(w1, "%15[^,],%6hd,%6hd,%4hd", mapname, &x, &y, &dir) != 4 ) { // <map name>,<x>,<y>,<facing>
 			ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			return end;// next line, try to continue
 			return end;// next line, try to continue
 		}
 		}
@@ -2970,8 +2975,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
 		ShowError("npc_parse_duplicate: coordinates %d/%d are out of bounds in map %s(%dx%d), in file '%s', line '%d'\n", x, y, map[m].name, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
 		ShowError("npc_parse_duplicate: coordinates %d/%d are out of bounds in map %s(%dx%d), in file '%s', line '%d'\n", x, y, map[m].name, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
 	}
 	}
 
 
-	if( type == NPCTYPE_WARP && sscanf(w4, "%d,%d", &xs, &ys) == 2 );// <spanx>,<spany>
-	else if( type == NPCTYPE_SCRIPT && sscanf(w4, "%*[^,],%d,%d", &xs, &ys) == 2);// <sprite id>,<triggerX>,<triggerY>
+	if( type == NPCTYPE_WARP && sscanf(w4, "%6hd,%6hd", &xs, &ys) == 2 );// <spanx>,<spany>
+	else if( type == NPCTYPE_SCRIPT && sscanf(w4, "%*[^,],%6hd,%6hd", &xs, &ys) == 2);// <sprite id>,<triggerX>,<triggerY>
 	else if( type == NPCTYPE_WARP ) {
 	else if( type == NPCTYPE_WARP ) {
 		ShowError("npc_parse_duplicate: Invalid span format for duplicate warp in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		ShowError("npc_parse_duplicate: Invalid span format for duplicate warp in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		return end;// next line, try to continue
 		return end;// next line, try to continue
@@ -3568,9 +3573,9 @@ void npc_parse_mob2(struct spawn_data* mob)
 
 
 static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
 {
 {
-	int num, class_, m,x,y,xs,ys, i,j;
-	int mob_lv = -1, ai = -1, size = -1;
-	char mapname[32], mobname[NAME_LENGTH];
+	int num, class_, i, j, mob_lv = -1, ai = -1, size = -1;
+	short m,x,y,xs,ys;
+	char mapname[MAP_NAME_LENGTH_EXT], mobname[NAME_LENGTH];
 	struct spawn_data mob, *data;
 	struct spawn_data mob, *data;
 	struct mob_db* db;
 	struct mob_db* db;
 
 
@@ -3581,9 +3586,9 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
 	// w1=<map name>,<x>,<y>,<xs>,<ys>
 	// w1=<map name>,<x>,<y>,<xs>,<ys>
 	// w3=<mob name>{,<mob level>}
 	// w3=<mob name>{,<mob level>}
 	// w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}
 	// w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}
-	if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3
-	||	sscanf(w3, "%23[^,],%d", mobname, &mob_lv) < 1
-	||	sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mob.delay1, &mob.delay2, mob.eventname, &size, &ai) < 2 )
+	if( sscanf(w1, "%15[^,],%6hd,%6hd,%6hd,%6hd", mapname, &x, &y, &xs, &ys) < 3
+	||	sscanf(w3, "%23[^,],%11d", mobname, &mob_lv) < 1
+	||	sscanf(w4, "%11d,%11d,%11u,%11u,%127[^,],%11d,%11d[^\t\r\n]", &class_, &num, &mob.delay1, &mob.delay2, mob.eventname, &size, &ai) < 2 )
 	{
 	{
 		ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 		return strchr(start,'\n');// skip and continue
 		return strchr(start,'\n');// skip and continue
@@ -3764,15 +3769,15 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 		state = 0;	//Disable mapflag rather than enable it. [Skotlex]
 		state = 0;	//Disable mapflag rather than enable it. [Skotlex]
 
 
 	if (!strcmpi(w3, "nosave")) {
 	if (!strcmpi(w3, "nosave")) {
-		char savemap[32];
-		int savex, savey;
+		char savemap[MAP_NAME_LENGTH_EXT];
+		short savex, savey;
 		if (state == 0)
 		if (state == 0)
 			; //Map flag disabled.
 			; //Map flag disabled.
 		else if (!strcmpi(w4, "SavePoint")) {
 		else if (!strcmpi(w4, "SavePoint")) {
 			map[m].save.map = 0;
 			map[m].save.map = 0;
 			map[m].save.x = -1;
 			map[m].save.x = -1;
 			map[m].save.y = -1;
 			map[m].save.y = -1;
-		} else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) {
+		} else if (sscanf(w4, "%15[^,],%6hd,%6hd", savemap, &savex, &savey) == 3) {
 			map[m].save.map = mapindex_name2id(savemap);
 			map[m].save.map = mapindex_name2id(savemap);
 			map[m].save.x = savex;
 			map[m].save.x = savex;
 			map[m].save.y = savey;
 			map[m].save.y = savey;
@@ -3828,7 +3833,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 	else if (!strcmpi(w3, "pvp_nightmaredrop")) {
 	else if (!strcmpi(w3, "pvp_nightmaredrop")) {
 		char drop_arg1[16], drop_arg2[16];
 		char drop_arg1[16], drop_arg2[16];
 		int drop_per = 0;
 		int drop_per = 0;
-		if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
+		if (sscanf(w4, "%15[^,],%15[^,],%11d", drop_arg1, drop_arg2, &drop_per) == 3) {
 			int drop_id = 0, drop_type = 0;
 			int drop_id = 0, drop_type = 0;
 			if (!strcmpi(drop_arg1, "random"))
 			if (!strcmpi(drop_arg1, "random"))
 				drop_id = -1;
 				drop_id = -1;
@@ -3881,7 +3886,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 	}
 	}
 	else if (!strcmpi(w3,"battleground")) {
 	else if (!strcmpi(w3,"battleground")) {
 		if( state ) {
 		if( state ) {
-			if( sscanf(w4, "%d", &state) == 1 )
+			if( sscanf(w4, "%11d", &state) == 1 )
 				map[m].flag.battleground = state;
 				map[m].flag.battleground = state;
 			else
 			else
 				map[m].flag.battleground = 1; // Default value
 				map[m].flag.battleground = 1; // Default value
@@ -3949,7 +3954,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 		map[m].flag.nomvploot=state;
 		map[m].flag.nomvploot=state;
 	else if (!strcmpi(w3,"nocommand")) {
 	else if (!strcmpi(w3,"nocommand")) {
 		if (state) {
 		if (state) {
-			if (sscanf(w4, "%d", &state) == 1)
+			if (sscanf(w4, "%11d", &state) == 1)
 				map[m].nocommand =state;
 				map[m].nocommand =state;
 			else //No level specified, block everyone.
 			else //No level specified, block everyone.
 				map[m].nocommand =100;
 				map[m].nocommand =100;
@@ -3958,9 +3963,14 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 	}
 	}
 	else if (!strcmpi(w3,"restricted")) {
 	else if (!strcmpi(w3,"restricted")) {
 		if (state) {
 		if (state) {
-			map[m].flag.restricted=1;
-			sscanf(w4, "%d", &state);
-			map[m].zone |= 1<<(state+1);
+			if (sscanf(w4, "%11d", &state) == 1) {
+				map[m].flag.restricted = 1;
+				map[m].zone |= 1<<(state+1);
+			} else { // Could not be read, no value defined
+				map[m].flag.restricted = 0;
+				map[m].zone = 0;
+				ShowWarning("npc_parse_mapflag: You did not set a zone value for the restricted mapflag! Removing flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer));
+			}
 		} else {
 		} else {
 			map[m].flag.restricted=0;
 			map[m].flag.restricted=0;
 			map[m].zone = 0;
 			map[m].zone = 0;
@@ -4014,7 +4024,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 				map_skill_damage_free(&map[m]);
 				map_skill_damage_free(&map[m]);
 		}
 		}
 		else {
 		else {
-			if (sscanf(w4, "%30[^,],%d,%d,%d,%d,%d[^\n]", skill, &caster, &pc, &mob, &boss, &other) >= 3) {
+			if (sscanf(w4, "%30[^,],%11d,%11d,%11d,%11d,%11d[^\n]", skill, &caster, &pc, &mob, &boss, &other) >= 3) {
 				caster = (!caster) ? SDC_ALL : caster;
 				caster = (!caster) ? SDC_ALL : caster;
 				pc = cap_value(pc, -100, INT_MAX);
 				pc = cap_value(pc, -100, INT_MAX);
 				mob = cap_value(mob, -100, INT_MAX);
 				mob = cap_value(mob, -100, INT_MAX);
@@ -4150,9 +4160,17 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit)
 
 
 		if( strcmp(w1,"-") !=0 && strcasecmp(w1,"function") != 0 )
 		if( strcmp(w1,"-") !=0 && strcasecmp(w1,"function") != 0 )
 		{// w1 = <map name>,<x>,<y>,<facing>
 		{// w1 = <map name>,<x>,<y>,<facing>
-			char mapname[MAP_NAME_LENGTH*2];
+			char mapname[MAP_NAME_LENGTH*2]; // TODO: Check why this does not use MAP_NAME_LENGTH_EXT
 			x = y = 0;
 			x = y = 0;
-			sscanf(w1,"%23[^,],%hd,%hd[^,]",mapname,&x,&y);
+			if (sscanf(w1,"%23[^,],%6hd,%6hd[^,]",mapname,&x,&y) != 3) {
+				ShowError("npc_parsesrcfile: Invalid script definition in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
+				if (strcasecmp(w2,"script") == 0 && count > 3) {
+					if ((p = npc_skip_script(p,buffer,filepath)) == NULL)
+						break;
+				}
+				p = strchr(p,'\n');// next line
+				continue;
+			}
 			if( !mapindex_name2id(mapname) )
 			if( !mapindex_name2id(mapname) )
 			{// Incorrect map, we must skip the script info...
 			{// Incorrect map, we must skip the script info...
 				ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer));
 				ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer));
@@ -4307,7 +4325,6 @@ void npc_clear_pathlist(void) {
 //Clear then reload npcs files
 //Clear then reload npcs files
 int npc_reload(void) {
 int npc_reload(void) {
 	struct npc_src_list *nsl;
 	struct npc_src_list *nsl;
-	int16 m, i;
 	int npc_new_min = npc_id;
 	int npc_new_min = npc_id;
 	struct s_mapiterator* iter;
 	struct s_mapiterator* iter;
 	struct block_list* bl;
 	struct block_list* bl;
@@ -4344,7 +4361,9 @@ int npc_reload(void) {
 
 
 	if(battle_config.dynamic_mobs)
 	if(battle_config.dynamic_mobs)
 	{// dynamic check by [random]
 	{// dynamic check by [random]
+		int16 m;
 		for (m = 0; m < map_num; m++) {
 		for (m = 0; m < map_num; m++) {
+			int16 i;
 			for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) {
 			for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) {
 				if (map[m].moblist[i] != NULL) {
 				if (map[m].moblist[i] != NULL) {
 					aFree(map[m].moblist[i]);
 					aFree(map[m].moblist[i]);

+ 7 - 0
src/map/party.c

@@ -774,7 +774,14 @@ int party_changeleader(struct map_session_data *sd, struct map_session_data *tsd
 			return 0; // Shouldn't happen
 			return 0; // Shouldn't happen
 	} else {
 	} else {
 		ARR_FIND(0,MAX_PARTY,mi,p->party.member[mi].leader);
 		ARR_FIND(0,MAX_PARTY,mi,p->party.member[mi].leader);
+
+		if (mi == MAX_PARTY)
+			return 0; // Shouldn't happen
+
 		ARR_FIND(0,MAX_PARTY,tmi,p->data[tmi].sd ==  tsd);
 		ARR_FIND(0,MAX_PARTY,tmi,p->data[tmi].sd ==  tsd);
+
+		if (tmi == MAX_PARTY)
+			return 0; // Shouldn't happen
 	}
 	}
 
 
 	// Change leadership.
 	// Change leadership.

+ 2 - 3
src/map/pc.c

@@ -1945,9 +1945,8 @@ int pc_disguise(struct map_session_data *sd, int class_)
 		}
 		}
 		if (sd->chatID) {
 		if (sd->chatID) {
 			struct chat_data* cd;
 			struct chat_data* cd;
-			nullpo_retr(1, sd);
-			cd = (struct chat_data*)map_id2bl(sd->chatID);
-			if( cd != NULL || (struct block_list*)sd == cd->owner )
+
+			if (cd = (struct chat_data*)map_id2bl(sd->chatID))
 				clif_dispchat(cd,0);
 				clif_dispchat(cd,0);
 		}
 		}
 	}
 	}

+ 12 - 15
src/map/script.c

@@ -2343,8 +2343,8 @@ static void read_constdb(void)
 			continue;
 			continue;
 		
 		
 		type=0;
 		type=0;
-		if(sscanf(line,"%1023[A-Za-z0-9/_],%1023[A-Za-z0-9/_-],%d",name,val,&type)>=2 ||
-		   sscanf(line,"%1023[A-Za-z0-9/_] %1023[A-Za-z0-9/_-] %d",name,val,&type)>=2){
+		if(sscanf(line,"%1023[A-Za-z0-9/_],%1023[A-Za-z0-9/_-],%11d",name,val,&type)>=2 ||
+		   sscanf(line,"%1023[A-Za-z0-9/_] %1023[A-Za-z0-9/_-] %11d",name,val,&type)>=2){
 			entries++;
 			entries++;
 			script_set_constant(name, (int)strtol(val, NULL, 0), (bool)type);
 			script_set_constant(name, (int)strtol(val, NULL, 0), (bool)type);
 		}
 		}
@@ -15571,7 +15571,7 @@ BUILDIN_FUNC(setd)
 	int elem;
 	int elem;
 	buffer = script_getstr(st, 2);
 	buffer = script_getstr(st, 2);
 
 
-	if(sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
+	if(sscanf(buffer, "%99[^[][%11d]", varname, &elem) < 2)
 		elem = 0;
 		elem = 0;
 
 
 	if( not_server_variable(*varname) ) {
 	if( not_server_variable(*varname) ) {
@@ -15733,7 +15733,7 @@ BUILDIN_FUNC(getd)
 
 
 	buffer = script_getstr(st, 2);
 	buffer = script_getstr(st, 2);
 
 
-	if(sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
+	if(sscanf(buffer, "%99[^[][%11d]", varname, &elem) < 2)
 		elem = 0;
 		elem = 0;
 
 
 	// Push the 'pointer' so it's more flexible [Lance]
 	// Push the 'pointer' so it's more flexible [Lance]
@@ -17902,7 +17902,7 @@ BUILDIN_FUNC(waitingroom2bg)
 	struct npc_data *nd;
 	struct npc_data *nd;
 	struct chat_data *cd;
 	struct chat_data *cd;
 	const char *map_name, *ev = "", *dev = "";
 	const char *map_name, *ev = "", *dev = "";
-	int x, y, mapindex = 0, bg_id, n;
+	int x, y, mapindex = 0, bg_id;
 	unsigned char i;
 	unsigned char i;
 
 
 	if( script_hasdata(st,7) )
 	if( script_hasdata(st,7) )
@@ -17938,9 +17938,7 @@ BUILDIN_FUNC(waitingroom2bg)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	n = cd->users;
-	for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ )
-	{
+	for (i = 0; i < cd->users; i++) { // Only add those who are in the chat room
 		struct map_session_data *sd;
 		struct map_session_data *sd;
 		if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) )
 		if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) )
 			mapreg_setreg(reference_uid(add_str("$@arenamembers"), i), sd->bl.id);
 			mapreg_setreg(reference_uid(add_str("$@arenamembers"), i), sd->bl.id);
@@ -19129,7 +19127,6 @@ BUILDIN_FUNC(cleanmap)
 {
 {
 	const char *mapname;
 	const char *mapname;
 	int16 m;
 	int16 m;
-	int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
 
 
 	mapname = script_getstr(st, 2);
 	mapname = script_getstr(st, 2);
 	m = map_mapname2mapid(mapname);
 	m = map_mapname2mapid(mapname);
@@ -19139,10 +19136,10 @@ BUILDIN_FUNC(cleanmap)
 	if ((script_lastdata(st) - 2) < 4) {
 	if ((script_lastdata(st) - 2) < 4) {
 		map_foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM);
 		map_foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM);
 	} else {
 	} else {
-		x0 = script_getnum(st, 3);
-		y0 = script_getnum(st, 4);
-		x1 = script_getnum(st, 5);
-		y1 = script_getnum(st, 6);
+		int16 x0 = script_getnum(st, 3);
+		int16 y0 = script_getnum(st, 4);
+		int16 x1 = script_getnum(st, 5);
+		int16 y1 = script_getnum(st, 6);
 		if (x0 > 0 && y0 > 0 && x1 > 0 && y1 > 0) {
 		if (x0 > 0 && y0 > 0 && x1 > 0 && y1 > 0) {
 			map_foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM);
 			map_foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM);
 		} else {
 		} else {
@@ -19975,11 +19972,11 @@ BUILDIN_FUNC(mergeitem) {
 
 
 	if (script_hasdata(st, 2)) {
 	if (script_hasdata(st, 2)) {
 		struct script_data *data = script_getdata(st, 2);
 		struct script_data *data = script_getdata(st, 2);
-		struct item_data *id;
 		get_val(st, data);
 		get_val(st, data);
 
 
 		if (data_isstring(data)) {// "<item name>"
 		if (data_isstring(data)) {// "<item name>"
 			const char *name = conv_str(st,data);
 			const char *name = conv_str(st,data);
+			struct item_data *id;
 			if (!(id = itemdb_searchname(name))) {
 			if (!(id = itemdb_searchname(name))) {
 				ShowError("buildin_mergeitem: Nonexistant item %s requested.\n", name);
 				ShowError("buildin_mergeitem: Nonexistant item %s requested.\n", name);
 				script_pushint(st, count);
 				script_pushint(st, count);
@@ -19989,7 +19986,7 @@ BUILDIN_FUNC(mergeitem) {
 		}
 		}
 		else if (data_isint(data)) {// <item id>
 		else if (data_isint(data)) {// <item id>
 			nameid = conv_num(st,data);
 			nameid = conv_num(st,data);
-			if (!(id = itemdb_exists(nameid))) {
+			if (!itemdb_exists(nameid)) {
 				ShowError("buildin_mergeitem: Nonexistant item %d requested.\n", nameid);
 				ShowError("buildin_mergeitem: Nonexistant item %d requested.\n", nameid);
 				script_pushint(st, count);
 				script_pushint(st, count);
 				return SCRIPT_CMD_FAILURE;
 				return SCRIPT_CMD_FAILURE;

+ 1 - 3
src/map/skill.c

@@ -20322,9 +20322,7 @@ static bool skill_parse_row_createarrowdb(char* split[], int columns, int curren
  */
  */
 static bool skill_parse_row_spellbookdb(char* split[], int columns, int current)
 static bool skill_parse_row_spellbookdb(char* split[], int columns, int current)
 {
 {
-	unsigned short skill_id = atoi(split[0]),
-		points = atoi(split[1]),
-		nameid = atoi(split[2]);
+	unsigned short skill_id = atoi(split[0]), points = atoi(split[1]), nameid = atoi(split[2]);
 
 
 	if (!skill_get_index(skill_id) || !skill_get_max(skill_id))
 	if (!skill_get_index(skill_id) || !skill_get_max(skill_id))
 		ShowError("skill_parse_row_spellbookdb: Invalid skill ID %d\n", skill_id);
 		ShowError("skill_parse_row_spellbookdb: Invalid skill ID %d\n", skill_id);

+ 1 - 1
src/map/status.c

@@ -13115,7 +13115,7 @@ static bool status_readdb_attrfix(const char *basedir,bool silent)
 				continue;
 				continue;
 
 
 			for (j = 0, p = line; j < ELE_ALL && p; j++) {
 			for (j = 0, p = line; j < ELE_ALL && p; j++) {
-				while (*p > 0 && *p == 32) //skipping newline and space (32=' ')
+				while (*p == 32) //skipping space (32=' ')
 					p++;
 					p++;
 				attr_fix_table[lv-1][i][j] = atoi(p);
 				attr_fix_table[lv-1][i][j] = atoi(p);
 				if (battle_config.attr_recover == 0 && attr_fix_table[lv-1][i][j] < 0)
 				if (battle_config.attr_recover == 0 && attr_fix_table[lv-1][i][j] < 0)