summaryrefslogtreecommitdiff
path: root/src/map/trade.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-06-15 05:00:04 -0300
committershennetsind <ind@henn.et>2013-06-15 05:00:04 -0300
commitcf78bebc95e3387cf7fbe0720825bacb95c1b61a (patch)
treee895ec5f3f9baa111476af18607ec292f06d9df6 /src/map/trade.c
parent1dd4882c00b82d9a2f138211dbc2c8c542e2af88 (diff)
parentde3f4423058405636c76e05cd87a6eae0bfa7707 (diff)
downloadhercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.gz
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.bz2
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.xz
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src/map/trade.c')
-rw-r--r--src/map/trade.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/map/trade.c b/src/map/trade.c
index 8311dbf3d..f469f4b28 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -331,7 +331,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -415,13 +415,13 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount)
if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
if( amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny )
{ // invalid values, no appropriate packet for it => abort
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -440,7 +440,7 @@ void trade_tradeok(struct map_session_data *sd)
return;
if ((target_sd = iMap->id2sd(sd->trade_partner)) == NULL) {
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
sd->state.deal_locked = 1;
@@ -532,18 +532,18 @@ void trade_tradecommit(struct map_session_data *sd)
//Now is a good time (to save on resources) to check that the trade can indeed be made and it's not exploitable.
// check exploit (trade more items that you have)
- if (impossible_trade_check(sd)) {
- trade_tradecancel(sd);
+ if (trade->check_impossible(sd)) {
+ trade->cancel(sd);
return;
}
// check exploit (trade more items that you have)
- if (impossible_trade_check(tsd)) {
- trade_tradecancel(tsd);
+ if (trade->check_impossible(tsd)) {
+ trade->cancel(tsd);
return;
}
// check for full inventory (can not add traded items)
- if (!trade_check(sd,tsd)) { // check the both players
- trade_tradecancel(sd);
+ if (!trade->check(sd,tsd)) { // check the both players
+ trade->cancel(sd);
return;
}
@@ -607,3 +607,18 @@ void trade_tradecommit(struct map_session_data *sd)
chrif_save(tsd,0);
}
}
+
+void trade_defaults(void)
+{
+ trade = &trade_s;
+
+ trade->request = trade_traderequest;
+ trade->ack = trade_tradeack;
+ trade->check_impossible = impossible_trade_check;
+ trade->check = trade_check;
+ trade->additem = trade_tradeadditem;
+ trade->addzeny = trade_tradeaddzeny;
+ trade->ok = trade_tradeok;
+ trade->cancel = trade_tradecancel;
+ trade->commit = trade_tradecommit;
+} \ No newline at end of file