Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/game/Commands/CreatureCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2081,9 +2081,18 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
if (subCmd == "del") // Remove WP, no additional command required
{
sWaypointMgr.DeleteNode(wpOwner->GetEntry(), wpOwner->GetGUIDLow(), wpId, wpPathId, wpSource);

if (TemporarySummonWaypoint* wpCreature = dynamic_cast<TemporarySummonWaypoint*>(targetCreature))
wpCreature->UnSummon();
// Unsummon old visuals, summon new ones
UnsummonVisualWaypoints(m_session->GetPlayer(), wpOwner->GetObjectGuid());
WaypointPath const* wpPath = sWaypointMgr.GetPathFromOrigin(wpOwner->GetEntry(), wpOwner->GetGUIDLow(), wpPathId, wpSource);
for (const auto& itr : *wpPath)
{
if (!Helper_CreateWaypointFor(wpOwner, wpSource, wpPathId, itr.first, &itr.second, waypointInfo))
{
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
SetSentErrorMessage(true);
return false;
}
}

if (wpPath->empty())
{
Expand Down
18 changes: 17 additions & 1 deletion src/game/Movement/WaypointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,28 @@ void WaypointManager::DeleteNode(uint32 entry, uint32 dbGuid, uint32 point, int3
if (!path)
return;

WaypointPath::iterator find = path->find(point);
if (find == path->end())
return;

WaypointPath::iterator findNext = path->find(point + 1);
while (findNext != path->end())
{
std::swap(find->second, findNext->second);
++find;
++findNext;
}

char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template";
char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry";
uint32 const key = wpOrigin == PATH_FROM_GUID ? dbGuid : entry;
WorldDatabase.PExecuteLog("DELETE FROM %s WHERE %s=%u AND point=%u", table, key_field, key, point+1);

path->erase(point);
for (WaypointPath::iterator itr = path->begin(); itr != path->end(); ++itr)
if (itr->first > point)
WorldDatabase.PExecuteLog("UPDATE %s SET point=point-1 WHERE %s=%u AND point=%u", table, key_field, key, itr->first + 1);

path->erase(find->first);
}

void WaypointManager::DeletePath(uint32 id)
Expand Down