diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-08 15:05:48 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-08 15:05:48 +0000 |
commit | 600ed9e0e1db5b2993827ecb1ac5db36ffe56c7b (patch) | |
tree | 0e9a2cefc176f5635ecd17237af105db0c2970d7 | |
parent | 06d3ecaabad6e81d0c6478d59632d0b4d4673423 (diff) | |
download | hercules-600ed9e0e1db5b2993827ecb1ac5db36ffe56c7b.tar.gz hercules-600ed9e0e1db5b2993827ecb1ac5db36ffe56c7b.tar.bz2 hercules-600ed9e0e1db5b2993827ecb1ac5db36ffe56c7b.tar.xz hercules-600ed9e0e1db5b2993827ecb1ac5db36ffe56c7b.zip |
- Now you can request a trade regardless of the state of the target trader.
- The trade will now fail when you accept it and either character is speaking with an npc, vending or has the storage open.
- Cleaned up some the trade ack function, added proper replies to some fail cases.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9438 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 4 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/trade.c | 71 |
3 files changed, 52 insertions, 33 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3f4277adb..40c9cf576 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/08 + * Now you can request a trade regardless of the state of the target trader. + [Skotlex] + * The trade will now fail when you accept it and either character is + speaking with an npc, vending or has the storage open. [Skotlex] * Fixed crash when looters became full. [Skotlex] * Autospell delay time is now the skill's full delay. [Skotlex] 2006/12/07 diff --git a/src/map/clif.c b/src/map/clif.c index 07c270f7c..50b2eb0ca 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9606,13 +9606,9 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) return; //You can trade while in a chatroom. // @noask [LuzZza] - if(t_sd) { - if (t_sd->state.noask) { - clif_noask_sub(sd, t_sd, 0); - return; - } - if(!t_sd->chatID && clif_cant_act(t_sd)) - return; + if(t_sd && t_sd->state.noask) { + clif_noask_sub(sd, t_sd, 0); + return; } if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){ diff --git a/src/map/trade.c b/src/map/trade.c index 09b07e02f..36c6d43f4 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -76,55 +76,74 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta /*========================================== * Reply to a trade-request. + * Type values: + * 0: Char is too far + * 1: Character does not exists + * 2: Trade failed + * 3: Accept + * 4: Cancel + * Weird enough, the client should only send 3/4 + * and the server is the one that can reply 0~2 *------------------------------------------ */ void trade_tradeack(struct map_session_data *sd, int type) { - struct map_session_data *target_sd; + struct map_session_data *tsd; nullpo_retv(sd); if (sd->state.trading || !sd->trade_partner) return; //Already trading or no partner set. - if ((target_sd = map_id2sd(sd->trade_partner)) == NULL) { + if ((tsd = map_id2sd(sd->trade_partner)) == NULL) { sd->trade_partner=0; + clif_tradestart(sd, 1); // character does not exist return; } - if (target_sd->state.trading || target_sd->trade_partner != sd->bl.id) + if (tsd->state.trading || tsd->trade_partner != sd->bl.id) + { + clif_tradestart(sd, 2); return; //Already trading or wrong partner. + } + + if (type == 4) { // Cancel + sd->state.deal_locked = 0; + sd->trade_partner = 0; + tsd->state.deal_locked = 0; + tsd->trade_partner = 0; + clif_tradestart(tsd, type); + clif_tradestart(sd, type); + return; + } + + if (type != 3) + return; //If client didn't send accept, it's a broken packet? //Copied here as well since the original character could had warped. - if (type == 3 && pc_isGM(target_sd) < lowest_gm_level && (sd->bl.m != target_sd->bl.m || - !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE) + if (pc_isGM(tsd) < lowest_gm_level && (sd->bl.m != tsd->bl.m || + !check_distance_bl(&sd->bl, &tsd->bl, TRADE_DISTANCE) )) { sd->trade_partner=0; - target_sd->trade_partner = 0; + tsd->trade_partner = 0; clif_tradestart(sd, 0); // too far return; } - //TODO: Type 4/3? What would 1/2 and the rest do? - if (type == 4) { // Cancel - sd->state.deal_locked = 0; - sd->trade_partner = 0; - target_sd->state.deal_locked = 0; - target_sd->trade_partner = 0; - clif_tradestart(target_sd, type); - clif_tradestart(sd, type); + //Check if you can start trade. + if (sd->npc_id || sd->vender_id || sd->state.storage_flag || + tsd->npc_id || tsd->vender_id || tsd->state.storage_flag) + { //Fail + clif_tradestart(sd, 2); + clif_tradestart(tsd, 2); + return; } - if (type == 3) { //Initiate trade - sd->state.trading = 1; - target_sd->state.trading = 1; - malloc_set(&sd->deal, 0, sizeof(sd->deal)); - malloc_set(&target_sd->deal, 0, sizeof(target_sd->deal)); - clif_tradestart(target_sd, type); - clif_tradestart(sd, type); - if (sd->npc_id) - npc_event_dequeue(sd); - if (target_sd->npc_id) - npc_event_dequeue(target_sd); - } + //Initiate trade + sd->state.trading = 1; + tsd->state.trading = 1; + malloc_set(&sd->deal, 0, sizeof(sd->deal)); + malloc_set(&tsd->deal, 0, sizeof(tsd->deal)); + clif_tradestart(tsd, type); + clif_tradestart(sd, type); } /*========================================== |