aboutsummaryrefslogtreecommitdiff
path: root/src/game/Level2.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-11 13:27:10 -0500
committermegamage <none@none>2009-05-11 13:27:10 -0500
commit8fc07d443acb86ca436caa05b435c86ea6e9071d (patch)
treec5c96ea63a946bb43d01396be7c3a40073d6def2 /src/game/Level2.cpp
parent91558b8b29f2f81a4a121a3941cf9aaa7243fe96 (diff)
*Change waypoint data structure. Use creature db guid as path id. If a creature uses waypoint movement as default movement type, the path id should be DBGUID*10. For paths of script use, the path id should be DBGUID*10+1 ~ DBGUID*10+9.
*Two sql queries are included. Converter is used to convert the existing path id to new path id. "...creature_add..." is used to change table structure. You can first run the converter, then run the other one. Or run the other one directly and get the new data from the db team. Because it may take hours to run the converter. *If you have custom data, you may need to run the converter. We suggest you use console to run it It is extremely slow to run the query. If you have multiple paths for a creature in your db, you need to do more work to convert it. However, if you know how to use multiple paths, you should already have more db knowledge than I do and you should know how to convert it. *There may be a faster query to convert the db. If you know, please tell us. I am no sql expert. *Backup your db first! *Thanks to X-Savior and subhuman_bob. --HG-- branch : trunk
Diffstat (limited to 'src/game/Level2.cpp')
-rw-r--r--src/game/Level2.cpp71
1 files changed, 43 insertions, 28 deletions
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index bc83aa7a352..782b0f9c44e 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1288,7 +1288,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(const char* args)
// update movement type
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
- if(pCreature && pCreature->GetWaypointPath())
+ if(pCreature && pCreature->GetWaypointPathId())
{
pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
pCreature->GetMotionMaster()->Initialize();
@@ -1609,7 +1609,7 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args)
{
// update movement type
if(doNotDelete == false)
- pCreature->LoadPath(0);
+ pCreature->SetWaypointPathId(0);
pCreature->SetDefaultMovementType(move_type);
pCreature->GetMotionMaster()->Initialize();
@@ -2639,7 +2639,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
if (!path_number)
{
if(target)
- pathid = target->GetWaypointPath();
+ pathid = target->GetWaypointPathId();
else
{
QueryResult *result = WorldDatabase.PQuery( "SELECT MAX(id) FROM waypoint_data");
@@ -2694,7 +2694,6 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
if(*args)
path_number = strtok((char*)args, " ");
-
uint32 pathid = 0;
uint32 guidlow = 0;
Creature* target = getSelectedCreature();
@@ -2725,6 +2724,7 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
return true;
}
+ /*
guidlow = target->GetDBTableGUIDLow();
QueryResult *result = WorldDatabase.PQuery( "SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow);
@@ -2735,10 +2735,11 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
}
else
WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid);
+ */
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow);
- target->LoadPath(pathid);
+ target->SetWaypointPathId(pathid);
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
target->GetMotionMaster()->Initialize();
target->MonsterSay("Path loaded.",0,0);
@@ -2746,20 +2747,19 @@ bool ChatHandler::HandleWpLoadPathCommand(const char *args)
return true;
}
-
bool ChatHandler::HandleReloadAllPaths(const char* args)
{
-if(!*args)
- return false;
+ if(!*args)
+ return false;
-uint32 id = atoi(args);
+ uint32 id = atoi(args);
-if(!id)
- return false;
+ if(!id)
+ return false;
PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id);
WaypointMgr.UpdatePath(id);
- return true;
+ return true;
}
bool ChatHandler::HandleWpUnLoadPathCommand(const char *args)
@@ -2773,24 +2773,39 @@ bool ChatHandler::HandleWpUnLoadPathCommand(const char *args)
return true;
}
- if(target->GetCreatureAddon())
+ if(target->GetWaypointPathId())
{
- if(target->GetCreatureAddon()->path_id != 0)
+ uint32 pathId = target->GetDBTableGUIDLow() * 10;
+ if(target->GetWaypointPathId() == pathId)
{
- WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow());
- target->UpdateWaypointID(0);
- WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
- target->LoadPath(0);
- target->SetDefaultMovementType(IDLE_MOTION_TYPE);
- target->GetMotionMaster()->MoveTargetedHome();
- target->GetMotionMaster()->Initialize();
- target->MonsterSay("Path unloaded.",0,0);
- return true;
+ for(uint32 i = 1; i < 11; ++i)
+ {
+ if(i == 10)
+ {
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target cannot have more than 9 script paths. Unloading failed.");
+ break;
+ }
+
+ if(WaypointMgr.GetPath(++pathId))
+ continue;
+
+ WorldDatabase.PExecute("UPDATE waypoint_data SET id = %u WHERE id = %u", pathId, target->GetDBTableGUIDLow() * 10);
+ WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
+ target->SetWaypointPathId(0);
+ target->UpdateWaypointID(0);
+ target->SetDefaultMovementType(IDLE_MOTION_TYPE);
+ target->GetMotionMaster()->Initialize();
+ target->GetMotionMaster()->MoveTargetedHome();
+ PSendSysMessage("Path unloaded.");
+ break;
+ }
}
- PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
- return true;
+ else
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target has path but that path is not its default path. Unloading failed.");
}
- PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
+ else
+ PSendSysMessage("%s%s|r", "|cffff33ff", "Target has no loaded path.");
+
return true;
}
@@ -3264,7 +3279,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
- pathid = target->GetWaypointPath();
+ pathid = target->GetWaypointPathId();
}
else
@@ -4629,7 +4644,7 @@ bool ChatHandler::HandleNpcAddFormationCommand(const char* args)
group_member->groupAI = 0;
CreatureGroupMap[lowguid] = group_member;
- pCreature->SearchFormation();
+ pCreature->SearchFormationAndPath();
WorldDatabase.PExecuteLog("INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`) VALUES ('%u','%u','%f', '%f', '%u')",
leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI);