TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FlightPathMovementGenerator Class Reference

#include <WaypointMovementGenerator.h>

Classes

struct  TaxiNodeChangeInfo
 node index where preloading starts More...
 

Public Member Functions

 FlightPathMovementGenerator ()
 
void LoadPath (Player *player, uint32 startNode=0)
 
void DoInitialize (Player *)
 
void DoReset (Player *)
 
void DoFinalize (Player *)
 
bool DoUpdate (Player *, uint32)
 
MovementGeneratorType GetMovementGeneratorType () const override
 
TaxiPathNodeList constGetPath ()
 
uint32 GetPathAtMapEnd () const
 
bool HasArrived () const
 
void SetCurrentNodeAfterTeleport ()
 
void SkipCurrentNode ()
 
void DoEventIfAny (Player *player, TaxiPathNodeEntry const *node, bool departure)
 
bool GetResetPos (Player *, float &x, float &y, float &z)
 
void InitEndGridInfo ()
 
void PreloadEndGrid ()
 
- Public Member Functions inherited from MovementGeneratorMedium< Player, FlightPathMovementGenerator >
void Initialize (Unit *u) override
 
void Finalize (Unit *u) override
 
void Reset (Unit *u) override
 
bool Update (Unit *u, uint32 time_diff) override
 
- Public Member Functions inherited from MovementGenerator
virtual ~MovementGenerator ()
 
virtual void unitSpeedChanged ()
 
virtual bool GetResetPosition (Unit *, float &, float &, float &)
 
- Public Member Functions inherited from PathMovementBase< Player, TaxiPathNodeList >
 PathMovementBase ()
 
virtual ~PathMovementBase ()
 
uint32 GetCurrentNode () const
 

Private Attributes

float _endGridX
 
float _endGridY
 X coord of last node location. More...
 
uint32 _endMapId
 Y coord of last node location. More...
 
uint32 _preloadTargetNode
 map Id of last node location More...
 
std::deque< TaxiNodeChangeInfo_pointsForPathSwitch
 

Additional Inherited Members

- Protected Attributes inherited from PathMovementBase< Player, TaxiPathNodeList >
TaxiPathNodeList i_path
 
uint32 i_currentNode
 

Detailed Description

FlightPathMovementGenerator generates movement of the player for the paths and hence generates ground and activities for the player.

Constructor & Destructor Documentation

FlightPathMovementGenerator::FlightPathMovementGenerator ( )
inlineexplicit
110  {
111  i_currentNode = 0;
112  _endGridX = 0.0f;
113  _endGridY = 0.0f;
114  _endMapId = 0;
115  _preloadTargetNode = 0;
116  }
uint32 _endMapId
Y coord of last node location.
Definition: WaypointMovementGenerator.h:140
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47
uint32 _preloadTargetNode
map Id of last node location
Definition: WaypointMovementGenerator.h:141
float _endGridX
Definition: WaypointMovementGenerator.h:138
float _endGridY
X coord of last node location.
Definition: WaypointMovementGenerator.h:139

Member Function Documentation

void FlightPathMovementGenerator::DoEventIfAny ( Player player,
TaxiPathNodeEntry const node,
bool  departure 
)
409 {
410  if (uint32 eventid = departure ? node->DepartureEventID : node->ArrivalEventID)
411  {
412  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());
413  player->GetMap()->ScriptsStart(sEventScripts, eventid, player, player);
414  }
415 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32_t uint32
Definition: Define.h:150
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:52

+ Here is the caller graph for this function:

void FlightPathMovementGenerator::DoFinalize ( Player player)
315 {
316  // remove flag to prevent send object build movement packets for flight state and crash (movement generator already not at top of stack)
317  player->ClearUnitState(UNIT_STATE_IN_FLIGHT);
318 
319  player->Dismount();
321 
322  if (player->m_taxi.empty())
323  {
324  player->getHostileRefManager().setOnlineOfflineState(true);
325  // update z position to ground and orientation for landing point
326  // this prevent cheating with landing point at lags
327  // when client side flight end early in comparison server side
328  player->StopMoving();
329  }
330 
331  player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_TAXI_BENCHMARK);
332 }
Definition: Unit.h:675
Definition: Unit.h:558
Definition: UpdateFields.h:109
Definition: UpdateFields.h:191
Definition: Player.h:534
Definition: Unit.h:693
void FlightPathMovementGenerator::DoInitialize ( Player player)
309 {
310  Reset(player);
311  InitEndGridInfo();
312 }
void Reset(Unit *u) override
Definition: MovementGenerator.h:66
void InitEndGridInfo()
Definition: WaypointMovementGenerator.cpp:426

+ Here is the call graph for this function:

