summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c14
-rw-r--r--src/char/int_guild.c11
-rw-r--r--src/common/core.c2
-rw-r--r--src/common/grfio.c16
-rw-r--r--src/common/raconf.c6
-rw-r--r--src/common/socket.c6
-rw-r--r--src/login/account_sql.c2
-rw-r--r--src/login/login.c7
-rw-r--r--src/map/atcommand.c43
-rw-r--r--src/map/battle.c11
-rw-r--r--src/map/chat.c4
-rw-r--r--src/map/chrif.c3
-rw-r--r--src/map/clif.c16
-rw-r--r--src/map/guild.c2
-rw-r--r--src/map/homunculus.c6
-rw-r--r--src/map/itemdb.c2
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/mob.c20
-rw-r--r--src/map/npc.c14
-rw-r--r--src/map/party.c5
-rw-r--r--src/map/pc.c33
-rw-r--r--src/map/pc_groups.c2
-rw-r--r--src/map/pet.c6
-rw-r--r--src/map/script.c15
-rw-r--r--src/map/skill.c21
25 files changed, 140 insertions, 131 deletions
diff --git a/src/char/char.c b/src/char/char.c
index e7220aa36..cd1b1da66 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2833,8 +2833,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);
@@ -2851,6 +2849,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;
@@ -2880,7 +2880,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;
@@ -2898,6 +2897,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.
@@ -4571,25 +4571,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));
}
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 7c2086722..46bba63db 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -217,8 +217,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);
@@ -509,7 +509,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);
}
@@ -604,7 +604,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;
}
@@ -1262,7 +1262,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 )
@@ -1285,6 +1285,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 )
{
diff --git a/src/common/core.c b/src/common/core.c
index 4495cf1a2..b004d2b96 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -272,7 +272,7 @@ const char *get_git_hash (void) {
char line[64];
char *rev = malloc (sizeof (char) * 50);
- if (fgets (line, sizeof (line), fp) && sscanf (line, "%s", rev))
+ if (fgets (line, sizeof (line), fp) && sscanf (line, "%50s", rev))
snprintf (HerculesGitHash, sizeof (HerculesGitHash), "%s", rev);
free (rev);
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 8f430cfb9..cc2f866f7 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -393,12 +393,12 @@ void* grfio_reads(const char* fname, int* size)
FILELIST* entry = filelist_find(fname);
if( entry == NULL || entry->gentry <= 0 ) {// LocalFileCheck
char lfname[256];
- int declen;
FILE* in;
grfio_localpath_create(lfname, sizeof(lfname), ( entry && entry->fnd ) ? entry->fnd : fname);
in = fopen(lfname, "rb");
if( in != NULL ) {
+ int declen;
fseek(in,0,SEEK_END);
declen = ftell(in);
fseek(in,0,SEEK_SET);
@@ -475,14 +475,14 @@ static char* decode_filename(unsigned char* buf, int len)
/// @return true if the file should undergo full mode 0 decryption, and true otherwise.
static bool isFullEncrypt(const char* fname)
{
- static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" };
- size_t i;
-
const char* ext = strrchr(fname, '.');
- if( ext != NULL )
+ if( ext != NULL ) {
+ static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" };
+ size_t i;
for( i = 0; i < ARRAYLENGTH(extensions); ++i )
if( strcmpi(ext, extensions[i]) == 0 )
return false;
+ }
return true;
}
@@ -492,7 +492,7 @@ static bool isFullEncrypt(const char* fname)
/// @param gentry index of the grf file name in the gentry_table
static int grfio_entryread(const char* grfname, int gentry)
{
- long grf_size,list_size;
+ long grf_size;
unsigned char grf_header[0x2e];
int entry,entrys,ofs,grf_version;
unsigned char *grf_filelist;
@@ -518,6 +518,7 @@ static int grfio_entryread(const char* grfname, int gentry)
grf_version = getlong(grf_header+0x2a) >> 8;
if( grf_version == 0x01 ) {// ****** Grf version 01xx ******
+ long list_size;
list_size = grf_size - ftell(fp);
grf_filelist = (unsigned char *) aMalloc(list_size);
if(fread(grf_filelist,1,list_size,fp) != list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); }
@@ -678,7 +679,7 @@ static bool grfio_parse_restable_row(const char* row)
static void grfio_resourcecheck(void)
{
char restable[256];
- char *ptr, *buf;
+ char *buf;
int size;
FILE* fp;
int i = 0;
@@ -705,6 +706,7 @@ static void grfio_resourcecheck(void)
buf = (char *)grfio_reads("data\\resnametable.txt", &size);
if( buf != NULL )
{
+ char *ptr;
buf[size] = '\0';
ptr = buf;
diff --git a/src/common/raconf.c b/src/common/raconf.c
index 2703560ff..f7d1284b7 100644
--- a/src/common/raconf.c
+++ b/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 == '.'){
diff --git a/src/common/socket.c b/src/common/socket.c
index 6977d4257..72633cf2b 100644
--- a/src/common/socket.c
+++ b/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
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index ae80163af..f89147334 100644
--- a/src/login/account_sql.c
+++ b/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) )
{
diff --git a/src/login/login.c b/src/login/login.c
index 1ced8cb93..54f066b53 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -1606,10 +1606,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);
@@ -1654,10 +1655,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) {
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 320ca83ff..ed42fdad4 100644
--- a/src/map/atcommand.c
+++ b/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;
}
@@ -5785,7 +5785,6 @@ ACMD_FUNC(partyoption)
ACMD_FUNC(autoloot)
{
int rate;
- double drate;
nullpo_retr(-1, sd);
// autoloot command without value
if(!message || !*message)
@@ -5795,6 +5794,7 @@ ACMD_FUNC(autoloot)
else
rate = 10000;
} else {
+ double drate;
drate = atof(message);
rate = (int)(drate*100);
}
@@ -6649,12 +6649,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] == '/' )
@@ -7729,7 +7730,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;
@@ -7770,9 +7771,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);
@@ -7786,6 +7785,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);
@@ -7800,8 +7800,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 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."
@@ -7838,9 +7840,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);
@@ -8608,7 +8609,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"
@@ -9425,7 +9426,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;
@@ -9466,8 +9467,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);
diff --git a/src/map/battle.c b/src/map/battle.c
index cfb3df52e..3140fbc18 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -338,13 +338,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);
@@ -4560,7 +4560,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;
@@ -4596,9 +4596,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 = min(damage,status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
*dmg = 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);
@@ -4993,9 +4993,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;
@@ -6109,7 +6110,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;
@@ -6123,6 +6123,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] == '/')
diff --git a/src/map/chat.c b/src/map/chat.c
index dfeb16cad..282b1730e 100644
--- a/src/map/chat.c
+++ b/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);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 573fd8501..484e48df8 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -863,7 +863,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);
@@ -880,6 +880,7 @@ int chrif_changedsex(int fd) {
// reset skill of some job
if ((sd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER) {
+ 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) {
diff --git a/src/map/clif.c b/src/map/clif.c
index ed2044127..b7117a64a 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -210,9 +210,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);
@@ -1221,12 +1221,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;
@@ -2977,7 +2976,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;
@@ -6457,12 +6456,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;
@@ -6869,7 +6868,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));
@@ -6886,6 +6884,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;
@@ -7823,7 +7822,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);
@@ -7831,6 +7829,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);
@@ -8434,7 +8433,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;
@@ -8458,6 +8457,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;
}
diff --git a/src/map/guild.c b/src/map/guild.c
index 780154590..f6d4f5c49 100644
--- a/src/map/guild.c
+++ b/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));
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 6cc671526..9a0a1c898 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -304,7 +304,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) {
@@ -353,6 +352,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,
@@ -1149,10 +1149,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) )
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 68baae1e1..79d303085 100644
--- a/src/map/itemdb.c
+++ b/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]);
diff --git a/src/map/map.c b/src/map/map.c
index c02506073..b43fc2f1a 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2309,7 +2309,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.
@@ -2710,7 +2710,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);
diff --git a/src/map/mob.c b/src/map/mob.c
index dbbf4f30c..5b55acce4 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1407,9 +1407,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)
@@ -1482,6 +1480,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
@@ -1548,6 +1547,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);
}
@@ -2101,7 +2101,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;
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;
@@ -3618,9 +3618,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;
@@ -3771,7 +3771,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) {
@@ -3783,6 +3782,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
@@ -3892,10 +3892,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))
{
@@ -4459,10 +4458,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))
{
@@ -4560,11 +4558,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;
diff --git a/src/map/npc.c b/src/map/npc.c
index d734381af..f72f6532c 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -492,7 +492,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);
@@ -530,6 +529,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 )
@@ -564,10 +564,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);
@@ -591,6 +590,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
@@ -1846,7 +1847,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);
@@ -3229,9 +3230,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)
@@ -3244,6 +3245,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;
diff --git a/src/map/party.c b/src/map/party.c
index f6b711791..d633170bd 100644
--- a/src/map/party.c
+++ b/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 &&
diff --git a/src/map/pc.c b/src/map/pc.c
index 77b9948c4..f601d851b 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -481,7 +481,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 )
@@ -489,6 +488,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
@@ -1361,14 +1361,15 @@ 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)
@@ -1390,6 +1391,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 && (
@@ -3669,7 +3671,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);
@@ -3699,6 +3700,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));
}
@@ -4214,7 +4216,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);
@@ -4264,6 +4266,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 );
@@ -6770,11 +6773,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;
@@ -7182,9 +7185,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;
@@ -8548,13 +8552,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 ) {
@@ -8571,13 +8575,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 ) {
@@ -8700,8 +8704,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;
@@ -8709,6 +8711,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 ) {
@@ -8731,13 +8734,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;
@@ -8815,7 +8818,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 *);
@@ -8850,7 +8853,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)
@@ -9486,7 +9489,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;
}
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 3111e2788..31ae03e2a 100644
--- a/src/map/pc_groups.c
+++ b/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();
diff --git a/src/map/pet.c b/src/map/pet.c
index 5c7f15151..f64012e69 100644
--- a/src/map/pet.c
+++ b/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++){
diff --git a/src/map/script.c b/src/map/script.c
index dd137d575..8827509ba 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10577,9 +10577,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;
@@ -16339,12 +16338,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 party_data *p;
+ struct map_session_data *sd;
+ int type;
type = script_getnum(st, 2);
if( type == 0 )
instance_id = st->instance_id;
@@ -16852,7 +16852,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 )
@@ -16861,6 +16861,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 :
@@ -16937,7 +16938,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) )
@@ -16946,6 +16946,7 @@ BUILDIN_FUNC(getcharip)
sd = map_nick2sd(script_getstr(st, 2));
else if (script_isint(st, 2) || script_getnum(st, 2))
{
+ int id;
id = script_getnum(st, 2);
sd = (map_id2sd(id) ? map_id2sd(id) : map_charid2sd(id));
}
diff --git a/src/map/skill.c b/src/map/skill.c
index 51124e93b..26d63f8ac 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -441,10 +441,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;
@@ -2305,7 +2306,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
@@ -3124,7 +3125,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);
@@ -4954,7 +4955,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)
@@ -4962,6 +4962,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) {
@@ -6191,12 +6192,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 ) {
@@ -7080,11 +7082,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
@@ -7253,7 +7256,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)
@@ -8523,7 +8526,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)
@@ -8531,6 +8533,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) {