OregonCore  revision be9e804-git
Your Favourite TBC server
Transports.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TRANSPORTS_H
19 #define TRANSPORTS_H
20 
21 #include "GameObject.h"
22 
23 #include <map>
24 #include <set>
25 #include <string>
26 
27 class Transport : public GameObject
28 {
29  public:
30  explicit Transport();
31 
32  bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
33  bool GenerateWaypoints(uint32 pathid, std::set<uint32>& mapids);
34  void Update(uint32 p_time) override;
35  bool AddPassenger(Player* passenger);
36  bool RemovePassenger(Player* passenger);
37  void CheckForEvent(uint32 entry, uint32 wp_id);
38 
39  typedef std::set<Player*> PlayerSet;
40  PlayerSet const& GetPassengers() const
41  {
42  return m_passengers;
43  }
44 
46 
47  private:
48  struct WayPoint
49  {
50  WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false), id(0) {}
51  WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id, uint32 _arrivalEventID = 0, uint32 _departureEventID = 0) :
52  mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id),
53  arrivalEventID(_arrivalEventID), departureEventID(_departureEventID) {}
55  float x;
56  float y;
57  float z;
58  bool teleport;
62  };
63 
64  typedef std::map<uint32, WayPoint> WayPointMap;
65 
66  WayPointMap::iterator m_curr;
67  WayPointMap::iterator m_next;
70 
71  PlayerSet m_passengers;
72 
73  public:
74  WayPointMap m_WayPoints;
77 
78  private:
79  void TeleportTransport(uint32 newMapid, float x, float y, float z);
80  void UpdateForMap(Map const* map);
81  void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
82  WayPointMap::iterator GetNextWayPoint();
83 
85 };
86 #endif
87 
bool GenerateWaypoints(uint32 pathid, std::set< uint32 > &mapids)
Definition: Transports.cpp:191
WayPointMap m_WayPoints
Definition: Transports.h:74
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
PlayerSet const & GetPassengers() const
Definition: Transports.h:40
PlayerSet m_passengers
Definition: Transports.h:71
void UpdateForMap(Map const *map)
Definition: Transports.cpp:530
bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
Definition: Transports.cpp:130
WayPointMap::iterator GetNextWayPoint()
Definition: Transports.cpp:394
void Update(uint32 p_time) override
Definition: Transports.cpp:475
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id, uint32 _arrivalEventID=0, uint32 _departureEventID=0)
Definition: Transports.h:51
bool AddPassenger(Player *passenger)
Definition: Transports.cpp:451
uint32 m_pathTime
Definition: Transports.h:68
Definition: Map.h:266
std::set< Player * > PlayerSet
Definition: Transports.h:39
void DoEventIfAny(WayPointMap::value_type const &node, bool departure)
Definition: Transports.cpp:563
void CheckForEvent(uint32 entry, uint32 wp_id)
Definition: Transports.cpp:468
WayPointMap::iterator m_curr
Definition: Transports.h:66
uint32 m_nextNodeTime
Definition: Transports.h:75
void SetDelayedAddModelToMap()
Definition: Transports.h:45
void TeleportTransport(uint32 newMapid, float x, float y, float z)
Definition: Transports.cpp:403
uint32 m_period
Definition: Transports.h:76
uint32 m_timer
Definition: Transports.h:69
bool RemovePassenger(Player *passenger)
Definition: Transports.cpp:461
bool _delayedAddModel
Definition: Transports.h:84
WayPointMap::iterator m_next
Definition: Transports.h:67
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:923
uint32 departureEventID
Definition: Transports.h:61
std::map< uint32, WayPoint > WayPointMap
Definition: Transports.h:64