Merge pull request #11945 from Dehravor/trade

Core/Trade: Correction of distance checking
This commit is contained in:
Discover-
2014-04-27 12:32:32 +02:00
3 changed files with 9 additions and 4 deletions

View File

@@ -33,6 +33,7 @@
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define INSPECT_DISTANCE 28.0f
#define TRADE_DISTANCE 11.11f
#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible objects
#define SIGHT_RANGE_UNIT 50.0f
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents

View File

@@ -6764,9 +6764,6 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t
if (GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
GetSession()->SendCancelTrade();
CheckAreaExploreAndOutdoor();
return true;

View File

@@ -276,6 +276,13 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
// set before checks for propertly undo at problems (it already set in to client)
my_trade->SetAccepted(true);
if (!_player->IsWithinDistInMap(trader, TRADE_DISTANCE, false))
{
SendTradeStatus(TRADE_STATUS_TARGET_TO_FAR);
my_trade->SetAccepted(false);
return;
}
// not accept case incorrect money amount
if (!_player->HasEnoughMoney(my_trade->GetMoney()))
{
@@ -648,7 +655,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
if (!pOther->IsWithinDistInMap(_player, 10.0f, false))
if (!pOther->IsWithinDistInMap(_player, TRADE_DISTANCE, false))
{
SendTradeStatus(TRADE_STATUS_TARGET_TO_FAR);
return;