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

#include <Transport.h>

Public Types

typedef std::set< WorldObject * > PassengerSet
 

Public Member Functions

 ~Transport ()
 
bool Create (ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
void Update (uint32 diff) override
 
void DelayedUpdate (uint32 diff)
 
void BuildUpdate (UpdateDataMapType &data_map) override
 
void AddPassenger (WorldObject *passenger)
 
void RemovePassenger (WorldObject *passenger)
 
PassengerSet constGetPassengers () const
 
CreatureCreateNPCPassenger (ObjectGuid::LowType guid, CreatureData const *data)
 
GameObjectCreateGOPassenger (ObjectGuid::LowType guid, GameObjectData const *data)
 
TempSummonSummonPassenger (uint32 entry, Position const &pos, TempSummonType summonType, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
 Temporarily summons a creature as passenger on this transport. More...
 
void CalculatePassengerPosition (float &x, float &y, float &z, float *o=NULL) const override
 This method transforms supplied transport offsets into global coordinates. More...
 
void CalculatePassengerOffset (float &x, float &y, float &z, float *o=NULL) const override
 This method transforms supplied global coordinates into local offsets. More...
 
uint32 GetTransportPeriod () const override
 
void SetPeriod (uint32 period)
 
uint32 GetTimer () const
 
KeyFrameVec constGetKeyFrames () const
 
void UpdatePosition (float x, float y, float z, float o)
 
void LoadStaticPassengers ()
 Needed when transport moves from inactive to active grid. More...
 
void UnloadStaticPassengers ()
 Needed when transport enters inactive grid. More...
 
void EnableMovement (bool enabled)
 
void SetDelayedAddModelToMap ()
 
TransportTemplate constGetTransportTemplate () const
 
- Public Member Functions inherited from GameObject
 GameObject ()
 
 ~GameObject ()
 
void BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
bool Create (ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
 
GameObjectTemplate constGetGOInfo () const
 
GameObjectData constGetGOData () const
 
GameObjectValue constGetGOValue () const
 
bool IsTransport () const
 
bool IsDynTransport () const
 
bool IsDestructibleBuilding () const
 
ObjectGuid::LowType GetSpawnId () const
 
void UpdateRotationFields (float rotation2=0.0f, float rotation3=0.0f)
 
std::string constGetNameForLocaleIdx (LocaleConstant locale_idx) const override
 
void SaveToDB ()
 
void SaveToDB (uint32 mapid, uint32 spawnMask, uint32 phaseMask)
 
bool LoadFromDB (ObjectGuid::LowType spawnId, Map *map)
 
bool LoadGameObjectFromDB (ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
 
void DeleteFromDB ()
 
void SetOwnerGUID (ObjectGuid owner)
 
ObjectGuid GetOwnerGUID () const
 
UnitGetOwner () const
 
void SetSpellId (uint32 id)
 
uint32 GetSpellId () const
 
time_t GetRespawnTime () const
 
time_t GetRespawnTimeEx () const
 
void SetRespawnTime (int32 respawn)
 
void Respawn ()
 
bool isSpawned () const
 
bool isSpawnedByDefault () const
 
void SetSpawnedByDefault (bool b)
 
uint32 GetRespawnDelay () const
 
void Refresh ()
 
void Delete ()
 
void getFishLoot (Loot *loot, Player *loot_owner)
 
void getFishLootJunk (Loot *loot, Player *loot_owner)
 
GameobjectTypes GetGoType () const
 
void SetGoType (GameobjectTypes type)
 
GOState GetGoState () const
 
void SetGoState (GOState state)
 
void SetTransportState (GOState state, uint32 stopFrame=0)
 
uint8 GetGoArtKit () const
 
void SetGoArtKit (uint8 artkit)
 
uint8 GetGoAnimProgress () const
 
void SetGoAnimProgress (uint8 animprogress)
 
bool SetInPhase (uint32 id, bool update, bool apply) override
 
void EnableCollision (bool enable)
 
void Use (Unit *user)
 
LootState getLootState () const
 
void SetLootState (LootState s, Unit *unit=NULL)
 
uint16 GetLootMode () const
 
bool HasLootMode (uint16 lootMode) const
 
void SetLootMode (uint16 lootMode)
 
void AddLootMode (uint16 lootMode)
 
void RemoveLootMode (uint16 lootMode)
 
void ResetLootMode ()
 
void AddToSkillupList (ObjectGuid const &PlayerGuidLow)
 
bool IsInSkillupList (ObjectGuid const &playerGuid) const
 
void ClearSkillupList ()
 
void AddUniqueUse (Player *player)
 
void AddUse ()
 
uint32 GetUseCount () const
 
uint32 GetUniqueUseCount () const
 
void SaveRespawnTime () override
 
PlayerGetLootRecipient () const
 
GroupGetLootRecipientGroup () const
 
void SetLootRecipient (Unit *unit)
 
bool IsLootAllowedFor (Player const *player) const
 
bool HasLootRecipient () const
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32 quest_id) const override
 
bool ActivateToQuest (Player *target) const
 
void UseDoorOrButton (uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
 
void ResetDoorOrButton ()
 
void TriggeringLinkedGameObject (uint32 trapEntry, Unit *target)
 
bool IsNeverVisible () const override
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsInvisibleDueToDespawn () const override
 
uint8 getLevelForTarget (WorldObject const *target) const override
 
GameObjectLookupFishingHoleAround (float range)
 
void CastSpell (Unit *target, uint32 spell, bool triggered=true)
 
void SendCustomAnim (uint32 anim)
 
bool IsInRange (float x, float y, float z, float radius) const
 
void ModifyHealth (int32 change, Unit *attackerOrHealer=NULL, uint32 spellId=0)
 
void SetDestructibleState (GameObjectDestructibleState state, Player *eventInvoker=NULL, bool setHealth=false)
 
GameObjectDestructibleState GetDestructibleState () const
 
void EventInform (uint32 eventId, WorldObject *invoker=NULL)
 
uint64 GetRotation () const
 
virtual uint32 GetScriptId () const
 
GameObjectAIAI () const
 
std::string GetAIName () const
 
void SetDisplayId (uint32 displayid)
 
uint32 GetDisplayId () const
 
uint32 GetFaction () const
 
void SetFaction (uint32 faction)
 
void GetRespawnPosition (float &x, float &y, float &z, float *ori=NULL) const
 
TransportToTransport ()
 
Transport constToTransport () const
 
float GetStationaryX () const override
 
float GetStationaryY () const override
 
float GetStationaryZ () const override
 
float GetStationaryO () const override
 
void RelocateStationaryPosition (float x, float y, float z, float o)
 
float GetInteractionDistance () const
 
void UpdateModelPosition ()
 
uint16 GetAIAnimKitId () const override
 
void SetAnimKitId (uint16 animKitId, bool oneshot)
 
- Public Member Functions inherited from WorldObject
virtual ~WorldObject ()
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
void CopyPhaseFrom (WorldObject *obj, bool update=false)
 
void UpdateAreaPhase ()
 
void ClearPhases (bool update=false)
 
void RebuildTerrainSwaps ()
 
void RebuildWorldMapAreaSwaps ()
 
bool HasInPhaseList (uint32 phase)
 
uint32 GetPhaseMask () const
 
bool IsInPhase (uint32 phase) const
 
bool IsInPhase (WorldObject const *obj) const
 
bool IsInTerrainSwap (uint32 terrainSwap) const
 
std::set< uint32 > constGetPhases () const
 
std::set< uint32 > constGetTerrainSwaps () const
 
std::set< uint32 > constGetWorldMapAreaSwaps () const
 
int32 GetDBPhase () const
 
void SetDBPhase (int32 p)
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
InstanceScriptGetInstanceScript ()
 
std::string constGetName () const
 
void SetName (std::string const &newname)
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinLOS (float x, float y, float z) const
 
bool IsWithinLOSInMap (WorldObject const *obj) const
 
bool GetDistanceOrder (WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
 
bool IsInRange (WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
 
bool IsInRange2d (float x, float y, float minRange, float maxRange) const
 
bool IsInRange3d (float x, float y, float z, float minRange, float maxRange) const
 
bool isInFront (WorldObject const *target, float arc=float(M_PI)) const
 
bool isInBack (WorldObject const *target, float arc=float(M_PI)) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void SendMessageToSet (WorldPacket const *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self)
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr)
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (WorldObject const *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map constGetBaseMap () const
 
void SetZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0) const
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetPlayerListInGrid (std::list< Player * > &lList, float fMaxSearchRange) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (float const &radius, NOTIFIER &notifier) const
 
TransportGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
virtual ObjectGuid GetTransGUID () const
 
void SetTransport (Transport *t)
 
virtual uint16 GetMovementAnimKitId () const
 
virtual uint16 GetMeleeAnimKitId () const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid constGetGUID () const
 
PackedGuid constGetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
virtual void DestroyForPlayer (Player *target) const
 
int32 GetInt32Value (uint16 index) const
 
uint32 GetUInt32Value (uint16 index) const
 
uint64 GetUInt64Value (uint16 index) const
 
float GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
ObjectGuid constGetGuidValue (uint16 index) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void UpdateUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, uint64 value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetGuidValue (uint16 index, ObjectGuid const &value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid const &value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid const &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt16Value (uint16 index, uint8 offset, int16 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleByteFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
std::vector< uint32 > constGetDynamicValues (uint16 index) const
 
void AddDynamicValue (uint16 index, uint32 value)
 
void RemoveDynamicValue (uint16 index, uint32 value)
 
void ClearDynamicValue (uint16 index)
 
void SetDynamicValue (uint16 index, uint8 offset, uint32 value)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player constToPlayer () const
 
CreatureToCreature ()
 
Creature constToCreature () const
 
UnitToUnit ()
 
Unit constToUnit () const
 
GameObjectToGameObject ()
 
GameObject constToGameObject () const
 
CorpseToCorpse ()
 
Corpse constToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject constToDynObject () const
 
AreaTriggerToAreaTrigger ()
 
AreaTrigger constToAreaTrigger () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
 WorldLocation (WorldLocation const &loc)
 
void WorldRelocate (WorldLocation const &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
WorldLocation GetWorldLocation () const
 
uint32 GetMapId () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
bool operator== (Position const &a)
 
bool operator!= (Position const &a)
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void Relocate (G3D::Vector3 const &pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYStreamer PositionXYStream ()
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (float x, float y) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 
- Public Member Functions inherited from GridObject< GameObject >
virtual ~GridObject ()
 
bool IsInGrid () const
 
void AddToGrid (GridRefManager< GameObject > &m)
 
void RemoveFromGrid ()
 

Private Member Functions

 Transport ()
 
void MoveToNextWaypoint ()
 
float CalculateSegmentPos (float perc)
 
bool TeleportTransport (uint32 newMapid, float x, float y, float z, float o)
 
void DelayedTeleportTransport ()
 
void UpdatePassengerPositions (PassengerSet &passengers)
 
void DoEventIfAny (KeyFrame const &node, bool departure)
 
bool IsMoving () const
 Helpers to know if stop frame was reached. More...
 
void SetMoving (bool val)
 

Private Attributes

TransportTemplate const_transportInfo
 
KeyFrameVec::const_iterator _currentFrame
 
KeyFrameVec::const_iterator _nextFrame
 
TimeTrackerSmall _positionChangeTimer
 
bool _isMoving
 
bool _pendingStop
 
bool _triggeredArrivalEvent
 These are needed to properly control events triggering only once for each frame. More...
 
bool _triggeredDepartureEvent
 
PassengerSet _passengers
 
PassengerSet::iterator _passengerTeleportItr
 
PassengerSet _staticPassengers
 
bool _delayedAddModel
 
bool _delayedTeleport
 

Friends

TransportTransportMgr::CreateTransport (uint32, ObjectGuid::LowType, Map *, uint32, uint32)
 

Additional Inherited Members

- Static Public Member Functions inherited from GameObject
static void SetGoArtKit (uint8 artkit, GameObject *go, ObjectGuid::LowType lowguid=UI64LIT(0))
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 
- Static Public Member Functions inherited from TransportBase
static void CalculatePassengerPosition (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 
static void CalculatePassengerOffset (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 
- Public Attributes inherited from GameObject
Loot loot
 
uint32 m_groupLootTimer
 
ObjectGuid lootingGroupLowGUID
 
GameObjectModelm_model
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealth
 
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealthDetect
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibility
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibilityDetect
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibility
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
MovementInfo m_movementInfo
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX
 
float m_positionY
 
float m_positionZ
 
- Protected Types inherited from GameObject
typedef std::map< uint32,
ObjectGuid
ChairSlotAndUser
 
- Protected Member Functions inherited from GameObject
bool AIM_Initialize ()
 
GameObjectModelCreateModel ()
 
void UpdateModel ()
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid const &guid)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
void _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
uint32 GetDynamicUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint32 flags) const
 
virtual void BuildDynamicValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MapObject
 MapObject ()
 
- Protected Member Functions inherited from TransportBase
 TransportBase ()
 
virtual ~TransportBase ()
 
- Protected Attributes inherited from GameObject
uint32 m_spellId
 
time_t m_respawnTime
 
uint32 m_respawnDelayTime
 
LootState m_lootState
 
ObjectGuid m_lootStateUnitGUID
 
bool m_spawnedByDefault
 
time_t m_cooldownTime
 
GuidSet m_SkillupList
 
ObjectGuid m_ritualOwnerGUID
 
GuidSet m_unique_users
 
uint32 m_usetimes
 
ChairSlotAndUser ChairListSlots
 
ObjectGuid::LowType m_spawnId
 For new or temporary gameobjects is 0 for saved it is lowguid. More...
 
GameObjectTemplate constm_goInfo
 
GameObjectData constm_goData
 
GameObjectValue m_goValue
 
uint64 m_rotation
 
Position m_stationaryPosition
 
ObjectGuid m_lootRecipient
 
ObjectGuid m_lootRecipientGroup
 
uint16 m_LootMode
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
Transportm_transport
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint32 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
std::vector< uint32 > * _dynamicValues
 
UpdateMask _changesMask
 
UpdateMask _dynamicChangesMask
 
UpdateMask_dynamicChangesArrayMask
 
uint16 m_valuesCount
 
uint16 _dynamicValuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Member Typedef Documentation

Constructor & Destructor Documentation

Transport::Transport ( )
private
32  : GameObject(),
33  _transportInfo(NULL), _isMoving(true), _pendingStop(false),
36 {
38 }
PassengerSet _passengers
Definition: Transport.h:127
Definition: UpdateData.h:46
arena_t NULL
Definition: jemalloc_internal.h:624
bool _pendingStop
Definition: Transport.h:121
GameObject()
Definition: GameObject.cpp:38
bool _isMoving
Definition: Transport.h:120
bool _triggeredDepartureEvent
Definition: Transport.h:125
Definition: UpdateData.h:40
bool _delayedTeleport
Definition: Transport.h:132
TransportTemplate const * _transportInfo
Definition: Transport.h:115
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:124
Definition: UpdateData.h:43
PassengerSet::iterator _passengerTeleportItr
Definition: Transport.h:128
bool _delayedAddModel
Definition: Transport.h:131
uint32 m_updateFlag
Definition: Object.h:230
Transport::~Transport ( )
41 {
42  ASSERT(_passengers.empty());
44 }
PassengerSet _passengers
Definition: Transport.h:127
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
Definition: Transport.cpp:548
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

Member Function Documentation

void Transport::AddPassenger ( WorldObject passenger)
238 {
239  if (!IsInWorld())
240  return;
241 
242  if (_passengers.insert(passenger).second)
243  {
244  passenger->SetTransport(this);
245  passenger->m_movementInfo.transport.guid = GetGUID();
246  TC_LOG_DEBUG("entities.transport", "Object %s boarded transport %s.", passenger->GetName().c_str(), GetName().c_str());
247 
248  if (Player* plr = passenger->ToPlayer())
249  sScriptMgr->OnAddPassenger(this, plr);
250  }
251 }
PassengerSet _passengers
Definition: Transport.h:127
MovementInfo m_movementInfo
Definition: Object.h:612
std::string const & GetName() const
Definition: Object.h:479
void SetTransport(Transport *t)
Definition: Object.h:610
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid guid
Definition: Object.h:289
#define sScriptMgr
Definition: ScriptMgr.h:837
bool IsInWorld() const
Definition: Object.h:100

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from WorldObject.

744 {
745  Map::PlayerList const& players = GetMap()->GetPlayers();
746  if (players.isEmpty())
747  return;
748 
749  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
750  BuildFieldsUpdate(itr->GetSource(), data_map);
751 
752  ClearUpdateMask(true);
753 }
void ClearUpdateMask(bool remove)
Definition: Object.cpp:829
Map * GetMap() const
Definition: Object.h:543
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
Definition: Object.cpp:844
iterator begin()
Definition: MapRefManager.h:37
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

void Transport::CalculatePassengerOffset ( float &  x,
float &  y,
float &  z,
float *  o = NULL 
) const
inlineoverridevirtual

This method transforms supplied global coordinates into local offsets.

Implements TransportBase.

79  {
81  }
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied global coordinates into local offsets.
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::CalculatePassengerPosition ( float &  x,
float &  y,
float &  z,
float *  o = NULL 
) const
inlineoverridevirtual

This method transforms supplied transport offsets into global coordinates.

Implements TransportBase.

73  {
75  }
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied transport offsets into global coordinates.
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Transport::CalculateSegmentPos ( float  perc)
private
578 {
579  KeyFrame const& frame = *_currentFrame;
580  const float speed = float(m_goInfo->moTransport.moveSpeed);
581  const float accel = float(m_goInfo->moTransport.accelRate);
582  float timeSinceStop = frame.TimeFrom + (now - (1.0f/IN_MILLISECONDS) * frame.DepartureTime);
583  float timeUntilStop = frame.TimeTo - (now - (1.0f/IN_MILLISECONDS) * frame.DepartureTime);
584  float segmentPos, dist;
585  float accelTime = _transportInfo->accelTime;
586  float accelDist = _transportInfo->accelDist;
587  // calculate from nearest stop, less confusing calculation...
588  if (timeSinceStop < timeUntilStop)
589  {
590  if (timeSinceStop < accelTime)
591  dist = 0.5f * accel * timeSinceStop * timeSinceStop;
592  else
593  dist = accelDist + (timeSinceStop - accelTime) * speed;
594  segmentPos = dist - frame.DistSinceStop;
595  }
596  else
597  {
598  if (timeUntilStop < _transportInfo->accelTime)
599  dist = 0.5f * accel * timeUntilStop * timeUntilStop;
600  else
601  dist = accelDist + (timeUntilStop - accelTime) * speed;
602  segmentPos = frame.DistUntilStop - dist;
603  }
604 
605  return segmentPos / frame.NextDistFromPrev;
606 }
uint32 DepartureTime
Definition: TransportMgr.h:58
float accelTime
Definition: TransportMgr.h:78
float DistUntilStop
Definition: TransportMgr.h:52
float TimeFrom
Definition: TransportMgr.h:54
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
float TimeTo
Definition: TransportMgr.h:55
float DistSinceStop
Definition: TransportMgr.h:51
TransportTemplate const * _transportInfo
Definition: Transport.h:115
Definition: Common.h:103
struct GameObjectTemplate::@221::@238 moTransport
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:117
Definition: TransportMgr.h:40
float NextDistFromPrev
Definition: TransportMgr.h:62
float accelDist
Definition: TransportMgr.h:79

+ Here is the caller graph for this function:

void Transport::CleanupsBeforeDelete ( bool  finalCleanup = true)
overridevirtual

Reimplemented from GameObject.

102 {
104  while (!_passengers.empty())
105  {
106  WorldObject* obj = *_passengers.begin();
107  RemovePassenger(obj);
108  }
109 
110  GameObject::CleanupsBeforeDelete(finalCleanup);
111 }
PassengerSet _passengers
Definition: Transport.h:127
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
Definition: Transport.cpp:548
Definition: Object.h:423
void RemovePassenger(WorldObject *passenger)
Definition: Transport.cpp:253
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: GameObject.cpp:98

+ Here is the call graph for this function:

bool Transport::Create ( ObjectGuid::LowType  guidlow,
uint32  entry,
uint32  mapid,
float  x,
float  y,
float  z,
float  ang,
uint32  animprogress 
)
47 {
48  Relocate(x, y, z, ang);
49 
50  if (!IsPositionValid())
51  {
52  TC_LOG_ERROR("entities.transport", "Transport (GUID: " UI64FMTD ") not created. Suggested coordinates isn't valid (X: %f Y: %f)",
53  guidlow, x, y);
54  return false;
55  }
56 
57  Object::_Create(ObjectGuid::Create<HighGuid::Transport>(guidlow));
58 
59  GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
60 
61  if (!goinfo)
62  {
63  TC_LOG_ERROR("sql.sql", "Transport not created: entry in `gameobject_template` not found, guidlow: " UI64FMTD " map: %u (X: %f Y: %f Z: %f) ang: %f", guidlow, mapid, x, y, z, ang);
64  return false;
65  }
66 
67  m_goInfo = goinfo;
68 
69  TransportTemplate const* tInfo = sTransportMgr->GetTransportTemplate(entry);
70  if (!tInfo)
71  {
72  TC_LOG_ERROR("sql.sql", "Transport %u (name: %s) will not be created, missing `transport_template` entry.", entry, goinfo->name.c_str());
73  return false;
74  }
75 
76  _transportInfo = tInfo;
77 
78  // initialize waypoints
79  _nextFrame = tInfo->keyFrames.begin();
81  _triggeredArrivalEvent = false;
83 
85  SetObjectScale(goinfo->size);
86  SetFaction(goinfo->faction);
88  SetPeriod(tInfo->pathTime);
89  SetEntry(goinfo->entry);
90  SetDisplayId(goinfo->displayId);
91  SetGoState(!goinfo->moTransport.allowstopping ? GO_STATE_READY : GO_STATE_ACTIVE);
93  SetGoAnimProgress(animprogress);
94  SetName(goinfo->name);
95  UpdateRotationFields(0.0f, 1.0f);
96 
97  m_model = CreateModel();
98  return true;
99 }
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:118
void _Create(ObjectGuid const &guid)
Definition: Object.cpp:125
void SetGoType(GameobjectTypes type)
Definition: GameObject.h:965
Definition: GameObject.h:34
#define sTransportMgr
Definition: TransportMgr.h:162
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
struct GameObjectValue::@273 Transport
uint32 displayId
Definition: GameObject.h:38
GameObjectModel * CreateModel()
Definition: GameObject.cpp:2475
void SetEntry(uint32 entry)
Definition: Object.h:108
uint32 faction
Definition: GameObject.h:43
void SetName(std::string const &newname)
Definition: Object.h:480
float size
Definition: GameObject.h:45
void SetGoAnimProgress(uint8 animprogress)
Definition: GameObject.h:973
#define sObjectMgr
Definition: ObjectMgr.h:1567
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
void SetDisplayId(uint32 displayid)
Definition: GameObject.cpp:2188
KeyFrameVec keyFrames
Definition: TransportMgr.h:77
GameObjectModel * m_model
Definition: GameObject.h:1070
void Relocate(float x, float y)
Definition: Position.h:67
bool _triggeredDepartureEvent
Definition: Transport.h:125
Definition: SharedDefines.h:2080
GameObjectValue m_goValue
Definition: GameObject.h:1113
G3D::int16 z
Definition: Vector3int16.h:46
#define UI64FMTD
Definition: Define.h:137
G3D::int16 y
Definition: Vector2int16.h:38
uint32 entry
Definition: GameObject.h:36
Definition: UpdateFields.h:319
Definition: GameObject.h:822
TransportTemplate const * _transportInfo
Definition: Transport.h:115
Definition: GameObject.h:823
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
std::string name
Definition: GameObject.h:39
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:124
virtual void SetObjectScale(float scale)
Definition: Object.h:111
struct GameObjectTemplate::@221::@238 moTransport
uint32 PathProgress
Definition: GameObject.h:779
void SetPeriod(uint32 period)
Definition: Transport.h:84
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:117
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsPositionValid() const
Definition: Position.cpp:40
uint32 flags
Definition: GameObject.h:44
G3D::int16 x
Definition: Vector2int16.h:37
uint32 pathTime
Definition: TransportMgr.h:76
void SetFaction(uint32 faction)
Definition: GameObject.h:1068
Definition: TransportMgr.h:69
void UpdateRotationFields(float rotation2=0.0f, float rotation3=0.0f)
Definition: GameObject.cpp:1943

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject * Transport::CreateGOPassenger ( ObjectGuid::LowType  guid,
GameObjectData const data 
)
339 {
340  Map* map = GetMap();
341  GameObject* go = new GameObject();
342 
343  if (!go->LoadGameObjectFromDB(guid, map, false))
344  {
345  delete go;
346  return NULL;
347  }
348 
349  ASSERT(data);
350 
351  float x = data->posX;
352  float y = data->posY;
353  float z = data->posZ;
354  float o = data->orientation;
355 
356  go->SetTransport(this);
358  go->m_movementInfo.transport.pos.Relocate(x, y, z, o);
359  CalculatePassengerPosition(x, y, z, &o);
360  go->Relocate(x, y, z, o);
361  go->RelocateStationaryPosition(x, y, z, o);
362 
363  if (!go->IsPositionValid())
364  {
365  TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUID().ToString().c_str(), go->GetPositionX(), go->GetPositionY());
366  delete go;
367  return NULL;
368  }
369 
370  if (!map->AddToMap(go))
371  {
372  delete go;
373  return NULL;
374  }
375 
376  _staticPassengers.insert(go);
377  return go;
378 }
Map * GetMap() const
Definition: Object.h:543
PassengerSet _staticPassengers
Definition: Transport.h:129
MovementInfo m_movementInfo
Definition: Object.h:612
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:72
arena_t NULL
Definition: jemalloc_internal.h:624
void SetTransport(Transport *t)
Definition: Object.h:610
GameObject()
Definition: GameObject.cpp:38
struct MovementInfo::TransportInfo transport
void Relocate(float x, float y)
Definition: Position.h:67
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
bool AddToMap(T *)
Definition: Map.cpp:566
bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
Definition: GameObject.cpp:858
void RelocateStationaryPosition(float x, float y, float z, float o)
Definition: GameObject.h:1080
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:880
Definition: Map.h:259
Position pos
Definition: Object.h:290
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
ObjectGuid guid
Definition: Object.h:289
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsPositionValid() const
Definition: Position.cpp:40
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Transport::CreateNPCPassenger ( ObjectGuid::LowType  guid,
CreatureData const data 
)

- transport models are not added to map's dynamic LoS calculations because the current GameObjectModel cannot be moved without recreating

283 {
284  Map* map = GetMap();
285  Creature* creature = new Creature();
286 
287  if (!creature->LoadCreatureFromDB(guid, map, false))
288  {
289  delete creature;
290  return NULL;
291  }
292 
293  ASSERT(data);
294 
295  float x = data->posX;
296  float y = data->posY;
297  float z = data->posZ;
298  float o = data->orientation;
299 
300  creature->SetTransport(this);
301  creature->m_movementInfo.transport.guid = GetGUID();
302  creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
303  CalculatePassengerPosition(x, y, z, &o);
304  creature->Relocate(x, y, z, o);
305  creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
307 
311 
312  if (!creature->IsPositionValid())
313  {
314  TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY());
315  delete creature;
316  return NULL;
317  }
318 
319  if (data->phaseid)
320  creature->SetInPhase(data->phaseid, false, true);
321  else if (data->phaseGroup)
322  for (auto phase : sDB2Manager.GetPhasesForGroup(data->phaseGroup))
323  creature->SetInPhase(phase, false, true);
324  else
325  creature->CopyPhaseFrom(this);
326 
327  if (!map->AddToMap(creature))
328  {
329  delete creature;
330  return NULL;
331  }
332 
333  _staticPassengers.insert(creature);
334  sScriptMgr->OnAddCreaturePassenger(this, creature);
335  return creature;
336 }
#define sDB2Manager
Definition: DB2Stores.h:224
void SetTransportHomePosition(float x, float y, float z, float o)
Definition: Creature.h:675
Map * GetMap() const
Definition: Object.h:543
PassengerSet _staticPassengers
Definition: Transport.h:129
void AddUnitState(uint32 f)
Definition: Unit.h:1394
MovementInfo m_movementInfo
Definition: Object.h:612
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:72
arena_t NULL
Definition: jemalloc_internal.h:624
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
void SetTransport(Transport *t)
Definition: Object.h:610
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
Definition: Creature.h:467
struct MovementInfo::TransportInfo transport
bool SetInPhase(uint32 id, bool update, bool apply) override
Definition: Unit.cpp:14578
float GetOrientation() const
Definition: Position.h:107
void Relocate(float x, float y)
Definition: Position.h:67
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
bool AddToMap(T *)
Definition: Map.cpp:566
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Position pos
Definition: Object.h:290
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
ObjectGuid guid
Definition: Object.h:289
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsPositionValid() const
Definition: Position.cpp:40
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
Definition: Unit.h:577
bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1327
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::DelayedTeleportTransport ( )
private
639 {
640  if (!_delayedTeleport)
641  return;
642 
643  _delayedTeleport = false;
644  Map* newMap = sMapMgr->CreateBaseMap(_nextFrame->Node->MapID);
645  GetMap()->RemoveFromMap<Transport>(this, false);
646  SetMap(newMap);
647 
648  float x = _nextFrame->Node->Loc.X,
649  y = _nextFrame->Node->Loc.Y,
650  z = _nextFrame->Node->Loc.Z,
651  o =_nextFrame->InitialOrientation;
652 
654  {
656 
657  float destX, destY, destZ, destO;
658  obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
659  TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
660 
661  switch (obj->GetTypeId())
662  {
663  case TYPEID_PLAYER:
664  if (!obj->ToPlayer()->TeleportTo(_nextFrame->Node->MapID, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
665  RemovePassenger(obj);
666  break;
668  obj->AddObjectToRemoveList();
669  break;
670  default:
671  RemovePassenger(obj);
672  break;
673  }
674  }
675 
676  Relocate(x, y, z, o);
677  GetMap()->AddToMap<Transport>(this);
678 }
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:118
PassengerSet _passengers
Definition: Transport.h:127
Map * GetMap() const
Definition: Object.h:543
void RemoveFromMap(T *, bool)
Definition: Map.cpp:890
MovementInfo m_movementInfo
Definition: Object.h:612
virtual void SetMap(Map *map)
Definition: Object.cpp:2169
Definition: Transport.h:28
Definition: Object.h:423
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied transport offsets into global coordinates.
void RemovePassenger(WorldObject *passenger)
Definition: Transport.cpp:253
TypeID GetTypeId() const
Definition: Object.h:113
void Relocate(float x, float y)
Definition: Position.h:67
void AddObjectToRemoveList()
Definition: Object.cpp:2205
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
bool AddToMap(T *)
Definition: Map.cpp:566
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
bool _delayedTeleport
Definition: Transport.h:132
Position pos
Definition: Object.h:290
Definition: ObjectGuid.h:33
#define sMapMgr
Definition: MapManager.h:194
PassengerSet::iterator _passengerTeleportItr
Definition: Transport.h:128
G3D::int16 x
Definition: Vector2int16.h:37
Definition: ObjectGuid.h:35

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::DelayedUpdate ( uint32  diff)
230 {
231  if (GetKeyFrames().size() <= 1)
232  return;
233 
235 }
void DelayedTeleportTransport()
Definition: Transport.cpp:638
KeyFrameVec const & GetKeyFrames() const
Definition: Transport.h:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::DoEventIfAny ( KeyFrame const node,
bool  departure 
)
private
734 {
735  if (uint32 eventid = departure ? node.Node->DepartureEventID : node.Node->ArrivalEventID)
736  {
737  TC_LOG_DEBUG("maps.script", "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.Node->NodeIndex, GetName().c_str());
738  GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
739  EventInform(eventid);
740  }
741 }
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33
Map * GetMap() const
Definition: Object.h:543
std::string const & GetName() const
Definition: Object.h:479
void EventInform(uint32 eventId, WorldObject *invoker=NULL)
Definition: GameObject.cpp:1913
#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 call graph for this function:

+ Here is the caller graph for this function:

void Transport::EnableMovement ( bool  enabled)
558 {
559  if (!GetGOInfo()->moTransport.allowstopping)
560  return;
561 
562  _pendingStop = !enabled;
563 }
uint32 allowstopping
Definition: GameObject.h:301
bool _pendingStop
Definition: Transport.h:121
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KeyFrameVec const& Transport::GetKeyFrames ( ) const
inline
87 { return _transportInfo->keyFrames; }
KeyFrameVec keyFrames
Definition: TransportMgr.h:77
TransportTemplate const * _transportInfo
Definition: Transport.h:115

+ Here is the caller graph for this function:

PassengerSet const& Transport::GetPassengers ( ) const
inline
48 { return _passengers; }
PassengerSet _passengers
Definition: Transport.h:127
uint32 Transport::GetTimer ( ) const
inline
85 { return GetGOValue()->Transport.PathProgress; }
struct GameObjectValue::@273 Transport
uint32 PathProgress
Definition: GameObject.h:779
GameObjectValue const * GetGOValue() const
Definition: GameObject.h:896

+ Here is the call graph for this function:

uint32 Transport::GetTransportPeriod ( ) const
inlineoverridevirtual

Reimplemented from GameObject.

uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:322

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TransportTemplate const* Transport::GetTransportTemplate ( ) const
inline
101 { return _transportInfo; }
TransportTemplate const * _transportInfo
Definition: Transport.h:115
bool Transport::IsMoving ( ) const
inlineprivate

Helpers to know if stop frame was reached.

112 { return _isMoving; }
bool _isMoving
Definition: Transport.h:120

+ Here is the caller graph for this function:

void Transport::LoadStaticPassengers ( )

Needed when transport moves from inactive to active grid.

528 {
529  if (uint32 mapId = GetGOInfo()->moTransport.mapID)
530  {
531  CellObjectGuidsMap const& cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetSpawnMode());
532  CellGuidSet::const_iterator guidEnd;
533  for (CellObjectGuidsMap::const_iterator cellItr = cells.begin(); cellItr != cells.end(); ++cellItr)
534  {
535  // Creatures on transport
536  guidEnd = cellItr->second.creatures.end();
537  for (CellGuidSet::const_iterator guidItr = cellItr->second.creatures.begin(); guidItr != guidEnd; ++guidItr)
538  CreateNPCPassenger(*guidItr, sObjectMgr->GetCreatureData(*guidItr));
539 
540  // GameObjects on transport
541  guidEnd = cellItr->second.gameobjects.end();
542  for (CellGuidSet::const_iterator guidItr = cellItr->second.gameobjects.begin(); guidItr != guidEnd; ++guidItr)
543  CreateGOPassenger(*guidItr, sObjectMgr->GetGOData(*guidItr));
544  }
545  }
546 }
Creature * CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const *data)
Definition: Transport.cpp:282
Map * GetMap() const
Definition: Object.h:543
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
int32 mapID
Definition: GameObject.h:245
GameObject * CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: Transport.cpp:338
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
Definition: ObjectMgr.h:415

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::MoveToNextWaypoint ( )
private
566 {
567  // Clear events flagging
568  _triggeredArrivalEvent = false;
569  _triggeredDepartureEvent = false;
570 
571  // Set frames
573  if (_nextFrame == GetKeyFrames().end())
574  _nextFrame = GetKeyFrames().begin();
575 }
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:118
KeyFrameVec const & GetKeyFrames() const
Definition: Transport.h:87
bool _triggeredDepartureEvent
Definition: Transport.h:125
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:124
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::RemovePassenger ( WorldObject passenger)
254 {
255  bool erased = false;
256  if (_passengerTeleportItr != _passengers.end())
257  {
258  PassengerSet::iterator itr = _passengers.find(passenger);
259  if (itr != _passengers.end())
260  {
261  if (itr == _passengerTeleportItr)
263 
264  _passengers.erase(itr);
265  erased = true;
266  }
267  }
268  else
269  erased = _passengers.erase(passenger) > 0;
270 
271  if (erased || _staticPassengers.erase(passenger)) // static passenger can remove itself in case of grid unload
272  {
273  passenger->SetTransport(NULL);
274  passenger->m_movementInfo.transport.Reset();
275  TC_LOG_DEBUG("entities.transport", "Object %s removed from transport %s.", passenger->GetName().c_str(), GetName().c_str());
276 
277  if (Player* plr = passenger->ToPlayer())
278  sScriptMgr->OnRemovePassenger(this, plr);
279  }
280 }
PassengerSet _passengers
Definition: Transport.h:127
PassengerSet _staticPassengers
Definition: Transport.h:129
MovementInfo m_movementInfo
Definition: Object.h:612
std::string const & GetName() const
Definition: Object.h:479
arena_t NULL
Definition: jemalloc_internal.h:624
void SetTransport(Transport *t)
Definition: Object.h:610
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
void Reset()
Definition: Object.h:279
PassengerSet::iterator _passengerTeleportItr
Definition: Transport.h:128
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::SetDelayedAddModelToMap ( )
inline
99 { _delayedAddModel = true; }
bool _delayedAddModel
Definition: Transport.h:131
void Transport::SetMoving ( bool  val)
inlineprivate
113 { _isMoving = val; }
bool _isMoving
Definition: Transport.h:120

+ Here is the caller graph for this function:

void Transport::SetPeriod ( uint32  period)
inline
84 { SetUInt32Value(GAMEOBJECT_LEVEL, period); }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:322

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Transport::SummonPassenger ( uint32  entry,
Position const pos,
TempSummonType  summonType,
SummonPropertiesEntry const properties = NULL,
uint32  duration = 0,
Unit summoner = NULL,
uint32  spellId = 0,
uint32  vehId = 0 
)

Temporarily summons a creature as passenger on this transport.

Parameters
entryId of the creature from creature_template table
posInitial position of the creature (transport offsets)
summonType
properties
durationDetermines how long the creauture will exist in world depending on (in milliseconds)
summonerSummoner of the creature (for AI purposes)
spellId
vehIdIf set, this value overrides vehicle id from creature_template that the creature will use
Returns
Summoned creature.

- transport models are not added to map's dynamic LoS calculations because the current GameObjectModel cannot be moved without recreating

381 {
382  Map* map = FindMap();
383  if (!map)
384  return NULL;
385 
386  uint32 mask = UNIT_MASK_SUMMON;
387  if (properties)
388  {
389  switch (properties->Category)
390  {
391  case SUMMON_CATEGORY_PET:
392  mask = UNIT_MASK_GUARDIAN;
393  break;
395  mask = UNIT_MASK_PUPPET;
396  break;
398  mask = UNIT_MASK_MINION;
399  break;
402  case SUMMON_CATEGORY_UNK:
403  {
404  switch (properties->Type)
405  {
406  case SUMMON_TYPE_MINION:
409  mask = UNIT_MASK_GUARDIAN;
410  break;
411  case SUMMON_TYPE_TOTEM:
413  mask = UNIT_MASK_TOTEM;
414  break;
415  case SUMMON_TYPE_VEHICLE:
417  mask = UNIT_MASK_SUMMON;
418  break;
419  case SUMMON_TYPE_MINIPET:
420  mask = UNIT_MASK_MINION;
421  break;
422  default:
423  if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
424  mask = UNIT_MASK_GUARDIAN;
425  break;
426  }
427  break;
428  }
429  default:
430  return NULL;
431  }
432  }
433 
434  std::set<uint32> phases;
435  if (summoner)
436  phases = summoner->GetPhases();
437  else
438  phases = GetPhases(); // If there was no summoner, try to use the transport phases
439 
440  TempSummon* summon = NULL;
441  switch (mask)
442  {
443  case UNIT_MASK_SUMMON:
444  summon = new TempSummon(properties, summoner, false);
445  break;
446  case UNIT_MASK_GUARDIAN:
447  summon = new Guardian(properties, summoner, false);
448  break;
449  case UNIT_MASK_PUPPET:
450  summon = new Puppet(properties, summoner);
451  break;
452  case UNIT_MASK_TOTEM:
453  summon = new Totem(properties, summoner);
454  break;
455  case UNIT_MASK_MINION:
456  summon = new Minion(properties, summoner, false);
457  break;
458  }
459 
460  float x, y, z, o;
461  pos.GetPosition(x, y, z, o);
462  CalculatePassengerPosition(x, y, z, &o);
463 
464  if (!summon->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, 0, entry, x, y, z, o, nullptr, vehId))
465  {
466  delete summon;
467  return NULL;
468  }
469 
470  for (uint32 phase : phases)
471  summon->SetInPhase(phase, false, true);
472 
473  summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
474 
475  summon->SetTransport(this);
476  summon->m_movementInfo.transport.guid = GetGUID();
477  summon->m_movementInfo.transport.pos.Relocate(pos);
478  summon->Relocate(x, y, z, o);
479  summon->SetHomePosition(x, y, z, o);
480  summon->SetTransportHomePosition(pos);
481 
485 
486  summon->InitStats(duration);
487 
488  if (!map->AddToMap<Creature>(summon))
489  {
490  delete summon;
491  return NULL;
492  }
493 
494  _staticPassengers.insert(summon);
495 
496  summon->InitSummon();
497  summon->SetTempSummonType(summonType);
498 
499  return summon;
500 }
Definition: TemporarySummon.h:83
Definition: TemporarySummon.h:40
void SetTransportHomePosition(float x, float y, float z, float o)
Definition: Creature.h:675
Definition: SharedDefines.h:4404
PassengerSet _staticPassengers
Definition: Transport.h:129
Definition: SharedDefines.h:4400
void AddUnitState(uint32 f)
Definition: Unit.h:1394
Definition: Unit.h:860
Definition: SharedDefines.h:4406
Definition: TemporarySummon.h:107
Definition: SharedDefines.h:4385
MovementInfo m_movementInfo
Definition: Object.h:612
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:72
Definition: UpdateFields.h:134
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const *data=nullptr, uint32 vehId=0)
Definition: Creature.cpp:834
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
void SetTransport(Transport *t)
Definition: Object.h:610
Definition: Creature.h:467
Definition: SharedDefines.h:4387
Definition: Unit.h:859
struct MovementInfo::TransportInfo transport
bool SetInPhase(uint32 id, bool update, bool apply) override
Definition: Unit.cpp:14578
Definition: Totem.h:38
Definition: TemporarySummon.h:66
void Relocate(float x, float y)
Definition: Position.h:67
Map * FindMap() const
Definition: Object.h:544
G3D::int16 z
Definition: Vector3int16.h:46
Definition: SharedDefines.h:4398
bool AddToMap(T *)
Definition: Map.cpp:566
Definition: SharedDefines.h:4401
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: SharedDefines.h:4386
Definition: Unit.h:858
Definition: Map.h:259
Definition: SharedDefines.h:4384
Position pos
Definition: Object.h:290
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::set< uint32 > const & GetPhases() const
Definition: Object.h:465
Definition: SharedDefines.h:4389
virtual void InitSummon()
Definition: TemporarySummon.cpp:220
Definition: SharedDefines.h:4405
Definition: SharedDefines.h:4397
ObjectGuid guid
Definition: Object.h:289
void SetTempSummonType(TempSummonType type)
Definition: TemporarySummon.cpp:232
Definition: Unit.h:861
virtual void InitStats(uint32 lifetime)
Definition: TemporarySummon.cpp:176
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
Definition: SharedDefines.h:4388
Definition: Unit.h:577
Definition: Unit.h:864
Definition: SharedDefines.h:4399

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Transport::TeleportTransport ( uint32  newMapid,
float  x,
float  y,
float  z,
float  o 
)
private
609 {
610  Map const* oldMap = GetMap();
611 
612  if (oldMap->GetId() != newMapid)
613  {
614  _delayedTeleport = true;
616  return true;
617  }
618  else
619  {
620  // Teleport players, they need to know it
621  for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
622  {
623  if ((*itr)->GetTypeId() == TYPEID_PLAYER)
624  {
625  float destX, destY, destZ, destO;
626  (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
627  TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
628 
629  (*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO);
630  }
631  }
632 
633  UpdatePosition(x, y, z, o);
634  return false;
635  }
636 }
PassengerSet _passengers
Definition: Transport.h:127
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
Definition: Transport.cpp:548
Map * GetMap() const
Definition: Object.h:543
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied transport offsets into global coordinates.
uint32 GetId(void) const
Definition: Map.h:325
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
bool _delayedTeleport
Definition: Transport.h:132
void UpdatePosition(float x, float y, float z, float o)
Definition: Transport.cpp:502
Definition: ObjectGuid.h:33
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::UnloadStaticPassengers ( )

Needed when transport enters inactive grid.

549 {
550  while (!_staticPassengers.empty())
551  {
552  WorldObject* obj = *_staticPassengers.begin();
553  obj->AddObjectToRemoveList(); // also removes from _staticPassengers
554  }
555 }
PassengerSet _staticPassengers
Definition: Transport.h:129
Definition: Object.h:423
void AddObjectToRemoveList()
Definition: Object.cpp:2205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::Update ( uint32  diff)
overridevirtual

Reimplemented from GameObject.

114 {
115  uint32 const positionUpdateDelay = 200;
116 
117  if (AI())
118  AI()->UpdateAI(diff);
119  else if (!AIM_Initialize())
120  TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");
121 
122  if (GetKeyFrames().size() <= 1)
123  return;
124 
125  if (IsMoving() || !_pendingStop)
127 
129 
130  // Set current waypoint
131  // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
132  // ... arrive | ... delay ... | departure
133  // event / event /
134  for (;;)
135  {
136  if (timer >= _currentFrame->ArriveTime)
137  {
139  {
140  DoEventIfAny(*_currentFrame, false);
141  _triggeredArrivalEvent = true;
142  }
143 
144  if (timer < _currentFrame->DepartureTime)
145  {
146  SetMoving(false);
148  {
153  }
154  break; // its a stop frame and we are waiting
155  }
156  }
157 
158  if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
159  {
160  DoEventIfAny(*_currentFrame, true); // departure event
162  }
163 
164  // not waiting anymore
165  SetMoving(true);
166 
167  // Enable movement
168  if (GetGOInfo()->moTransport.allowstopping)
170 
171  if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
172  break; // found current waypoint
173 
175 
176  sScriptMgr->OnRelocate(this, _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);
177 
178  TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);
179 
180  // Departure event
181  if (_currentFrame->IsTeleportFrame())
182  if (TeleportTransport(_nextFrame->Node->MapID, _nextFrame->Node->Loc.X, _nextFrame->Node->Loc.Y, _nextFrame->Node->Loc.Z, _nextFrame->InitialOrientation))
183  return; // Update more in new map thread
184  }
185 
186  // Add model to map after we are fully done with moving maps
187  if (_delayedAddModel)
188  {
189  _delayedAddModel = false;
190  if (m_model)
192  }
193 
194  // Set position
197  {
198  _positionChangeTimer.Reset(positionUpdateDelay);
199  if (IsMoving())
200  {
201  float t = CalculateSegmentPos(float(timer) * 0.001f);
202  G3D::Vector3 pos, dir;
203  _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
204  _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
205  UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI));
206  }
207  else
208  {
209  /* There are four possible scenarios that trigger loading/unloading passengers:
210  1. transport moves from inactive to active grid
211  2. the grid that transport is currently in becomes active
212  3. transport moves from active to inactive grid
213  4. the grid that transport is currently in unloads
214  */
215  bool gridActive = GetMap()->IsGridLoaded(GetPositionX(), GetPositionY());
216 
217  if (_staticPassengers.empty() && gridActive) // 2.
219  else if (!_staticPassengers.empty() && !gridActive)
220  // 4. - if transports stopped on grid edge, some passengers can remain in active grids
221  // unload all static passengers otherwise passengers won't load correctly when the grid that transport is currently in becomes active
223  }
224  }
225 
226  sScriptMgr->OnTransportUpdate(this, diff);
227 }
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:118
GameObjectAI * AI() const
Definition: GameObject.h:1061
bool AIM_Initialize()
Definition: GameObject.cpp:77
float x
Definition: Vector3.h:62
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
Definition: Transport.cpp:548
GOState GetGoState() const
Definition: GameObject.h:966
Map * GetMap() const
Definition: Object.h:543
PassengerSet _staticPassengers
Definition: Transport.h:129
#define M_PI
Definition: Common.h:163
uint32 allowstopping
Definition: GameObject.h:301
std::string const & GetName() const
Definition: Object.h:479
uint32 GetTransportPeriod() const override
Definition: Transport.h:83
bool _pendingStop
Definition: Transport.h:121
struct GameObjectValue::@273 Transport
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void DoEventIfAny(KeyFrame const &node, bool departure)
Definition: Transport.cpp:733
float y
Definition: Vector3.h:62
Definition: Vector3.h:58
virtual void UpdateAI(uint32)
Definition: GameObjectAI.h:37
KeyFrameVec const & GetKeyFrames() const
Definition: Transport.h:87
void Update(int32 diff)
Definition: Timer.h:143
GameObjectModel * m_model
Definition: GameObject.h:1070
bool _triggeredDepartureEvent
Definition: Transport.h:125
GameObjectValue m_goValue
Definition: GameObject.h:1113
float GetPositionY() const
Definition: Position.h:105
void LoadStaticPassengers()
Needed when transport moves from inactive to active grid.
Definition: Transport.cpp:527
void SetMoving(bool val)
Definition: Transport.h:113
float CalculateSegmentPos(float perc)
Definition: Transport.cpp:577
TimeTrackerSmall _positionChangeTimer
Definition: Transport.h:119
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
void Reset(uint32 interval)
Definition: Timer.h:153
Definition: GameObject.h:822
Definition: GameObject.h:823
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
Definition: Transport.cpp:608
float z
Definition: Vector3.h:62
void UpdatePosition(float x, float y, float z, float o)
Definition: Transport.cpp:502
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:124
void MoveToNextWaypoint()
Definition: Transport.cpp:565
uint32 PathProgress
Definition: GameObject.h:779
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:117
bool _delayedAddModel
Definition: Transport.h:131
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
float GetPositionX() const
Definition: Position.h:104
void InsertGameObjectModel(const GameObjectModel &model)
Definition: Map.h:506
bool IsMoving() const
Helpers to know if stop frame was reached.
Definition: Transport.h:112
bool Passed() const
Definition: Timer.h:148

+ Here is the call graph for this function:

void Transport::UpdatePassengerPositions ( PassengerSet passengers)
private
681 {
682  for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
683  {
684  WorldObject* passenger = *itr;
685  // transport teleported but passenger not yet (can happen for players)
686  if (passenger->GetMap() != GetMap())
687  continue;
688 
689  // if passenger is on vehicle we have to assume the vehicle is also on transport
690  // and its the vehicle that will be updating its passengers
691  if (Unit* unit = passenger->ToUnit())
692  if (unit->GetVehicle())
693  continue;
694 
695  // Do not use Unit::UpdatePosition here, we don't want to remove auras
696  // as if regular movement occurred
697  float x, y, z, o;
698  passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o);
699  CalculatePassengerPosition(x, y, z, &o);
700  switch (passenger->GetTypeId())
701  {
702  case TYPEID_UNIT:
703  {
704  Creature* creature = passenger->ToCreature();
705  GetMap()->CreatureRelocation(creature, x, y, z, o, false);
706  creature->GetTransportHomePosition(x, y, z, o);
707  CalculatePassengerPosition(x, y, z, &o);
708  creature->SetHomePosition(x, y, z, o);
709  break;
710  }
711  case TYPEID_PLAYER:
712  //relocate only passengers in world and skip any player that might be still logging in/teleporting
713  if (passenger->IsInWorld())
714  GetMap()->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
715  break;
716  case TYPEID_GAMEOBJECT:
717  GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
718  passenger->ToGameObject()->RelocateStationaryPosition(x, y, z, o);
719  break;
721  GetMap()->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
722  break;
723  default:
724  break;
725  }
726 
727  if (Unit* unit = passenger->ToUnit())
728  if (Vehicle* vehicle = unit->GetVehicleKit())
729  vehicle->RelocatePassengers();
730  }
731 }
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition: Map.cpp:982
Definition: Vehicle.h:32
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:677
Map * GetMap() const
Definition: Object.h:543
MovementInfo m_movementInfo
Definition: Object.h:612
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:72
Definition: ObjectGuid.h:32
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
Definition: Object.h:423
Definition: Creature.h:467
DynamicObject * ToDynObject()
Definition: Object.h:206
GameObject * ToGameObject()
Definition: Object.h:200
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
Definition: ObjectGuid.h:34
void RelocateStationaryPosition(float x, float y, float z, float o)
Definition: GameObject.h:1080
G3D::int16 y
Definition: Vector2int16.h:38
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
Definition: Map.cpp:950
Position pos
Definition: Object.h:290
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
Definition: Map.cpp:1019
G3D::int16 x
Definition: Vector2int16.h:37
bool IsInWorld() const
Definition: Object.h:100
Definition: ObjectGuid.h:35
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float orientation)
Definition: Map.cpp:1052
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Transport::UpdatePosition ( float  x,
float  y,
float  z,
float  o 
)
503 {
504  bool newActive = GetMap()->IsGridLoaded(x, y);
505  Cell oldCell(GetPositionX(), GetPositionY());
506 
507  Relocate(x, y, z, o);
509 
511 
512  /* There are four possible scenarios that trigger loading/unloading passengers:
513  1. transport moves from inactive to active grid
514  2. the grid that transport is currently in becomes active
515  3. transport moves from active to inactive grid
516  4. the grid that transport is currently in unloads
517  */
518  if (_staticPassengers.empty() && newActive) // 1.
520  else if (!_staticPassengers.empty() && !newActive && oldCell.DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
522  else
524  // 4. is handed by grid unload
525 }
PassengerSet _passengers
Definition: Transport.h:127
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
Definition: Transport.cpp:548
Map * GetMap() const
Definition: Object.h:543
PassengerSet _staticPassengers
Definition: Transport.h:129
void UpdatePassengerPositions(PassengerSet &passengers)
Definition: Transport.cpp:680
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void Relocate(float x, float y)
Definition: Position.h:67
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
void LoadStaticPassengers()
Needed when transport moves from inactive to active grid.
Definition: Transport.cpp:527
G3D::int16 y
Definition: Vector2int16.h:38
void UpdateModelPosition()
Definition: GameObject.cpp:2425
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

Member Data Documentation

KeyFrameVec::const_iterator Transport::_currentFrame
private
bool Transport::_delayedAddModel
private
bool Transport::_delayedTeleport
private
bool Transport::_isMoving
private
KeyFrameVec::const_iterator Transport::_nextFrame
private
PassengerSet Transport::_passengers
private
PassengerSet::iterator Transport::_passengerTeleportItr
private
bool Transport::_pendingStop
private
TimeTrackerSmall Transport::_positionChangeTimer
private
PassengerSet Transport::_staticPassengers
private
TransportTemplate const* Transport::_transportInfo
private
bool Transport::_triggeredArrivalEvent
private

These are needed to properly control events triggering only once for each frame.

bool Transport::_triggeredDepartureEvent
private

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