void FlightPathMovementGenerator::DoReset ( Player player)
337 {
338  player->getHostileRefManager().setOnlineOfflineState(false);
339  player->AddUnitState(UNIT_STATE_IN_FLIGHT);
341 
342  Movement::MoveSplineInit init(player);
343  uint32 end = GetPathAtMapEnd();
344  for (uint32 i = GetCurrentNode(); i != end; ++i)
345  {
346  G3D::Vector3 vertice(i_path[i]->Loc.X, i_path[i]->Loc.Y, i_path[i]->Loc.Z);
347  init.Path().push_back(vertice);
348  }
349  init.SetFirstPointId(GetCurrentNode());
350  init.SetFly();
351  init.SetSmooth();
352  init.SetUncompressed();
353  init.SetWalk(true);
354  init.SetVelocity(PLAYER_FLIGHT_SPEED);
355  init.Launch();
356 }
uint32 GetCurrentNode() const
Definition: WaypointMovementGenerator.h:43
Definition: Unit.h:675
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
Definition: Vector3.h:58
uint32_t uint32
Definition: Define.h:150
Definition: Unit.h:558
#define PLAYER_FLIGHT_SPEED
Definition: WaypointMovementGenerator.cpp:334
Definition: UpdateFields.h:109
uint32 GetPathAtMapEnd() const
Definition: WaypointMovementGenerator.cpp:246
Definition: MoveSplineInit.h:52
Definition: Unit.h:693

+ Here is the call graph for this function:

bool FlightPathMovementGenerator::DoUpdate ( Player player,
uint32   
)
359 {
360  uint32 pointId = (uint32)player->movespline->currentPathIdx();
361  if (pointId > i_currentNode)
362  {
363  bool departureEvent = true;
364  do
365  {
366  DoEventIfAny(player, i_path[i_currentNode], departureEvent);
367  while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= i_currentNode)
368  {
369  _pointsForPathSwitch.pop_front();
370  player->m_taxi.NextTaxiDestination();
371  if (!_pointsForPathSwitch.empty())
372  {
373  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, _pointsForPathSwitch.front().Cost);
374  player->ModifyMoney(-_pointsForPathSwitch.front().Cost);
375  }
376  }
377 
378  if (pointId == i_currentNode)
379  break;
380 
382  PreloadEndGrid();
383  i_currentNode += (uint32)departureEvent;
384  departureEvent = !departureEvent;
385  }
386  while (true);
387  }
388 
389  return i_currentNode < (i_path.size() - 1);
390 }
void PreloadEndGrid()
Definition: WaypointMovementGenerator.cpp:437
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
std::deque< TaxiNodeChangeInfo > _pointsForPathSwitch
Definition: WaypointMovementGenerator.h:149
uint32_t uint32
Definition: Define.h:150
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47
void DoEventIfAny(Player *player, TaxiPathNodeEntry const *node, bool departure)
Definition: WaypointMovementGenerator.cpp:408
uint32 _preloadTargetNode
map Id of last node location
Definition: WaypointMovementGenerator.h:141
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

MovementGeneratorType FlightPathMovementGenerator::GetMovementGeneratorType ( ) const
inlineoverridevirtual

Implements MovementGenerator.

122 { return FLIGHT_MOTION_TYPE; }
Definition: MotionMaster.h:45
TaxiPathNodeList const& FlightPathMovementGenerator::GetPath ( )
inline
124 { return i_path; }
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46

+ Here is the caller graph for this function:

uint32 FlightPathMovementGenerator::GetPathAtMapEnd ( ) const
247 {
248  if (i_currentNode >= i_path.size())
249  return i_path.size();
250 
251  uint32 curMapId = i_path[i_currentNode]->MapID;
252  for (uint32 i = i_currentNode; i < i_path.size(); ++i)
253  if (i_path[i]->MapID != curMapId)
254  return i;
255 
256  return i_path.size();
257 }
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
uint32_t uint32
Definition: Define.h:150
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47

+ Here is the caller graph for this function:

bool FlightPathMovementGenerator::GetResetPos ( Player ,
float &  x,
float &  y,
float &  z 
)
418 {
419  TaxiPathNodeEntry const* node = i_path[i_currentNode];
420  x = node->Loc.X;
421  y = node->Loc.Y;
422  z = node->Loc.Z;
423  return true;
424 }
float Z
Definition: DBCEnums.h:36
float Y
Definition: DBCEnums.h:35
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
float X
Definition: DBCEnums.h:34
Definition: DB2Structure.h:1345
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47
DBCPosition3D Loc
Definition: DB2Structure.h:1351
G3D::int16 x
Definition: Vector2int16.h:37
bool FlightPathMovementGenerator::HasArrived ( ) const
inline
126 { return (i_currentNode >= i_path.size()); }
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47
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.

Number of nodes in path.

MapId of last node

427 {
430  uint32 nodeCount = i_path.size();
431  _endMapId = i_path[nodeCount - 1]->MapID;
432  _preloadTargetNode = nodeCount - 3;
433  _endGridX = i_path[nodeCount - 1]->Loc.X;
434  _endGridY = i_path[nodeCount - 1]->Loc.Y;
435 }
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
uint32 _endMapId
Y coord of last node location.
Definition: WaypointMovementGenerator.h:140
uint32_t uint32
Definition: Define.h:150
uint32 _preloadTargetNode
map Id of last node location
Definition: WaypointMovementGenerator.h:141
float _endGridX
Definition: WaypointMovementGenerator.h:138
float _endGridY
X coord of last node location.
Definition: WaypointMovementGenerator.h:139

+ Here is the caller graph for this function:

void FlightPathMovementGenerator::LoadPath ( Player player,
uint32  startNode = 0 
)
267 {
268  i_path.clear();
269  i_currentNode = startNode;
270  _pointsForPathSwitch.clear();
271  std::deque<uint32> const& taxi = player->m_taxi.GetPath();
272  for (uint32 src = 0, dst = 1; dst < taxi.size(); src = dst++)
273  {
274  uint32 path, cost;
275  sObjectMgr->GetTaxiPath(taxi[src], taxi[dst], path, cost);
276  if (path > sTaxiPathNodesByPath.size())
277  return;
278 
279  TaxiPathNodeList const& nodes = sTaxiPathNodesByPath[path];
280  if (!nodes.empty())
281  {
282  TaxiPathNodeEntry const* start = nodes[0];
283  TaxiPathNodeEntry const* end = nodes[nodes.size() - 1];
284  bool passedPreviousSegmentProximityCheck = false;
285  for (uint32 i = 0; i < nodes.size(); ++i)
286  {
287  if (passedPreviousSegmentProximityCheck || !src || i_path.empty() || IsNodeIncludedInShortenedPath(i_path.back(), nodes[i]))
288  {
289  if ((!src || (IsNodeIncludedInShortenedPath(start, nodes[i]) && i >= 2)) &&
290  (dst == taxi.size() - 1 || (IsNodeIncludedInShortenedPath(end, nodes[i]) && i < nodes.size() - 1)))
291  {
292  passedPreviousSegmentProximityCheck = true;
293  i_path.push_back(nodes[i]);
294  }
295  }
296  else
297  {
298  i_path.pop_back();
299  --_pointsForPathSwitch.back().PathIndex;
300  }
301  }
302  }
303 
304  _pointsForPathSwitch.push_back({ uint32(i_path.size() - 1), int32(cost) });
305  }
306 }
bool IsNodeIncludedInShortenedPath(TaxiPathNodeEntry const *p1, TaxiPathNodeEntry const *p2)
Definition: WaypointMovementGenerator.cpp:261
TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DB2Stores.cpp:139
#define sObjectMgr
Definition: ObjectMgr.h:1567
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
std::deque< TaxiNodeChangeInfo > _pointsForPathSwitch
Definition: WaypointMovementGenerator.h:149
uint32_t uint32
Definition: Define.h:150
Definition: DB2Structure.h:1345
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47
int32_t int32
Definition: g3dmath.h:167
uint32_t uint32
Definition: g3dmath.h:168
std::vector< TaxiPathNodeEntry const * > TaxiPathNodeList
Definition: DB2Structure.h:1449

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FlightPathMovementGenerator::PreloadEndGrid ( )
438 {
439  // used to preload the final grid where the flightmaster is
440  Map* endMap = sMapMgr->FindBaseNonInstanceMap(_endMapId);
441 
442  // Load the grid
443  if (endMap)
444  {
445  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));
446  endMap->LoadGrid(_endGridX, _endGridY);
447  }
448  else
449  TC_LOG_DEBUG("misc", "Unable to determine map to preload flightmaster grid");
450 }
void LoadGrid(float x, float y)
Definition: Map.cpp:508
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
uint32 _endMapId
Y coord of last node location.
Definition: WaypointMovementGenerator.h:140
uint32_t uint32
Definition: Define.h:150
Definition: Map.h:259
uint32 _preloadTargetNode
map Id of last node location
Definition: WaypointMovementGenerator.h:141
#define sMapMgr
Definition: MapManager.h:194
float _endGridX
Definition: WaypointMovementGenerator.h:138
float _endGridY
X coord of last node location.
Definition: WaypointMovementGenerator.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport ( )
393 {
394  if (i_path.empty() || i_currentNode >= i_path.size())
395  return;
396 
397  uint32 map0 = i_path[i_currentNode]->MapID;
398  for (size_t i = i_currentNode + 1; i < i_path.size(); ++i)
399  {
400  if (i_path[i]->MapID != map0)
401  {
402  i_currentNode = i;
403  return;
404  }
405  }
406 }
TaxiPathNodeList i_path
Definition: WaypointMovementGenerator.h:46
uint32_t uint32
Definition: Define.h:150
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47

+ Here is the caller graph for this function:

void FlightPathMovementGenerator::SkipCurrentNode ( )
inline
128 { ++i_currentNode; }
uint32 i_currentNode
Definition: WaypointMovementGenerator.h:47

+ Here is the caller graph for this function:

Member Data Documentation

float FlightPathMovementGenerator::_endGridX
private
float FlightPathMovementGenerator::_endGridY
private

X coord of last node location.

uint32 FlightPathMovementGenerator::_endMapId
private

Y coord of last node location.

std::deque<TaxiNodeChangeInfo> FlightPathMovementGenerator::_pointsForPathSwitch
private
uint32 FlightPathMovementGenerator::_preloadTargetNode
private

map Id of last node location


The documentation for this class was generated from the following files: