From 62e5234535d1825b152c882fdaea9d2257194e6d Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 24 Apr 2014 20:25:03 -0700 Subject: Small changes; warning fixing. --- src/World.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 25ac9b021..21cabe434 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -316,12 +316,9 @@ int cWorld::GetDefaultWeatherInterval(eWeather a_Weather) { return 2400 + (m_TickRand.randInt() % 4800); // 2 - 6 minutes } - default: - { - LOGWARNING("%s: Missing default weather interval for weather %d.", __FUNCTION__, a_Weather); - return -1; - } - } // switch (Weather) + } + LOGWARNING("%s: Missing default weather interval for weather %d.", __FUNCTION__, a_Weather); + return -1; } -- cgit v1.2.3 From 083cec5a09eed6e018a06734c44919419fe76620 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 25 Apr 2014 16:26:24 -0700 Subject: Removed extraneous switch{} in Start() Squashed a warning. --- src/World.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 21cabe434..6582c1c07 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -518,21 +518,6 @@ void cWorld::Start(void) } AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld"); m_Dimension = StringToDimension(Dimension); - switch (m_Dimension) - { - case dimNether: - case dimOverworld: - case dimEnd: - { - break; - } - default: - { - LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", Dimension.c_str()); - m_Dimension = dimOverworld; - break; - } - } // switch (m_Dimension) // Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found int KeyNum = IniFile.FindKey("SpawnPosition"); -- cgit v1.2.3 From c124fc39d44f5a5e06a269d294736939aef22a32 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 25 Apr 2014 16:32:20 -0700 Subject: Removed impossible default case. Squashed a warning. --- src/World.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 6582c1c07..4a71a7e4c 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -574,12 +574,6 @@ void cWorld::Start(void) case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; case dimEnd: DefaultMonsters = "enderman"; break; - default: - { - ASSERT(!"Unhandled world dimension"); - DefaultMonsters = "wither"; - break; - } } m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true); AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters); -- cgit v1.2.3 From 2c0bb7b717a759204ff6c332f9ccde85a89a1aff Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 25 Apr 2014 16:55:38 -0700 Subject: Moved the weather picker out of TickWeather(), squashing a warning and improving readability. --- src/World.cpp | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'src/World.cpp') 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) { -- cgit v1.2.3