diff options
| author | Riztazz <felianther15@gmail.com> | 2016-11-25 00:31:10 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-08-17 20:04:14 +0200 |
| commit | 2caec4f4d20b4c0f91abbcc60b756e00838c7bdd (patch) | |
| tree | 6dcc7dcdd3ed501a1ca87809fec05f7ccfb2a8bc /src/server/game/Movement/Waypoints | |
| parent | 7d60b9a289ee0942cf57b49626c0f3f9caeed331 (diff) | |
Revert "[3.3.5][master] Core/Movement: Smooth movement #13467 (#18020)"
This reverts commit 05fb27dae4e8af859e01e5b9e52b082cba217657.
(cherrypicked from a3c6880579f3326088ecbe5b8c08c4b75ed91a59)
Diffstat (limited to 'src/server/game/Movement/Waypoints')
| -rw-r--r-- | src/server/game/Movement/Waypoints/WaypointManager.cpp | 70 | ||||
| -rw-r--r-- | src/server/game/Movement/Waypoints/WaypointManager.h | 29 |
2 files changed, 69 insertions, 30 deletions
diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp index bf7eb0703ab..9ddf05fe85a 100644 --- a/src/server/game/Movement/Waypoints/WaypointManager.cpp +++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp @@ -24,6 +24,19 @@ WaypointMgr::WaypointMgr() { } +WaypointMgr::~WaypointMgr() +{ + for (WaypointPathContainer::iterator itr = _waypointStore.begin(); itr != _waypointStore.end(); ++itr) + { + for (WaypointPath::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) + delete *it; + + itr->second.clear(); + } + + _waypointStore.clear(); +} + void WaypointMgr::Load() { uint32 oldMSTime = getMSTime(); @@ -42,6 +55,7 @@ void WaypointMgr::Load() do { Field* fields = result->Fetch(); + WaypointData* wp = new WaypointData(); uint32 pathId = fields[0].GetUInt32(); WaypointPath& path = _waypointStore[pathId]; @@ -54,25 +68,25 @@ void WaypointMgr::Load() Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); - WaypointNode wp; - wp.id = fields[1].GetUInt32(); - wp.x = x; - wp.y = y; - wp.z = z; - wp.orientation = o; - wp.moveType = fields[6].GetUInt32(); + wp->id = fields[1].GetUInt32(); + wp->x = x; + wp->y = y; + wp->z = z; + wp->orientation = o; + wp->move_type = fields[6].GetUInt32(); - if (wp.moveType >= WAYPOINT_MOVE_TYPE_MAX) + if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX) { - TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp.id); + TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp->id); + delete wp; continue; } - wp.delay = fields[7].GetUInt32(); - wp.eventId = fields[8].GetUInt32(); - wp.eventChance = fields[9].GetInt16(); + wp->delay = fields[7].GetUInt32(); + wp->event_id = fields[8].GetUInt32(); + wp->event_chance = fields[9].GetInt16(); - path.nodes.push_back(std::move(wp)); + path.push_back(wp); ++count; } while (result->NextRow()); @@ -91,6 +105,9 @@ void WaypointMgr::ReloadPath(uint32 id) WaypointPathContainer::iterator itr = _waypointStore.find(id); if (itr != _waypointStore.end()) { + for (WaypointPath::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) + delete *it; + _waypointStore.erase(itr); } @@ -108,6 +125,7 @@ void WaypointMgr::ReloadPath(uint32 id) do { Field* fields = result->Fetch(); + WaypointData* wp = new WaypointData(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); @@ -117,25 +135,25 @@ void WaypointMgr::ReloadPath(uint32 id) Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); - WaypointNode wp; - wp.id = fields[0].GetUInt32(); - wp.x = x; - wp.y = y; - wp.z = z; - wp.orientation = o; - wp.moveType = fields[5].GetUInt32(); + wp->id = fields[0].GetUInt32(); + wp->x = x; + wp->y = y; + wp->z = z; + wp->orientation = o; + wp->move_type = fields[5].GetUInt32(); - if (wp.moveType >= WAYPOINT_MOVE_TYPE_MAX) + if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX) { - TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp.id); + TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp->id); + delete wp; continue; } - wp.delay = fields[6].GetUInt32(); - wp.eventId = fields[7].GetUInt32(); - wp.eventChance = fields[8].GetUInt8(); + wp->delay = fields[6].GetUInt32(); + wp->event_id = fields[7].GetUInt32(); + wp->event_chance = fields[8].GetUInt8(); - path.nodes.push_back(std::move(wp)); + path.push_back(wp); } while (result->NextRow()); diff --git a/src/server/game/Movement/Waypoints/WaypointManager.h b/src/server/game/Movement/Waypoints/WaypointManager.h index 33e7e650f9f..92867c9c692 100644 --- a/src/server/game/Movement/Waypoints/WaypointManager.h +++ b/src/server/game/Movement/Waypoints/WaypointManager.h @@ -20,9 +20,30 @@ #define TRINITY_WAYPOINTMANAGER_H #include "Define.h" -#include "WaypointDefines.h" +#include <vector> #include <unordered_map> +enum WaypointMoveType +{ + WAYPOINT_MOVE_TYPE_WALK, + WAYPOINT_MOVE_TYPE_RUN, + WAYPOINT_MOVE_TYPE_LAND, + WAYPOINT_MOVE_TYPE_TAKEOFF, + + WAYPOINT_MOVE_TYPE_MAX +}; + +struct WaypointData +{ + uint32 id; + float x, y, z, orientation; + uint32 delay; + uint32 event_id; + uint32 move_type; + uint8 event_chance; +}; + +typedef std::vector<WaypointData*> WaypointPath; typedef std::unordered_map<uint32, WaypointPath> WaypointPathContainer; class TC_GAME_API WaypointMgr @@ -43,14 +64,14 @@ class TC_GAME_API WaypointMgr if (itr != _waypointStore.end()) return &itr->second; - return nullptr; + return NULL; } private: WaypointMgr(); - ~WaypointMgr() { } + ~WaypointMgr(); - std::unordered_map<uint32, WaypointPath> _waypointStore; + WaypointPathContainer _waypointStore; }; #define sWaypointMgr WaypointMgr::instance() |
