* 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

@ -1440,7 +1440,7 @@ void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... );
/// @param __heap Binary heap
/// @param __topcmp Comparator
/// @param __swp Swapper
#define BHEAP_POP2(__heap,__topcmp,__swp) \
#define BHEAP_POP2(__heap,__topcmp,__swp) \
do{ \
VECTOR_INDEX(__heap,0) = VECTOR_POP(__heap); /* put last at index */ \
if( !VECTOR_LENGTH(__heap) ) /* removed last, nothing to do */ \

View File

@ -11018,11 +11018,13 @@ int pc_bonus_script_timer(int tid, unsigned int tick, int id, intptr_t data) {
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);
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]);
status_calc_pc(sd,SCO_NONE);
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
)))
{
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]);
count++;
}
@ -11092,7 +11095,8 @@ void pc_bonus_script_clear_all(struct map_session_data *sd, bool permanent) {
continue;
if (!permanent && sd->bonus_script[i].flag&BSF_PERMANENT)
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]);
count++;
}

View File

@ -346,6 +346,7 @@ struct map_session_data {
short sp_gain_race_attack[RC_MAX];
short hp_gain_race_attack[RC_MAX];
// zeroed arrays end here.
// zeroed structures start here
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];
@ -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.
unsigned short id;
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 {
short value;
int rate;
@ -377,9 +378,11 @@ struct map_session_data {
int rate, tick;
} def_set_race[RC_MAX], mdef_set_race[RC_MAX];
// zeroed structures end 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
// manually zeroed structures end here.
// zeroed vars start here.
struct s_bonus {
int hp, sp;
@ -421,7 +424,6 @@ struct map_session_data {
int ematk; // matk bonus from equipment
int eatk; // atk bonus from equipment
} bonus;
// zeroed vars end here.
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;
// These are not zeroed. [zzo]
sd->hprate=100;
sd->sprate=100;
sd->castrate=100;
sd->delayrate=100;
sd->dsprate=100;
sd->hprate = 100;
sd->sprate = 100;
sd->castrate = 100;
sd->delayrate = 100;
sd->dsprate = 100;
sd->hprecov_rate = 100;
sd->sprecov_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->expaddrace)
+ sizeof(sd->expaddclass)
+ sizeof(sd->ignore_def_by_race)
+ sizeof(sd->ignore_mdef_by_race)
+ sizeof(sd->ignore_mdef_by_class)
+ sizeof(sd->ignore_def_by_race)
+ sizeof(sd->sp_gain_race)
+ sizeof(sd->sp_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;
// Zero up structures...
memset(&sd->autospell,0,sizeof(sd->autospell)
memset(&sd->autospell, 0, sizeof(sd->autospell)
+ sizeof(sd->autospell2)
+ sizeof(sd->autospell3)
+ 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->skillheal)
+ 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->sp_loss)
+ sizeof(sd->hp_regen)
+ sizeof(sd->sp_regen)
+ sizeof(sd->skillblown)
+ sizeof(sd->skillcast)
+ sizeof(sd->add_def)
+ sizeof(sd->add_mdef)
+ sizeof(sd->add_mdmg)
+ sizeof(sd->add_drop)
+ sizeof(sd->itemhealrate)
+ sizeof(sd->subele2)
+ sizeof(sd->skillcooldown)
+ sizeof(sd->skillfixcast)
+ sizeof(sd->skillvarcast)
+ sizeof(sd->skillfixcastrate)
+ sizeof(sd->def_set_race)
+ sizeof(sd->mdef_set_race)
);
memset (&sd->bonus, 0,sizeof(sd->bonus));
memset (&sd->bonus, 0, sizeof(sd->bonus));
// Autobonus
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);
// 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]
if(index < 0)
if (index < 0)
continue;
if(i == EQI_AMMO)
if (i == EQI_AMMO)
continue;
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue;
if(!sd->inventory_data[index])
if (!sd->inventory_data[index])
continue;
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)
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;
struct weapon_data *wd;
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;
// 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]
if(index < 0)
if (index < 0)
continue;
if(i == EQI_AMMO)
if (i == EQI_AMMO)
continue;
if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
continue;
if(sd->inventory_data[index]) {
if (sd->inventory_data[index]) {
int j;
struct item_data *data;
// Card script execution.
if(itemdb_isspecial(sd->status.inventory[index].card[0]))
if (itemdb_isspecial(sd->status.inventory[index].card[0]))
continue;
for(j=0;j<MAX_SLOTS;j++) { // Uses MAX_SLOTS to support Soul Bound system [Inkfish]
int c= sd->status.inventory[index].card[j];
for (j = 0; j < MAX_SLOTS; j++) { // Uses MAX_SLOTS to support Soul Bound system [Inkfish]
int c = sd->status.inventory[index].card[j];
current_equip_card_id= c;
if(!c)
continue;