* Fixed bonus_script doesn't remove Status Icon when timer is over (bugreport:9341)

* Some little code stylization

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
Cydh Ramdh 2014-10-19 20:59:44 +07:00
parent a52b010668
commit 03dc02d4d6
4 changed files with 38 additions and 32 deletions

View File

@ -11018,11 +11018,13 @@ int pc_bonus_script_timer(int tid, unsigned int tick, int id, intptr_t data) {
return 0; return 0;
} }
if (i > MAX_PC_BONUS_SCRIPT|| !(&sd->bonus_script[i]) || !sd->bonus_script[i].script) { if (i >= MAX_PC_BONUS_SCRIPT || !(&sd->bonus_script[i]) || !sd->bonus_script[i].script) {
ShowDebug("pc_bonus_script_timer: Invalid index %d\n",i); ShowDebug("pc_bonus_script_timer: Invalid index %d\n",i);
return 0; return 0;
} }
if (sd->bonus_script[i].icon != SI_BLANK)
clif_status_load(&sd->bl, sd->bonus_script[i].icon, 0);
pc_bonus_script_remove(&sd->bonus_script[i]); pc_bonus_script_remove(&sd->bonus_script[i]);
status_calc_pc(sd,SCO_NONE); status_calc_pc(sd,SCO_NONE);
return 0; return 0;
@ -11067,7 +11069,8 @@ void pc_bonus_script_clear(struct map_session_data *sd, uint16 flag) {
(flag&BSF_REM_DEBUFF && sd->bonus_script[i].type == 2)) //Remove bonus script based on debuff type (flag&BSF_REM_DEBUFF && sd->bonus_script[i].type == 2)) //Remove bonus script based on debuff type
))) )))
{ {
clif_status_change(&sd->bl,sd->bonus_script[i].icon,0,0,0,0,0); if (sd->bonus_script[i].icon != SI_BLANK)
clif_status_load(&sd->bl, sd->bonus_script[i].icon, 0);
pc_bonus_script_remove(&sd->bonus_script[i]); pc_bonus_script_remove(&sd->bonus_script[i]);
count++; count++;
} }
@ -11092,7 +11095,8 @@ void pc_bonus_script_clear_all(struct map_session_data *sd, bool permanent) {
continue; continue;
if (!permanent && sd->bonus_script[i].flag&BSF_PERMANENT) if (!permanent && sd->bonus_script[i].flag&BSF_PERMANENT)
continue; continue;
clif_status_change(&sd->bl,sd->bonus_script[i].icon,0,0,0,0,0); if (sd->bonus_script[i].icon != SI_BLANK)
clif_status_load(&sd->bl, sd->bonus_script[i].icon, 0);
pc_bonus_script_remove(&sd->bonus_script[i]); pc_bonus_script_remove(&sd->bonus_script[i]);
count++; count++;
} }

View File

@ -346,6 +346,7 @@ struct map_session_data {
short sp_gain_race_attack[RC_MAX]; short sp_gain_race_attack[RC_MAX];
short hp_gain_race_attack[RC_MAX]; short hp_gain_race_attack[RC_MAX];
// zeroed arrays end here. // zeroed arrays end here.
// zeroed structures start here // zeroed structures start here
struct s_autospell autospell[MAX_PC_BONUS], autospell2[MAX_PC_BONUS], autospell3[MAX_PC_BONUS]; struct s_autospell autospell[MAX_PC_BONUS], autospell2[MAX_PC_BONUS], autospell3[MAX_PC_BONUS];
struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS]; struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
@ -354,7 +355,7 @@ struct map_session_data {
struct s_skill_bonus { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills. struct s_skill_bonus { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
unsigned short id; unsigned short id;
short val; short val;
} skillatk[MAX_PC_BONUS], skillusesprate[MAX_PC_BONUS], skillusesp[MAX_PC_BONUS], skillheal[5], skillheal2[5], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS], skillcooldown[MAX_PC_BONUS], skillfixcast[MAX_PC_BONUS], skillvarcast[MAX_PC_BONUS], skillfixcastrate[MAX_PC_BONUS]; } skillatk[MAX_PC_BONUS], skillusesprate[MAX_PC_BONUS], skillusesp[MAX_PC_BONUS], skillheal[MAX_PC_BONUS], skillheal2[MAX_PC_BONUS], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS], skillcooldown[MAX_PC_BONUS], skillfixcast[MAX_PC_BONUS], skillvarcast[MAX_PC_BONUS], skillfixcastrate[MAX_PC_BONUS];
struct s_regen { struct s_regen {
short value; short value;
int rate; int rate;
@ -377,9 +378,11 @@ struct map_session_data {
int rate, tick; int rate, tick;
} def_set_race[RC_MAX], mdef_set_race[RC_MAX]; } def_set_race[RC_MAX], mdef_set_race[RC_MAX];
// zeroed structures end here // zeroed structures end here
// manually zeroed structures start here. // manually zeroed structures start here.
struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
// manually zeroed structures end here. // manually zeroed structures end here.
// zeroed vars start here. // zeroed vars start here.
struct s_bonus { struct s_bonus {
int hp, sp; int hp, sp;
@ -421,7 +424,6 @@ struct map_session_data {
int ematk; // matk bonus from equipment int ematk; // matk bonus from equipment
int eatk; // atk bonus from equipment int eatk; // atk bonus from equipment
} bonus; } bonus;
// zeroed vars end here. // zeroed vars end here.
int castrate,delayrate,hprate,sprate,dsprate; int castrate,delayrate,hprate,sprate,dsprate;

View File

@ -2825,11 +2825,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
status = &sd->base_status; status = &sd->base_status;
// These are not zeroed. [zzo] // These are not zeroed. [zzo]
sd->hprate=100; sd->hprate = 100;
sd->sprate=100; sd->sprate = 100;
sd->castrate=100; sd->castrate = 100;
sd->delayrate=100; sd->delayrate = 100;
sd->dsprate=100; sd->dsprate = 100;
sd->hprecov_rate = 100; sd->hprecov_rate = 100;
sd->sprecov_rate = 100; sd->sprecov_rate = 100;
sd->matk_rate = 100; sd->matk_rate = 100;
@ -2864,9 +2864,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
+ sizeof(sd->critaddrace) + sizeof(sd->critaddrace)
+ sizeof(sd->expaddrace) + sizeof(sd->expaddrace)
+ sizeof(sd->expaddclass) + sizeof(sd->expaddclass)
+ sizeof(sd->ignore_def_by_race)
+ sizeof(sd->ignore_mdef_by_race) + sizeof(sd->ignore_mdef_by_race)
+ sizeof(sd->ignore_mdef_by_class) + sizeof(sd->ignore_mdef_by_class)
+ sizeof(sd->ignore_def_by_race)
+ sizeof(sd->sp_gain_race) + sizeof(sd->sp_gain_race)
+ sizeof(sd->sp_gain_race_attack) + sizeof(sd->sp_gain_race_attack)
+ sizeof(sd->hp_gain_race_attack) + sizeof(sd->hp_gain_race_attack)
@ -2909,7 +2909,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
status->class_ = CLASS_NORMAL; status->class_ = CLASS_NORMAL;
// Zero up structures... // Zero up structures...
memset(&sd->autospell,0,sizeof(sd->autospell) memset(&sd->autospell, 0, sizeof(sd->autospell)
+ sizeof(sd->autospell2) + sizeof(sd->autospell2)
+ sizeof(sd->autospell3) + sizeof(sd->autospell3)
+ sizeof(sd->addeff) + sizeof(sd->addeff)
@ -2920,27 +2920,27 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
+ sizeof(sd->skillusesp) + sizeof(sd->skillusesp)
+ sizeof(sd->skillheal) + sizeof(sd->skillheal)
+ sizeof(sd->skillheal2) + sizeof(sd->skillheal2)
+ sizeof(sd->skillblown)
+ sizeof(sd->skillcast)
+ sizeof(sd->skillcooldown)
+ sizeof(sd->skillfixcast)
+ sizeof(sd->skillvarcast)
+ sizeof(sd->skillfixcastrate)
+ sizeof(sd->hp_loss) + sizeof(sd->hp_loss)
+ sizeof(sd->sp_loss) + sizeof(sd->sp_loss)
+ sizeof(sd->hp_regen) + sizeof(sd->hp_regen)
+ sizeof(sd->sp_regen) + sizeof(sd->sp_regen)
+ sizeof(sd->skillblown)
+ sizeof(sd->skillcast)
+ sizeof(sd->add_def) + sizeof(sd->add_def)
+ sizeof(sd->add_mdef) + sizeof(sd->add_mdef)
+ sizeof(sd->add_mdmg) + sizeof(sd->add_mdmg)
+ sizeof(sd->add_drop) + sizeof(sd->add_drop)
+ sizeof(sd->itemhealrate) + sizeof(sd->itemhealrate)
+ sizeof(sd->subele2) + sizeof(sd->subele2)
+ sizeof(sd->skillcooldown)
+ sizeof(sd->skillfixcast)
+ sizeof(sd->skillvarcast)
+ sizeof(sd->skillfixcastrate)
+ sizeof(sd->def_set_race) + sizeof(sd->def_set_race)
+ sizeof(sd->mdef_set_race) + sizeof(sd->mdef_set_race)
); );
memset (&sd->bonus, 0,sizeof(sd->bonus)); memset (&sd->bonus, 0, sizeof(sd->bonus));
// Autobonus // Autobonus
pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true); pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
@ -2952,15 +2952,15 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
npc_script_event(sd, NPCE_STATCALC); npc_script_event(sd, NPCE_STATCALC);
// Parse equipment // Parse equipment
for(i=0;i<EQI_MAX;i++) { for (i = 0; i < EQI_MAX; i++) {
current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0) if (index < 0)
continue; continue;
if(i == EQI_AMMO) if (i == EQI_AMMO)
continue; continue;
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index)) if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue; continue;
if(!sd->inventory_data[index]) if (!sd->inventory_data[index])
continue; continue;
status->def += sd->inventory_data[index]->def; status->def += sd->inventory_data[index]->def;
@ -2977,7 +2977,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
if (sd->status.inventory[index].refine > MAX_REFINE) if (sd->status.inventory[index].refine > MAX_REFINE)
sd->status.inventory[index].refine = MAX_REFINE; sd->status.inventory[index].refine = MAX_REFINE;
if(sd->inventory_data[index]->type == IT_WEAPON) { if (sd->inventory_data[index]->type == IT_WEAPON) {
int r = sd->status.inventory[index].refine, wlv = sd->inventory_data[index]->wlv; int r = sd->status.inventory[index].refine, wlv = sd->inventory_data[index]->wlv;
struct weapon_data *wd; struct weapon_data *wd;
struct weapon_atk *wa; struct weapon_atk *wa;
@ -3089,24 +3089,24 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
status->def += (refinedef+50)/100; status->def += (refinedef+50)/100;
// Parse Cards // Parse Cards
for(i=0;i<EQI_MAX;i++) { for (i = 0; i < EQI_MAX; i++) {
current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0) if (index < 0)
continue; continue;
if(i == EQI_AMMO) if (i == EQI_AMMO)
continue; continue;
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index)) if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue; continue;
if(sd->inventory_data[index]) { if (sd->inventory_data[index]) {
int j; int j;
struct item_data *data; struct item_data *data;
// Card script execution. // Card script execution.
if(itemdb_isspecial(sd->status.inventory[index].card[0])) if (itemdb_isspecial(sd->status.inventory[index].card[0]))
continue; continue;
for(j=0;j<MAX_SLOTS;j++) { // Uses MAX_SLOTS to support Soul Bound system [Inkfish] for (j = 0; j < MAX_SLOTS; j++) { // Uses MAX_SLOTS to support Soul Bound system [Inkfish]
int c= sd->status.inventory[index].card[j]; int c = sd->status.inventory[index].card[j];
current_equip_card_id= c; current_equip_card_id= c;
if(!c) if(!c)
continue; continue;