From 9433c91d6019e7d44342869cdfd5581d2526d6c2 Mon Sep 17 00:00:00 2001 From: sucofog <4pdcvicente@gmail.com> Date: Thu, 16 Nov 2017 15:47:13 +0100 Subject: [PATCH] Import this fix's: https://github.com/TrinityCore/TrinityCore/commit/da6065db00768735e70cd0a81af7f5ec4c2f0414 https://github.com/Golrag/TrinityCore/commit/d550f0fee8abe2517a6cbb43fbfa1f1a2fcbda9b --- data/sql/updates/db_world/2017_11_16_00.sql | 26 +++++++++++++++ src/game/Entities/Object/Object.cpp | 37 ++++++++++++++++++--- src/game/Entities/Object/Object.h | 2 ++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 data/sql/updates/db_world/2017_11_16_00.sql diff --git a/data/sql/updates/db_world/2017_11_16_00.sql b/data/sql/updates/db_world/2017_11_16_00.sql new file mode 100644 index 000000000..0ca780be8 --- /dev/null +++ b/data/sql/updates/db_world/2017_11_16_00.sql @@ -0,0 +1,26 @@ +-- DB update 2017_11_14_01 -> 2017_11_16_00 +DROP PROCEDURE IF EXISTS `updateDb`; +DELIMITER // +CREATE PROCEDURE updateDb () +proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; +SELECT COUNT(*) INTO @COLEXISTS +FROM information_schema.COLUMNS +WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2017_11_14_01'; +IF @COLEXISTS = 0 THEN LEAVE proc; END IF; +START TRANSACTION; +ALTER TABLE version_db_world CHANGE COLUMN 2017_11_14_01 2017_11_16_00 bit; +SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1510843288942649400'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; +-- +-- START UPDATING QUERIES +-- +INSERT INTO version_db_world (`sql_rev`) VALUES ('1510843288942649400'); + +UPDATE `creature_model_info` SET `BoundingRadius`=7.5, `CombatReach`=6 WHERE `DisplayID`=30890;-- +-- END UPDATING QUERIES +-- +COMMIT; +END; +// +DELIMITER ; +CALL updateDb(); +DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/src/game/Entities/Object/Object.cpp b/src/game/Entities/Object/Object.cpp index 9590bd35e..10773c872 100644 --- a/src/game/Entities/Object/Object.cpp +++ b/src/game/Entities/Object/Object.cpp @@ -1095,9 +1095,13 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const if (!IsInMap(obj)) return false; - float ox, oy, oz; - obj->GetPosition(ox, oy, oz); - return IsWithinLOS(ox, oy, oz); + float x, y, z; + if (obj->GetTypeId() == TYPEID_PLAYER) + obj->GetPosition(x, y, z); + else + obj->GetHitSpherePointFor(GetPosition(), x, y, z); + + return IsWithinLOS(x, y, z); } bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const @@ -1107,11 +1111,36 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const VMAP::IVMapManager* vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); return vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f);*/ if (IsInWorld()) - return GetMap()->isInLineOfSight(GetPositionX(), GetPositionY(), GetPositionZ()+2.f, ox, oy, oz+2.f, GetPhaseMask()); + { + float x, y, z; + if (GetTypeId() == TYPEID_PLAYER) + GetPosition(x, y, z); + else + GetHitSpherePointFor({ ox, oy, oz }, x, y, z); + + return GetMap()->isInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f, GetPhaseMask()); + } return true; } +Position WorldObject::GetHitSpherePointFor(Position const& dest) const +{ + G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ()); + G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); + G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * std::min(dest.GetExactDist(GetPosition()), GetObjectSize()); + + return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y)); +} + +void WorldObject::GetHitSpherePointFor(Position const& dest, float& x, float& y, float& z) const +{ + Position pos = GetHitSpherePointFor(dest); + x = pos.GetPositionX(); + y = pos.GetPositionY(); + z = pos.GetPositionZ(); +} + bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const { float dx1 = GetPositionX() - obj1->GetPositionX(); diff --git a/src/game/Entities/Object/Object.h b/src/game/Entities/Object/Object.h index 123b1aa08..78234cb40 100644 --- a/src/game/Entities/Object/Object.h +++ b/src/game/Entities/Object/Object.h @@ -785,6 +785,8 @@ class WorldObject : public Object, public WorldLocation } bool IsWithinLOS(float x, float y, float z) const; bool IsWithinLOSInMap(const WorldObject* obj) const; + Position GetHitSpherePointFor(Position const& dest) const; + void GetHitSpherePointFor(Position const& dest, float& x, float& y, float& z) const; bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D = true) const; bool IsInRange(WorldObject const* obj, float minRange, float maxRange, bool is3D = true) const; bool IsInRange2d(float x, float y, float minRange, float maxRange) const;