Skip to content

Commit

Permalink
Merge pull request #3139 from MrKeiKun/update-bonus_add_sub_ele
Browse files Browse the repository at this point in the history
addele and subele Update
  • Loading branch information
MishimaHaruna authored Jun 2, 2022
2 parents 2b307bd + 1a113fd commit a7ee823
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 33 deletions.
65 changes: 32 additions & 33 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2365,71 +2365,67 @@ static int pc_endautobonus(int tid, int64 tick, int id, intptr_t data)
return 0;
}

static int pc_bonus_addele(struct map_session_data *sd, unsigned char ele, short rate, short flag)
static void pc_bonus_addele(struct map_session_data *sd, unsigned char ele, short rate, short flag)
{
int i;
struct weapon_data* wd;
struct weapon_data *wd;

nullpo_ret(sd);
nullpo_retv(sd);
wd = (sd->state.lr_flag ? &sd->left_weapon : &sd->right_weapon);

ARR_FIND(0, MAX_PC_BONUS, i, wd->addele2[i].rate == 0);

if (i == MAX_PC_BONUS)
{
if (i == MAX_PC_BONUS) {
ShowWarning("pc_addele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
return 0;
return;
}

if (!(flag&BF_RANGEMASK))
flag |= BF_SHORT|BF_LONG;
if (!(flag&BF_WEAPONMASK))
if ((flag & BF_RANGEMASK) == 0)
flag |= BF_SHORT | BF_LONG;
if ((flag & BF_WEAPONMASK) == 0)
flag |= BF_WEAPON;
if (!(flag&BF_SKILLMASK))
{
if (flag&(BF_MAGIC|BF_MISC))
if ((flag & BF_SKILLMASK) == 0) {
if ((flag & (BF_MAGIC | BF_MISC)) != 0)
flag |= BF_SKILL;
if (flag&BF_WEAPON)
flag |= BF_NORMAL|BF_SKILL;
if ((flag & BF_WEAPON) != 0)
flag |= BF_NORMAL | BF_SKILL;
}

wd->addele2[i].ele = ele;
wd->addele2[i].rate = rate;
wd->addele2[i].flag = flag;

return 0;
return;
}

static int pc_bonus_subele(struct map_session_data *sd, unsigned char ele, short rate, short flag)
static void pc_bonus_subele(struct map_session_data *sd, unsigned char ele, short rate, short flag)
{
int i;

nullpo_ret(sd);
nullpo_retv(sd);
ARR_FIND(0, MAX_PC_BONUS, i, sd->subele2[i].rate == 0);

if (i == MAX_PC_BONUS)
{
if (i == MAX_PC_BONUS) {
ShowWarning("pc_subele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
return 0;
return;
}

if (!(flag&BF_RANGEMASK))
flag |= BF_SHORT|BF_LONG;
if (!(flag&BF_WEAPONMASK))
if ((flag & BF_RANGEMASK) == 0)
flag |= BF_SHORT | BF_LONG;
if ((flag & BF_WEAPONMASK) == 0)
flag |= BF_WEAPON;
if (!(flag&BF_SKILLMASK))
{
if (flag&(BF_MAGIC|BF_MISC))
if ((flag & BF_SKILLMASK) == 0) {
if ((flag & (BF_MAGIC | BF_MISC)) != 0)
flag |= BF_SKILL;
if (flag&BF_WEAPON)
flag |= BF_NORMAL|BF_SKILL;
if ((flag & BF_WEAPON) != 0)
flag |= BF_NORMAL | BF_SKILL;
}

sd->subele2[i].ele = ele;
sd->subele2[i].rate = rate;
sd->subele2[i].flag = flag;

return 0;
return;
}

/**
Expand Down Expand Up @@ -4061,9 +4057,9 @@ static int pc_bonus3(struct map_session_data *sd, int type, int type2, int type3
if ( sd->state.lr_flag != 2 ) {
if ( type2 == ELE_ALL ) {
for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
pc_bonus_addele(sd, (unsigned char)i, type3, val);
pc->bonus_addele(sd, (unsigned char)i, type3, val);
} else {
pc_bonus_addele(sd, (unsigned char)type2, type3, val);
pc->bonus_addele(sd, (unsigned char)type2, type3, val);
}
}
break;
Expand All @@ -4076,9 +4072,9 @@ static int pc_bonus3(struct map_session_data *sd, int type, int type2, int type3
if ( sd->state.lr_flag != 2 ) {
if ( type2 == ELE_ALL ) {
for ( i = ELE_NEUTRAL; i < ELE_MAX; i++ )
pc_bonus_subele(sd, (unsigned char)i, type3, val);
pc->bonus_subele(sd, (unsigned char)i, type3, val);
} else {
pc_bonus_subele(sd, (unsigned char)type2, type3, val);
pc->bonus_subele(sd, (unsigned char)type2, type3, val);
}
}
break;
Expand Down Expand Up @@ -13054,6 +13050,9 @@ void pc_defaults(void)
pc->endautobonus = pc_endautobonus;
pc->delautobonus = pc_delautobonus;

pc->bonus_addele = pc_bonus_addele;
pc->bonus_subele = pc_bonus_subele;

pc->bonus = pc_bonus;
pc->bonus2 = pc_bonus2;
pc->bonus3 = pc_bonus3;
Expand Down
3 changes: 3 additions & 0 deletions src/map/pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ END_ZEROED_BLOCK; /* End */
int (*endautobonus) (int tid, int64 tick, int id, intptr_t data);
int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);

void (*bonus_addele) (struct map_session_data* sd, unsigned char ele, short rate, short flag);
void (*bonus_subele) (struct map_session_data* sd, unsigned char ele, short rate, short flag);

int (*bonus) (struct map_session_data *sd,int type,int val);
int (*bonus2) (struct map_session_data *sd,int type,int type2,int val);
int (*bonus3) (struct map_session_data *sd,int type,int type2,int type3,int val);
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/HPMHooking/HPMHooking.Defs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6360,6 +6360,10 @@ typedef int (*HPMHOOK_pre_pc_endautobonus) (int *tid, int64 *tick, int *id, intp
typedef int (*HPMHOOK_post_pc_endautobonus) (int retVal___, int tid, int64 tick, int id, intptr_t data);
typedef int (*HPMHOOK_pre_pc_delautobonus) (struct map_session_data **sd, struct s_autobonus **bonus, char *max, bool *restore);
typedef int (*HPMHOOK_post_pc_delautobonus) (int retVal___, struct map_session_data *sd, struct s_autobonus *bonus, char max, bool restore);
typedef void (*HPMHOOK_pre_pc_bonus_addele) (struct map_session_data **sd, unsigned char *ele, short *rate, short *flag);
typedef void (*HPMHOOK_post_pc_bonus_addele) (struct map_session_data *sd, unsigned char ele, short rate, short flag);
typedef void (*HPMHOOK_pre_pc_bonus_subele) (struct map_session_data **sd, unsigned char *ele, short *rate, short *flag);
typedef void (*HPMHOOK_post_pc_bonus_subele) (struct map_session_data *sd, unsigned char ele, short rate, short flag);
typedef int (*HPMHOOK_pre_pc_bonus) (struct map_session_data **sd, int *type, int *val);
typedef int (*HPMHOOK_post_pc_bonus) (int retVal___, struct map_session_data *sd, int type, int val);
typedef int (*HPMHOOK_pre_pc_bonus2) (struct map_session_data **sd, int *type, int *type2, int *val);
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4932,6 +4932,10 @@ struct {
struct HPMHookPoint *HP_pc_endautobonus_post;
struct HPMHookPoint *HP_pc_delautobonus_pre;
struct HPMHookPoint *HP_pc_delautobonus_post;
struct HPMHookPoint *HP_pc_bonus_addele_pre;
struct HPMHookPoint *HP_pc_bonus_addele_post;
struct HPMHookPoint *HP_pc_bonus_subele_pre;
struct HPMHookPoint *HP_pc_bonus_subele_post;
struct HPMHookPoint *HP_pc_bonus_pre;
struct HPMHookPoint *HP_pc_bonus_post;
struct HPMHookPoint *HP_pc_bonus2_pre;
Expand Down Expand Up @@ -12259,6 +12263,10 @@ struct {
int HP_pc_endautobonus_post;
int HP_pc_delautobonus_pre;
int HP_pc_delautobonus_post;
int HP_pc_bonus_addele_pre;
int HP_pc_bonus_addele_post;
int HP_pc_bonus_subele_pre;
int HP_pc_bonus_subele_post;
int HP_pc_bonus_pre;
int HP_pc_bonus_post;
int HP_pc_bonus2_pre;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2526,6 +2526,8 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pc->exeautobonus, HP_pc_exeautobonus) },
{ HP_POP(pc->endautobonus, HP_pc_endautobonus) },
{ HP_POP(pc->delautobonus, HP_pc_delautobonus) },
{ HP_POP(pc->bonus_addele, HP_pc_bonus_addele) },
{ HP_POP(pc->bonus_subele, HP_pc_bonus_subele) },
{ HP_POP(pc->bonus, HP_pc_bonus) },
{ HP_POP(pc->bonus2, HP_pc_bonus2) },
{ HP_POP(pc->bonus3, HP_pc_bonus3) },
Expand Down
52 changes: 52 additions & 0 deletions src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65571,6 +65571,58 @@ int HP_pc_delautobonus(struct map_session_data *sd, struct s_autobonus *bonus, c
}
return retVal___;
}
void HP_pc_bonus_addele(struct map_session_data *sd, unsigned char ele, short rate, short flag) {
int hIndex = 0;
if (HPMHooks.count.HP_pc_bonus_addele_pre > 0) {
void (*preHookFunc) (struct map_session_data **sd, unsigned char *ele, short *rate, short *flag);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_addele_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_pc_bonus_addele_pre[hIndex].func;
preHookFunc(&sd, &ele, &rate, &flag);
}
if (*HPMforce_return) {
*HPMforce_return = false;
return;
}
}
{
HPMHooks.source.pc.bonus_addele(sd, ele, rate, flag);
}
if (HPMHooks.count.HP_pc_bonus_addele_post > 0) {
void (*postHookFunc) (struct map_session_data *sd, unsigned char ele, short rate, short flag);
for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_addele_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_pc_bonus_addele_post[hIndex].func;
postHookFunc(sd, ele, rate, flag);
}
}
return;
}
void HP_pc_bonus_subele(struct map_session_data *sd, unsigned char ele, short rate, short flag) {
int hIndex = 0;
if (HPMHooks.count.HP_pc_bonus_subele_pre > 0) {
void (*preHookFunc) (struct map_session_data **sd, unsigned char *ele, short *rate, short *flag);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_subele_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_pc_bonus_subele_pre[hIndex].func;
preHookFunc(&sd, &ele, &rate, &flag);
}
if (*HPMforce_return) {
*HPMforce_return = false;
return;
}
}
{
HPMHooks.source.pc.bonus_subele(sd, ele, rate, flag);
}
if (HPMHooks.count.HP_pc_bonus_subele_post > 0) {
void (*postHookFunc) (struct map_session_data *sd, unsigned char ele, short rate, short flag);
for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_bonus_subele_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_pc_bonus_subele_post[hIndex].func;
postHookFunc(sd, ele, rate, flag);
}
}
return;
}
int HP_pc_bonus(struct map_session_data *sd, int type, int val) {
int hIndex = 0;
int retVal___ = 0;
Expand Down

0 comments on commit a7ee823

Please sign in to comment.