diff options
| author | treeston <treeston.mmoc@gmail.com> | 2016-09-20 20:19:15 +0200 |
|---|---|---|
| committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-03-02 20:47:29 +0100 |
| commit | 205ec4c3bf26d74fefa2452baae714c56d956956 (patch) | |
| tree | 0841a7c4bcf3e13bfa6df282520898960b9009f5 /src/server/game | |
| parent | b94642fb49305192f44387e520d1410b1552094f (diff) | |
Core/Unit: Standardize SetFacingTo and SetFacingToObject behavior while moving. Both now fail while moving unless arg2 bool is true.
Movement/SplineChain: Bump value range for DB chainId up to uint16 (0 to 65535) from uint8 (0 to 255). Turns out sniffs generate far more chains than I expected.
(cherry picked from commit 2170541a51ced3c15675b8854e0ae49461884f8c)
Code style follow-up, I blame Notepad++.
(cherry picked from commit 7860da0de6e53c7740862cae18840c9d399dda7f)
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 11 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 4 | ||||
| -rw-r--r-- | src/server/game/Movement/MotionMaster.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Movement/MotionMaster.h | 2 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptSystem.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptSystem.h | 6 |
8 files changed, 22 insertions, 17 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 4520aa197fb..ecba6c9abe2 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -162,7 +162,7 @@ void CreatureAI::TriggerAlert(Unit const* who) const me->SendAIReaction(AI_REACTION_ALERT); // Face the unit (stealthed player) and set distracted state for 5 seconds - me->SetFacingTo(me->GetAngle(who->GetPositionX(), who->GetPositionY())); + me->SetFacingTo(me->GetAngle(who->GetPositionX(), who->GetPositionY()), true); me->StopMoving(); me->GetMotionMaster()->MoveDistract(5 * IN_MILLISECONDS); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 958d97e785e..cbb026fb665 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2800,10 +2800,10 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target) bool canTurnDuringCast = !focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST); // Face the target - we need to do this before the unit state is modified for no-turn spells if (target) - SetFacingTo(GetAngle(target)); + SetFacingToObject(target); else if (!canTurnDuringCast) if (Unit* victim = GetVictim()) - SetFacingTo(GetAngle(victim)); // ensure orientation is correct at beginning of cast + SetFacingToObject(victim); // ensure orientation is correct at beginning of cast if (!canTurnDuringCast) AddUnitState(UNIT_STATE_CANNOT_TURN); @@ -2849,7 +2849,7 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) if (!m_suppressedTarget.IsEmpty()) { if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) - SetFacingTo(GetAngle(objTarget)); + SetFacingToObject(objTarget); } else SetFacingTo(m_suppressedOrientation); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bd104032a10..6ea885e8d78 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15271,8 +15271,11 @@ void Unit::SetInFront(WorldObject const* target) SetOrientation(GetAngle(target)); } -void Unit::SetFacingTo(float ori) +void Unit::SetFacingTo(float ori, bool force) { + if (!force && !IsStopped()) + return; + Movement::MoveSplineInit init(this); init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), false); if (GetTransport()) @@ -15281,10 +15284,10 @@ void Unit::SetFacingTo(float ori) init.Launch(); } -void Unit::SetFacingToObject(WorldObject const* object) +void Unit::SetFacingToObject(WorldObject const* object, bool force) { - // never face when already moving - if (!IsStopped()) + // do not face when already moving + if (!force && !IsStopped()) return; /// @todo figure out under what conditions creature will move towards object instead of facing it where it currently is. diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 054db0ef5eb..0337939cdbe 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1711,8 +1711,8 @@ class TC_GAME_API Unit : public WorldObject void SendSetVehicleRecId(uint32 vehicleId); void SetInFront(WorldObject const* target); - void SetFacingTo(float ori); - void SetFacingToObject(WorldObject const* object); + void SetFacingTo(float ori, bool force = false); + void SetFacingToObject(WorldObject const* object, bool force = false); void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference); void SendClearThreatListOpcode(); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 79d7c1026d4..898e4841559 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -481,7 +481,7 @@ void MotionMaster::MoveSmoothPath(uint32 pointId, Movement::PointsArray const& p //MovePoint(EVENT_CHARGE_PREPATH, pos, false); } -void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint32 dbChainId, bool walk) +void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk) { Creature* owner = _owner->ToCreature(); if (!owner) diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index a36fab0e735..2dbc5c8f49e 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -210,7 +210,7 @@ class TC_GAME_API MotionMaster //: private std::stack<MovementGenerator *> void MoveSmoothPath(uint32 pointId, G3D::Vector3 const* pathPoints, size_t pathSize, bool walk); void MoveSmoothPath(uint32 pointId, Movement::PointsArray const& points, bool walk); // Walk along spline chain stored in DB (script_spline_chain_meta and script_spline_chain_waypoints) - void MoveAlongSplineChain(uint32 pointId, uint32 dbChainId, bool walk); + void MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk); void MoveAlongSplineChain(uint32 pointId, SplineChain const& chain, bool walk); void ResumeSplineChain(SplineChainResumeInfo const& info); void MoveFall(uint32 id = 0); diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 6cae097c8c4..3e67a44384c 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -106,7 +106,8 @@ void SystemMgr::LoadScriptSplineChains() { Field* fieldsMeta = resultMeta->Fetch(); uint32 entry = fieldsMeta[0].GetUInt32(); - uint8 chainId = fieldsMeta[1].GetUInt8(), splineId = fieldsMeta[2].GetUInt8(); + uint16 chainId = fieldsMeta[1].GetUInt16(); + uint8 splineId = fieldsMeta[2].GetUInt8(); SplineChain& chain = m_mSplineChainsMap[{entry,chainId}]; if (splineId != chain.size()) @@ -127,7 +128,8 @@ void SystemMgr::LoadScriptSplineChains() { Field* fieldsWP = resultWP->Fetch(); uint32 entry = fieldsWP[0].GetUInt32(); - uint8 chainId = fieldsWP[1].GetUInt8(), splineId = fieldsWP[2].GetUInt8(), wpId = fieldsWP[3].GetUInt8(); + uint16 chainId = fieldsWP[1].GetUInt16(); + uint8 splineId = fieldsWP[2].GetUInt8(), wpId = fieldsWP[3].GetUInt8(); float posX = fieldsWP[4].GetFloat(), posY = fieldsWP[5].GetFloat(), posZ = fieldsWP[6].GetFloat(); auto it = m_mSplineChainsMap.find({entry,chainId}); if (it == m_mSplineChainsMap.end()) diff --git a/src/server/game/Scripting/ScriptSystem.h b/src/server/game/Scripting/ScriptSystem.h index 6086b10e2be..7bce7b2e69e 100644 --- a/src/server/game/Scripting/ScriptSystem.h +++ b/src/server/game/Scripting/ScriptSystem.h @@ -87,9 +87,9 @@ class TC_GAME_API SystemMgr return &itr->second; } - SplineChain const* GetSplineChain(uint32 entry, uint8 id) const + SplineChain const* GetSplineChain(uint32 entry, uint16 chainId) const { - auto it = m_mSplineChainsMap.find({ entry, id }); + auto it = m_mSplineChainsMap.find({ entry, chainId }); if (it == m_mSplineChainsMap.end()) return nullptr; return &it->second; @@ -99,7 +99,7 @@ class TC_GAME_API SystemMgr protected: PointMoveMap m_mPointMoveMap; //coordinates for waypoints - typedef std::pair<uint32, uint8> ChainKeyType; // creature entry + chain ID + typedef std::pair<uint32, uint16> ChainKeyType; // creature entry + chain ID std::unordered_map<ChainKeyType, SplineChain> m_mSplineChainsMap; // spline chains }; |
