TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MovementTypedefs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #ifndef TRINITYSERVER_TYPEDEFS_H
20 #define TRINITYSERVER_TYPEDEFS_H
21 
22 #include "Common.h"
23 
24 namespace G3D
25 {
26  class Vector3;
27  class Vector4;
28 }
29 
30 namespace Movement
31 {
32  using G3D::Vector3;
33  using G3D::Vector4;
34 
36  {
41  };
42 
43  inline uint32 SecToMS(float sec)
44  {
45  return static_cast<uint32>(sec * 1000.f);
46  }
47 
48  inline float MSToSec(uint32 ms)
49  {
50  return ms / 1000.f;
51  }
52 
53  float computeFallTime(float path_length, bool isSafeFall);
54  float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity = 0.0f);
55 
56  template<class T, T limit>
57  class counter
58  {
59  public:
60  counter() { init(); }
61 
62  void Increase()
63  {
64  if (m_counter == limit)
65  init();
66  else
67  ++m_counter;
68  }
69 
70  T NewId() { Increase(); return m_counter; }
71  T getCurrent() const { return m_counter; }
72 
73  private:
74  void init() { m_counter = 0; }
76  };
77 
79 
80  TC_GAME_API extern float gravity;
81  TC_GAME_API extern UInt32Counter splineIdGen;
82  TC_GAME_API extern std::string MovementFlags_ToString(uint32 flags);
84 }
85 
86 #endif // TRINITYSERVER_TYPEDEFS_H
TC_GAME_API std::string MovementFlags_ToString(uint32 flags)
Definition: MovementUtil.cpp:195
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
Definition: MovementTypedefs.h:39
T m_counter
Definition: MovementTypedefs.h:75
void init()
Definition: MovementTypedefs.h:74
Definition: AABox.h:25
MonsterMoveType
Definition: MovementTypedefs.h:35
uint32 SecToMS(float sec)
Definition: MovementTypedefs.h:43
Definition: MovementTypedefs.h:57
Definition: Vector3.h:58
float computeFallTime(float path_length, bool isSafeFall)
Definition: MovementUtil.cpp:35
T getCurrent() const
Definition: MovementTypedefs.h:71
TC_GAME_API std::string MovementFlagsExtra_ToString(uint32 flags)
Definition: MovementUtil.cpp:202
float MSToSec(uint32 ms)
Definition: MovementTypedefs.h:48
T NewId()
Definition: MovementTypedefs.h:70
Definition: Unit.h:409
uint32_t uint32
Definition: Define.h:150
Definition: Vector4.h:39
counter()
Definition: MovementTypedefs.h:60
#define TC_GAME_API
Definition: Define.h:134
uint8 flags
Definition: DisableMgr.cpp:44
float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity=0.0f)
Definition: MovementUtil.cpp:59
Definition: MovementTypedefs.h:37
void Increase()
Definition: MovementTypedefs.h:62
Definition: MovementTypedefs.h:38
TC_GAME_API UInt32Counter splineIdGen
Definition: MovementUtil.cpp:24
Definition: MovementTypedefs.h:40
counter< uint32, 0xFFFFFFFF > UInt32Counter
Definition: MovementTypedefs.h:78