Script/Commands: Some safer code in wp modify
This commit is contained in:
@@ -223,6 +223,7 @@ public:
|
|||||||
sWaypointMgr->ReloadPath(id);
|
sWaypointMgr->ReloadPath(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/)
|
static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -605,7 +606,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show == "del" && target)
|
if (show == "del")
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
|
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
|
||||||
|
|
||||||
@@ -615,10 +616,13 @@ public:
|
|||||||
if (wpGuid != 0)
|
if (wpGuid != 0)
|
||||||
{
|
{
|
||||||
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||||
|
if (wpCreature)
|
||||||
|
{
|
||||||
wpCreature->CombatStop();
|
wpCreature->CombatStop();
|
||||||
wpCreature->DeleteFromDB();
|
wpCreature->DeleteFromDB();
|
||||||
wpCreature->AddObjectToRemoveList();
|
wpCreature->AddObjectToRemoveList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
|
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
|
||||||
|
|
||||||
@@ -638,7 +642,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
} // del
|
} // del
|
||||||
|
|
||||||
if (show == "move" && target)
|
if (show == "move")
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
|
handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
|
||||||
|
|
||||||
@@ -652,16 +656,20 @@ public:
|
|||||||
// Respawn the owner of the waypoints
|
// Respawn the owner of the waypoints
|
||||||
if (wpGuid != 0)
|
if (wpGuid != 0)
|
||||||
{
|
{
|
||||||
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||||
|
if (wpCreature)
|
||||||
|
{
|
||||||
wpCreature->CombatStop();
|
wpCreature->CombatStop();
|
||||||
wpCreature->DeleteFromDB();
|
wpCreature->DeleteFromDB();
|
||||||
wpCreature->AddObjectToRemoveList();
|
wpCreature->AddObjectToRemoveList();
|
||||||
|
}
|
||||||
// re-create
|
// re-create
|
||||||
Creature* wpCreature2 = new Creature;
|
Creature* wpCreature2 = new Creature;
|
||||||
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||||
delete wpCreature2;
|
delete wpCreature2;
|
||||||
|
wpCreature2 = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,6 +680,7 @@ public:
|
|||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||||
delete wpCreature2;
|
delete wpCreature2;
|
||||||
|
wpCreature2 = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
|
//sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
|
||||||
|
|||||||
Reference in New Issue
Block a user