Ver Fonte

> Hercules merges:
* 7e72f0c, 3bba651:
Improvements all over the place.

* 327a46d:
Arrullo no longer crashes the server when used by monsters.

* 1093763:
Fixed official behiavior of WZ_SIGHTBLASTER dealing with HW_MAGICPOWER.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17139 54d463be-8e91-2dee-dedb-b68131a5f0ec

euphyy há 12 anos atrás
pai
commit
058a7b4f4e

+ 74 - 82
npc/warps/pvp.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= Athena (any)
 //===== Current Version: =====================================
-//= 1.3
+//= 1.4
 //===== Compatible With: =====================================
 //= Any Athena Version
 //===== Description: =========================================
@@ -13,6 +13,7 @@
 //= 1.1 Fixed Prontera Arena warp [Yor]
 //= 1.2 Added addition warps for PvP Nightmare Mode maps.
 //= 1.3 Fixed duplicate warp names [Timexy]
+//= 1.4 Disabled ordeal_*-3 and ordeal_*-4 maps.
 //============================================================
 
 //Battle Ordeal Mode
@@ -40,30 +41,30 @@ ordeal_1-2,153,180,0	warp	ord12-5	1,1,ordeal_1-2,144,284
 ordeal_1-2,172,135,0	warp	ord12-6	1,1,ordeal_1-2,284,24
 ordeal_1-2,172,172,0	warp	ord12-7	1,1,ordeal_1-2,284,284
 ordeal_1-2,180,154,0	warp	ord12-8	1,1,ordeal_1-2,284,164
-ordeal_1-3,100,150,0	warp	ord13-1	1,1,ordeal_1-3,128,150
-ordeal_1-3,114,183,0	warp	ord13-2	1,1,ordeal_1-3,135,163
-ordeal_1-3,115,115,0	warp	ord13-3	1,1,ordeal_1-3,136,136
-ordeal_1-3,123,150,0	warp	ord13-4	1,1,ordeal_1-3,95,150
-ordeal_1-3,130,168,0	warp	ord13-5	1,1,ordeal_1-3,109,188
-ordeal_1-3,131,131,0	warp	ord13-6	1,1,ordeal_1-3,110,110
-ordeal_1-3,148,176,0	warp	ord13-7	1,1,ordeal_1-3,149,204
-ordeal_1-3,149,99,0	warp	ord13-8	1,1,ordeal_1-3,151,129
-ordeal_1-3,149,199,0	warp	ord13-9	1,1,ordeal_1-3,148,171
-ordeal_1-3,151,124,0	warp	ord13-10	1,1,ordeal_1-3,151,94
-ordeal_1-3,168,168,0	warp	ord13-11	1,1,ordeal_1-3,189,189
-ordeal_1-3,169,131,0	warp	ord13-12	1,1,ordeal_1-3,188,111
-ordeal_1-3,176,150,0	warp	ord13-13	1,1,ordeal_1-3,204,150
-ordeal_1-3,183,116,0	warp	ord13-14	1,1,ordeal_1-3,164,136
-ordeal_1-3,184,184,0	warp	ord13-15	1,1,ordeal_1-3,163,163
-ordeal_1-3,199,150,0	warp	ord13-16	1,1,ordeal_1-3,171,150
-ordeal_1-4,128,154,0	warp	ord14-1	1,1,ordeal_1-4,24,154
-ordeal_1-4,136,136,0	warp	ord14-2	1,1,ordeal_1-4,24,24
-ordeal_1-4,136,172,0	warp	ord14-3	1,1,ordeal_1-4,24,284
-ordeal_1-4,153,128,0	warp	ord14-4	1,1,ordeal_1-4,153,23
-ordeal_1-4,153,180,0	warp	ord14-5	1,1,ordeal_1-4,144,284
-ordeal_1-4,172,135,0	warp	ord14-6	1,1,ordeal_1-4,284,24
-ordeal_1-4,172,172,0	warp	ord14-7	1,1,ordeal_1-4,284,284
-ordeal_1-4,180,154,0	warp	ord14-8	1,1,ordeal_1-4,284,164
+//ordeal_1-3,100,150,0	warp	ord13-1	1,1,ordeal_1-3,128,150
+//ordeal_1-3,114,183,0	warp	ord13-2	1,1,ordeal_1-3,135,163
+//ordeal_1-3,115,115,0	warp	ord13-3	1,1,ordeal_1-3,136,136
+//ordeal_1-3,123,150,0	warp	ord13-4	1,1,ordeal_1-3,95,150
+//ordeal_1-3,130,168,0	warp	ord13-5	1,1,ordeal_1-3,109,188
+//ordeal_1-3,131,131,0	warp	ord13-6	1,1,ordeal_1-3,110,110
+//ordeal_1-3,148,176,0	warp	ord13-7	1,1,ordeal_1-3,149,204
+//ordeal_1-3,149,99,0	warp	ord13-8	1,1,ordeal_1-3,151,129
+//ordeal_1-3,149,199,0	warp	ord13-9	1,1,ordeal_1-3,148,171
+//ordeal_1-3,151,124,0	warp	ord13-10	1,1,ordeal_1-3,151,94
+//ordeal_1-3,168,168,0	warp	ord13-11	1,1,ordeal_1-3,189,189
+//ordeal_1-3,169,131,0	warp	ord13-12	1,1,ordeal_1-3,188,111
+//ordeal_1-3,176,150,0	warp	ord13-13	1,1,ordeal_1-3,204,150
+//ordeal_1-3,183,116,0	warp	ord13-14	1,1,ordeal_1-3,164,136
+//ordeal_1-3,184,184,0	warp	ord13-15	1,1,ordeal_1-3,163,163
+//ordeal_1-3,199,150,0	warp	ord13-16	1,1,ordeal_1-3,171,150
+//ordeal_1-4,128,154,0	warp	ord14-1	1,1,ordeal_1-4,24,154
+//ordeal_1-4,136,136,0	warp	ord14-2	1,1,ordeal_1-4,24,24
+//ordeal_1-4,136,172,0	warp	ord14-3	1,1,ordeal_1-4,24,284
+//ordeal_1-4,153,128,0	warp	ord14-4	1,1,ordeal_1-4,153,23
+//ordeal_1-4,153,180,0	warp	ord14-5	1,1,ordeal_1-4,144,284
+//ordeal_1-4,172,135,0	warp	ord14-6	1,1,ordeal_1-4,284,24
+//ordeal_1-4,172,172,0	warp	ord14-7	1,1,ordeal_1-4,284,284
+//ordeal_1-4,180,154,0	warp	ord14-8	1,1,ordeal_1-4,284,164
 ordeal_2-1,100,150,0	warp	ord21-1	1,1,ordeal_2-1,128,150
 ordeal_2-1,123,150,0	warp	ord21-2	1,1,ordeal_2-1,95,150
 ordeal_2-1,114,183,0	warp	ord21-3	1,1,ordeal_2-1,135,163
@@ -88,30 +89,30 @@ ordeal_2-2,153,180,0	warp	ord22-5	1,1,ordeal_2-2,144,284
 ordeal_2-2,172,135,0	warp	ord22-6	1,1,ordeal_2-2,284,24
 ordeal_2-2,172,172,0	warp	ord22-7	1,1,ordeal_2-2,284,284
 ordeal_2-2,180,154,0	warp	ord22-8	1,1,ordeal_2-2,284,164
-ordeal_2-3,100,150,0	warp	ord23-1	1,1,ordeal_2-3,128,150
-ordeal_2-3,114,183,0	warp	ord23-2	1,1,ordeal_2-3,135,163
-ordeal_2-3,115,115,0	warp	ord23-3	1,1,ordeal_2-3,136,136
-ordeal_2-3,123,150,0	warp	ord23-4	1,1,ordeal_2-3,95,150
-ordeal_2-3,130,168,0	warp	ord23-5	1,1,ordeal_2-3,109,188
-ordeal_2-3,131,131,0	warp	ord23-6	1,1,ordeal_2-3,110,110
-ordeal_2-3,148,176,0	warp	ord23-7	1,1,ordeal_2-3,149,204
-ordeal_2-3,149,99,0	warp	ord23-8	1,1,ordeal_2-3,151,129
-ordeal_2-3,149,199,0	warp	ord23-9	1,1,ordeal_2-3,148,171
-ordeal_2-3,151,124,0	warp	ord23-10	1,1,ordeal_2-3,151,94
-ordeal_2-3,168,168,0	warp	ord23-11	1,1,ordeal_2-3,189,189
-ordeal_2-3,169,131,0	warp	ord23-12	1,1,ordeal_2-3,188,111
-ordeal_2-3,176,150,0	warp	ord23-13	1,1,ordeal_2-3,204,150
-ordeal_2-3,183,116,0	warp	ord23-14	1,1,ordeal_2-3,164,136
-ordeal_2-3,184,184,0	warp	ord23-15	1,1,ordeal_2-3,163,163
-ordeal_2-3,199,150,0	warp	ord23-16	1,1,ordeal_2-3,171,150
-ordeal_2-4,128,154,0	warp	ord24-1	1,1,ordeal_2-4,24,154
-ordeal_2-4,136,136,0	warp	ord24-2	1,1,ordeal_2-4,24,24
-ordeal_2-4,136,172,0	warp	ord24-3	1,1,ordeal_2-4,24,284
-ordeal_2-4,153,128,0	warp	ord24-4	1,1,ordeal_2-4,153,23
-ordeal_2-4,153,180,0	warp	ord24-5	1,1,ordeal_2-4,144,284
-ordeal_2-4,172,135,0	warp	ord24-6	1,1,ordeal_2-4,284,24
-ordeal_2-4,172,172,0	warp	ord24-7	1,1,ordeal_2-4,284,284
-ordeal_2-4,180,154,0	warp	ord24-8	1,1,ordeal_2-4,284,164
+//ordeal_2-3,100,150,0	warp	ord23-1	1,1,ordeal_2-3,128,150
+//ordeal_2-3,114,183,0	warp	ord23-2	1,1,ordeal_2-3,135,163
+//ordeal_2-3,115,115,0	warp	ord23-3	1,1,ordeal_2-3,136,136
+//ordeal_2-3,123,150,0	warp	ord23-4	1,1,ordeal_2-3,95,150
+//ordeal_2-3,130,168,0	warp	ord23-5	1,1,ordeal_2-3,109,188
+//ordeal_2-3,131,131,0	warp	ord23-6	1,1,ordeal_2-3,110,110
+//ordeal_2-3,148,176,0	warp	ord23-7	1,1,ordeal_2-3,149,204
+//ordeal_2-3,149,99,0	warp	ord23-8	1,1,ordeal_2-3,151,129
+//ordeal_2-3,149,199,0	warp	ord23-9	1,1,ordeal_2-3,148,171
+//ordeal_2-3,151,124,0	warp	ord23-10	1,1,ordeal_2-3,151,94
+//ordeal_2-3,168,168,0	warp	ord23-11	1,1,ordeal_2-3,189,189
+//ordeal_2-3,169,131,0	warp	ord23-12	1,1,ordeal_2-3,188,111
+//ordeal_2-3,176,150,0	warp	ord23-13	1,1,ordeal_2-3,204,150
+//ordeal_2-3,183,116,0	warp	ord23-14	1,1,ordeal_2-3,164,136
+//ordeal_2-3,184,184,0	warp	ord23-15	1,1,ordeal_2-3,163,163
+//ordeal_2-3,199,150,0	warp	ord23-16	1,1,ordeal_2-3,171,150
+//ordeal_2-4,128,154,0	warp	ord24-1	1,1,ordeal_2-4,24,154
+//ordeal_2-4,136,136,0	warp	ord24-2	1,1,ordeal_2-4,24,24
+//ordeal_2-4,136,172,0	warp	ord24-3	1,1,ordeal_2-4,24,284
+//ordeal_2-4,153,128,0	warp	ord24-4	1,1,ordeal_2-4,153,23
+//ordeal_2-4,153,180,0	warp	ord24-5	1,1,ordeal_2-4,144,284
+//ordeal_2-4,172,135,0	warp	ord24-6	1,1,ordeal_2-4,284,24
+//ordeal_2-4,172,172,0	warp	ord24-7	1,1,ordeal_2-4,284,284
+//ordeal_2-4,180,154,0	warp	ord24-8	1,1,ordeal_2-4,284,164
 ordeal_3-1,100,150,0	warp	ord31-1	1,1,ordeal_3-1,128,150
 ordeal_3-1,123,150,0	warp	ord31-2	1,1,ordeal_3-1,95,150
 ordeal_3-1,114,183,0	warp	ord31-3	1,1,ordeal_3-1,135,163
@@ -136,39 +137,30 @@ ordeal_3-2,153,180,0	warp	ord32-5	1,1,ordeal_3-2,144,284
 ordeal_3-2,172,135,0	warp	ord32-6	1,1,ordeal_3-2,284,24
 ordeal_3-2,172,172,0	warp	ord32-7	1,1,ordeal_3-2,284,284
 ordeal_3-2,180,154,0	warp	ord32-8	1,1,ordeal_3-2,284,164
-ordeal_3-3,100,150,0	warp	ord33-1	1,1,ordeal_3-3,128,150
-ordeal_3-3,114,183,0	warp	ord33-2	1,1,ordeal_3-3,135,163
-ordeal_3-3,115,115,0	warp	ord33-3	1,1,ordeal_3-3,136,136
-ordeal_3-3,123,150,0	warp	ord33-4	1,1,ordeal_3-3,95,150
-ordeal_3-3,130,168,0	warp	ord33-5	1,1,ordeal_3-3,109,188
-ordeal_3-3,131,131,0	warp	ord33-6	1,1,ordeal_3-3,110,110
-ordeal_3-3,148,176,0	warp	ord33-7	1,1,ordeal_3-3,149,204
-ordeal_3-3,149,99,0	warp	ord33-8	1,1,ordeal_3-3,151,129
-ordeal_3-3,149,199,0	warp	ord33-9	1,1,ordeal_3-3,148,171
-ordeal_3-3,151,124,0	warp	ord33-10	1,1,ordeal_3-3,151,94
-ordeal_3-3,168,168,0	warp	ord33-11	1,1,ordeal_3-3,189,189
-ordeal_3-3,169,131,0	warp	ord33-12	1,1,ordeal_3-3,188,111
-ordeal_3-3,176,150,0	warp	ord33-13	1,1,ordeal_3-3,204,150
-ordeal_3-3,183,116,0	warp	ord33-14	1,1,ordeal_3-3,164,136
-ordeal_3-3,184,184,0	warp	ord33-15	1,1,ordeal_3-3,163,163
-ordeal_3-3,199,150,0	warp	ord33-16	1,1,ordeal_3-3,171,150
-ordeal_3-4,128,154,0	warp	ord34-1	1,1,ordeal_3-4,24,154
-ordeal_3-4,136,136,0	warp	ord34-2	1,1,ordeal_3-4,24,24
-ordeal_3-4,136,172,0	warp	ord34-3	1,1,ordeal_3-4,24,284
-ordeal_3-4,153,128,0	warp	ord34-4	1,1,ordeal_3-4,153,23
-ordeal_3-4,153,180,0	warp	ord34-5	1,1,ordeal_3-4,144,284
-ordeal_3-4,172,135,0	warp	ord34-6	1,1,ordeal_3-4,284,24
-ordeal_3-4,172,172,0	warp	ord34-7	1,1,ordeal_3-4,284,284
-ordeal_3-4,180,154,0	warp	ord34-8	1,1,ordeal_3-4,284,164
-//This map doesn't even exists. Is it ordeal_a02 or ordea_la00?
-//ordeal_a04,128,154,0	warp	orda1	0,0,ordeal_a04,24,154
-//ordeal_a04,136,136,0	warp	orda2	0,0,ordeal_a04,24,24
-//ordeal_a04,136,172,0	warp	orda3	0,0,ordeal_a04,24,284
-//ordeal_a04,153,128,0	warp	orda4	0,0,ordeal_a04,153,23
-//ordeal_a04,153,180,0	warp	orda5	0,0,ordeal_a04,144,284
-//ordeal_a04,172,135,0	warp	orda6	0,0,ordeal_a04,284,24
-//ordeal_a04,172,172,0	warp	orda7	0,0,ordeal_a04,284,284
-//ordeal_a04,180,154,0	warp	orda8	0,0,ordeal_a04,284,164
+//ordeal_3-3,100,150,0	warp	ord33-1	1,1,ordeal_3-3,128,150
+//ordeal_3-3,114,183,0	warp	ord33-2	1,1,ordeal_3-3,135,163
+//ordeal_3-3,115,115,0	warp	ord33-3	1,1,ordeal_3-3,136,136
+//ordeal_3-3,123,150,0	warp	ord33-4	1,1,ordeal_3-3,95,150
+//ordeal_3-3,130,168,0	warp	ord33-5	1,1,ordeal_3-3,109,188
+//ordeal_3-3,131,131,0	warp	ord33-6	1,1,ordeal_3-3,110,110
+//ordeal_3-3,148,176,0	warp	ord33-7	1,1,ordeal_3-3,149,204
+//ordeal_3-3,149,99,0	warp	ord33-8	1,1,ordeal_3-3,151,129
+//ordeal_3-3,149,199,0	warp	ord33-9	1,1,ordeal_3-3,148,171
+//ordeal_3-3,151,124,0	warp	ord33-10	1,1,ordeal_3-3,151,94
+//ordeal_3-3,168,168,0	warp	ord33-11	1,1,ordeal_3-3,189,189
+//ordeal_3-3,169,131,0	warp	ord33-12	1,1,ordeal_3-3,188,111
+//ordeal_3-3,176,150,0	warp	ord33-13	1,1,ordeal_3-3,204,150
+//ordeal_3-3,183,116,0	warp	ord33-14	1,1,ordeal_3-3,164,136
+//ordeal_3-3,184,184,0	warp	ord33-15	1,1,ordeal_3-3,163,163
+//ordeal_3-3,199,150,0	warp	ord33-16	1,1,ordeal_3-3,171,150
+//ordeal_3-4,128,154,0	warp	ord34-1	1,1,ordeal_3-4,24,154
+//ordeal_3-4,136,136,0	warp	ord34-2	1,1,ordeal_3-4,24,24
+//ordeal_3-4,136,172,0	warp	ord34-3	1,1,ordeal_3-4,24,284
+//ordeal_3-4,153,128,0	warp	ord34-4	1,1,ordeal_3-4,153,23
+//ordeal_3-4,153,180,0	warp	ord34-5	1,1,ordeal_3-4,144,284
+//ordeal_3-4,172,135,0	warp	ord34-6	1,1,ordeal_3-4,284,24
+//ordeal_3-4,172,172,0	warp	ord34-7	1,1,ordeal_3-4,284,284
+//ordeal_3-4,180,154,0	warp	ord34-8	1,1,ordeal_3-4,284,164
 
 // PvP Nightmare More warps
 pvp_n_8-4,33,122,0	warp	Link#pt_link_1-11	0,2,pvp_n_8-4,0,0

+ 7 - 7
src/char/char.c

@@ -2832,8 +2832,6 @@ int parse_frommap(int fd)
 			if( RFIFOREST(fd) < 18 )
 				return 0;
 		{
-			struct auth_node* node;
-
 			int account_id = RFIFOL(fd,2);
 			uint32 login_id1 = RFIFOL(fd,6);
 			uint32 login_id2 = RFIFOL(fd,10);
@@ -2850,6 +2848,8 @@ int parse_frommap(int fd)
 			}
 			else
 			{
+				struct auth_node* node;
+
 				// create temporary auth entry
 				CREATE(node, struct auth_node, 1);
 				node->account_id = account_id;
@@ -2879,7 +2879,6 @@ int parse_frommap(int fd)
 				return 0;
 		{
 			int map_id, map_fd = -1;
-			struct online_char_data* data;
 			struct mmo_charstatus* char_data;
 			struct mmo_charstatus char_dat;
 
@@ -2897,6 +2896,7 @@ int parse_frommap(int fd)
 				session_isActive(map_fd) &&
 				char_data )
 			{	//Send the map server the auth of this player.
+				struct online_char_data* data;
 				struct auth_node* node;
 
 				//Update the "last map" as this is where the player must be spawned on the new map server.
@@ -4570,25 +4570,25 @@ int char_config_read(const char* cfgName)
 				safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name));
 			}
 		} else if (strcmpi(w1, "login_ip") == 0) {
-			char ip_str[16];
 			login_ip = host2ip(w2);
 			if (login_ip) {
+				char ip_str[16];
 				safestrncpy(login_ip_str, w2, sizeof(login_ip_str));
 				ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
 			}
 		} else if (strcmpi(w1, "login_port") == 0) {
 			login_port = atoi(w2);
 		} else if (strcmpi(w1, "char_ip") == 0) {
-			char ip_str[16];
 			char_ip = host2ip(w2);
-			if (char_ip){
+			if (char_ip) {
+				char ip_str[16];
 				safestrncpy(char_ip_str, w2, sizeof(char_ip_str));
 				ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str));
 			}
 		} else if (strcmpi(w1, "bind_ip") == 0) {
-			char ip_str[16];
 			bind_ip = host2ip(w2);
 			if (bind_ip) {
+				char ip_str[16];
 				safestrncpy(bind_ip_str, w2, sizeof(bind_ip_str));
 				ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
 			}

+ 6 - 5
src/char/int_guild.c

@@ -216,8 +216,8 @@ int inter_guild_tosql(struct guild *g,int flag)
 			strcat(t_info, " level");
 			if( add_comma )
 				StringBuf_AppendStr(&buf, ", ");
-			else
-				add_comma = true;
+			//else	//last condition using add_coma setting
+			//	add_comma = true;
 			StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member);
 		}
 		StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id);
@@ -508,7 +508,7 @@ struct guild * inter_guild_fromsql(int guild_id)
 	{
 		int id;
 		Sql_GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
-		if( id < 0 && id >= MAX_GUILDSKILL )
+		if( id < 0 || id >= MAX_GUILDSKILL )
 			continue;// invalid guild skill
 		Sql_GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data);
 	}
@@ -603,7 +603,7 @@ static bool exp_guild_parse_row(char* split[], int column, int current)
 {
 	unsigned int exp = (unsigned int)atol(split[0]);
 
-	if (exp < 0 || exp >= UINT_MAX) {
+	if (exp >= UINT_MAX) {
 		ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current);
 		return false;
 	}
@@ -1261,7 +1261,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m)
 // Delete member from guild
 int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes)
 {
-	int i, j;
+	int i;
 
 	struct guild* g = inter_guild_fromsql(guild_id);
 	if( g == NULL )
@@ -1284,6 +1284,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
 	if( flag )
 	{	// Write expulsion reason
 		// Find an empty slot
+		int j;
 		ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 );
 		if( j == MAX_GUILDEXPULSION )
 		{

+ 3 - 3
src/common/raconf.c

@@ -41,12 +41,11 @@ struct conf_value{
 
 static struct conf_value *makeValue(const char *key, char *val, size_t val_len){
 	struct conf_value *v;
-	char *p;
-	size_t sz;
+/*	size_t sz;
 		
 	sz = sizeof(struct conf_value);
 	if(val_len >=  sizeof(v->strval))
-		sz += (val_len - sizeof(v->strval) +  1);
+		sz += (val_len - sizeof(v->strval) +  1);*/
 	
 	v = (struct conf_value*)aCalloc(1, sizeof(struct conf_value));
 	if(v == NULL){
@@ -106,6 +105,7 @@ static struct conf_value *makeValue(const char *key, char *val, size_t val_len){
 	}else if( *val >='0' && *val <= '9'){	// begins with normal digit, so assume its dec.
 		// is it float?
 		bool is_float = false;
+		char *p;
 		
 		for(p = val; *p != '\0'; p++){
 			if(*p == '.'){

+ 3 - 3
src/common/socket.c

@@ -1017,14 +1017,14 @@ int access_ipmask(const char* str, AccessControl* acc)
 {
 	uint32 ip;
 	uint32 mask;
-	unsigned int a[4];
-	unsigned int m[4];
-	int n;
 
 	if( strcmp(str,"all") == 0 ) {
 		ip   = 0;
 		mask = 0;
 	} else {
+		unsigned int a[4];
+		unsigned int m[4];
+		int n;
 		if( ((n=sscanf(str,"%u.%u.%u.%u/%u.%u.%u.%u",a,a+1,a+2,a+3,m,m+1,m+2,m+3)) != 8 && // not an ip + standard mask
 				(n=sscanf(str,"%u.%u.%u.%u/%u",a,a+1,a+2,a+3,m)) != 5 && // not an ip + bit mask
 				(n=sscanf(str,"%u.%u.%u.%u",a,a+1,a+2,a+3)) != 4 ) || // not an ip

+ 1 - 1
src/login/account_sql.c

@@ -486,7 +486,6 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
 	AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self;
 	AccountDB_SQL* db = (AccountDB_SQL*)iter->db;
 	Sql* sql_handle = db->accounts;
-	int account_id;
 	char* data;
 
 	// get next account ID
@@ -501,6 +500,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
 		SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, NULL) &&
 		data != NULL )
 	{// get account data
+		int account_id;
 		account_id = atoi(data);
 		if( mmo_auth_fromsql(db, acc, account_id) )
 		{

+ 4 - 3
src/login/login.c

@@ -1605,10 +1605,11 @@ int login_config_read(const char* cfgName)
 				ShowInfo("Console Silent Setting: %d\n", atoi(w2));
 		}
 		else if( !strcmpi(w1, "bind_ip") ) {
-			char ip_str[16];
 			login_config.login_ip = host2ip(w2);
-			if( login_config.login_ip )
+			if( login_config.login_ip ) {
+				char ip_str[16];
 				ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str));
+			}
 		}
 		else if( !strcmpi(w1, "login_port") ) {
 			login_config.login_port = (uint16)atoi(w2);
@@ -1653,10 +1654,10 @@ int login_config_read(const char* cfgName)
 		else if(!strcmpi(w1, "client_hash")) {
 			int group = 0;
 			char md5[33];
-			int i;
 
 			if (sscanf(w2, "%d, %32s", &group, md5) == 2) {
 				struct client_hash_node *nnode;
+				int i;
 				CREATE(nnode, struct client_hash_node, 1);
 
 				for (i = 0; i < 32; i += 2) {

+ 22 - 21
src/map/atcommand.c

@@ -920,7 +920,7 @@ ACMD_FUNC(option)
 
 	if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
 	{// failed to match the parameters so inform the user of the options
-		const char* text = NULL;
+		const char* text;
 
 		// attempt to find the setting information for this command
 		text = atcommand_help_string( command );
@@ -1230,8 +1230,6 @@ ACMD_FUNC(item2)
 	int item_id, number = 0;
 	int identify = 0, refine = 0, attr = 0;
 	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
-	int flag = 0;
-	int loop, get_count, i;
 	nullpo_retr(-1, sd);
 
 	memset(item_name, '\0', sizeof(item_name));
@@ -1254,6 +1252,8 @@ ACMD_FUNC(item2)
 		item_id = item_data->nameid;
 
 	if (item_id > 500) {
+		int flag = 0;
+		int loop, get_count, i;
 		loop = 1;
 		get_count = number;
 		if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
@@ -2161,7 +2161,6 @@ ACMD_FUNC(produce)
 {
 	char item_name[100];
 	int item_id, attribute = 0, star = 0;
-	int flag = 0;
 	struct item_data *item_data;
 	struct item tmp_item;
 	nullpo_retr(-1, sd);
@@ -2186,6 +2185,7 @@ ACMD_FUNC(produce)
 	item_id = item_data->nameid;
 
 	if (itemdb_isequip2(item_data)) {
+		int flag = 0;
 		if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
 			attribute = ATTRIBUTE_NORMAL;
 		if (star < MIN_STAR || star > MAX_STAR)
@@ -2822,7 +2822,7 @@ ACMD_FUNC(char_ban)
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
 
-	if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
+	if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
 		clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
 		return -1;
 	}
@@ -3310,14 +3310,14 @@ ACMD_FUNC(guild)
 
 ACMD_FUNC(breakguild)
 {
-	int ret = 0;
-	struct guild *g;
 	nullpo_retr(-1, sd);
 
 	if (sd->status.guild_id) { // Check if the player has a guild
+		struct guild *g;
 		g = guild_search(sd->status.guild_id); // Search the guild
 		if (g) { // Check if guild was found
 			if (sd->state.gmaster_flag) { // Check if player is guild master
+				int ret = 0;
 				ret = guild_break(sd, g->name); // Break guild
 				if (ret) { // Check if anything went wrong
 					return 0; // Guild was broken
@@ -4625,7 +4625,7 @@ ACMD_FUNC(jailfor)
 	short m_index = 0;
 	nullpo_retr(-1, sd);
 
-	if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
+	if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
 		clif_displaymessage(fd, msg_txt(400));	//Usage: @jailfor <time> <character name>
 		return -1;
 	}
@@ -5786,7 +5786,6 @@ ACMD_FUNC(partyoption)
 ACMD_FUNC(autoloot)
 {
 	int rate;
-	double drate;
 	nullpo_retr(-1, sd);
 	// autoloot command without value
 	if(!message || !*message)
@@ -5796,6 +5795,7 @@ ACMD_FUNC(autoloot)
 		else
 			rate = 10000;
 	} else {
+		double drate;
 		drate = atof(message);
 		rate = (int)(drate*100);
 	}
@@ -6650,12 +6650,13 @@ ACMD_FUNC(identify)
  *------------------------------------------*/
 ACMD_FUNC(gmotd)
 {
-	char buf[CHAT_SIZE_MAX];
-	size_t len;
 	FILE* fp;
 
 	if( ( fp = fopen(motd_txt, "r") ) != NULL )
 	{
+		char buf[CHAT_SIZE_MAX];
+		size_t len;
+
 		while( fgets(buf, sizeof(buf), fp) )
 		{
 			if( buf[0] == '/' && buf[1] == '/' )
@@ -7730,7 +7731,7 @@ ACMD_FUNC(invite)
 	unsigned int did = sd->duel_group;
 	struct map_session_data *target_sd = map_nick2sd((char *)message);
 
-	if(did <= 0)	{
+	if(did == 0) {
 		// "Duel: @invite without @duel."
 		clif_displaymessage(fd, msg_txt(350));
 		return 0;
@@ -7771,9 +7772,7 @@ ACMD_FUNC(invite)
 
 ACMD_FUNC(duel)
 {
-	char output[CHAT_SIZE_MAX];
-	unsigned int maxpl=0, newduel;
-	struct map_session_data *target_sd;
+	unsigned int maxpl = 0;
 
 	if(sd->duel_group > 0) {
 		duel_showinfo(sd->duel_group, sd);
@@ -7787,6 +7786,7 @@ ACMD_FUNC(duel)
 	}
 
 	if(!duel_checktime(sd)) {
+		char output[CHAT_SIZE_MAX];
 		// "Duel: You can take part in duel only one time per %d minutes."
 		sprintf(output, msg_txt(356), battle_config.duel_time_interval);
 		clif_displaymessage(fd, output);
@@ -7801,8 +7801,10 @@ ACMD_FUNC(duel)
 			}
 			duel_create(sd, maxpl);
 		} else {
+			struct map_session_data *target_sd;
 			target_sd = map_nick2sd((char *)message);
 			if(target_sd != NULL) {
+				unsigned int maxpl=0, newduel;
 				if((newduel = duel_create(sd, 2)) != -1) {
 					if(target_sd->duel_group > 0 ||	target_sd->duel_invite > 0) {
 						clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
@@ -7839,9 +7841,8 @@ ACMD_FUNC(leave)
 
 ACMD_FUNC(accept)
 {
-	char output[CHAT_SIZE_MAX];
-
 	if(!duel_checktime(sd)) {
+		char output[CHAT_SIZE_MAX];
 		// "Duel: You can take part in duel only one time per %d minutes."
 		sprintf(output, msg_txt(356), battle_config.duel_time_interval);
 		clif_displaymessage(fd, output);
@@ -8609,7 +8610,7 @@ ACMD_FUNC(set) {
 	int toset = 0, len;
 	bool is_str = false;
 
-	if( !message || !*message || (toset = sscanf(message, "%32s %128[^\n]s", reg, val)) < 1  ) {
+	if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1  ) {
 		clif_displaymessage(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
 		clif_displaymessage(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
 		clif_displaymessage(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
@@ -9426,7 +9427,7 @@ static void atcommand_config_read(const char* config_filename)
 		int count = config_setting_length(aliases);
 
 		for (i = 0; i < count; ++i) {
-			config_setting_t *command = NULL;
+			config_setting_t *command;
 			const char *commandname = NULL;
 			int j = 0, alias_count = 0;
 			AtCommandInfo *commandinfo = NULL;
@@ -9467,8 +9468,8 @@ static void atcommand_config_read(const char* config_filename)
 		int i;
 
 		for (i = 0; i < count; ++i) {
-			config_setting_t *command = NULL;
-			const char *commandname = NULL;
+			config_setting_t *command;
+			const char *commandname;
 
 			command = config_setting_get_elem(help, i);
 			commandname = config_setting_name(command);

+ 6 - 5
src/map/battle.c

@@ -340,13 +340,13 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
 			struct skill_unit *su = (struct skill_unit*)target;
 			struct skill_unit_group *sg;
 			struct block_list *src;
-			int x,y;
 
 			if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 ||
 			   (src = map_id2bl(sg->src_id)) == NULL || status_isdead(src) )
 				return 0;
 
 			if( sg->unit_id != UNT_FIREWALL ) {
+				int x,y;
 				x = sg->val3 >> 16;
 				y = sg->val3 & 0xffff;
 				skill_unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1);
@@ -4550,7 +4550,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
 
 //Calculates BF_WEAPON returned damage.
 int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int *dmg, int flag, uint16 skill_id){
-	struct map_session_data* sd = NULL;
+	struct map_session_data* sd;
 	int rdamage = 0, damage = *dmg;
 	struct status_change* sc;
 
@@ -4586,9 +4586,9 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int
 			if(sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !(src->type == BL_MOB && is_boss(src)) ) {
 				uint8 dir = map_calc_dir(bl,src->x,src->y),
 					t_dir = unit_getdir(bl);
-				int	rd1 = 0;
 
 				if( distance_bl(src,bl) <= 0 || !map_check_dir(dir,t_dir) ) {
+					int rd1 = 0;
 					rd1 = (int64)min(damage,status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
 					*dmg = (int64)rd1 * 30 / 100; // Received damage = 30% of amplifly damage.
 					clif_skill_damage(src,bl,gettick(), status_get_amotion(src), 0, -30000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1,6);
@@ -4983,9 +4983,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 			sd->status.skill[sc->data[SC__AUTOSHADOWSPELL]->val1].id != 0 && sd->status.skill[sc->data[SC__AUTOSHADOWSPELL]->val1].flag == SKILL_FLAG_PLAGIARIZED )
 		{
 			int r_skill = sd->status.skill[sc->data[SC__AUTOSHADOWSPELL]->val1].id,
-				r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2, type;
+				r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2;
 
 			if (r_skill != AL_HOLYLIGHT && r_skill != PR_MAGNUS) {
+				int type;
 				if( (type = skill_get_casttype(r_skill)) == CAST_GROUND ) {
 					int maxcount = 0;
 
@@ -6096,7 +6097,6 @@ void battle_adjust_conf()
 
 int battle_config_read(const char* cfgName)
 {
-	char line[1024], w1[1024], w2[1024];
 	FILE* fp;
 	static int count = 0;
 
@@ -6110,6 +6110,7 @@ int battle_config_read(const char* cfgName)
 		ShowError("File not found: %s\n", cfgName);
 	else
 	{
+		char line[1024], w1[1024], w2[1024];
 		while(fgets(line, sizeof(line), fp))
 		{
 			if (line[0] == '/' && line[1] == '/')

+ 2 - 2
src/map/chat.c

@@ -203,8 +203,8 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
 
 
 	if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom
-		struct skill_unit* unit = NULL;
-		struct skill_unit_group* group = NULL;	
+		struct skill_unit* unit;
+		struct skill_unit_group* group;	
 
 		clif_clearchat(cd, 0);
 		db_destroy(cd->kick_list);

+ 4 - 3
src/map/chrif.c

@@ -862,7 +862,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
  * Request char server to change sex of char (modified by Yor)
  *------------------------------------------*/
 int chrif_changedsex(int fd) {
-	int acc, sex, i;
+	int acc, sex;
 	struct map_session_data *sd;
 
 	acc = RFIFOL(fd,2);
@@ -879,7 +879,8 @@ int chrif_changedsex(int fd) {
 
 		// reset skill of some job
 		if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) {
-			// remove specifical skills of Bard classes 
+			int i;
+			// remove specifical skills of Bard classes
 			for(i = 315; i <= 322; i++) {
 				if (sd->status.skill[i].id > 0 && sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) {
 					sd->status.skill_point += sd->status.skill[i].lv;
@@ -887,7 +888,7 @@ int chrif_changedsex(int fd) {
 					sd->status.skill[i].lv = 0;
 				}
 			}
-			// remove specifical skills of Dancer classes 
+			// remove specifical skills of Dancer classes
 			for(i = 323; i <= 330; i++) {
 				if (sd->status.skill[i].id > 0 && sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) {
 					sd->status.skill_point += sd->status.skill[i].lv;

+ 8 - 8
src/map/clif.c

@@ -209,9 +209,9 @@ int clif_setip(const char* ip)
 
 void clif_setbindip(const char* ip)
 {
-	char ip_str[16];
 	bind_ip = host2ip(ip);
 	if (bind_ip) {
+		char ip_str[16];
 		ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(bind_ip, ip_str));
 	} else {
 		ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
@@ -1220,12 +1220,11 @@ static void clif_setdisguise(struct block_list *bl, unsigned char *buf,int len)
 ///     unused
 void clif_class_change(struct block_list *bl,int class_,int type)
 {
-	unsigned char buf[16];
-
 	nullpo_retv(bl);
 
 	if(!pcdb_checkid(class_))
 	{// player classes yield missing sprites
+		unsigned char buf[16];
 		WBUFW(buf,0)=0x1b0;
 		WBUFL(buf,2)=bl->id;
 		WBUFB(buf,6)=type;
@@ -2975,7 +2974,7 @@ void clif_changestatus(struct map_session_data* sd,int type,int val)
 void clif_changelook(struct block_list *bl,int type,int val)
 {
 	unsigned char buf[16];
-	struct map_session_data* sd = NULL;
+	struct map_session_data* sd;
 	struct status_change* sc;
 	struct view_data* vd;
 	enum send_target target = AREA;
@@ -6455,12 +6454,12 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag
 void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag)
 {
 	unsigned char buf[64];
-	int i;
 
 	nullpo_retv(p);
 
 	if(!sd && (flag&0xf0)==0)
 	{
+		int i;
 		for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
 			if (i < MAX_PARTY)
 				sd = p->data[i].sd;
@@ -6867,7 +6866,6 @@ void clif_autospell(struct map_session_data *sd,uint16 skill_lv)
 void clif_devotion(struct block_list *src, struct map_session_data *tsd)
 {
 	unsigned char buf[56];
-	int i;
 
 	nullpo_retv(src);
 	memset(buf,0,packet_len(0x1cf));
@@ -6884,6 +6882,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd)
 	}
 	else
 	{
+		int i;
 		struct map_session_data *sd = BL_CAST(BL_PC,src);
 		if( sd == NULL )
 			return;
@@ -7821,7 +7820,6 @@ void clif_wedding_effect(struct block_list *bl)
 void clif_callpartner(struct map_session_data *sd)
 {
 	unsigned char buf[26];
-	const char *p;
 
 	nullpo_retv(sd);
 
@@ -7829,6 +7827,7 @@ void clif_callpartner(struct map_session_data *sd)
 
 	if( sd->status.partner_id )
 	{
+		const char *p;
 		if( ( p = map_charid2nick(sd->status.partner_id) ) != NULL )
 		{
 			memcpy(WBUFP(buf,2), p, NAME_LENGTH);
@@ -8432,7 +8431,7 @@ void clif_charnameack (int fd, struct block_list *bl)
 void clif_charnameupdate (struct map_session_data *ssd)
 {
 	unsigned char buf[103];
-	int cmd = 0x195, ps = -1, i;
+	int cmd = 0x195, ps = -1;
 	struct party_data *p = NULL;
 	struct guild *g = NULL;
 
@@ -8456,6 +8455,7 @@ void clif_charnameupdate (struct map_session_data *ssd)
 
 	if( ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL )
 	{
+		int i;
 		ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id);
 		if( i < g->max_member ) ps = g->member[i].position;
 	}

+ 1 - 1
src/map/guild.c

@@ -1650,13 +1650,13 @@ int guild_broken_sub(DBKey key, DBData *data, va_list ap)
  */
 int castle_guild_broken_sub(DBKey key, DBData *data, va_list ap)
 {
-	char name[EVENT_NAME_LENGTH];
 	struct guild_castle *gc = db_data2ptr(data);
 	int guild_id = va_arg(ap, int);
 
 	nullpo_ret(gc);
 
 	if (gc->guild_id == guild_id) {
+		char name[EVENT_NAME_LENGTH];
 		// We call castle_event::OnGuildBreak of all castles of the guild
 		// You can set all castle_events in the 'db/castle_db.txt'
 		safestrncpy(name, gc->castle_event, sizeof(name));

+ 3 - 3
src/map/homunculus.c

@@ -303,7 +303,6 @@ int merc_hom_levelup(struct homun_data *hd)
 	struct h_stats *min, *max;
 	int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ;
 	int growth_max_hp, growth_max_sp ;
-	char output[256] ;
 	int m_class;
 
 	if((m_class = hom_class2mapid(hd->homunculus.class_)) == -1) {
@@ -352,6 +351,7 @@ int merc_hom_levelup(struct homun_data *hd)
 	hom->luk += growth_luk;
 
 	if ( battle_config.homunculus_show_growth ) {
+		char output[256] ;
 		sprintf(output,
 			"Growth: hp:%d sp:%d str(%.2f) agi(%.2f) vit(%.2f) int(%.2f) dex(%.2f) luk(%.2f) ",
 			growth_max_hp, growth_max_sp,
@@ -1148,10 +1148,10 @@ int read_homunculusdb(void)
 	memset(homunculus_db,0,sizeof(homunculus_db));
 	for(i = 0; i<ARRAYLENGTH(filename); i++)
 	{
-		char path[256];
-
 		if( i > 0 )
 		{
+			char path[256];
+
 			sprintf(path, "%s/%s", db_path, filename[i]);
 
 			if( !exists(path) )

+ 1 - 1
src/map/itemdb.c

@@ -867,7 +867,7 @@ void itemdb_read_combos() {
 			
 			/* populate the children to refer to this combo */
 			for( v = 1; v < retcount; v++ ) {
-				struct item_data * it = NULL;
+				struct item_data * it;
 				int index;
 				
 				it = itemdb_exists(items[v]);

+ 2 - 2
src/map/map.c

@@ -2308,7 +2308,7 @@ int16 map_mapindex2mapid(unsigned short mapindex)
  *------------------------------------------*/
 int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port)
 {
-	struct map_data_other_server *mdos=NULL;
+	struct map_data_other_server *mdos;
 
 	mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name);
 	if(mdos==NULL || mdos->cell) //If gat isn't null, this is a local map.
@@ -2709,7 +2709,7 @@ static DBData create_map_data_other_server(DBKey key, va_list args)
  *------------------------------------------*/
 int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
 {
-	struct map_data_other_server *mdos=NULL;
+	struct map_data_other_server *mdos;
 
 	mdos= uidb_ensure(map_db,(unsigned int)mapindex, create_map_data_other_server);
 

+ 8 - 12
src/map/mob.c

@@ -1406,9 +1406,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target)
 static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 {
 	struct block_list *tbl = NULL, *abl = NULL;
-	int dist;
 	int mode;
-	int search_size;
 	int view_range, can_move;
 
 	if(md->bl.prev == NULL || md->status.hp <= 0)
@@ -1481,6 +1479,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 		else
 		if( (abl = map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode)) )
 		{
+			int dist;
 			if( md->bl.m != abl->m || abl->prev == NULL
 				|| (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area
 				|| battle_check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob
@@ -1547,6 +1546,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 	else
 	if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW))
 	{
+		int search_size;
 		search_size = view_range<md->status.rhw.range ? view_range:md->status.rhw.range;
 		map_foreachinrange (mob_ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl);
 	}
@@ -2100,7 +2100,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		int id,zeny;
 		unsigned int base_exp,job_exp;
 	} pt[DAMAGELOG_SIZE];
-	int i,temp,count,pnum=0,m=md->bl.m;
+	int i, temp, count, m = md->bl.m, pnum = 0;
 	int dmgbltypes = 0;  // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution
 	unsigned int mvp_damage, tick = gettick();
 	bool rebirth, homkillonly;
@@ -3617,9 +3617,9 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
  */
 static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust)
 {
-	int i;
 	if( item_drop_ratio_db[nameid] ) {
 		if( item_drop_ratio_db[nameid]->mob_id[0] ) { // only for listed mobs
+			int i;
 			ARR_FIND(0, MAX_ITEMRATIO_MOBS, i, item_drop_ratio_db[nameid]->mob_id[i] == mob_id);
 			if(i < MAX_ITEMRATIO_MOBS) // found
 				*rate_adjust = item_drop_ratio_db[nameid]->drop_ratio;
@@ -3770,7 +3770,6 @@ static bool mob_parse_dbrow(char** str)
 
 	// MVP Drops: MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per
 	for(i = 0; i < MAX_MVP_DROP; i++) {
-		struct item_data *id;
 		int rate_adjust = battle_config.item_rate_mvp;;
 		db->mvpitem[i].nameid = atoi(str[31+i*2]);
 		if (!db->mvpitem[i].nameid) {
@@ -3782,6 +3781,7 @@ static bool mob_parse_dbrow(char** str)
 
 		//calculate and store Max available drop chance of the MVP item
 		if (db->mvpitem[i].p) {
+			struct item_data *id;
 			id = itemdb_search(db->mvpitem[i].nameid);
 			if (id->maxchance == -1 || (id->maxchance < db->mvpitem[i].p/10 + 1) ) {
 				//item has bigger drop chance or sold in shops
@@ -3891,10 +3891,9 @@ static void mob_readdb(void)
 
 	for( fi = 0; fi < ARRAYLENGTH(filename); ++fi )
 	{
-		char path[256];
-
 		if(fi > 0)
 		{
+			char path[256];
 			sprintf(path, "%s/%s", db_path, filename[fi]);
 			if(!exists(path))
 			{
@@ -4458,10 +4457,9 @@ static void mob_readskilldb(void) {
 
 	for( fi = 0; fi < ARRAYLENGTH(filename); ++fi )
 	{
-		char path[256];
-
 		if(fi > 0)
 		{
+			char path[256];
 			sprintf(path, "%s/%s", db_path, filename[fi]);
 			if(!exists(path))
 			{
@@ -4559,11 +4557,9 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
 static bool mob_readdb_itemratio(char* str[], int columns, int current)
 {
 	int nameid, ratio, i;
-	struct item_data *id;
-
 	nameid = atoi(str[0]);
 
-	if( ( id = itemdb_exists(nameid) ) == NULL )
+	if( itemdb_exists(nameid) == NULL )
 	{
 		ShowWarning("itemdb_read_itemratio: Invalid item id %d.\n", nameid);
 		return false;

+ 8 - 6
src/map/npc.c

@@ -491,7 +491,6 @@ struct timer_event_data {
  *------------------------------------------*/
 int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
 {
-	int next;
 	int old_rid, old_timer;
 	unsigned int old_tick;
 	struct npc_data* nd=(struct npc_data *)map_id2bl(id);
@@ -529,6 +528,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
 	ted->next++;
 	if( nd->u.scr.timeramount > ted->next )
 	{
+		int next;
 		next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer;
 		ted->time += next;
 		if( sd )
@@ -563,10 +563,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
  *------------------------------------------*/
 int npc_timerevent_start(struct npc_data* nd, int rid)
 {
-	int j, next;
+	int j;
 	unsigned int tick = gettick();
 	struct map_session_data *sd = NULL; //Player to whom script is attached.
-	struct timer_event_data *ted;
 
 	nullpo_ret(nd);
 
@@ -590,6 +589,8 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
 
 	if (j < nd->u.scr.timeramount)
 	{
+		int next;
+		struct timer_event_data *ted;
 		// Arrange for the next event
 		ted = ers_alloc(timer_event_ers, struct timer_event_data);
 		ted->next = j; // Set event index
@@ -1845,7 +1846,7 @@ int npc_unload(struct npc_data* nd, bool single) {
 		mapit_free(iter);
 
 		if (nd->u.scr.timerid != INVALID_TIMER) {
-			const struct TimerData *td = NULL;
+			const struct TimerData *td;
 			td = get_timer(nd->u.scr.timerid);
 			if (td && td->data)
 				ers_free(timer_event_ers, (void*)td->data);
@@ -3231,9 +3232,9 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 		map[m].flag.pvp_noguild=state;
 	else if (!strcmpi(w3, "pvp_nightmaredrop")) {
 		char drop_arg1[16], drop_arg2[16];
-		int drop_id = 0, drop_type = 0, drop_per = 0;
+		int drop_per = 0;
 		if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
-			int i;
+			int drop_id = 0, drop_type = 0;
 			if (!strcmpi(drop_arg1, "random"))
 				drop_id = -1;
 			else if (itemdb_exists((drop_id = atoi(drop_arg1))) == NULL)
@@ -3246,6 +3247,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
 				drop_type = 3;
 
 			if (drop_id != 0){
+				int i;
 				for (i = 0; i < MAX_DROP_PER_MAP; i++) {
 					if (map[m].drop_list[i].drop_id == 0){
 						map[m].drop_list[i].drop_id = drop_id;

+ 2 - 3
src/map/party.c

@@ -204,11 +204,10 @@ int party_request_info(int party_id, int char_id)
 /// Invoked (from char-server) when the party info is not found.
 int party_recv_noinfo(int party_id, int char_id)
 {
-	struct map_session_data* sd;
-
 	party_broken(party_id);
 	if( char_id != 0 )// requester
 	{
+		struct map_session_data* sd;
 		sd = map_charid2sd(char_id);
 		if( sd && sd->status.party_id == party_id )
 			sd->status.party_id = 0;
@@ -721,7 +720,6 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m
 
 void party_send_movemap(struct map_session_data *sd)
 {
-	int i;
 	struct party_data *p;
 
 	if( sd->status.party_id==0 )
@@ -740,6 +738,7 @@ void party_send_movemap(struct map_session_data *sd)
 	}
 
 	if (sd->fd) { // synchronize minimap positions with the rest of the party
+		int i;
 		for(i=0; i < MAX_PARTY; i++) {
 			if (p->data[i].sd &&
 				p->data[i].sd != sd &&

+ 18 - 14
src/map/pc.c

@@ -482,7 +482,6 @@ void pc_inventory_rentals(struct map_session_data *sd)
 
 void pc_inventory_rental_add(struct map_session_data *sd, int seconds)
 {
-	const struct TimerData * td;
 	int tick = seconds * 1000;
 
 	if( sd == NULL )
@@ -490,6 +489,7 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds)
 
 	if( sd->rental_timer != INVALID_TIMER )
 	{
+		const struct TimerData * td;
 		td = get_timer(sd->rental_timer);
 		if( DIFF_TICK(td->tick, gettick()) > tick )
 		{ // Update Timer as this one ends first than the current one
@@ -1355,14 +1355,16 @@ int pc_calc_skilltree(struct map_session_data *sd)
 		flag = 0;
 		for( i = 0; i < MAX_SKILL_TREE && (id = skill_tree[c][i].id) > 0; i++ )
 		{
-			int j, f, k, inf2;
+			int f;
 
 			if( sd->status.skill[id].id )
 				continue; //Skill already known.
 
 			f = 1;
 			if(!battle_config.skillfree) {
+				int j;
 				for(j = 0; j < MAX_PC_SKILL_REQUIRE; j++) {
+					int k;
 					if((k=skill_tree[c][i].need[j].id))
 					{
 						if (sd->status.skill[k].id == 0 || sd->status.skill[k].flag == SKILL_FLAG_TEMPORARY || sd->status.skill[k].flag == SKILL_FLAG_PLAGIARIZED)
@@ -1384,6 +1386,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
 			}
 
 			if( f ) {
+				int inf2;
 				inf2 = skill_get_inf2(id);
 
 				if(!sd->status.skill[id].lv && (
@@ -3651,7 +3654,6 @@ int pc_payzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type,
 
 int pc_paycash(struct map_session_data *sd, int price, int points)
 {
-	char output[128];
 	int cash;
 	nullpo_retr(-1,sd);
 
@@ -3681,6 +3683,7 @@ int pc_paycash(struct map_session_data *sd, int price, int points)
 
 	if( battle_config.cashshop_show_points )
 	{
+		char output[128];
 		sprintf(output, msg_txt(504), points, cash, sd->kafraPoints, sd->cashPoints);
 		clif_disp_onlyself(sd, output, strlen(output));
 	}
@@ -4196,7 +4199,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
 int pc_useitem(struct map_session_data *sd,int n)
 {
 	unsigned int tick = gettick();
-	int amount, i, nameid;
+	int amount, nameid;
 	struct script_code *script;
 
 	nullpo_ret(sd);
@@ -4246,6 +4249,7 @@ int pc_useitem(struct map_session_data *sd,int n)
 		return 0;
 
 	if( sd->inventory_data[n]->delay > 0 ) {
+		int i;
 		ARR_FIND(0, MAX_ITEMDELAYS, i, sd->item_delay[i].nameid == nameid );
 			if( i == MAX_ITEMDELAYS ) /* item not found. try first empty now */
 				ARR_FIND(0, MAX_ITEMDELAYS, i, !sd->item_delay[i].nameid );
@@ -6752,11 +6756,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
 				int eq_num=0,eq_n[MAX_INVENTORY];
 				memset(eq_n,0,sizeof(eq_n));
 				for(i=0;i<MAX_INVENTORY;i++){
-					int k;
 					if( (type == 1 && !sd->status.inventory[i].equip)
 						|| (type == 2 && sd->status.inventory[i].equip)
 						||  type == 3)
 					{
+						int k;
 						ARR_FIND( 0, MAX_INVENTORY, k, eq_n[k] <= 0 );
 						if( k < MAX_INVENTORY )
 							eq_n[k] = i;
@@ -7163,9 +7167,10 @@ void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int ty
  *------------------------------------------*/
 int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
 {
-	int i, bonus;
+	int bonus;
 
 	if(hp) {
+		int i;
 		bonus = 100 + (sd->battle_status.vit<<1)
 			+ pc_checkskill(sd,SM_RECOVERY)*10
 			+ pc_checkskill(sd,AM_LEARNINGPOTION)*5;
@@ -8529,13 +8534,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
 
 	/* check for combos (MUST be before status_calc_pc) */
 	if ( id ) {
-		struct item_data *data;
 		if( id->combos_count )
 			pc_checkcombo(sd,id);
 		if(itemdb_isspecial(sd->status.inventory[n].card[0]))
 			; //No cards
 		else {
 			for( i = 0; i < id->slot; i++ ) {
+				struct item_data *data;
 				if (!sd->status.inventory[n].card[i])
 					continue;
 				if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
@@ -8552,13 +8557,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
 
 	//OnEquip script [Skotlex]
 	if (id) {
-		struct item_data *data;
 		if (id->equip_script)
 			run_script(id->equip_script,0,sd->bl.id,fake_nd->bl.id);
 		if(itemdb_isspecial(sd->status.inventory[n].card[0]))
 			; //No cards
 		else {
 			for( i = 0; i < id->slot; i++ ) {
+				struct item_data *data;
 				if (!sd->status.inventory[n].card[i])
 					continue;
 				if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
@@ -8681,8 +8686,6 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
 
 	/* check for combos (MUST be before status_calc_pc) */
 	if ( sd->inventory_data[n] ) {
-		struct item_data *data;
-
 		if( sd->inventory_data[n]->combos_count ) {
 			if( pc_removecombo(sd,sd->inventory_data[n]) )
 				status_cacl = true;
@@ -8690,6 +8693,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
 			; //No cards
 		else {
 			for( i = 0; i < sd->inventory_data[n]->slot; i++ ) {
+				struct item_data *data;
 				if (!sd->status.inventory[n].card[i])
 					continue;
 				if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
@@ -8712,13 +8716,13 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
 
 	//OnUnEquip script [Skotlex]
 	if (sd->inventory_data[n]) {
-		struct item_data *data;
 		if (sd->inventory_data[n]->unequip_script)
 			run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id);
 		if(itemdb_isspecial(sd->status.inventory[n].card[0]))
 			; //No cards
 		else {
 			for( i = 0; i < sd->inventory_data[n]->slot; i++ ) {
+				struct item_data *data;
 				if (!sd->status.inventory[n].card[i])
 					continue;
 
@@ -8796,7 +8800,7 @@ int pc_checkitem(struct map_session_data *sd)
  *------------------------------------------*/
 int pc_calc_pvprank_sub(struct block_list *bl,va_list ap)
 {
-	struct map_session_data *sd1,*sd2=NULL;
+	struct map_session_data *sd1,*sd2;
 
 	sd1=(struct map_session_data *)bl;
 	sd2=va_arg(ap,struct map_session_data *);
@@ -8831,7 +8835,7 @@ int pc_calc_pvprank(struct map_session_data *sd)
  *------------------------------------------*/
 int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data)
 {
-	struct map_session_data *sd=NULL;
+	struct map_session_data *sd;
 
 	sd=map_id2sd(id);
 	if(sd==NULL)
@@ -9467,7 +9471,7 @@ static bool pc_readdb_levelpenalty(char* fields[], int columns, int current)
 		return false;
 	}
 
-	if( race < 0 && race > RC_MAX ){
+	if( race < 0 || race > RC_MAX ){
 		ShowWarning("pc_readdb_levelpenalty: Invalid race %d specified.\n", race);
 		return false;
 	}

+ 1 - 1
src/map/pc_groups.c

@@ -452,7 +452,7 @@ void do_final_pc_groups(void)
  */
 void pc_groups_reload(void) {
 	struct map_session_data* sd = NULL;
-	struct s_mapiterator* iter = NULL;
+	struct s_mapiterator* iter;
 
 	do_final_pc_groups();
 	do_init_pc_groups();

+ 2 - 4
src/map/pet.c

@@ -100,8 +100,6 @@ int pet_unlocktarget(struct pet_data *pd)
  *------------------------------------------*/
 int pet_attackskill(struct pet_data *pd, int target_id)
 {
-	struct block_list *bl;
-
 	if (!battle_config.pet_status_support || !pd->a_skill || 
 		(battle_config.pet_equip_required && !pd->pet.equip))
 		return 0;
@@ -112,6 +110,7 @@ int pet_attackskill(struct pet_data *pd, int target_id)
 	if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000))
 	{	//Skotlex: Use pet's skill 
 		int inf;
+		struct block_list *bl;
 
 		bl=map_id2bl(target_id);
 		if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) ||
@@ -779,13 +778,12 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
 
 static int pet_randomwalk(struct pet_data *pd,unsigned int tick)
 {
-	const int retrycount=20;
-
 	nullpo_ret(pd);
 
 	Assert((pd->msd == 0) || (pd->msd->pd == pd));
 
 	if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit_can_move(&pd->bl)) {
+		const int retrycount=20;
 		int i,x,y,c,d=12-pd->move_fail_count;
 		if(d<5) d=5;
 		for(i=0;i<retrycount;i++){

+ 12 - 12
src/map/script.c

@@ -13,7 +13,7 @@
 #include "../common/nullpo.h"
 #include "../common/random.h"
 #include "../common/showmsg.h"
-#include "../common/socket.h"	// usage: getcharip
+#include "../common/socket.h"
 #include "../common/strlib.h"
 #include "../common/timer.h"
 #include "../common/utils.h"
@@ -10574,9 +10574,8 @@ static void script_detach_rid(struct script_state* st)
 BUILDIN_FUNC(attachrid)
 {
 	int rid = script_getnum(st,2);
-	struct map_session_data* sd;
 
-	if ((sd = map_id2sd(rid))!=NULL) {
+	if (map_id2sd(rid) != NULL) {
 		script_detach_rid(st);
 
 		st->rid = rid;
@@ -16336,12 +16335,13 @@ BUILDIN_FUNC(instance_attach)
 
 BUILDIN_FUNC(instance_id)
 {
-	int type, instance_id;
-	struct map_session_data *sd;
-	struct party_data *p;
+	int instance_id;
 
 	if( script_hasdata(st, 2) )
 	{
+		struct map_session_data *sd;
+		struct party_data *p;
+		int type;
 		type = script_getnum(st, 2);
 		if( type == 0 )
 			instance_id = st->instance_id;
@@ -16849,7 +16849,7 @@ BUILDIN_FUNC(checkdragon) {
 BUILDIN_FUNC(setdragon) {
 	TBL_PC* sd;
 	int color = script_hasdata(st,2) ? script_getnum(st,2) : 0;
-	unsigned int option = OPTION_DRAGON1;
+
 	if( (sd = script_rid2sd(st)) == NULL )
 		return 0;
 	if( !pc_checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
@@ -16858,6 +16858,7 @@ BUILDIN_FUNC(setdragon) {
 		pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
 		script_pushint(st,1);
 	} else {//Not mounted; Mount now.
+		unsigned int option = OPTION_DRAGON1;
 		if( color ) {
 			option = ( color == 1 ? OPTION_DRAGON1 :
 					   color == 2 ? OPTION_DRAGON2 :
@@ -16934,7 +16935,6 @@ BUILDIN_FUNC(getargcount) {
 BUILDIN_FUNC(getcharip)
 {
 	struct map_session_data* sd = NULL;
-	int id = 0;
 
 	/* check if a character name is specified */
 	if( script_hasdata(st, 2) )
@@ -16943,6 +16943,7 @@ BUILDIN_FUNC(getcharip)
 			sd = map_nick2sd(script_getstr(st, 2));
 		else if (script_isint(st, 2) || script_getnum(st, 2))
 		{
+			int id = 0;
 			id = script_getnum(st, 2);
 			sd = (map_id2sd(id) ? map_id2sd(id) : map_charid2sd(id));
 		}
@@ -17332,10 +17333,9 @@ BUILDIN_FUNC(npcskill)
 	return 0;
 }
 
-/* Consumes a item
- * consumeitem <item id>
- * consumeitem "<item name>"
-*/
+/* Consumes an item.
+ * consumeitem <item id>;
+ * consumeitem "<item name>"; */
 BUILDIN_FUNC(consumeitem)
 {
 	TBL_NPC *nd;

+ 13 - 10
src/map/skill.c

@@ -440,10 +440,11 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
 		default:
 			{
 				struct status_data *status = status_get_status_data(src);
-				int min, max, wMatk, variance;
+				int min, max;
 
 				min = max = status_base_matk(status, status_get_lv(src));
 				if( status->rhw.matk > 0 ){
+					int wMatk, variance;
 					wMatk = status->rhw.matk;
 					variance = wMatk * status->rhw.wlv / 10;
 					min += wMatk - variance;
@@ -2304,7 +2305,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 		rdamage = battle_calc_return_damage(bl,src, &damage, dmg.flag, skill_id);
 
 	if( damage && sc && sc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){
-		struct block_list *nbl = NULL;
+		struct block_list *nbl;
 		nbl = battle_getenemyarea(bl,bl->x,bl->y,2,BL_CHAR,bl->id);
 		if( nbl ){ // Only one target is chosen.
 			damage = damage / 2; // Deflect half of the damage to a target nearby
@@ -3123,7 +3124,7 @@ static int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data)
 {
 	struct block_list *src = map_id2bl(id),*target;
 	struct unit_data *ud = unit_bl2ud(src);
-	struct skill_timerskill *skl = NULL;
+	struct skill_timerskill *skl;
 	int range;
 
 	nullpo_ret(src);
@@ -4953,7 +4954,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			{// mob-casted
 				struct unit_data *ud = unit_bl2ud(src);
 				int inf = skill_get_inf(abra_skill_id);
-				int target_id = 0;
 				if (!ud) break;
 				if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) {
 					if (src->type == BL_PET)
@@ -4961,6 +4961,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 					if (!bl) bl = src;
 					unit_skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv);
 				} else {	//Assume offensive skills
+					int target_id = 0;
 					if (ud->target)
 						target_id = ud->target;
 					else switch (src->type) {
@@ -6190,12 +6191,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 
 	case AM_BERSERKPITCHER:
 	case AM_POTIONPITCHER: {
-			int i,x,hp = 0,sp = 0,bonus=100;
+			int i,hp = 0,sp = 0;
 			if( dstmd && dstmd->class_ == MOBID_EMPERIUM ) {
 				map_freeblock_unlock();
 				return 1;
 			}
 			if( sd ) {
+				int x,bonus=100;
 				x = skill_lv%11 - 1;
 				i = pc_search_inventory(sd,skill_db[skill_id].itemid[x]);
 				if( i < 0 || skill_db[skill_id].itemid[x] <= 0 ) {
@@ -7079,11 +7081,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 					break;
 				case 3:	// 1000 damage, random armor destroyed
 					{
-						int where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM, EQP_SHOES, EQP_GARMENT };
 						status_fix_damage(src, bl, 1000, 0);
 						clif_damage(src,bl,tick,0,0,1000,0,0,0);
-						if( !status_isdead(bl) )
+						if( !status_isdead(bl) ) {
+							int where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM, EQP_SHOES, EQP_GARMENT };
 							skill_break_equip(bl, where[rnd()%5], 10000, BCT_ENEMY);
+						}
 					}
 					break;
 				case 4:	// atk halved
@@ -7252,7 +7255,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			int dx[9]={-1, 1, 0, 0,-1, 1,-1, 1, 0};
 			int dy[9]={ 0, 0, 1,-1, 1,-1,-1, 1, 0};
 			int j = 0;
-			struct guild *g = NULL;
+			struct guild *g;
 			// i don't know if it actually summons in a circle, but oh well. ;P
 			g = sd?sd->state.gmaster_flag:guild_search(status_get_guild_id(src));
 			if (!g)
@@ -8522,7 +8525,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			} else {
 				struct unit_data *ud = unit_bl2ud(src);
 				int inf = skill_get_inf(improv_skill_id);
-				int target_id = 0;
 				if (!ud) break;
 				if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) {
 					if (src->type == BL_PET)
@@ -8530,6 +8532,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 					if (!bl) bl = src;
 					unit_skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv);
 				} else {
+					int target_id = 0;
 					if (ud->target)
 						target_id = ud->target;
 					else switch (src->type) {
@@ -8594,7 +8597,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 	case SO_ARRULLO:
 		{
 			// [(15 + 5 * Skill Level) + ( Caster’s INT / 5 ) + ( Caster’s Job Level / 5 ) - ( Target’s INT / 6 ) - ( Target’s LUK / 10 )] %
-			int rate = (15 + 5 * skill_lv) + status_get_int(src)/5 + (sd)?sd->status.job_level:0;
+			int rate = (15 + 5 * skill_lv) + status_get_int(src)/5 + (sd ? sd->status.job_level : 0);
 			rate -= status_get_int(bl)/6 - status_get_luk(bl)/10;
 			clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
 			sc_start2(bl, type, rate, skill_lv, 1, skill_get_time(skill_id, skill_lv));

+ 5 - 4
src/map/status.c

@@ -4687,7 +4687,7 @@ static unsigned short status_calc_matk(struct block_list *bl, struct status_chan
     if (sc->data[SC_IZAYOI])
         matk += 50 * sc->data[SC_IZAYOI]->val1;
 #endif
-    if (sc->data[SC_MAGICPOWER])
+    if (sc->data[SC_MAGICPOWER] && sc->data[SC_MAGICPOWER]->val4)
         matk += matk * sc->data[SC_MAGICPOWER]->val3/100;
     if (sc->data[SC_MINDBREAKER])
         matk += matk * sc->data[SC_MINDBREAKER]->val2/100;
@@ -6283,7 +6283,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
 			tick -= (status->int_ + status->luk) / 20 * 1000;
 			break;
 		case SC_STASIS:
-			//5 second (fixed) + { Stasis Skill level * 5 - (Targets VIT + DEX) / 20 }
+			//5 second (fixed) + { Stasis Skill level * 5 - (Target's VIT + DEX) / 20 }
 			tick -= (status->vit + status->dex) / 20 * 1000;
 		break;
 	case SC_WHITEIMPRISON:
@@ -10671,9 +10671,10 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
 		if (battle_check_target( src, bl, BCT_ENEMY ) > 0 &&
 			status_check_skilluse(src, bl, WZ_SIGHTBLASTER, 2))
 		{
-			skill_attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,1,tick,0);
-			if (sce && !(bl->type&BL_SKILL)) //The hit is not counted if it's against a trap
+			if (sce && !(bl->type&BL_SKILL) //The hit is not counted if it's against a trap
+				&& skill_attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,1,tick,0)){
 				sce->val2 = 0; //This signals it to end.
+			}
 		}
 		break;
 	case SC_CLOSECONFINE: