aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2018-06-03 10:06:57 -0700
committerGitHub <noreply@github.com>2018-06-03 10:06:57 -0700
commit982643cd96790ffc54e7a3e507469649f3b074d2 (patch)
tree90e65482d064fc9b2e8d0e215f2dec6e5fe663c9 /src/server/scripts/Commands
parentb84348f6fc7746349fdcbd443b32fe5483174442 (diff)
Core/Movement: MotionMaster reimplementation (#21888)
Internal structure and handling changes, nothing behavioural (or thats the intention at least).
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_go.cpp82
-rw-r--r--src/server/scripts/Commands/cs_group.cpp9
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp87
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp22
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp35
5 files changed, 72 insertions, 163 deletions
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index a9771331b8c..a3d4c6f13c9 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -27,7 +27,6 @@ EndScriptData */
#include "DatabaseEnv.h"
#include "Language.h"
#include "MapManager.h"
-#include "MotionMaster.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "RBAC.h"
@@ -147,13 +146,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(mapId, x, y, z, o);
return true;
@@ -192,13 +187,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, player->GetOrientation());
return true;
@@ -234,13 +225,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
Map const* map = sMapMgr->CreateBaseMap(mapId);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
@@ -284,13 +271,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(goData->spawnPoint);
return true;
@@ -329,13 +312,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(node->map_id, node->x, node->y, node->z, player->GetOrientation());
return true;
@@ -374,13 +353,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(at->mapid, at->x, at->y, at->z, player->GetOrientation());
return true;
@@ -445,13 +420,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
@@ -506,13 +477,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(mapId, x, y, z, ort);
return true;
@@ -539,13 +506,12 @@ public:
}
Player* player = handler->GetSession()->GetPlayer();
+
+ // stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
ticket->TeleportTo(player);
return true;
@@ -583,13 +549,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(player->GetMapId(), x, y, z, o);
return true;
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index 75f3e222497..b6ed2a60a7b 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -24,7 +24,6 @@
#include "Language.h"
#include "LFG.h"
#include "Map.h"
-#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "RBAC.h"
@@ -142,13 +141,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
// before GM
float x, y, z;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 5565c89e630..36a7a00c2da 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -20,11 +20,9 @@
#include "ArenaTeamMgr.h"
#include "CellImpl.h"
#include "CharacterCache.h"
-#include "ChaseMovementGenerator.h"
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
-#include "FollowMovementGenerator.h"
#include "GridNotifiers.h"
#include "Group.h"
#include "GroupMgr.h"
@@ -37,7 +35,6 @@
#include "MMapFactory.h"
#include "MotionMaster.h"
#include "MovementDefines.h"
-#include "MovementGenerator.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
@@ -449,13 +446,9 @@ public:
// stop flight if need
if (_player->IsInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ _player->FinishTaxiFlight();
else
- _player->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
// to point to see at target with same orientation
float x, y, z;
@@ -483,13 +476,9 @@ public:
// stop flight if need
if (_player->IsInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ _player->FinishTaxiFlight();
else
- _player->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
_player->TeleportTo(map, x, y, z, _player->GetOrientation());
}
@@ -579,14 +568,10 @@ public:
ChatHandler(target->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
// stop flight if need
- if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ if (_player->IsInFlight())
+ _player->FinishTaxiFlight();
else
- target->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
// before GM
float x, y, z;
@@ -885,12 +870,7 @@ public:
return false;
}
- // stop flight if need
- if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
+ target->FinishTaxiFlight();
target->Recall();
return true;
@@ -2138,20 +2118,19 @@ public:
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().GetCounter());
- MotionMaster* motionMaster = unit->GetMotionMaster();
+ if (unit->GetMotionMaster()->Empty())
+ {
+ handler->SendSysMessage("Empty");
+ return true;
+ }
+
float x, y, z;
- motionMaster->GetDestination(x, y, z);
+ unit->GetMotionMaster()->GetDestination(x, y, z);
- for (uint8 itr = 0; itr < MAX_MOTION_SLOT; ++itr)
+ std::vector<MovementGeneratorInformation> list = unit->GetMotionMaster()->GetMovementGeneratorsInformation();
+ for (MovementGeneratorInformation info : list)
{
- MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(MovementSlot(itr));
- if (!movementGenerator)
- {
- handler->SendSysMessage("Empty");
- continue;
- }
-
- switch (movementGenerator->GetMovementGeneratorType())
+ switch (info.Type)
{
case IDLE_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_IDLE);
@@ -2166,45 +2145,33 @@ public:
handler->SendSysMessage(LANG_MOVEGENS_CONFUSED);
break;
case CHASE_MOTION_TYPE:
- {
- Unit* target = static_cast<ChaseMovementGenerator const*>(movementGenerator)->GetTarget();
-
- if (!target)
+ if (info.TargetGUID.IsEmpty())
handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
+ else if (info.TargetGUID.IsPlayer())
+ handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, info.TargetName.c_str(), info.TargetGUID.GetCounter());
else
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
+ handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, info.TargetName.c_str(), info.TargetGUID.GetCounter());
break;
- }
case FOLLOW_MOTION_TYPE:
- {
- Unit* target = static_cast<FollowMovementGenerator const*>(movementGenerator)->GetTarget();
-
- if (!target)
+ if (info.TargetGUID.IsEmpty())
handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
+ else if (info.TargetGUID.IsPlayer())
+ handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, info.TargetName.c_str(), info.TargetGUID.GetCounter());
else
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
+ handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, info.TargetName.c_str(), info.TargetGUID.GetCounter());
break;
- }
case HOME_MOTION_TYPE:
- {
if (unit->GetTypeId() == TYPEID_UNIT)
handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z);
else
handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER);
break;
- }
case FLIGHT_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_FLIGHT);
break;
case POINT_MOTION_TYPE:
- {
handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
break;
- }
case FLEEING_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_FEAR);
break;
@@ -2215,7 +2182,7 @@ public:
handler->SendSysMessage(LANG_MOVEGENS_EFFECT);
break;
default:
- handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
+ handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, info.Type);
break;
}
}
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index ee4d0024450..50fe639eb3f 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -1289,7 +1289,7 @@ public:
return true;
}
- //npc unfollow handling
+ // npc unfollow handling
static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
@@ -1302,26 +1302,24 @@ public:
return false;
}
- if (/*creature->GetMotionMaster()->empty() ||*/
- creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE)
+ MovementGenerator* movement = creature->GetMotionMaster()->GetMovementGenerator([player](MovementGenerator const* a) -> bool
{
- handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
- handler->SetSentErrorMessage(true);
+ if (a->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)
+ {
+ FollowMovementGenerator const* followMovement = dynamic_cast<FollowMovementGenerator const*>(a);
+ return followMovement && followMovement->GetTarget() == player;
+ }
return false;
- }
-
- FollowMovementGenerator const* mgen = static_cast<FollowMovementGenerator const*>((creature->GetMotionMaster()->top()));
+ });
- if (mgen->GetTarget() != player)
+ if (!movement)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
- // reset movement
- creature->GetMotionMaster()->MovementExpired(true);
-
+ creature->GetMotionMaster()->Remove(movement);
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
return true;
}
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 3a9c0331cb2..7afeff82163 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -29,7 +29,6 @@ EndScriptData */
#include "Group.h"
#include "Language.h"
#include "MapManager.h"
-#include "MotionMaster.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "RBAC.h"
@@ -185,13 +184,9 @@ public:
// stop flight if need
if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ target->FinishTaxiFlight();
else
- target->SaveRecallPosition();
+ target->SaveRecallPosition(); // save only in non-flight case
target->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
@@ -283,13 +278,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
@@ -302,7 +293,7 @@ public:
if (!*args)
return false;
- Player* me = handler->GetSession()->GetPlayer();
+ Player* player = handler->GetSession()->GetPlayer();
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
@@ -313,7 +304,7 @@ public:
return false;
}
- if (me->IsInCombat() && !handler->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_TELE_NAME))
+ if (player->IsInCombat() && !handler->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_TELE_NAME))
{
handler->SendSysMessage(LANG_YOU_IN_COMBAT);
handler->SetSentErrorMessage(true);
@@ -321,7 +312,7 @@ public:
}
MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
- if (!map || (map->IsBattlegroundOrArena() && (me->GetMapId() != tele->mapId || !me->IsGameMaster())))
+ if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
{
handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
handler->SetSentErrorMessage(true);
@@ -329,16 +320,12 @@ public:
}
// stop flight if need
- if (me->IsInFlight())
- {
- me->GetMotionMaster()->MovementExpired();
- me->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ if (player->IsInFlight())
+ player->FinishTaxiFlight();
else
- me->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
- me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
+ player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
return true;
}
};