Core/Players: Changed multi-segment taxi paths to fly nearby flight masters along the way, not directly through them

* Taxi cost on multi-segment paths is now charged per segment when it is started
This commit is contained in:
Shauren committed 2015-09-12 20:15:34 +02:00
1 parent 497aa4425b
commit 2056961aae
13 files changed
+162 -231

No files matched your search

+1
View File
@@ -39,6 +39,7 @@
#include <sstream>
#include <algorithm>
#include <memory>
#include <vector>
#include "Debugging/Errors.h"
+1 -1
View File
@@ -570,7 +570,7 @@ void LoadDBCStores(const std::string& dataPath)
// fill data
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
sTaxiPathNodesByPath[entry->PathID].set(entry->NodeIndex, entry);
sTaxiPathNodesByPath[entry->PathID][entry->NodeIndex] = entry;
// Initialize global taxinodes mask
// include existed nodes that have at least single not spell base (scripted) path
+1 -14
View File
@@ -22,13 +22,8 @@
#include "Common.h"
#include "DBCEnums.h"
#include "Define.h"
#include "Path.h"
#include "Util.h"
#include <map>
#include <set>
#include <vector>
// Structures using to access raw DBC data and required packing to portability
#pragma pack(push, 1)
@@ -2211,15 +2206,7 @@ struct TaxiPathBySourceAndDestination
typedef std::map<uint32, TaxiPathBySourceAndDestination> TaxiPathSetForSource;
typedef std::map<uint32, TaxiPathSetForSource> TaxiPathSetBySource;
struct TaxiPathNodePtr
{
TaxiPathNodePtr() : i_ptr(NULL) { }
TaxiPathNodePtr(TaxiPathNodeEntry const* ptr) : i_ptr(ptr) { }
TaxiPathNodeEntry const* i_ptr;
operator TaxiPathNodeEntry const& () const { return *i_ptr; }
};
typedef Path<TaxiPathNodePtr, TaxiPathNodeEntry const> TaxiPathNodeList;
typedef std::vector<TaxiPathNodeEntry const*> TaxiPathNodeList;
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
#define TaxiMaskSize 14
+19 -14
View File
@@ -21158,6 +21158,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
// fill destinations path tail
uint32 sourcepath = 0;
uint32 totalcost = 0;
uint32 firstcost = 0;
uint32 prevnode = sourcenode;
uint32 lastnode = 0;
@@ -21176,6 +21177,8 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
}
totalcost += cost;
if (i == 1)
firstcost = cost;
if (prevnode == sourcenode)
sourcepath = path;
@@ -21214,8 +21217,6 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
}
//Checks and preparations done, DO FLIGHT
ModifyMoney(-(int32)totalcost);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, totalcost);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN, 1);
// prevent stealth flight
@@ -21226,11 +21227,15 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]);
ASSERT(lastPathNode);
m_taxi.ClearTaxiDestinations();
ModifyMoney(-(int32)totalcost);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, totalcost);
TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation());
return false;
}
else
{
ModifyMoney(-(int32)firstcost);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, firstcost);
GetSession()->SendActivateTaxiReply(ERR_TAXIOK);
GetSession()->SendDoFlight(mount_display_id, sourcepath);
}
@@ -21281,30 +21286,30 @@ void Player::ContinueTaxiFlight()
float distPrev = MAP_SIZE*MAP_SIZE;
float distNext =
(nodeList[0].LocX-GetPositionX())*(nodeList[0].LocX-GetPositionX())+
(nodeList[0].LocY-GetPositionY())*(nodeList[0].LocY-GetPositionY())+
(nodeList[0].LocZ-GetPositionZ())*(nodeList[0].LocZ-GetPositionZ());
(nodeList[0]->LocX - GetPositionX())*(nodeList[0]->LocX - GetPositionX()) +
(nodeList[0]->LocY - GetPositionY())*(nodeList[0]->LocY - GetPositionY()) +
(nodeList[0]->LocZ - GetPositionZ())*(nodeList[0]->LocZ - GetPositionZ());
for (uint32 i = 1; i < nodeList.size(); ++i)
{
TaxiPathNodeEntry const& node = nodeList[i];
TaxiPathNodeEntry const& prevNode = nodeList[i-1];
TaxiPathNodeEntry const* node = nodeList[i];
TaxiPathNodeEntry const* prevNode = nodeList[i-1];
// skip nodes at another map
if (node.MapID != GetMapId())
if (node->MapID != GetMapId())
continue;
distPrev = distNext;
distNext =
(node.LocX-GetPositionX())*(node.LocX-GetPositionX())+
(node.LocY-GetPositionY())*(node.LocY-GetPositionY())+
(node.LocZ-GetPositionZ())*(node.LocZ-GetPositionZ());
(node->LocX - GetPositionX())*(node->LocX - GetPositionX()) +
(node->LocY - GetPositionY())*(node->LocY - GetPositionY()) +
(node->LocZ - GetPositionZ())*(node->LocZ - GetPositionZ());
float distNodes =
(node.LocX-prevNode.LocX)*(node.LocX-prevNode.LocX)+
(node.LocY-prevNode.LocY)*(node.LocY-prevNode.LocY)+
(node.LocZ-prevNode.LocZ)*(node.LocZ-prevNode.LocZ);
(node->LocX - prevNode->LocX)*(node->LocX - prevNode->LocX) +
(node->LocY - prevNode->LocY)*(node->LocY - prevNode->LocY) +
(node->LocZ - prevNode->LocZ)*(node->LocZ - prevNode->LocZ);
if (distNext + distPrev < distNodes)
{
+2
View File
@@ -952,6 +952,8 @@ class PlayerTaxi
m_TaxiDestinations.pop_front();
return GetTaxiDestination();
}
std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
bool empty() const { return m_TaxiDestinations.empty(); }
friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
+7 -7
View File
@@ -3990,7 +3990,7 @@ void ObjectMgr::LoadQuests()
"ItemDrop1, ItemDrop2, ItemDrop3, ItemDrop4, ItemDropQuantity1, ItemDropQuantity2, ItemDropQuantity3, ItemDropQuantity4, "
// 87 88 89 90 91 92 93 94 95 96 97 98
"RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
// 99 100 101 102 103
// 99 100 101 102 103
"Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
" FROM quest_template");
if (!result)
@@ -4011,7 +4011,7 @@ void ObjectMgr::LoadQuests()
} while (result->NextRow());
std::map<uint32, uint32> usedMailTemplates;
// Load `quest_details`
// 0 1 2 3 4 5 6 7 8
result = WorldDatabase.Query("SELECT ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4 FROM quest_details");
@@ -5090,13 +5090,13 @@ void ObjectMgr::LoadEventScripts()
{
for (size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
{
TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx];
TaxiPathNodeEntry const* node = sTaxiPathNodesByPath[path_idx][node_idx];
if (node.ArrivalEventID)
evt_scripts.insert(node.ArrivalEventID);
if (node->ArrivalEventID)
evt_scripts.insert(node->ArrivalEventID);
if (node.DepartureEventID)
evt_scripts.insert(node.DepartureEventID);
if (node->DepartureEventID)
evt_scripts.insert(node->DepartureEventID);
}
}
+19 -47
View File
@@ -24,7 +24,6 @@
#include "Log.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Path.h"
#include "WaypointMovementGenerator.h"
void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvData)
@@ -212,7 +211,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData)
MovementInfo movementInfo; // used only for proper packet read
ReadMovementInfo(recvData, &movementInfo);
recvData.read_skip<uint32>(); // unk
recvData.read_skip<uint32>(); // spline id
// in taxi flight packet received in 2 case:
// 1) end taxi path in far (multi-node) flight
@@ -220,59 +219,32 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData)
// we need process only (1)
uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination();
if (!curDest)
return;
TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest);
// far teleport case
if (curDestNode && curDestNode->map_id != GetPlayer()->GetMapId())
if (curDest)
{
if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest);
// far teleport case
if (curDestNode && curDestNode->map_id != GetPlayer()->GetMapId())
{
// short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->SetCurrentNodeAfterTeleport();
TaxiPathNodeEntry const& node = flight->GetPath()[flight->GetCurrentNode()];
flight->SkipCurrentNode();
GetPlayer()->TeleportTo(curDestNode->map_id, node.LocX, node.LocY, node.LocZ, GetPlayer()->GetOrientation());
}
return;
}
uint32 destinationnode = GetPlayer()->m_taxi.NextTaxiDestination();
if (destinationnode > 0) // if more destinations to go
{
// current source node for next destination
uint32 sourcenode = GetPlayer()->m_taxi.GetTaxiSource();
// Add to taximask middle hubs in taxicheat mode (to prevent having player with disabled taxicheat and not having back flight path)
if (GetPlayer()->isTaxiCheater())
{
if (GetPlayer()->m_taxi.SetTaximaskNode(sourcenode))
if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
{
WorldPacket data(SMSG_NEW_TAXI_PATH, 0);
_player->GetSession()->SendPacket(&data);
// short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->SetCurrentNodeAfterTeleport();
TaxiPathNodeEntry const* node = flight->GetPath()[flight->GetCurrentNode()];
flight->SkipCurrentNode();
GetPlayer()->TeleportTo(curDestNode->map_id, node->LocX, node->LocY, node->LocZ, GetPlayer()->GetOrientation());
}
}
TC_LOG_DEBUG("network", "WORLD: Taxi has to go from %u to %u", sourcenode, destinationnode);
uint32 mountDisplayId = sObjectMgr->GetTaxiMountDisplayId(sourcenode, GetPlayer()->GetTeam());
uint32 path, cost;
sObjectMgr->GetTaxiPath(sourcenode, destinationnode, path, cost);
if (path && mountDisplayId)
SendDoFlight(mountDisplayId, path, 1); // skip start fly node
else
GetPlayer()->m_taxi.ClearTaxiDestinations(); // clear problematic path and next
return;
}
else
GetPlayer()->m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
// at this point only 1 node is expected (final destination)
if (GetPlayer()->m_taxi.GetPath().size() != 1)
return;
GetPlayer()->CleanupAfterTaxiFlight();
GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ());
+4 -4
View File
@@ -112,7 +112,7 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
Movement::PointsArray splinePath, allPoints;
bool mapChange = false;
for (size_t i = 0; i < path.size(); ++i)
allPoints.push_back(G3D::Vector3(path[i].LocX, path[i].LocY, path[i].LocZ));
allPoints.push_back(G3D::Vector3(path[i]->LocX, path[i]->LocY, path[i]->LocZ));
// Add extra points to allow derivative calculations for all path nodes
allPoints.insert(allPoints.begin(), allPoints.front().lerp(allPoints[1], -0.2f));
@@ -128,8 +128,8 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
{
if (!mapChange)
{
TaxiPathNodeEntry const& node_i = path[i];
if (i != path.size() - 1 && (node_i.Flags & 1 || node_i.MapID != path[i + 1].MapID))
TaxiPathNodeEntry const* node_i = path[i];
if (i != path.size() - 1 && (node_i->Flags & 1 || node_i->MapID != path[i + 1]->MapID))
{
keyFrames.back().Teleport = true;
mapChange = true;
@@ -142,7 +142,7 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
k.InitialOrientation = Position::NormalizeOrientation(std::atan2(h.y, h.x) + float(M_PI));
keyFrames.push_back(k);
splinePath.push_back(G3D::Vector3(node_i.LocX, node_i.LocY, node_i.LocZ));
splinePath.push_back(G3D::Vector3(node_i->LocX, node_i->LocY, node_i->LocZ));
transport->mapsUsed.insert(k.Node->MapID);
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ typedef std::unordered_map<uint32, std::set<uint32> > TransportInstanceMap;
struct KeyFrame
{
explicit KeyFrame(TaxiPathNodeEntry const& _node) : Index(0), Node(&_node), InitialOrientation(0.0f),
explicit KeyFrame(TaxiPathNodeEntry const* node) : Index(0), Node(node), InitialOrientation(0.0f),
DistSinceStop(-1.0f), DistUntilStop(-1.0f), DistFromPrev(-1.0f), TimeFrom(0.0f), TimeTo(0.0f),
Teleport(false), ArriveTime(0), DepartureTime(0), Spline(NULL), NextDistFromPrev(0.0f), NextArriveTime(0)
{
+2 -1
View File
@@ -563,7 +563,8 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
if (path < sTaxiPathNodesByPath.size())
{
TC_LOG_DEBUG("misc", "%s taxi to (Path %u node %u)", _owner->GetName().c_str(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(pathnode);
mgen->LoadPath(_owner->ToPlayer());
Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
@@ -245,17 +245,64 @@ bool WaypointMovementGenerator<Creature>::GetResetPos(Creature*, float& x, float
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{
if (i_currentNode >= i_path->size())
return i_path->size();
if (i_currentNode >= i_path.size())
return i_path.size();
uint32 curMapId = (*i_path)[i_currentNode].MapID;
for (uint32 i = i_currentNode; i < i_path->size(); ++i)
{
if ((*i_path)[i].MapID != curMapId)
uint32 curMapId = i_path[i_currentNode]->MapID;
for (uint32 i = i_currentNode; i < i_path.size(); ++i)
if (i_path[i]->MapID != curMapId)
return i;
}
return i_path->size();
return i_path.size();
}
#define SKIP_SPLINE_POINT_DISTANCE_SQ (40.0f * 40.0f)
bool IsNodeIncludedInShortenedPath(TaxiPathNodeEntry const* p1, TaxiPathNodeEntry const* p2)
{
return p1->MapID != p2->MapID || std::pow(p1->LocX - p2->LocX, 2) + std::pow(p1->LocY - p2->LocY, 2) > SKIP_SPLINE_POINT_DISTANCE_SQ;
}
void FlightPathMovementGenerator::LoadPath(Player* player)
{
_pointsForPathSwitch.clear();
std::deque<uint32> const& taxi = player->m_taxi.GetPath();
for (uint32 src = 0, dst = 1; dst < taxi.size(); src = dst++)
{
uint32 path, cost;
sObjectMgr->GetTaxiPath(taxi[src], taxi[dst], path, cost);
if (path > sTaxiPathNodesByPath.size())
return;
TaxiPathNodeList const& nodes = sTaxiPathNodesByPath[path];
if (!nodes.empty())
{
TaxiPathNodeEntry const* start = nodes[0];
TaxiPathNodeEntry const* end = nodes[nodes.size() - 1];
bool passedPreviousSegmentProximityCheck = false;
for (uint32 i = 0; i < nodes.size(); ++i)
{
sMapMgr->CreateMap(nodes[i]->MapID, player)->SummonCreature(1, { nodes[i]->LocX, nodes[i]->LocY, nodes[i]->LocZ, 0.0f })->SetLevel(i ? i : 1);
if (passedPreviousSegmentProximityCheck || !src || i_path.empty() || IsNodeIncludedInShortenedPath(i_path[i_path.size() - 1], nodes[i]))
{
if ((!src || (IsNodeIncludedInShortenedPath(start, nodes[i]) && i >= 2)) &&
(dst == taxi.size() - 1 || (IsNodeIncludedInShortenedPath(end, nodes[i]) && i < nodes.size() - 1)))
{
passedPreviousSegmentProximityCheck = true;
i_path.push_back(nodes[i]);
}
}
else
{
i_path.pop_back();
--_pointsForPathSwitch.back().PathIndex;
}
}
}
_pointsForPathSwitch.push_back({ uint32(i_path.size() - 1), int32(cost) });
}
}
void FlightPathMovementGenerator::DoInitialize(Player* player)
@@ -296,7 +343,7 @@ void FlightPathMovementGenerator::DoReset(Player* player)
uint32 end = GetPathAtMapEnd();
for (uint32 i = GetCurrentNode(); i != end; ++i)
{
G3D::Vector3 vertice((*i_path)[i].LocX, (*i_path)[i].LocY, (*i_path)[i].LocZ);
G3D::Vector3 vertice(i_path[i]->LocX, i_path[i]->LocY, i_path[i]->LocZ);
init.Path().push_back(vertice);
}
init.SetFirstPointId(GetCurrentNode());
@@ -313,9 +360,21 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
bool departureEvent = true;
do
{
DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent);
DoEventIfAny(player, i_path[i_currentNode], departureEvent);
while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= i_currentNode)
{
_pointsForPathSwitch.pop_front();
player->m_taxi.NextTaxiDestination();
if (!_pointsForPathSwitch.empty())
{
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, _pointsForPathSwitch.front().Cost);
player->ModifyMoney(-_pointsForPathSwitch.front().Cost);
}
}
if (pointId == i_currentNode)
break;
if (i_currentNode == _preloadTargetNode)
PreloadEndGrid();
i_currentNode += (uint32)departureEvent;
@@ -324,18 +383,18 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
while (true);
}
return i_currentNode < (i_path->size()-1);
return i_currentNode < (i_path.size() - 1);
}
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
{
if (i_path->empty())
if (i_path.empty() || i_currentNode >= i_path.size())
return;
uint32 map0 = (*i_path)[0].MapID;
for (size_t i = 1; i < i_path->size(); ++i)
uint32 map0 = i_path[i_currentNode]->MapID;
for (size_t i = i_currentNode + 1; i < i_path.size(); ++i)
{
if ((*i_path)[i].MapID != map0)
if (i_path[i]->MapID != map0)
{
i_currentNode = i;
return;
@@ -343,19 +402,21 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
}
}
void FlightPathMovementGenerator::DoEventIfAny(Player* player, TaxiPathNodeEntry const& node, bool departure)
void FlightPathMovementGenerator::DoEventIfAny(Player* player, TaxiPathNodeEntry const* node, bool departure)
{
if (uint32 eventid = departure ? node.DepartureEventID : node.ArrivalEventID)
if (uint32 eventid = departure ? node->DepartureEventID : node->ArrivalEventID)
{
TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.NodeIndex, node.PathID, player->GetName().c_str());
TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node->NodeIndex, node->PathID, player->GetName().c_str());
player->GetMap()->ScriptsStart(sEventScripts, eventid, player, player);
}
}
bool FlightPathMovementGenerator::GetResetPos(Player*, float& x, float& y, float& z)
{
const TaxiPathNodeEntry& node = (*i_path)[i_currentNode];
x = node.LocX; y = node.LocY; z = node.LocZ;
TaxiPathNodeEntry const* node = i_path[i_currentNode];
x = node->LocX;
y = node->LocY;
z = node->LocZ;
return true;
}
@@ -363,11 +424,11 @@ void FlightPathMovementGenerator::InitEndGridInfo()
{
/*! Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will
be reinitialized for each flightmaster at the end of each spline (or stop) in the flight. */
uint32 nodeCount = (*i_path).size(); //! Number of nodes in path.
_endMapId = (*i_path)[nodeCount - 1].MapID; //! MapId of last node
uint32 nodeCount = i_path.size(); //! Number of nodes in path.
_endMapId = i_path[nodeCount - 1]->MapID; //! MapId of last node
_preloadTargetNode = nodeCount - 3;
_endGridX = (*i_path)[nodeCount - 1].LocX;
_endGridY = (*i_path)[nodeCount - 1].LocY;
_endGridX = i_path[nodeCount - 1]->LocX;
_endGridY = i_path[nodeCount - 1]->LocY;
}
void FlightPathMovementGenerator::PreloadEndGrid()
@@ -378,7 +439,7 @@ void FlightPathMovementGenerator::PreloadEndGrid()
// Load the grid
if (endMap)
{
TC_LOG_DEBUG("misc", "Preloading rid (%f, %f) for map %u at node index %u/%u", _endGridX, _endGridY, _endMapId, _preloadTargetNode, (uint32)(i_path->size()-1));
TC_LOG_DEBUG("misc", "Preloading rid (%f, %f) for map %u at node index %u/%u", _endGridX, _endGridY, _endMapId, _preloadTargetNode, (uint32)(i_path.size() - 1));
endMap->LoadGrid(_endGridX, _endGridY);
}
else
@@ -27,13 +27,8 @@
#include "MovementGenerator.h"
#include "WaypointManager.h"
#include "Path.h"
#include "Player.h"
#include <vector>
#include <set>
#define FLIGHT_TRAVEL_UPDATE 100
#define STOP_TIME_FOR_PLAYER 3 * MINUTE * IN_MILLISECONDS // 3 Minutes
#define TIMEDIFF_NEXT_WP 250
@@ -45,8 +40,6 @@ class PathMovementBase
PathMovementBase() : i_path(NULL), i_currentNode(0) { }
virtual ~PathMovementBase() { };
// template pattern, not defined .. override required
void LoadPath(T &);
uint32 GetCurrentNode() const { return i_currentNode; }
protected:
@@ -110,30 +103,30 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium< Crea
* and hence generates ground and activities for the player.
*/
class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, FlightPathMovementGenerator >,
public PathMovementBase<Player, TaxiPathNodeList const*>
public PathMovementBase<Player, TaxiPathNodeList>
{
public:
explicit FlightPathMovementGenerator(TaxiPathNodeList const& pathnodes, uint32 startNode = 0)
explicit FlightPathMovementGenerator(uint32 startNode = 0)
{
i_path = &pathnodes;
i_currentNode = startNode;
_endGridX = 0.0f;
_endGridY = 0.0f;
_endMapId = 0;
_preloadTargetNode = 0;
}
void LoadPath(Player* player);
void DoInitialize(Player*);
void DoReset(Player*);
void DoFinalize(Player*);
bool DoUpdate(Player*, uint32);
MovementGeneratorType GetMovementGeneratorType() const override { return FLIGHT_MOTION_TYPE; }
TaxiPathNodeList const& GetPath() { return *i_path; }
TaxiPathNodeList const& GetPath() { return i_path; }
uint32 GetPathAtMapEnd() const;
bool HasArrived() const { return (i_currentNode >= i_path->size()); }
bool HasArrived() const { return (i_currentNode >= i_path.size()); }
void SetCurrentNodeAfterTeleport();
void SkipCurrentNode() { ++i_currentNode; }
void DoEventIfAny(Player* player, TaxiPathNodeEntry const& node, bool departure);
void DoEventIfAny(Player* player, TaxiPathNodeEntry const* node, bool departure);
bool GetResetPos(Player*, float& x, float& y, float& z);
@@ -141,9 +134,18 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig
void PreloadEndGrid();
private:
float _endGridX; //! X coord of last node location
float _endGridY; //! Y coord of last node location
uint32 _endMapId; //! map Id of last node location
uint32 _preloadTargetNode; //! node index where preloading starts
float _endGridX; //! X coord of last node location
float _endGridY; //! Y coord of last node location
uint32 _endMapId; //! map Id of last node location
uint32 _preloadTargetNode; //! node index where preloading starts
struct TaxiNodeChangeInfo
{
uint32 PathIndex;
int32 Cost;
};
std::deque<TaxiNodeChangeInfo> _pointsForPathSwitch; //! node indexes and costs where TaxiPath changes
};
#endif
-100
View File
@@ -1,100 +0,0 @@
/*
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITYCORE_PATH_H
#define TRINITYCORE_PATH_H
#include "Common.h"
#include <deque>
struct PathNode
{
PathNode(): x(0.0f), y(0.0f), z(0.0f) { }
PathNode(float _x, float _y, float _z): x(_x), y(_y), z(_z) { }
float x, y, z;
};
template<typename PathElem, typename PathNode = PathElem>
class Path
{
public:
size_t size() const { return i_nodes.size(); }
bool empty() const { return i_nodes.empty(); }
void resize(unsigned int sz) { i_nodes.resize(sz); }
void clear() { i_nodes.clear(); }
void erase(uint32 idx) { i_nodes.erase(i_nodes.begin()+idx); }
void crop(unsigned int start, unsigned int end)
{
while (start && !i_nodes.empty())
{
i_nodes.pop_front();
--start;
}
while (end && !i_nodes.empty())
{
i_nodes.pop_back();
--end;
}
}
float GetTotalLength(uint32 start, uint32 end) const
{
float len = 0.0f;
for (uint32 idx=start+1; idx < end; ++idx)
{
PathNode const& node = i_nodes[idx];
PathNode const& prev = i_nodes[idx-1];
float xd = node.x - prev.x;
float yd = node.y - prev.y;
float zd = node.z - prev.z;
len += std::sqrt(xd*xd + yd*yd + zd*zd);
}
return len;
}
float GetTotalLength() const { return GetTotalLength(0, size()); }
float GetPassedLength(uint32 curnode, float x, float y, float z) const
{
float len = GetTotalLength(0, curnode);
if (curnode > 0)
{
PathNode const& node = i_nodes[curnode-1];
float xd = x - node.x;
float yd = y - node.y;
float zd = z - node.z;
len += std::sqrt(xd*xd + yd*yd + zd*zd);
}
return len;
}
PathNode& operator[](size_t idx) { return i_nodes[idx]; }
PathNode const& operator[](size_t idx) const { return i_nodes[idx]; }
void set(size_t idx, PathElem elem) { i_nodes[idx] = elem; }
protected:
std::deque<PathElem> i_nodes;
};
typedef Path<PathNode> SimplePath;
#endif