Bug Fixes
* Fixed an operator check for WE_MALE and WE_FEMALE. Thanks Baalberith. Optimizations * Fixed a possible null pointer dereference in Spirit Ball check, Change Cart check, WE_BABY, MH_PYROCLASTIC, and MH_LIGHT_OF_REGENE. * Fixed a reassigned value being reset before being checked. * Fixed a homunculus expression always being false because of prior check. * Fixed sprintf specifier output trying to display int value when return value is unsigned int. * Fixed a redundant check for when monster's HP is less than 0 when HP is declared as an unsigned int. * Fixed a redundant check for when uAccLen or uTokenLen are less then 0 when both are declared as unsigned int. * Various other clean ups.
This commit is contained in:
parent
780b9d33d2
commit
eca4fa0e38
@ -1573,7 +1573,7 @@ int parse_login(int fd)
|
||||
|
||||
version = RFIFOL(fd,4);
|
||||
|
||||
if(uAccLen > NAME_LENGTH - 1 || uAccLen <= 0 || uTokenLen > NAME_LENGTH - 1 || uTokenLen <= 0)
|
||||
if(uAccLen > NAME_LENGTH - 1 || uAccLen == 0 || uTokenLen > NAME_LENGTH - 1 || uTokenLen == 0)
|
||||
{
|
||||
login_auth_failed(sd, 3);
|
||||
return 0;
|
||||
|
@ -2807,7 +2807,7 @@ ACMD_FUNC(char_ban)
|
||||
{
|
||||
char * modif_p;
|
||||
int32 timediff=0; //don't set this as uint as we may want to decrease banned time
|
||||
int bantype=2; //2=account block, 6=char specific
|
||||
int bantype=0; //2=account block, 6=char specific
|
||||
char output[256];
|
||||
|
||||
nullpo_retr(-1, sd);
|
||||
@ -2880,7 +2880,7 @@ ACMD_FUNC(char_unblock)
|
||||
* char unban command (usage: charunban <player_name>)
|
||||
*------------------------------------------*/
|
||||
ACMD_FUNC(char_unban){
|
||||
int unbantype=4;
|
||||
int unbantype=0;
|
||||
nullpo_retr(-1, sd);
|
||||
|
||||
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
|
||||
@ -7942,7 +7942,7 @@ ACMD_FUNC(duel)
|
||||
}
|
||||
|
||||
if( message[0] ) {
|
||||
if(sscanf(message, "%d", &maxpl) >= 1) {
|
||||
if(sscanf(message, "%ui", &maxpl) >= 1) {
|
||||
if(maxpl < 2 || maxpl > 65535) {
|
||||
clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
|
||||
return 0;
|
||||
@ -8653,7 +8653,7 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At
|
||||
if ( atcmd_binding_count ) {
|
||||
int i, count_bind, gm_lvl = pc_get_group_level(sd);
|
||||
for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
|
||||
if ( gm_lvl >= ( type -1 ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
|
||||
if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
|
||||
unsigned int slen = strlen(atcmd_binding[i]->command);
|
||||
if ( count_bind == 0 ) {
|
||||
cur = line_buff;
|
||||
@ -9143,12 +9143,12 @@ ACMD_FUNC(fontcolor)
|
||||
ACMD_FUNC(langtype)
|
||||
{
|
||||
char langstr[8];
|
||||
int i=0, test=0;
|
||||
int i=0, fail=0;
|
||||
|
||||
memset(langstr, '\0', sizeof(langstr));
|
||||
|
||||
if(sscanf(message, "%3s", langstr) >= 1){
|
||||
int lang=-1;
|
||||
int lang=0;
|
||||
lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
|
||||
if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
|
||||
char output[100];
|
||||
@ -9166,9 +9166,9 @@ ACMD_FUNC(langtype)
|
||||
//wrong or no entry
|
||||
clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
|
||||
clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
|
||||
while(test!=-1){ //out of range
|
||||
test = msg_checklangtype(i,false);
|
||||
if(test == 1)
|
||||
while(fail != -1){ //out of range
|
||||
fail = msg_checklangtype(i,false);
|
||||
if(fail == 1)
|
||||
clif_displaymessage(fd,msg_langtype2langstr(i));
|
||||
i++;
|
||||
}
|
||||
|
@ -5548,11 +5548,10 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
|
||||
if(mflag > 1) //Autocasted Blitz.
|
||||
nk|=NK_SPLASHSPLIT;
|
||||
|
||||
if (skill_id == SN_FALCONASSAULT)
|
||||
{
|
||||
if (skill_id == SN_FALCONASSAULT) {
|
||||
//Div fix of Blitzbeat
|
||||
skill = skill_get_num(HT_BLITZBEAT, 5);
|
||||
damage_div_fix(md.damage, skill);
|
||||
md.div_ = skill_get_num(HT_BLITZBEAT, 5);
|
||||
damage_div_fix(md.damage, md.div_);
|
||||
|
||||
//Falcon Assault Modifier
|
||||
md.damage=(int64)md.damage*(150+70*skill_lv)/100;
|
||||
|
@ -8746,7 +8746,7 @@ void clif_charnameack (int fd, struct block_list *bl)
|
||||
if( battle_config.show_mob_info&1 )
|
||||
str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
|
||||
if( battle_config.show_mob_info&2 )
|
||||
str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp));
|
||||
str_p += sprintf(str_p, "HP: %ui%% | ", get_percentage(md->status.hp, md->status.max_hp));
|
||||
//Even thought mobhp ain't a name, we send it as one so the client
|
||||
//can parse it. [Skotlex]
|
||||
if( str_p != mobhp )
|
||||
@ -11024,7 +11024,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
|
||||
{// TODO: State tracking?
|
||||
int type;
|
||||
|
||||
if( sd && pc_checkskill(sd, MC_CHANGECART) < 1 )
|
||||
if( !sd || pc_checkskill(sd, MC_CHANGECART) < 1 )
|
||||
return;
|
||||
|
||||
type = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
|
||||
|
@ -58,14 +58,14 @@ struct view_data* merc_get_hom_viewdata(int class_)
|
||||
|
||||
enum homun_type hom_class2type(int class_) {
|
||||
int mid = hom_class2mapid(class_);
|
||||
if(mid&(HOM_REG|HOM_EVO))
|
||||
if((mid&(HOM_REG|HOM_EVO)) == (HOM_REG|HOM_EVO))
|
||||
return HT_EVO;
|
||||
else if(mid&(HOM_REG))
|
||||
return HT_REG;
|
||||
else if(mid&(HOM_S))
|
||||
return HT_S;
|
||||
else //invalid type
|
||||
return -1;
|
||||
else
|
||||
return HT_INVALID;
|
||||
}
|
||||
|
||||
int hom_class2mapid(int hom_class)
|
||||
@ -73,23 +73,23 @@ int hom_class2mapid(int hom_class)
|
||||
switch(hom_class)
|
||||
{
|
||||
// Normal Homunculus
|
||||
case 6001: case 6005: return MAPID_LIF;
|
||||
case 6002: case 6006: return MAPID_AMISTR;
|
||||
case 6003: case 6007: return MAPID_FILIR;
|
||||
case 6004: case 6008: return MAPID_VANILMIRTH;
|
||||
case 6001: case 6005: return MAPID_LIF;
|
||||
case 6002: case 6006: return MAPID_AMISTR;
|
||||
case 6003: case 6007: return MAPID_FILIR;
|
||||
case 6004: case 6008: return MAPID_VANILMIRTH;
|
||||
// Evolved Homunculus
|
||||
case 6009: case 6013: return MAPID_LIF_E;
|
||||
case 6010: case 6014: return MAPID_AMISTR_E;
|
||||
case 6011: case 6015: return MAPID_FILIR_E;
|
||||
case 6012: case 6016: return MAPID_VANILMIRTH_E;
|
||||
case 6009: case 6013: return MAPID_LIF_E;
|
||||
case 6010: case 6014: return MAPID_AMISTR_E;
|
||||
case 6011: case 6015: return MAPID_FILIR_E;
|
||||
case 6012: case 6016: return MAPID_VANILMIRTH_E;
|
||||
// Homunculus S
|
||||
case 6048: return MAPID_EIRA;
|
||||
case 6049: return MAPID_BAYERI;
|
||||
case 6050: return MAPID_SERA;
|
||||
case 6051: return MAPID_DIETER;
|
||||
case 6052: return MAPID_ELANOR;
|
||||
case 6048: return MAPID_EIRA;
|
||||
case 6049: return MAPID_BAYERI;
|
||||
case 6050: return MAPID_SERA;
|
||||
case 6051: return MAPID_DIETER;
|
||||
case 6052: return MAPID_ELANOR;
|
||||
|
||||
default: return -1;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,10 @@ enum {
|
||||
MAPID_ELANOR,
|
||||
};
|
||||
enum homun_type {
|
||||
HT_REG = 0x1,
|
||||
HT_EVO = 0x2,
|
||||
HT_S = 0x4,
|
||||
HT_REG = 0x1,
|
||||
HT_EVO = 0x2,
|
||||
HT_S = 0x4,
|
||||
HT_INVALID = -1,
|
||||
};
|
||||
|
||||
#define homdb_checkid(id) (id >= HM_CLASS_BASE && id <= HM_CLASS_MAX)
|
||||
|
@ -1417,7 +1417,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
|
||||
int mode;
|
||||
int view_range, can_move;
|
||||
|
||||
if(md->bl.prev == NULL || md->status.hp <= 0)
|
||||
if(md->bl.prev == NULL || md->status.hp == 0)
|
||||
return false;
|
||||
|
||||
if (DIFF_TICK(tick, md->last_thinktime) < MIN_MOBTHINKTIME)
|
||||
@ -3338,7 +3338,7 @@ int mobskill_event(struct mob_data *md, struct block_list *src, unsigned int tic
|
||||
{
|
||||
int target_id, res = 0;
|
||||
|
||||
if(md->bl.prev == NULL || md->status.hp <= 0)
|
||||
if(md->bl.prev == NULL || md->status.hp == 0)
|
||||
return 0;
|
||||
|
||||
target_id = md->target_id;
|
||||
|
@ -274,7 +274,7 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
|
||||
{
|
||||
int heap[MAX_HEAP+1];
|
||||
struct tmp_path tp[MAX_WALKPATH*MAX_WALKPATH];
|
||||
register int i,j,len,x,y,dx,dy;
|
||||
register int i,j,len,x,y,dx=0,dy=0;
|
||||
int rp,xs,ys;
|
||||
struct map_data *md;
|
||||
struct walkpath_data s_wpd;
|
||||
|
@ -6887,7 +6887,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
||||
//Reset ticks.
|
||||
sd->hp_loss.tick = sd->sp_loss.tick = sd->hp_regen.tick = sd->sp_regen.tick = 0;
|
||||
|
||||
if ( sd && (sd->spiritball)!=0 )
|
||||
if ( sd->spiritball !=0 )
|
||||
pc_delspiritball(sd,sd->spiritball,0);
|
||||
|
||||
for(i = 1; i < 5; i++)
|
||||
|
@ -1659,14 +1659,13 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
|
||||
skill = (sd->autospell[i].id > 0) ? sd->autospell[i].id : -sd->autospell[i].id;
|
||||
|
||||
sd->state.autocast = 1;
|
||||
if ( skill_isNotOk(skill, sd) )
|
||||
continue;
|
||||
sd->state.autocast = 0;
|
||||
|
||||
skill_lv = sd->autospell[i].lv?sd->autospell[i].lv:1;
|
||||
if (skill_lv < 0) skill_lv = 1+rnd()%(-skill_lv);
|
||||
|
||||
if ( skill_isNotOk(skill, sd) )
|
||||
continue;
|
||||
|
||||
rate = (!sd->state.arrow_atk) ? sd->autospell[i].rate : sd->autospell[i].rate / 2;
|
||||
|
||||
if (rnd()%1000 >= rate)
|
||||
@ -2002,10 +2001,9 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
|
||||
rate>>=1;
|
||||
|
||||
dstsd->state.autocast = 1;
|
||||
dstsd->state.autocast = 0;
|
||||
|
||||
if ( skill_isNotOk(skill_id, dstsd) )
|
||||
continue;
|
||||
dstsd->state.autocast = 0;
|
||||
|
||||
if (rnd()%1000 >= rate)
|
||||
continue;
|
||||
@ -7255,14 +7253,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
|
||||
break;
|
||||
|
||||
case WE_MALE:
|
||||
if( status_get_hp(bl) < status_get_max_hp(bl) / 10 ) {
|
||||
if( status_get_hp(bl) > status_get_max_hp(bl) / 10 ) {
|
||||
int hp_rate=(!skill_lv)? 0:skill_get_hp_rate(skill_id, skill_lv);
|
||||
int gain_hp= tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it costed the caster. [Skotlex]
|
||||
clif_skill_nodamage(src,bl,skill_id,status_heal(bl, gain_hp, 0, 0),1);
|
||||
}
|
||||
break;
|
||||
case WE_FEMALE:
|
||||
if( status_get_sp(bl) < status_get_max_sp(bl) / 10 ) {
|
||||
if( status_get_sp(bl) > status_get_max_sp(bl) / 10 ) {
|
||||
int sp_rate=(!skill_lv)? 0:skill_get_sp_rate(skill_id, skill_lv);
|
||||
int gain_sp=tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it costed the caster. [Skotlex]
|
||||
clif_skill_nodamage(src,bl,skill_id,status_heal(bl, 0, gain_sp, 0),1);
|
||||
@ -7274,16 +7272,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
|
||||
if(sd){
|
||||
struct map_session_data *f_sd = pc_get_father(sd);
|
||||
struct map_session_data *m_sd = pc_get_mother(sd);
|
||||
struct block_list *b_bl = map_id2bl(sd->bl.id);
|
||||
struct block_list *f_bl = map_id2bl(f_sd->bl.id);
|
||||
struct block_list *m_bl = map_id2bl(m_sd->bl.id);
|
||||
if( (!f_sd && !m_sd) // if neither was found
|
||||
|| (sd->status.party_id != 0 && //not in same party
|
||||
((!f_sd || sd->status.party_id != f_sd->status.party_id)
|
||||
&& (!m_sd || sd->status.party_id != m_sd->status.party_id) //if both are online they should all be in same team
|
||||
))
|
||||
|| ((!f_sd || !check_distance_bl(b_bl, f_bl, AREA_SIZE)) //not in same screen
|
||||
&& (!m_bl && !check_distance_bl(b_bl, m_bl, AREA_SIZE)))
|
||||
|| ((!f_sd || !check_distance_bl(&sd->bl, &f_sd->bl, AREA_SIZE)) //not in same screen
|
||||
&& (!m_sd || !check_distance_bl(&sd->bl, &m_sd->bl, AREA_SIZE)))
|
||||
) {
|
||||
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
|
||||
map_freeblock_unlock();
|
||||
@ -9702,19 +9697,19 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
|
||||
break;
|
||||
case MH_GRANITIC_ARMOR:
|
||||
case MH_PYROCLASTIC:
|
||||
{
|
||||
struct block_list *s_bl = battle_get_master(src);
|
||||
if(s_bl) sc_start2(src, s_bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv)); //start on master
|
||||
sc_start2(src, bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv));
|
||||
if (hd) skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv));
|
||||
if(hd) {
|
||||
struct block_list *s_bl = battle_get_master(src);
|
||||
if(s_bl) sc_start2(src, s_bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv)); //start on master
|
||||
sc_start2(src, bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv));
|
||||
skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv));
|
||||
}
|
||||
break;
|
||||
case MH_LIGHT_OF_REGENE: //self
|
||||
sc_start2(src, src, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv));
|
||||
if(hd) {
|
||||
hd->homunculus.intimacy = 251; //change to neutral (can't be cast if < 750)
|
||||
if(sd) clif_send_homdata(sd, SP_INTIMATE, hd->homunculus.intimacy); //refresh intimacy info
|
||||
skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv));
|
||||
sc_start2(src, src, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv));
|
||||
hd->homunculus.intimacy = 251; //change to neutral (can't be cast if < 750)
|
||||
if(sd) clif_send_homdata(sd, SP_INTIMATE, hd->homunculus.intimacy); //refresh intimacy info
|
||||
skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv));
|
||||
}
|
||||
break;
|
||||
case MH_STYLE_CHANGE:
|
||||
|
Loading…
x
Reference in New Issue
Block a user