*Taxi - preload flightmaster at end of path, by MrSmite

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-13 21:23:05 -07:00
parent 335a3529c1
commit 32d3907576
2 changed files with 46 additions and 0 deletions
+38
View File
@@ -21,6 +21,7 @@
//Extended headers //Extended headers
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "World.h" #include "World.h"
#include "MapManager.h" // for flightmaster grid preloading
//Creature-specific headers //Creature-specific headers
#include "Creature.h" #include "Creature.h"
#include "CreatureAI.h" #include "CreatureAI.h"
@@ -254,6 +255,18 @@ void FlightPathMovementGenerator::Initialize(Player &player)
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd()); player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd());
// 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_mapIds.size(); // Get the number of nodes in the path. i_path and i_mapIds are the
// same size when loaded in ObjectMgr::GetTaxiPathNodes, called from LoadPath()
m_endMapId = i_mapIds[nodeCount -1]; // Get the map ID from the last node
m_preloadTargetNode = nodeCount / 2; // Split the number of nodes in half to preload the flightmaster half-way through the flight
m_endGridX = i_path[nodeCount -1].x; // Get the X position from the last node
m_endGridY = i_path[nodeCount -1].y; // Get tye Y position from the last node
} }
void FlightPathMovementGenerator::Finalize(Player & player) void FlightPathMovementGenerator::Finalize(Player & player)
@@ -285,6 +298,13 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
// do not send movement, it was sent already // do not send movement, it was sent already
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
} }
// check if it's time to preload the flightmaster grid
// at path end
if (i_currentNode == m_preloadTargetNode)
{
PreloadEndGrid();
}
return true; return true;
} }
//else HasArrived() //else HasArrived()
@@ -316,6 +336,24 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
} }
} }
void FlightPathMovementGenerator::PreloadEndGrid()
{
// used to preload the final grid where the flightmaster is
Map *endMap = MapManager::Instance().FindMap(m_endMapId);
// Load the grid
if (endMap)
{
sLog.outDetail("Preloading flightmaster at grid (%f, %f) for map %u", m_endGridX, m_endGridY, m_endMapId);
endMap->LoadGrid(m_endGridX, m_endGridY);
}
else
{
sLog.outDetail("Unable to determine map to preload flightmaster grid");
}
}
// //
// Unique1's ASTAR Pathfinding Code... For future use & reference... // Unique1's ASTAR Pathfinding Code... For future use & reference...
// //
+8
View File
@@ -114,6 +114,14 @@ public PathMovementBase<Player>
void SkipCurrentNode() { ++i_currentNode; } void SkipCurrentNode() { ++i_currentNode; }
bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x,y,z); return true; } bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x,y,z); return true; }
private:
// storage for preloading the flightmaster grid at end
// before reaching final waypoint
uint32 m_endMapId;
uint32 m_preloadTargetNode;
float m_endGridX;
float m_endGridY;
void PreloadEndGrid();
}; };
#endif #endif