[7915] Implement more stricted checks and limitations at loading creature addon data.
[getmangos.git] / src / game / DestinationHolder.h
blob72ee7776218a03bb320764aa00c61f6f5a50a93d
1 /*
2 * Copyright (C) 2005-2009 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 MANGOS_DESTINATION_HOLDER_H
20 #define MANGOS_DESTINATION_HOLDER_H
22 #include "Platform/Define.h"
23 #include "Timer.h"
25 class WorldObject;
27 #define TRAVELLER_UPDATE_INTERVAL 300
29 template<typename TRAVELLER>
30 class MANGOS_DLL_DECL DestinationHolder
32 TimeTrackerSmall i_tracker;
33 uint32 i_totalTravelTime;
34 uint32 i_timeElapsed;
35 bool i_destSet;
36 float i_fromX, i_fromY, i_fromZ;
37 float i_destX, i_destY, i_destZ;
39 public:
40 DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0),
41 i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {}
43 uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true);
44 void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; }
45 bool UpdateExpired(void) const { return i_tracker.Passed(); }
46 void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); }
47 uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; }
48 void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; }
49 bool HasDestination(void) const { return i_destSet; }
50 float GetDestinationDiff(float x, float y, float z) const;
51 bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
52 bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false);
53 uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
54 void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const;
55 void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
56 float GetDistance2dFromDestSq(const WorldObject &obj) const;
58 private:
59 void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
62 #endif