Updated Copyright year to 2013
[getmangos.git] / src / game / Transports.h
blob590e93352d4e950ebc1ee7fa5ea0882d4ea73f5d
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef TRANSPORTS_H
20 #define TRANSPORTS_H
22 #include "GameObject.h"
24 #include <map>
25 #include <set>
26 #include <string>
28 class Transport : public GameObject
30 public:
31 explicit Transport();
33 bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue);
34 bool GenerateWaypoints(uint32 pathid, std::set<uint32>& mapids);
35 void Update(uint32 update_diff, uint32 p_time) override;
36 bool AddPassenger(Player* passenger);
37 bool RemovePassenger(Player* passenger);
39 typedef std::set<Player*> PlayerSet;
40 PlayerSet const& GetPassengers() const { return m_passengers; }
42 private:
43 struct WayPoint
45 WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {}
46 WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _arrivalEventID = 0, uint32 _departureEventID = 0)
47 : mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport),
48 arrivalEventID(_arrivalEventID), departureEventID(_departureEventID)
52 uint32 mapid;
53 float x;
54 float y;
55 float z;
56 bool teleport;
57 uint32 arrivalEventID;
58 uint32 departureEventID;
61 typedef std::map<uint32, WayPoint> WayPointMap;
63 WayPointMap::const_iterator m_curr;
64 WayPointMap::const_iterator m_next;
65 uint32 m_pathTime;
66 uint32 m_timer;
68 PlayerSet m_passengers;
70 public:
71 WayPointMap m_WayPoints;
72 uint32 m_nextNodeTime;
73 uint32 m_period;
75 private:
76 void TeleportTransport(uint32 newMapid, float x, float y, float z);
77 void UpdateForMap(Map const* map);
78 void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
79 void MoveToNextWayPoint(); // move m_next/m_cur to next points
81 #endif