diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 47 | ||||
-rw-r--r-- | src/map/pc.h | 36 |
2 files changed, 39 insertions, 44 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 0792f59d5..ef530ea6d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -82,13 +82,6 @@ struct s_packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; //To make the assignation of the level based on limits clearer/easier. [Skotlex] #define clif_setlevel(lv) (lv<battle_config.max_lv?lv:battle_config.max_lv-(lv<battle_config.aura_lv?1:0)); -//Removed sd->npc_shopid because there is no packet sent from the client when you cancel a buy! -//Quick check to know if the player shouldn't be "busy" with something else to deny action requests. [Skotlex] -#define clif_cant_act(sd) (sd->npc_id || sd->vender_id || sd->chatID || sd->sc.opt1 || sd->state.trading || sd->state.storage_flag) - -// Checks if SD is in a trade/shop (where messing with the inventory can cause problems/exploits) -#define clif_trading(sd) (sd->npc_id || sd->vender_id || sd->state.trading ) - //To idenfity disguised characters. #define disguised(bl) ((bl)->type==BL_PC && ((TBL_PC*)bl)->disguise) @@ -8197,7 +8190,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) if (sd->sc.opt1 && sd->sc.opt1 == OPT1_STONEWAIT) ; //You CAN walk on this OPT1 value. - else if (clif_cant_act(sd)) + else if (pc_cant_act(sd)) return; if(sd->sc.count && sd->sc.data[SC_RUN].timer != -1) @@ -8650,7 +8643,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, case 0x00: // once attack case 0x07: // continuous attack - if (clif_cant_act(sd) || sd->sc.option&OPTION_HIDE) + if (pc_cant_act(sd) || sd->sc.option&OPTION_HIDE) return; if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER)) @@ -8971,7 +8964,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m) break; - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) break; //Disable cloaking/chasewalking characters from looting [Skotlex] @@ -9006,7 +8999,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) return; } - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) return; if (sd->sc.count && ( @@ -9044,7 +9037,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) if (sd->npc_id != sd->npc_item_flag) return; } else - if (clif_trading(sd)) + if (pc_istrading(sd)) return; pc_delinvincibletimer(sd); @@ -9079,7 +9072,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) return; } else if (sd->state.storage_flag || sd->sc.opt1) ; //You can equip/unequip stuff while storage is open/under status changes - else if (clif_cant_act(sd)) + else if (pc_cant_act(sd)) return; if(sd->sc.data[SC_BLADESTOP].timer!=-1 || sd->sc.data[SC_BERSERK].timer!=-1 ) @@ -9119,7 +9112,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd) if (sd->state.storage_flag) ; //You can equip/unequip stuff while storage is open. - else if (clif_cant_act(sd)) + else if (pc_cant_act(sd)) return; index = RFIFOW(fd,2)-2; @@ -9139,7 +9132,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) return; } - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) return; bl = map_id2bl(RFIFOL(fd,2)); @@ -9324,7 +9317,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) t_sd = map_id2sd(RFIFOL(fd,2)); - if(!sd->chatID && clif_cant_act(sd)) + if(!sd->chatID && pc_cant_act(sd)) return; //You can trade while in a chatroom. // @noask [LuzZza] @@ -9392,7 +9385,7 @@ void clif_parse_StopAttack(int fd,struct map_session_data *sd) *------------------------------------------*/ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) { - if (clif_trading(sd)) + if (pc_istrading(sd)) return; if (!pc_iscarton(sd)) return; @@ -9505,7 +9498,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) return; } - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) return; if (pc_issit(sd)) return; @@ -9661,7 +9654,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilll void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) return; if (pc_issit(sd)) return; @@ -9677,7 +9670,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) { - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) return; if (pc_issit(sd)) return; @@ -9702,7 +9695,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) if(skill_num != sd->menuskill_id) return; - if (clif_cant_act(sd)) + if (pc_cant_act(sd)) { sd->menuskill_id = sd->menuskill_val = 0; return; @@ -9727,7 +9720,7 @@ void clif_parse_ProduceMix(int fd,struct map_session_data *sd) if (sd->menuskill_id != AM_PHARMACY) return; - if (clif_trading(sd)) { + if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skillid,0,0); sd->menuskill_val = sd->menuskill_id = 0; @@ -9743,7 +9736,7 @@ void clif_parse_RepairItem(int fd, struct map_session_data *sd) { if (sd->menuskill_id != BS_REPAIRWEAPON) return; - if (clif_trading(sd)) { + if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skillid,0,0); sd->menuskill_val = sd->menuskill_id = 0; @@ -9762,7 +9755,7 @@ void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit? return; - if (clif_trading(sd)) { + if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skillid,0,0); sd->menuskill_val = sd->menuskill_id = 0; @@ -9856,7 +9849,7 @@ void clif_parse_SelectArrow(int fd,struct map_session_data *sd) { if (sd->menuskill_id != AC_MAKINGARROW) return; - if (clif_trading(sd)) { + if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skillid,0,0); sd->menuskill_val = sd->menuskill_id = 0; @@ -9960,7 +9953,7 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) { int item_index, item_amount; - if (clif_trading(sd)) + if (pc_istrading(sd)) return; item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2; @@ -10244,7 +10237,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) *------------------------------------------*/ void clif_parse_OpenVending(int fd,struct map_session_data *sd) { - if (clif_trading(sd)) + if (pc_istrading(sd)) return; if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM) return; diff --git a/src/map/pc.h b/src/map/pc.h index be0569b21..97f08c78b 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -88,26 +88,28 @@ enum { EQI_MAX } equip_index_enum; -#define pc_setdead(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 1) -#define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2) -#define pc_isdead(sd) ((sd)->state.dead_sit == 1) -#define pc_issit(sd) ((sd)->vd.dead_sit == 2) -#define pc_isidle(sd) ((sd)->chatID || (sd)->vender_id || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share) -#define pc_setdir(sd,b,h) ((sd)->ud.dir = (b) ,(sd)->head_dir = (h) ) -#define pc_setchatid(sd,n) ((sd)->chatID = n) -#define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK)) -#define pc_iscloaking(sd) (!((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK)) -#define pc_ischasewalk(sd) ((sd)->sc.option&OPTION_CHASEWALK) -#define pc_iscarton(sd) ((sd)->sc.option&OPTION_CART) -#define pc_isfalcon(sd) ((sd)->sc.option&OPTION_FALCON) -#define pc_isriding(sd) ((sd)->sc.option&OPTION_RIDING) -#define pc_isinvisible(sd) ((sd)->sc.option&OPTION_INVISIBLE) +#define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 ) +#define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 ) +#define pc_isdead(sd) ( (sd)->state.dead_sit == 1 ) +#define pc_issit(sd) ( (sd)->vd.dead_sit == 2 ) +#define pc_isidle(sd) ( (sd)->chatID || (sd)->vender_id || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share ) +#define pc_istrading(sd) ( (sd)->npc_id || (sd)->vender_id || (sd)->state.trading ) +#define pc_cant_act(sd) ( (sd)->npc_id || (sd)->vender_id || (sd)->chatID || (sd)->sc.opt1 || (sd)->state.trading || (sd)->state.storage_flag ) +#define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) ) +#define pc_setchatid(sd,n) ( (sd)->chatID = n ) +#define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) ) +#define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) ) +#define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK ) +#define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART ) +#define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON ) +#define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING ) +#define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE ) #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate ) #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 ) -#define pc_maxparameter(sd) ((sd->class_&JOBL_BABY) ? battle_config.max_baby_parameter : battle_config.max_parameter) +#define pc_maxparameter(sd) ( (sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter ) -#define pc_stop_attack(sd) { if (sd->ud.attacktimer!=-1) { unit_stop_attack(&sd->bl); sd->ud.target = 0; } } -#define pc_stop_walking(sd, type) { if (sd->ud.walktimer!=-1) unit_stop_walking(&sd->bl, type); } +#define pc_stop_attack(sd) { if( (sd)->ud.attacktimer != -1 ) { unit_stop_attack(&(sd)->bl); (sd)->ud.target = 0; } } +#define pc_stop_walking(sd, type) { if( (sd)->ud.walktimer != -1 ) unit_stop_walking(&(sd)->bl, type); } //Weapon check considering dual wielding. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \ |