Core/Movement: Smooth movement

Implement smooth movement for all waypoint pathing and escortai
This commit is contained in:
Aokromes committed 2016-11-27 16:59:31 +01:00
1 parent 0737ea9b6e
commit f6160d4d0b
14 files changed
+592 -605

No files matched your search

@@ -38,14 +38,6 @@ void SmartWaypointMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
for (std::unordered_map<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
{
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
delete pathItr->second;
delete itr->second;
}
waypoint_map.clear();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMARTAI_WP);
@@ -73,9 +65,10 @@ void SmartWaypointMgr::LoadFromDB()
y = fields[3].GetFloat();
z = fields[4].GetFloat();
WPPath& path = waypoint_map[entry];
if (last_entry != entry)
{
waypoint_map[entry] = new WPPath();
last_id = 1;
count++;
}
@@ -84,7 +77,14 @@ void SmartWaypointMgr::LoadFromDB()
TC_LOG_ERROR("sql.sql", "SmartWaypointMgr::LoadFromDB: Path entry %u, unexpected point id %u, expected %u.", entry, id, last_id);
last_id++;
(*waypoint_map[entry])[id] = new WayPoint(id, x, y, z);
WayPoint point;
point.id = id;
point.x = x;
point.y = y;
point.z = z;
path.push_back(std::move(point));
last_entry = entry;
total++;
@@ -94,17 +94,6 @@ void SmartWaypointMgr::LoadFromDB()
TC_LOG_INFO("server.loading", ">> Loaded %u SmartAI waypoint paths (total %u waypoints) in %u ms", count, total, GetMSTimeDiffToNow(oldMSTime));
}
SmartWaypointMgr::~SmartWaypointMgr()
{
for (std::unordered_map<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
{
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
delete pathItr->second;
delete itr->second;
}
}
SmartAIMgr* SmartAIMgr::instance()
{
static SmartAIMgr instance;
@@ -1064,7 +1053,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
case SMART_ACTION_WP_START:
{
if (!sSmartWaypointMgr->GetPath(e.action.wpStart.pathID))
WPPath const* path = sSmartWaypointMgr->GetPath(e.action.wpStart.pathID);
if (!path || path->empty())
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature %d Event %u Action %u uses non-existent WaypointPath id %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID);
return false;
@@ -1212,7 +1202,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
}
case SMART_ACTION_START_CLOSEST_WAYPOINT:
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:
case SMART_ACTION_STORE_TARGET_LIST: