Skip to content

Commit

Permalink
Movement: Add missing support for waypoint_path and use PathId as Pat…
Browse files Browse the repository at this point in the history
…hId rather than as Entry
  • Loading branch information
killerwife committed Jun 4, 2022
1 parent 3d36ba9 commit 3805416
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/game/Chat/Level2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,7 @@ bool ChatHandler::HandleWpExportCommand(char* args)
case PATH_FROM_ENTRY: key = wpOwner->GetEntry(); key_field = "Entry"; table = "creature_movement_template"; break;
case PATH_FROM_GUID: key = wpOwner->GetGUIDLow(); key_field = "Id"; table = "creature_movement"; break;
case PATH_FROM_EXTERNAL: key = wpOwner->GetEntry(); key_field = "Entry"; table = sWaypointMgr.GetExternalWPTable(); break;
case PATH_FROM_WAYPOINT_PATH: key = wpOwner->GetMotionMaster()->GetPathId(); key_field = "PathId"; table = "waypoint_path"; break;
default:
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/game/MotionGenerators/MotionMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ void MotionMaster::Initialize()
{
// check if creature is part of formation and use waypoint path as path origin
WaypointPathOrigin pathOrigin = WaypointPathOrigin::PATH_NO_PATH;
uint32 pathEntry = 0;
auto creatureGroup = creature->GetCreatureGroup();
if (creatureGroup && creatureGroup->GetFormationEntry() && creatureGroup->GetGroupEntry().GetFormationSlotId(m_owner->GetDbGuid()) == 0)
{
pathEntry = creatureGroup->GetFormationEntry()->MovementID;
m_currentPathId = creatureGroup->GetFormationEntry()->MovementID;
pathOrigin = WaypointPathOrigin::PATH_FROM_WAYPOINT_PATH;
}

(static_cast<WaypointMovementGenerator<Creature>*>(top()))->InitializeWaypointPath(*creature, m_currentPathId, pathOrigin, 0, pathEntry);
(static_cast<WaypointMovementGenerator<Creature>*>(top()))->InitializeWaypointPath(*creature, m_currentPathId, pathOrigin, 0);
}
}
else
Expand Down
40 changes: 35 additions & 5 deletions src/game/MotionGenerators/WaypointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,13 @@ void WaypointManager::DeleteNode(uint32 entry, uint32 dbGuid, uint32 point, uint

char const* const table = waypointOriginTables[wpOrigin];
char const* const key_field = waypointKeyColumn[wpOrigin];
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : entry;
uint32 key = 0;
if (wpOrigin == PATH_FROM_GUID)
key = dbGuid;
else if (wpOrigin == PATH_FROM_WAYPOINT_PATH)
key = pathId;
else
key = ((entry << 8) + pathId);
if (wpOrigin == PATH_FROM_ENTRY)
WorldDatabase.PExecuteLog("DELETE FROM %s WHERE %s=%u AND Point=%u AND PathId=%u", table, key_field, key, point, pathId);
else
Expand Down Expand Up @@ -621,7 +627,13 @@ void WaypointManager::SetNodePosition(uint32 entry, uint32 dbGuid, uint32 point,

char const* const table = waypointOriginTables[wpOrigin];
char const* const key_field = waypointKeyColumn[wpOrigin];
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : entry;
uint32 key = 0;
if (wpOrigin == PATH_FROM_GUID)
key = dbGuid;
else if (wpOrigin == PATH_FROM_WAYPOINT_PATH)
key = pathId;
else
key = ((entry << 8) + pathId);
if (wpOrigin == PATH_FROM_ENTRY)
WorldDatabase.PExecuteLog("UPDATE %s SET PositionX=%f, PositionY=%f, PositionZ=%f WHERE %s=%u AND Point=%u AND PathId=%u", table, x, y, z, key_field, key, point, pathId);
else
Expand All @@ -648,7 +660,13 @@ void WaypointManager::SetNodeWaittime(uint32 entry, uint32 dbGuid, uint32 point,

char const* const table = waypointOriginTables[wpOrigin];
char const* const key_field = waypointKeyColumn[wpOrigin];
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : entry;
uint32 key = 0;
if (wpOrigin == PATH_FROM_GUID)
key = dbGuid;
else if (wpOrigin == PATH_FROM_WAYPOINT_PATH)
key = pathId;
else
key = ((entry << 8) + pathId);
if (wpOrigin == PATH_FROM_ENTRY)
WorldDatabase.PExecuteLog("UPDATE %s SET WaitTime=%u WHERE %s=%u AND Point=%u AND PathId=%u", table, waittime, key_field, key, point, pathId);
else
Expand All @@ -671,7 +689,13 @@ void WaypointManager::SetNodeOrientation(uint32 entry, uint32 dbGuid, uint32 poi

char const* const table = waypointOriginTables[wpOrigin];
char const* const key_field = waypointKeyColumn[wpOrigin];
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : entry;
uint32 key = 0;
if (wpOrigin == PATH_FROM_GUID)
key = dbGuid;
else if (wpOrigin == PATH_FROM_WAYPOINT_PATH)
key = pathId;
else
key = ((entry << 8) + pathId);
if (wpOrigin == PATH_FROM_ENTRY)
WorldDatabase.PExecuteLog("UPDATE %s SET Orientation=%f WHERE %s=%u AND Point=%u AND PathId=%u", table, orientation, key_field, key, point, pathId);
else
Expand All @@ -695,7 +719,13 @@ bool WaypointManager::SetNodeScriptId(uint32 entry, uint32 dbGuid, uint32 point,

char const* const table = waypointOriginTables[wpOrigin];
char const* const key_field = waypointKeyColumn[wpOrigin];
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : ((entry << 8) + pathId);
uint32 key = 0;
if (wpOrigin == PATH_FROM_GUID)
key = dbGuid;
else if (wpOrigin == PATH_FROM_WAYPOINT_PATH)
key = pathId;
else
key = ((entry << 8) + pathId);
if (wpOrigin == PATH_FROM_ENTRY)
WorldDatabase.PExecuteLog("UPDATE %s SET ScriptId=%u WHERE %s=%u AND Point=%u AND PathId=%u", table, scriptId, key_field, key, point, pathId);
else
Expand Down
2 changes: 1 addition & 1 deletion src/game/MotionGenerators/WaypointManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class WaypointManager
wpMap = &m_externalPathTemplateMap;
break;
case PATH_FROM_WAYPOINT_PATH:
key = entry;
key = pathId;
wpMap = &m_pathMovementTemplateMap;
break;
case PATH_NO_PATH:
Expand Down
2 changes: 1 addition & 1 deletion src/game/MotionGenerators/WaypointMovementGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pat
m_PathOrigin = wpOrigin == PATH_NO_PATH ? PATH_FROM_ENTRY : wpOrigin;
i_path = sWaypointMgr.GetPathFromOrigin(overwriteEntry, creature.GetDbGuid(), pathId, m_PathOrigin);
}
m_pathId = wpOrigin == PATH_FROM_WAYPOINT_PATH ? overwriteEntry : pathId; // waypoint path stores pathId in overwriteEntry
m_pathId = pathId;

// No movement found for entry nor guid
if (!i_path)
Expand Down

0 comments on commit 3805416

Please sign in to comment.