aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp97
1 files changed, 39 insertions, 58 deletions
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index ef61c231104..59036b29186 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -565,25 +565,21 @@ public:
Creature* target = handler->getSelectedCreature();
PreparedStatement* stmt = NULL;
+ // User did select a visual waypoint?
if (!target || target->GetEntry() != VISUAL_WAYPOINT)
{
handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
return false;
}
- // The visual waypoint
- wpGuid = target->GetGUID().GetCounter();
-
- // User did select a visual waypoint?
-
// Check the creature
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
- stmt->setUInt32(0, wpGuid);
+ stmt->setUInt32(0, target->GetSpawnId());
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID().GetCounter());
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetSpawnId());
// Select waypoint number from database
// Since we compare float values, we have to deal with
// some difficulties.
@@ -603,7 +599,7 @@ public:
if (!queryResult)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetSpawnId());
return true;
}
}
@@ -631,13 +627,8 @@ public:
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
- if (wpGuid != 0)
- if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpGuid)))
- {
- wpCreature->CombatStop();
- wpCreature->DeleteFromDB();
- wpCreature->AddObjectToRemoveList();
- }
+ target->DeleteFromDB();
+ target->AddObjectToRemoveList();
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
stmt->setUInt32(0, pathid);
@@ -659,51 +650,40 @@ public:
Player* chr = handler->GetSession()->GetPlayer();
Map* map = chr->GetMap();
+ // What to do:
+ // Move the visual spawnpoint
+ // Respawn the owner of the waypoints
+ target->DeleteFromDB();
+ target->AddObjectToRemoveList();
+
+ // re-create
+ Creature* wpCreature = new Creature();
+ if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
- // What to do:
- // Move the visual spawnpoint
- // Respawn the owner of the waypoints
- if (wpGuid != 0)
- {
- if (Creature* wpCreature = map->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpGuid)))
- {
- wpCreature->CombatStop();
- wpCreature->DeleteFromDB();
- wpCreature->AddObjectToRemoveList();
- }
- // re-create
- Creature* wpCreature2 = new Creature();
- if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
- {
- handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
- delete wpCreature2;
- wpCreature2 = NULL;
- return false;
- }
+ handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
+ delete wpCreature;
+ return false;
+ }
- wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
- // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
- /// @todo Should we first use "Create" then use "LoadFromDB"?
- if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map))
- {
- handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
- delete wpCreature2;
- wpCreature2 = NULL;
- return false;
- }
- //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
- }
+ wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
+ // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
+ /// @todo Should we first use "Create" then use "LoadFromDB"?
+ if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map))
+ {
+ handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
+ delete wpCreature;
+ return false;
+ }
- stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);
- stmt->setFloat(0, chr->GetPositionX());
- stmt->setFloat(1, chr->GetPositionY());
- stmt->setFloat(2, chr->GetPositionZ());
- stmt->setUInt32(3, pathid);
- stmt->setUInt32(4, point);
- WorldDatabase.Execute(stmt);
+ stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);
+ stmt->setFloat(0, chr->GetPositionX());
+ stmt->setFloat(1, chr->GetPositionY());
+ stmt->setFloat(2, chr->GetPositionZ());
+ stmt->setUInt32(3, pathid);
+ stmt->setUInt32(4, point);
+ WorldDatabase.Execute(stmt);
- handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
- }
+ handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
return true;
} // move
@@ -897,14 +877,15 @@ public:
return false;
}
+ wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
+
// Set "wpguid" column to the visual waypoint
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
- stmt->setInt32(0, int32(wpCreature->GetGUID().GetCounter()));
+ stmt->setInt32(0, int32(wpCreature->GetSpawnId()));
stmt->setUInt32(1, pathid);
stmt->setUInt32(2, point);
WorldDatabase.Execute(stmt);
- wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map))
{