Core/Movement: first batch of followup commits

This commit is contained in:
Ovahlord committed 2018-08-02 16:03:19 +02:00
1 parent c808b981f7
commit 075a79dac1
13 files changed
+52 -50

No files matched your search

@@ -144,6 +144,7 @@ void SmartAI::PausePath(uint32 delay, bool forced)
_waypointPauseForced = forced;
SetRun(mRun);
me->PauseMovement();
me->SetHomePosition(me->GetPosition());
}
else
_waypointReached = false;
@@ -407,6 +408,7 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
{
_waypointReached = true;
me->PauseMovement();
me->SetHomePosition(me->GetPosition());
}
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
@@ -268,13 +268,6 @@ void Creature::DisappearAndDie()
RemoveCorpse(false);
}
void Creature::PauseMovement(uint32 timer/* = 0*/, uint8 slot/* = 0*/)
{
Unit::PauseMovement(timer, slot);
SetHomePosition(GetPosition());
}
bool Creature::IsReturningHome() const
{
if (GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == HOME_MOTION_TYPE)
@@ -292,7 +292,6 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
uint32 GetCurrentWaypointID() const { return m_waypointID; }
void UpdateWaypointID(uint32 wpID) { m_waypointID = wpID; }
void PauseMovement(uint32 timer = 0, uint8 slot = 0) override; // timer in ms
bool IsReturningHome() const;
void SearchFormation();
+2 -2
View File
@@ -1771,8 +1771,8 @@ class TC_GAME_API Unit : public WorldObject
bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); }
void StopMoving();
virtual void PauseMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms
void ResumeMovement(uint32 timer = 0, uint8 slot = 0);
void PauseMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms
void ResumeMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms
void AddUnitMovementFlag(uint32 f) { m_movementInfo.AddMovementFlag(f); }
void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.RemoveMovementFlag(f); }
@@ -55,6 +55,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData)
// Stop the npc if moving
unit->PauseMovement(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER));
unit->SetHomePosition(unit->GetPosition());
BattlegroundTypeId bgTypeId = sBattlegroundMgr->GetBattleMasterBG(unit->GetEntry());
+1
View File
@@ -613,6 +613,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
// Stop the npc if moving
vendor->PauseMovement(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER));
vendor->SetHomePosition(vendor->GetPosition());
VendorItemData const* vendorItems = vendor->GetVendorItems();
uint32 rawItemCount = vendorItems ? vendorItems->GetItemCount() : 0;
+1
View File
@@ -344,6 +344,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData)
// Stop the npc if moving
unit->PauseMovement(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER));
unit->SetHomePosition(unit->GetPosition());
// If spiritguide, no need for gossip menu, just put player into resurrect queue
if (unit->IsSpiritGuide())
@@ -93,6 +93,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recvData)
// Stop the npc if moving
creature->PauseMovement(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER));
creature->SetHomePosition(creature->GetPosition());
_player->PlayerTalkClass->ClearMenus();
if (creature->AI()->GossipHello(_player))
+2 -2
View File
@@ -73,7 +73,7 @@ void MotionMaster::Initialize()
// clear ALL movement generators (including default)
while (!empty())
{
MovementGenerator *curr = top();
MovementGenerator* curr = top();
pop();
if (curr)
DirectDelete(curr);
@@ -862,7 +862,7 @@ void MotionMaster::DirectDelete(MovementGenerator* curr)
void MotionMaster::DelayedDelete(MovementGenerator* curr)
{
TC_LOG_FATAL("misc", "Unit (Entry %u) is trying to delete its updating Movement Generator (Type %u)!", _owner->GetEntry(), curr->GetMovementGeneratorType());
TC_LOG_DEBUG("misc", "MotionMaster::DelayedDelete: unit (%u) delayed deleting movement generator (type %u)", _owner->GetEntry(), curr->GetMovementGeneratorType());
if (IsStatic(curr))
return;
@@ -31,16 +31,15 @@
#include "WaypointManager.h"
#include "World.h"
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& path, bool repeating)
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(uint32 pathId, bool repeating) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId),
_repeating(repeating), _loadedFromDB(true), _stalled(false), _done(false)
{
}
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& path, bool repeating) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(0),
_repeating(repeating), _loadedFromDB(false), _stalled(false), _done(false)
{
_path = &path;
_nextMoveTime = 0;
_recalculateSpeed = false;
_isArrivalDone = false;
_pathId = 0;
_repeating = repeating;
_loadedFromDB = false;
_stalled = false;
}
void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
@@ -60,14 +59,12 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
return;
}
_nextMoveTime.Reset(3000);
if (CanMove(creature))
StartMoveNow(creature);
_nextMoveTime.Reset(1000);
}
void WaypointMovementGenerator<Creature>::DoInitialize(Creature* creature)
{
_done = false;
LoadPath(creature);
}
@@ -79,8 +76,14 @@ void WaypointMovementGenerator<Creature>::DoFinalize(Creature* creature)
void WaypointMovementGenerator<Creature>::DoReset(Creature* creature)
{
if (CanMove(creature))
if (!_done && CanMove(creature))
StartMoveNow(creature);
else if (_done)
{
// mimic IdleMovementGenerator
if (!creature->IsStopped())
creature->StopMoving();
}
}
void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
@@ -117,10 +120,10 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
{
if (!creature || !creature->IsAlive())
return false;
return true;
if (!_path || _path->nodes.empty())
return false;
if (_done || !_path || _path->nodes.empty())
return true;
// if the owner is the leader of its formation, check members status
if (creature->IsFormationLeader() && !creature->IsFormationLeaderMoveAllowed())
@@ -157,7 +160,8 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
transportPath = false;
// else if (vehicle) - this should never happen, vehicle offsets are const
}
return false;
_done = true;
return true;
}
_currentNode = (_currentNode + 1) % _path->nodes.size();
@@ -229,7 +233,10 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 diff)
{
if (!creature || !creature->IsAlive())
return false;
return true;
if (_done || !_path || _path->nodes.empty())
return true;
if (_stalled || creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
{
@@ -237,10 +244,6 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
return true;
}
// prevent a crash at empty waypoint path.
if (!_path || _path->nodes.empty())
return false;
if (!_nextMoveTime.Passed())
{
_nextMoveTime.Update(diff);
@@ -267,7 +270,7 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
StartMove(creature);
}
}
return true;
return true;
}
void WaypointMovementGenerator<Creature>::MovementInform(Creature* creature)
@@ -315,7 +318,14 @@ bool WaypointMovementGenerator<Creature>::CanMove(Creature* creature)
#define SKIP_SPLINE_POINT_DISTANCE_SQ (40.f * 40.f)
#define PLAYER_FLIGHT_SPEED 32.0f
//----------------------------------------------------//
FlightPathMovementGenerator::FlightPathMovementGenerator(uint32 startNode)
{
_currentNode = startNode;
_endGridX = 0.0f;
_endGridY = 0.0f;
_endMapId = 0;
_preloadTargetNode = 0;
}
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{
@@ -55,7 +55,7 @@ template<>
class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creature, WaypointMovementGenerator<Creature>>, public PathMovementBase<Creature, WaypointPath const*>
{
public:
explicit WaypointMovementGenerator(uint32 pathId = 0, bool repeating = true) : _nextMoveTime(0), _recalculateSpeed(false), _isArrivalDone(false), _pathId(pathId), _repeating(repeating), _loadedFromDB(true), _stalled(false) { }
explicit WaypointMovementGenerator(uint32 pathId = 0, bool repeating = true);
explicit WaypointMovementGenerator(WaypointPath& path, bool repeating = true);
~WaypointMovementGenerator() { _path = nullptr; }
@@ -92,6 +92,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
bool _repeating;
bool _loadedFromDB;
bool _stalled;
bool _done;
};
/**
@@ -101,14 +102,8 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, FlightPathMovementGenerator>, public PathMovementBase<Player, TaxiPathNodeList>
{
public:
explicit FlightPathMovementGenerator(uint32 startNode = 0)
{
_currentNode = startNode;
_endGridX = 0.0f;
_endGridY = 0.0f;
_endMapId = 0;
_preloadTargetNode = 0;
}
explicit FlightPathMovementGenerator(uint32 startNode = 0);
void LoadPath(Player* player);
void DoInitialize(Player*);
void DoReset(Player*);
@@ -31,7 +31,7 @@ void WaypointMgr::Load()
if (!result)
{
TC_LOG_ERROR("server.loading", ">> Loaded 0 waypoints. DB table `waypoint_data` is empty!");
TC_LOG_INFO("server.loading", ">> Loaded 0 waypoints. DB table `waypoint_data` is empty!");
return;
}
@@ -578,11 +578,10 @@ struct npc_raz_the_crazed : public EscortAI
SetCombatMovement(false);
}
void EnterEvadeMode(EvadeReason /*why*/) override
void EnterEvadeMode(EvadeReason why) override
{
me->DeleteThreatList();
me->CombatStop(true);
ReturnToLastPoint();
EscortAI::EnterEvadeMode(why);
DoCastSelf(SPELL_AGGRO_NEARBY_TARGETS, true);
}
void JustAppeared() override