diff options
Diffstat (limited to 'src/map/trade.c')
-rw-r--r-- | src/map/trade.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/src/map/trade.c b/src/map/trade.c index 44b669ebd..3bbb73568 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/socket.h" +#define HERCULES_CORE #include "trade.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" +#include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" #include "pc.h" -#include "npc.h" -#include "battle.h" -#include "chrif.h" #include "storage.h" -#include "intif.h" -#include "atcommand.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/socket.h" struct trade_interface trade_s; @@ -59,7 +61,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta if( previous_sd ){ previous_sd->trade_partner = 0; clif->tradecancelled(previous_sd); - } // Once cancelled then continue to the new one. + } // Once canceled then continue to the new one. sd->trade_partner = 0; clif->tradecancelled(sd); } @@ -164,11 +166,13 @@ void trade_tradeack(struct map_session_data *sd, int type) { clif->tradestart(sd, type); } -/*========================================== - * Check here hacker for duplicate item in trade - * normal client refuse to have 2 same types of item (except equipment) in same trade window - * normal client authorise only no equiped item and only from inventory - *------------------------------------------*/ +/** + * Checks if an impossible trade will occur + * Normal clients refuse to have 2 items of the same type (except equipment) in the same trade window + * Normal clients authorize only no equipped items and only items from inventory + * @retval 0 The trade can continue + * @retval 1 Hack attempt + **/ int impossible_trade_check(struct map_session_data *sd) { struct item inventory[MAX_INVENTORY]; @@ -177,17 +181,15 @@ int impossible_trade_check(struct map_session_data *sd) nullpo_retr(1, sd); - if(sd->deal.zeny > sd->status.zeny) { - pc_setglobalreg(sd,script->add_str("ZENY_HACKER"),1); - return -1; - } + if( sd->deal.zeny > sd->status.zeny ) + return 1; // get inventory of player memcpy(&inventory, &sd->status.inventory, sizeof(struct item) * MAX_INVENTORY); - // remove this part: arrows can be trade and equiped + // remove this part: arrows can be trade and equipped // re-added! [celest] - // remove equiped items (they can not be trade) + // remove equipped items (they can not be trade) for (i = 0; i < MAX_INVENTORY; i++) if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & EQP_AMMO)) memset(&inventory[i], 0, sizeof(struct item)); @@ -455,7 +457,7 @@ void trade_tradeok(struct map_session_data *sd) { } /*========================================== - * 'Cancel' is pressed. (or trade was force-cancelled by the code) + * 'Cancel' is pressed. (or trade was force-canceled by the code) *------------------------------------------*/ void trade_tradecancel(struct map_session_data *sd) { struct map_session_data *target_sd; @@ -464,7 +466,7 @@ void trade_tradecancel(struct map_session_data *sd) { target_sd = map->id2sd(sd->trade_partner); if(!sd->state.trading) - { // Not trade acepted + { // Not trade accepted if( target_sd ) { target_sd->trade_partner = 0; clif->tradecancelled(target_sd); |