summaryrefslogtreecommitdiffstats
path: root/src/World.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-18 11:21:36 +0100
committerMattes D <github@xoft.cz>2015-01-18 11:21:36 +0100
commite38f41d32fa970c9a1493f9ca0ff16ad3faf33d3 (patch)
tree75983459166f6ebebebcc5e4bfb9c551f4e3aedb /src/World.h
parentMerge pull request #1707 from UltraCoderRU/master (diff)
parentFixed type-conversion warnings. (diff)
downloadcuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar.gz
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar.bz2
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar.lz
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar.xz
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.tar.zst
cuberite-e38f41d32fa970c9a1493f9ca0ff16ad3faf33d3.zip
Diffstat (limited to 'src/World.h')
-rw-r--r--src/World.h26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/World.h b/src/World.h
index 2ee33375f..1f58ddbb7 100644
--- a/src/World.h
+++ b/src/World.h
@@ -157,8 +157,8 @@ public:
BroadcastTimeUpdate();
}
- virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
- virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; }
+ virtual Int64 GetWorldAge (void) const override { return std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count(); }
+ virtual int GetTimeOfDay(void) const override { return std::chrono::duration_cast<cTickTime>(m_TimeOfDay).count(); }
void SetTicksUntilWeatherChange(int a_WeatherInterval)
{
@@ -167,8 +167,7 @@ public:
virtual void SetTimeOfDay(int a_TimeOfDay) override
{
- m_TimeOfDay = a_TimeOfDay;
- m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0;
+ m_TimeOfDay = cTickTime(a_TimeOfDay);
UpdateSkyDarkness();
BroadcastTimeUpdate();
}
@@ -914,14 +913,13 @@ private:
bool m_BroadcastAchievementMessages;
bool m_IsDaylightCycleEnabled;
- double m_WorldAgeSecs; // World age, in seconds. Is only incremented, cannot be set by plugins.
- double m_TimeOfDaySecs; // Time of day in seconds. Can be adjusted. Is wrapped to zero each day.
- Int64 m_WorldAge; // World age in ticks, calculated off of m_WorldAgeSecs
- int m_TimeOfDay; // Time in ticks, calculated off of m_TimeOfDaySecs
- Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent.
- Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred
- Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
- std::map<cMonster::eFamily, Int64> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
+ // std::chrono::milliseconds is guaranteed to be good for 292 years by the standard.
+ std::chrono::milliseconds m_WorldAge;
+ std::chrono::milliseconds m_TimeOfDay;
+ cTickTimeLong m_LastTimeUpdate; // The tick in which the last time update has been sent.
+ cTickTimeLong m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred
+ cTickTimeLong m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
+ std::map<cMonster::eFamily, cTickTimeLong> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
NIBBLETYPE m_SkyDarkness;
@@ -1051,13 +1049,13 @@ private:
cWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "");
virtual ~cWorld();
- void Tick(float a_Dt, int a_LastTickDurationMSec);
+ void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
/** Handles the weather in each tick */
void TickWeather(float a_Dt);
/** Handles the mob spawning/moving/destroying each tick */
- void TickMobs(float a_Dt);
+ void TickMobs(std::chrono::milliseconds a_Dt);
/** Executes all tasks queued onto the tick thread */
void TickQueuedTasks(void);