3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef ENVIRONMENT_HEADER
21 #define ENVIRONMENT_HEADER
24 This class is the game's environment.
29 - The current time in the game
37 #include "activeobject.h"
38 #include "util/numeric.h"
41 #include "threading/mutex.h"
42 #include "threading/atomic.h"
43 #include "network/networkprotocol.h" // for AccessDeniedCode
55 // Environment will delete the map passed to the constructor
57 virtual ~Environment();
60 Step everything in environment.
65 virtual void step(f32 dtime) = 0;
67 virtual Map & getMap() = 0;
69 u32 getDayNightRatio();
72 virtual void setTimeOfDay(u32 time);
74 float getTimeOfDayF();
76 void stepTimeOfDay(float dtime);
78 void setTimeOfDaySpeed(float speed);
80 void setDayNightRatioOverride(bool enable, u32 value);
84 // counter used internally when triggering ABMs
88 GenericAtomic<float> m_time_of_day_speed;
91 * Below: values managed by m_time_lock
93 // Time of day in milli-hours (0-23999); determines day and night
95 // Time of day in 0...1
96 float m_time_of_day_f;
97 // Stores the skew created by the float -> u32 conversion
98 // to be applied at next conversion, so that there is no real skew.
99 float m_time_conversion_skew;
100 // Overriding the day-night ratio is useful for custom sky visuals
101 bool m_enable_day_night_ratio_override;
102 u32 m_day_night_ratio_override;
103 // Days from the server start, accounts for time shift
104 // in game (e.g. /time or bed usage)
105 Atomic<u32> m_day_count;
107 * Above: values managed by m_time_lock
110 /* TODO: Add a callback function so these can be updated when a setting
111 * changes. At this point in time it doesn't matter (e.g. /set
112 * is documented to change server settings only)
114 * TODO: Local caching of settings is not optimal and should at some stage
115 * be updated to use a global settings object for getting thse values
116 * (as opposed to the this local caching). This can be addressed in
119 bool m_cache_enable_shaders;
120 float m_cache_active_block_mgmt_interval;
121 float m_cache_abm_interval;
122 float m_cache_nodetimer_interval;
127 DISABLE_CLASS_COPY(Environment);