Skip to content

Commit

Permalink
Several Trading fixes (TrinityCore#169)
Browse files Browse the repository at this point in the history
* FIX : HandleAdditemCommand (delete items in bank)

The .additem command was not deleting items in the bank

* FIX : HandleAdditemCommand (delete items in buyback tab)

The .additem command was not deleting items in the buyback vendor tab for npc vendors

* Enchance LANG_REMOVEITEM text

* Fix Tabs / spaces in Language.h

* Fix Language.h file generator

* Trade Fix : For GMs starting a trade session with an opposite faction player

Allow a GM to start a trading session with an opposite faction player even if CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_TRADE = false

* Trade Fix : Avoid hanging trade sessions for invisible GMs

Check visibility in order to avoid hanging trade sessions
  • Loading branch information
Elmsroth authored Dec 29, 2021
1 parent 39381b1 commit 7bc78be
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/game/WorldHandlers/TradeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,26 +671,39 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}

if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_TRADE) && pOther->GetTeam() != _player->GetTeam())
// Checking faction restrictions but allow a GM to start a trade even if not in same faction
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_TRADE) && pOther->GetTeam() != GetPlayer()->GetTeam() && GetSecurity() == SEC_PLAYER)
{
info.Status = TRADE_STATUS_WRONG_FACTION;
SendTradeStatus(info);
return;
}

if (!pOther->IsWithinDistInMap(_player, TRADE_DISTANCE, false))
if (!pOther->IsWithinDistInMap(GetPlayer(), TRADE_DISTANCE, false))
{
info.Status = TRADE_STATUS_TARGET_TO_FAR;
SendTradeStatus(info);
return;
}

// Check visibility in order to avoid hanging trade sessions
if (GetSecurity() > SEC_PLAYER && GetPlayer()->GetVisibility() == VISIBILITY_OFF &&
( pOther->GetSession()->GetSecurity() < GetSecurity()
|| (pOther->GetSession()->GetSecurity() > GetSecurity() && pOther->GetVisibility() == VISIBILITY_OFF)
)
)
{
info.Status = TRADE_STATUS_TRADE_CANCELED;
SendTradeStatus(info);
return;
}

// OK start trade
_player->m_trade = new TradeData(_player, pOther);
pOther->m_trade = new TradeData(pOther, _player);
GetPlayer()->m_trade = new TradeData(GetPlayer(), pOther);
pOther->m_trade = new TradeData(pOther, GetPlayer());

info.Status = TRADE_STATUS_BEGIN_TRADE;
info.TraderGuid = _player->GetObjectGuid();
info.TraderGuid = GetPlayer()->GetObjectGuid();
pOther->GetSession()->SendTradeStatus(info);
}

Expand Down

0 comments on commit 7bc78be

Please sign in to comment.