[1189] Added ChangeWeatherInterval to mangosd configuration.
[mangos-git.git] / src / game / World.h
blobdb01af22dfc99c004af61d80b01babcfc7ef7433
1 /*
2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
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 __WORLD_H
20 #define __WORLD_H
22 #include "Timer.h"
23 #include "Policies/Singleton.h"
24 #include "SharedDefines.h"
26 class Object;
27 class WorldPacket;
28 class WorldSession;
29 class Player;
30 class Weather;
32 enum WorldTimers
34 WUPDATE_OBJECTS = 0,
35 WUPDATE_SESSIONS = 1,
36 WUPDATE_AUCTIONS = 2,
37 WUPDATE_WEATHERS = 3,
38 WUPDATE_COUNT = 4
41 enum Rates
43 RATE_HEALTH=0,
44 RATE_POWER1,
45 RATE_POWER2,
46 RATE_POWER3,
47 RATE_DROP,
48 RATE_XP,
49 MAX_RATES
52 enum EnviromentalDamage
54 DAMAGE_EXHAUSTED = 0,
55 DAMAGE_DROWNING = 1,
56 DAMAGE_FALL = 2,
57 DAMAGE_LAVA = 3,
58 DAMAGE_SLIME = 4,
59 DAMAGE_FIRE = 5
62 class World
64 public:
65 World();
66 ~World();
68 WorldSession* FindSession(uint32 id) const;
69 void AddSession(WorldSession *s);
70 void RemoveSession(uint32 id);
71 uint32 GetSessionCount() const { return m_sessions.size(); }
72 Player* FindPlayerInZone(uint32 zone);
74 Weather* FindWeather(uint32 id) const;
75 void AddWeather(Weather *w);
76 void RemoveWeather(uint32 id);
78 uint32 GetPlayerLimit() const { return m_playerLimit; }
79 void SetPlayerLimit(uint32 limit) { m_playerLimit = limit; }
81 bool getAllowMovement() const { return m_allowMovement; }
82 void SetAllowMovement(bool allow) { m_allowMovement = allow; }
84 void SetMotd(const char *motd) { m_motd = motd; }
85 const char* GetMotd() const { return m_motd.c_str(); }
87 time_t GetGameTime() const { return m_gameTime; }
89 void SetInitialWorldSettings();
91 void SendWorldText(const char *text, WorldSession *self = 0);
92 void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0);
94 void Update(time_t diff);
96 void setRate(int index,float value)
98 if((index>=0)&&(index<MAX_RATES))
99 regen_values[index]=value;
102 float getRate(int index)
104 if((index>=0)&&(index<MAX_RATES))
105 return regen_values[index];
106 else
107 return 0;
110 protected:
112 time_t _UpdateGameTime()
115 time_t thisTime = time(NULL);
116 m_gameTime += thisTime - m_lastTick;
117 m_lastTick = thisTime;
119 return m_gameTime;
122 private:
124 IntervalTimer m_timers[WUPDATE_COUNT];
126 typedef HM_NAMESPACE::hash_map<uint32, Weather*> WeatherMap;
127 WeatherMap m_weathers;
128 typedef HM_NAMESPACE::hash_map<uint32, WorldSession*> SessionMap;
129 SessionMap m_sessions;
130 float regen_values[5];
131 uint32 m_playerLimit;
132 bool m_allowMovement;
133 std::string m_motd;
135 time_t m_gameTime;
136 time_t m_lastTick;
138 time_t m_nextThinkTime;
141 #define sWorld MaNGOS::Singleton<World>::Instance()
142 #endif