diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-07 13:17:53 +0000 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-07 13:17:53 +0000 |
commit | a4650533313a4dc74c77488f83132522506efb3d (patch) | |
tree | 02b89a261a6e3e9844407b0bfcd3186f91cb1f32 /src/map/trade.c | |
parent | b80647dacebd450ca85616044503f9da9d0ddceb (diff) | |
download | tmwa-a4650533313a4dc74c77488f83132522506efb3d.tar.gz tmwa-a4650533313a4dc74c77488f83132522506efb3d.tar.bz2 tmwa-a4650533313a4dc74c77488f83132522506efb3d.tar.xz tmwa-a4650533313a4dc74c77488f83132522506efb3d.zip |
Add some code to prevent GP duplication with trade
Diffstat (limited to 'src/map/trade.c')
-rw-r--r-- | src/map/trade.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/map/trade.c b/src/map/trade.c index 3fef59a..7fcfb41 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -277,6 +277,7 @@ void trade_tradecommit(struct map_session_data *sd) } } if(sd->deal_zeny) { + if (sd->deal_zeny > sd->status.zeny) sd->deal_zeny = sd->status.zeny; sd->status.zeny -= sd->deal_zeny; clif_updatestatus(sd,SP_ZENY); target_sd->status.zeny += sd->deal_zeny; @@ -284,6 +285,7 @@ void trade_tradecommit(struct map_session_data *sd) sd->deal_zeny=0; } if(target_sd->deal_zeny) { + if (target_sd->deal_zeny > target_sd->status.zeny) target_sd->deal_zeny = target_sd->status.zeny; target_sd->status.zeny -= target_sd->deal_zeny; clif_updatestatus(target_sd,SP_ZENY); sd->status.zeny += target_sd->deal_zeny; @@ -300,3 +302,20 @@ void trade_tradecommit(struct map_session_data *sd) } } } + +// This is called when a char's zeny is changed +// This helps prevent money duplication and other problems +// [Jaxad0127] +void trade_verifyzeny(struct map_session_data *sd) +{ + struct map_session_data *target_sd; + + nullpo_retv(sd); + + if((target_sd = map_id2sd(sd->trade_partner)) != NULL) { + if (sd->deal_zeny > sd->status.zeny) { + if (sd->deal_locked < 1) trade_tradeadditem(sd, 0, sd->status.zeny); // Fix money ammount + else trade_tradecancel(sd); // Or cancel the trade if we can't fix it + } + } +} |