summaryrefslogtreecommitdiff
path: root/src/map/trade.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-11 20:03:22 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-11 20:03:22 +0000
commita3cd04965d83f00ee9ca0020f60bea1f5c83ac6b (patch)
tree63da4f4d60806a5eb790b7d1072e042d38872b3a /src/map/trade.c
parent7eaf99edd466011a1ac3c909157b0422120cae4e (diff)
downloadhercules-a3cd04965d83f00ee9ca0020f60bea1f5c83ac6b.tar.gz
hercules-a3cd04965d83f00ee9ca0020f60bea1f5c83ac6b.tar.bz2
hercules-a3cd04965d83f00ee9ca0020f60bea1f5c83ac6b.tar.xz
hercules-a3cd04965d83f00ee9ca0020f60bea1f5c83ac6b.zip
- Changed a bit the MAX_ZENY checks in trade.c to prevent overflows.
- Rewrote npc_selllist for a more proper-clean implementation. - Increased NPC_POWERUP's dex bonus to +25*lv - Moved TK_DOWNKICK's stun time from time to time2 - Added TK_TURNKICK's stun to splash-pushed mobs. Duration is 2secs (time2) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6557 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/trade.c')
-rw-r--r--src/map/trade.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/map/trade.c b/src/map/trade.c
index 002d974da..5de4ffd91 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -187,21 +187,21 @@ int impossible_trade_check(struct map_session_data *sd) {
* Checks if trade is possible (against zeny limits, inventory limits, etc)
*------------------------------------------
*/
-int trade_check(struct map_session_data *sd, struct map_session_data *target_sd) {
+int trade_check(struct map_session_data *sd, struct map_session_data *tsd) {
struct item inventory[MAX_INVENTORY];
struct item inventory2[MAX_INVENTORY];
struct item_data *data;
int trade_i, i, amount, n;
// check zenys value against hackers (Zeny was already checked on time of adding, but you never know when you lost some zeny since then.
- if(sd->deal.zeny > sd->status.zeny || (target_sd->status.zeny + sd->deal.zeny) > MAX_ZENY)
+ if(sd->deal.zeny > sd->status.zeny || (tsd->status.zeny > MAX_ZENY - sd->deal.zeny))
return 0;
- if(target_sd->deal.zeny > target_sd->status.zeny || (sd->status.zeny + target_sd->deal.zeny) > MAX_ZENY)
+ if(tsd->deal.zeny > tsd->status.zeny || (sd->status.zeny > MAX_ZENY - tsd->deal.zeny))
return 0;
// get inventory of player
memcpy(&inventory, &sd->status.inventory, sizeof(struct item) * MAX_INVENTORY);
- memcpy(&inventory2, &target_sd->status.inventory, sizeof(struct item) * MAX_INVENTORY);
+ memcpy(&inventory2, &tsd->status.inventory, sizeof(struct item) * MAX_INVENTORY);
// check free slot in both inventory
for(trade_i = 0; trade_i < 10; trade_i++) {
@@ -240,10 +240,10 @@ int trade_check(struct map_session_data *sd, struct map_session_data *target_sd)
// memset(&inventory[n], 0, sizeof(struct item));
}
}
- amount = target_sd->deal.item[trade_i].amount;
+ amount = tsd->deal.item[trade_i].amount;
if (!amount)
continue;
- n = target_sd->deal.item[trade_i].index;
+ n = tsd->deal.item[trade_i].index;
if (amount > inventory2[n].amount)
return 0;
// search if it's possible to add item (for full inventory)
@@ -297,8 +297,8 @@ void trade_tradeadditem(struct map_session_data *sd, int index, int amount) {
if (index == 0)
{ //Adding Zeny
- if (amount >= 0 && amount <= MAX_ZENY && amount <= sd->status.zeny && // check amount
- (target_sd->status.zeny + amount) <= MAX_ZENY) // fix positiv overflow
+ if (amount >= 0 && amount <= sd->status.zeny && // check amount
+ (amount <= MAX_ZENY - target_sd->status.zeny)) // fix positiv overflow
{ //Check Ok
sd->deal.zeny = amount;
clif_tradeadditem(sd, target_sd, 0, amount);