mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 08:00:48 +01:00
Core/Gameobjects: Fix an exploit where it was possible to use gameobjects from any distance. Fixes for example picking up the WSG flag from any distance using hacking tools.
This commit is contained in:
@@ -2209,3 +2209,19 @@ void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /*
|
||||
if (ori)
|
||||
*ori = GetOrientation();
|
||||
}
|
||||
|
||||
float GameObject::GetInteractionDistance()
|
||||
{
|
||||
switch (GetGoType())
|
||||
{
|
||||
/// @todo find out how the client calculates the maximal usage distance to spellless working
|
||||
// gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
|
||||
case GAMEOBJECT_TYPE_GUILD_BANK:
|
||||
case GAMEOBJECT_TYPE_MAILBOX:
|
||||
return 10.0f;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
return 20.0f + CONTACT_DISTANCE; // max spell range
|
||||
default:
|
||||
return INTERACTION_DISTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,6 +830,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
|
||||
float GetStationaryZ() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); }
|
||||
float GetStationaryO() const { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); }
|
||||
|
||||
float GetInteractionDistance();
|
||||
|
||||
protected:
|
||||
bool AIM_Initialize();
|
||||
void UpdateModel(); // updates model in case displayId were changed
|
||||
|
||||
@@ -2765,30 +2765,14 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes
|
||||
{
|
||||
if (go->GetGoType() == type)
|
||||
{
|
||||
float maxdist;
|
||||
switch (type)
|
||||
{
|
||||
/// @todo find out how the client calculates the maximal usage distance to spellless working
|
||||
// gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
|
||||
case GAMEOBJECT_TYPE_GUILD_BANK:
|
||||
case GAMEOBJECT_TYPE_MAILBOX:
|
||||
maxdist = 10.0f;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
maxdist = 20.0f+CONTACT_DISTANCE; // max spell range
|
||||
break;
|
||||
default:
|
||||
maxdist = INTERACTION_DISTANCE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (go->IsWithinDistInMap(this, maxdist))
|
||||
if (go->IsWithinDistInMap(this, go->GetInteractionDistance()))
|
||||
return go;
|
||||
|
||||
TC_LOG_DEBUG("maps", "IsGameObjectOfTypeInRange: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name.c_str(),
|
||||
TC_LOG_DEBUG("maps", "GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name.c_str(),
|
||||
go->GetGUIDLow(), GetName().c_str(), GetGUIDLow(), go->GetDistance(this));
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,19 +266,21 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData)
|
||||
{
|
||||
uint64 guid;
|
||||
|
||||
recvData >> guid;
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid));
|
||||
|
||||
if (GameObject* obj = GetPlayer()->GetMap()->GetGameObject(guid))
|
||||
{
|
||||
if (!obj->IsWithinDistInMap(GetPlayer(), obj->GetInteractionDistance()))
|
||||
return;
|
||||
|
||||
// ignore for remote control state
|
||||
if (_player->m_mover != _player)
|
||||
if (!(_player->IsOnVehicle(_player->m_mover) || _player->IsMounted()) && !obj->GetGOInfo()->IsUsableMounted())
|
||||
if (GetPlayer()->m_mover != GetPlayer())
|
||||
if (!(GetPlayer()->IsOnVehicle(GetPlayer()->m_mover) || GetPlayer()->IsMounted()) && !obj->GetGOInfo()->IsUsableMounted())
|
||||
return;
|
||||
|
||||
obj->Use(_player);
|
||||
obj->Use(GetPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user