summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-04-26 01:55:38 +0200
committerarchshift <admin@archshift.com>2014-04-26 01:55:38 +0200
commit2c0bb7b717a759204ff6c332f9ccde85a89a1aff (patch)
tree48326e598d0223678c4adefcb72a42fa9d47d7d7
parentRemoved impossible default case. (diff)
downloadcuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar.gz
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar.bz2
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar.lz
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar.xz
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.tar.zst
cuberite-2c0bb7b717a759204ff6c332f9ccde85a89a1aff.zip
-rw-r--r--src/World.cpp50
-rw-r--r--src/World.h5
2 files changed, 30 insertions, 25 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 4a71a7e4c..5ac8e0a6e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -663,6 +663,30 @@ void cWorld::GenerateRandomSpawn(void)
+eWeather cWorld::ChooseNewWeather()
+{
+ // Pick a new weather. Only reasonable transitions allowed:
+ switch (m_Weather)
+ {
+ case eWeather_Sunny:
+ case eWeather_ThunderStorm: return eWeather_Rain;
+
+ case eWeather_Rain:
+ {
+ // 1/8 chance of turning into a thunderstorm
+ return ((m_TickRand.randInt() % 256) < 32) ? eWeather_ThunderStorm : eWeather_Sunny;
+ }
+ }
+
+ LOGWARNING("Unknown current weather: %d. Setting sunny.", m_Weather);
+ ASSERT(!"Unknown weather");
+ return eWeather_Sunny;
+}
+
+
+
+
+
void cWorld::Stop(void)
{
// Delete the clients that have been in this world:
@@ -762,30 +786,8 @@ void cWorld::TickWeather(float a_Dt)
else
{
// Change weather:
-
- // Pick a new weather. Only reasonable transitions allowed:
- eWeather NewWeather = m_Weather;
- switch (m_Weather)
- {
- case eWeather_Sunny: NewWeather = eWeather_Rain; break;
- case eWeather_ThunderStorm: NewWeather = eWeather_Rain; break;
- case eWeather_Rain:
- {
- // 1/8 chance of turning into a thunderstorm
- NewWeather = ((m_TickRand.randInt() % 256) < 32) ? eWeather_ThunderStorm : eWeather_Sunny;
- break;
- }
-
- default:
- {
- LOGWARNING("Unknown current weather: %d. Setting sunny.", m_Weather);
- ASSERT(!"Unknown weather");
- NewWeather = eWeather_Sunny;
- }
- }
-
- SetWeather(NewWeather);
- } // else (m_WeatherInterval > 0)
+ SetWeather(ChooseNewWeather());
+ }
if (m_Weather == eWeather_ThunderStorm)
{
diff --git a/src/World.h b/src/World.h
index e2be4cd35..f789916df 100644
--- a/src/World.h
+++ b/src/World.h
@@ -938,7 +938,10 @@ private:
/** <summary>Generates a random spawnpoint on solid land by walking chunks and finding their biomes</summary> */
void GenerateRandomSpawn(void);
-
+
+ /** Chooses a reasonable transition from the current weather to a new weather **/
+ eWeather ChooseNewWeather(void);
+
/** Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) */
cFluidSimulator * InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock);