summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-07 13:17:53 +0000
committerJared Adams <jaxad0127@gmail.com>2009-02-07 13:17:53 +0000
commita4650533313a4dc74c77488f83132522506efb3d (patch)
tree02b89a261a6e3e9844407b0bfcd3186f91cb1f32 /src
parentb80647dacebd450ca85616044503f9da9d0ddceb (diff)
downloadtmwa-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')
-rw-r--r--src/map/clif.c1
-rw-r--r--src/map/trade.c19
-rw-r--r--src/map/trade.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7b602c2..8fe1ae6 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2470,6 +2470,7 @@ int clif_updatestatus(struct map_session_data *sd,int type)
case SP_ZENY:
+ trade_verifyzeny(sd);
WFIFOW(fd,0)=0xb1;
if(sd->status.zeny < 0)
sd->status.zeny = 0;
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
+ }
+ }
+}
diff --git a/src/map/trade.h b/src/map/trade.h
index 01cbce7..4ef112b 100644
--- a/src/map/trade.h
+++ b/src/map/trade.h
@@ -9,5 +9,6 @@ void trade_tradeadditem(struct map_session_data *sd,int index,int amount);
void trade_tradeok(struct map_session_data *sd);
void trade_tradecancel(struct map_session_data *sd);
void trade_tradecommit(struct map_session_data *sd);
+void trade_verifyzeny(struct map_session_data *sd);
#endif // _TRADE_H_