Browse Source

Fixed some misc. stuff (#1974)

* Empty string checking
* Unsigned/signed variables changed to fit their context
* Assignment order within if clause
* hom_is_active already checks for sd->hd
* Fixed SC_MDEFSET being set by the wrong condition
* channel_ajoin inner for has same iter variable as outer
Matheus Macabu 8 years ago
parent
commit
4a2964f763
9 changed files with 21 additions and 18 deletions
  1. 1 1
      src/char/int_storage.c
  2. 2 3
      src/map/atcommand.c
  3. 1 1
      src/map/battle.c
  4. 3 3
      src/map/channel.c
  5. 1 1
      src/map/chrif.c
  6. 1 1
      src/map/clif.c
  7. 2 1
      src/map/script.c
  8. 3 2
      src/map/skill.c
  9. 7 5
      src/map/status.c

+ 1 - 1
src/char/int_storage.c

@@ -173,7 +173,7 @@ static void inter_storage_checkDB(void) {
 	int i = 0;
 	int i = 0;
 	// Checking storage tables
 	// Checking storage tables
 	for (i = 0; i < interserv_config.storage_count; i++) {
 	for (i = 0; i < interserv_config.storage_count; i++) {
-		if (!&interserv_config.storages[i] || !interserv_config.storages[i].name || !interserv_config.storages[i].table || interserv_config.storages[i].table == '\0')
+		if (!&interserv_config.storages[i] || !interserv_config.storages[i].name || !interserv_config.storages[i].table || *interserv_config.storages[i].table == '\0')
 			continue;
 			continue;
 		if (SQL_ERROR == Sql_Query(sql_handle, "SELECT  `id`,`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,"
 		if (SQL_ERROR == Sql_Query(sql_handle, "SELECT  `id`,`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,"
 			"`attribute`,`card0`,`card1`,`card2`,`card3`,`option_id0`,`option_val0`,`option_parm0`,`option_id1`,`option_val1`,`option_parm1`,"
 			"`attribute`,`card0`,`card1`,`card2`,`card3`,`option_id0`,`option_val0`,`option_parm0`,`option_id1`,`option_val1`,`option_parm1`,"

+ 2 - 3
src/map/atcommand.c

@@ -5725,8 +5725,7 @@ ACMD_FUNC(useskill)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if (SKILL_CHK_HOMUN(skill_id)
-		&& sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
+	if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
 		bl = &sd->hd->bl;
 		bl = &sd->hd->bl;
 	else
 	else
 		bl = &sd->bl;
 		bl = &sd->bl;
@@ -9203,7 +9202,7 @@ ACMD_FUNC(set) {
 				break;
 				break;
 		}
 		}
 
 
-		if( value == NULL || value == '\0' ){// empty string
+		if( value == NULL || *value == '\0' ){// empty string
 			sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
 			sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
 		}else{
 		}else{
 			sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
 			sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s

+ 1 - 1
src/map/battle.c

@@ -3705,7 +3705,7 @@ static int battle_calc_attack_skill_ratio(struct Damage wd, struct block_list *s
 			break;
 			break;
 #endif
 #endif
 		case KN_CHARGEATK: { // +100% every 3 cells of distance but hard-limited to 500%
 		case KN_CHARGEATK: { // +100% every 3 cells of distance but hard-limited to 500%
-				unsigned int k = (wd.miscflag-1)/3;
+				int k = (wd.miscflag-1)/3;
 				if (k < 0)
 				if (k < 0)
 					k = 0;
 					k = 0;
 				else if (k > 4)
 				else if (k > 4)

+ 3 - 3
src/map/channel.c

@@ -182,7 +182,7 @@ int channel_mjoin(struct map_session_data *sd) {
  *  -1 : invalid guild or no channel for guild
  *  -1 : invalid guild or no channel for guild
  */
  */
 int channel_ajoin(struct guild *g){
 int channel_ajoin(struct guild *g){
-	int i;
+	int i, j;
 	struct map_session_data *pl_sd;
 	struct map_session_data *pl_sd;
 
 
 	if(!g || !g->channel) return -1;
 	if(!g || !g->channel) return -1;
@@ -190,8 +190,8 @@ int channel_ajoin(struct guild *g){
 		struct guild *ag; //allied guld
 		struct guild *ag; //allied guld
 		struct guild_alliance *ga = &g->alliance[i]; //guild alliance
 		struct guild_alliance *ga = &g->alliance[i]; //guild alliance
 		if(ga->guild_id && (ga->opposition==0) && (ag=guild_search(ga->guild_id))){
 		if(ga->guild_id && (ga->opposition==0) && (ag=guild_search(ga->guild_id))){
-			for (i = 0; i < ag->max_member; i++){ //load all guildmember
-				pl_sd = ag->member[i].sd;
+			for (j = 0; j < ag->max_member; j++){ //load all guildmember
+				pl_sd = ag->member[j].sd;
 				if(channel_haspc(ag->channel,pl_sd)==1)  //only if they are in their own guildchan
 				if(channel_haspc(ag->channel,pl_sd)==1)  //only if they are in their own guildchan
 					channel_join(g->channel,pl_sd);
 					channel_join(g->channel,pl_sd);
 			}
 			}

+ 1 - 1
src/map/chrif.c

@@ -354,7 +354,7 @@ int chrif_save(struct map_session_data *sd, enum e_chrif_save_opt flag) {
 
 
 	if( sd->status.pet_id > 0 && sd->pd )
 	if( sd->status.pet_id > 0 && sd->pd )
 		intif_save_petdata(sd->status.account_id,&sd->pd->pet);
 		intif_save_petdata(sd->status.account_id,&sd->pd->pet);
-	if( sd->hd && hom_is_active(sd->hd) )
+	if( hom_is_active(sd->hd) )
 		hom_save(sd->hd);
 		hom_save(sd->hd);
 	if( sd->md && mercenary_get_lifetime(sd->md) > 0 )
 	if( sd->md && mercenary_get_lifetime(sd->md) > 0 )
 		mercenary_save(sd->md);
 		mercenary_save(sd->md);

+ 1 - 1
src/map/clif.c

@@ -1676,7 +1676,7 @@ void clif_homskillup(struct map_session_data *sd, uint16 skill_id)
 	short idx = -1;
 	short idx = -1;
 	nullpo_retv(sd);
 	nullpo_retv(sd);
 
 
-	if ((idx = hom_skill_get_index(skill_id) == -1))
+	if ((idx = hom_skill_get_index(skill_id)) == -1)
 		return;
 		return;
 
 
 	fd = sd->fd;
 	fd = sd->fd;

+ 2 - 1
src/map/script.c

@@ -10179,7 +10179,8 @@ BUILDIN_FUNC(killmonsterall)
 BUILDIN_FUNC(clone)
 BUILDIN_FUNC(clone)
 {
 {
 	TBL_PC *sd, *msd=NULL;
 	TBL_PC *sd, *msd=NULL;
-	uint32 char_id, master_id = 0, x, y, flag = 0, m;
+	uint32 char_id, master_id = 0, x, y, flag = 0;
+	int16 m;
 	enum e_mode mode = 0;
 	enum e_mode mode = 0;
 
 
 	unsigned int duration = 0;
 	unsigned int duration = 0;

+ 3 - 2
src/map/skill.c

@@ -1949,7 +1949,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
 			if (sd->def_set_race[tstatus->race].rate)
 			if (sd->def_set_race[tstatus->race].rate)
 				status_change_start(src,bl, SC_DEFSET, sd->def_set_race[tstatus->race].rate, sd->def_set_race[tstatus->race].value,
 				status_change_start(src,bl, SC_DEFSET, sd->def_set_race[tstatus->race].rate, sd->def_set_race[tstatus->race].value,
 					0, 0, 0, sd->def_set_race[tstatus->race].tick, SCSTART_NOTICKDEF);
 					0, 0, 0, sd->def_set_race[tstatus->race].tick, SCSTART_NOTICKDEF);
-			if (sd->def_set_race[tstatus->race].rate)
+			if (sd->mdef_set_race[tstatus->race].rate)
 				status_change_start(src,bl, SC_MDEFSET, sd->mdef_set_race[tstatus->race].rate, sd->mdef_set_race[tstatus->race].value,
 				status_change_start(src,bl, SC_MDEFSET, sd->mdef_set_race[tstatus->race].rate, sd->mdef_set_race[tstatus->race].value,
 					0, 0, 0, sd->mdef_set_race[tstatus->race].tick, SCSTART_NOTICKDEF);
 					0, 0, 0, sd->mdef_set_race[tstatus->race].tick, SCSTART_NOTICKDEF);
 			if (sd->norecover_state_race[tstatus->race].rate)
 			if (sd->norecover_state_race[tstatus->race].rate)
@@ -19460,7 +19460,8 @@ int skill_magicdecoy(struct map_session_data *sd, unsigned short nameid) {
 	pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
 	pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
 	x = sd->sc.comet_x;
 	x = sd->sc.comet_x;
 	y = sd->sc.comet_y;
 	y = sd->sc.comet_y;
-	sd->sc.comet_x = sd->sc.comet_y = 0;
+	sd->sc.comet_x = 0;
+	sd->sc.comet_y = 0;
 	sd->menuskill_val = 0;
 	sd->menuskill_val = 0;
 
 
 	// Item picked decides the mob class
 	// Item picked decides the mob class

+ 7 - 5
src/map/status.c

@@ -4947,11 +4947,13 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
 				int variance = 0;
 				int variance = 0;
 
 
 				// Any +MATK you get from skills and cards, including cards in weapon, is added here.
 				// Any +MATK you get from skills and cards, including cards in weapon, is added here.
-				if (sd->bonus.ematk > 0)
-					status->matk_min += sd->bonus.ematk;
-				if (sd && pc_checkskill(sd, SU_POWEROFLAND) > 0) {
-					if (pc_checkskill(sd, SU_SV_STEMSPEAR) == 5 && pc_checkskill(sd, SU_CN_POWDERING) == 5 && pc_checkskill(sd, SU_CN_METEOR) == 5 && pc_checkskill(sd, SU_SV_ROOTTWIST) == 5)
-						status->matk_min += status->matk_min * 20 / 100;
+				if (sd) {
+					if (sd->bonus.ematk > 0)
+						status->matk_min += sd->bonus.ematk;
+					if (pc_checkskill(sd, SU_POWEROFLAND) > 0) {
+						if (pc_checkskill(sd, SU_SV_STEMSPEAR) == 5 && pc_checkskill(sd, SU_CN_POWDERING) == 5 && pc_checkskill(sd, SU_CN_METEOR) == 5 && pc_checkskill(sd, SU_SV_ROOTTWIST) == 5)
+							status->matk_min += status->matk_min * 20 / 100;
+					}
 				}
 				}
 
 
 				status->matk_min = status_calc_ematk(bl, sc, status->matk_min);
 				status->matk_min = status_calc_ematk(bl, sc, status->matk_min);