Deal with covered switches consistently (#4161)

* Fixes a number of "<function>: not all control paths return a value" warnings on MSVC.

* Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults.

* Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message()
This commit is contained in:
peterbell10
2018-02-04 23:07:12 +00:00
committed by GitHub
parent 2df14a0496
commit d3c1c626f5
40 changed files with 267 additions and 392 deletions
+6 -12
View File
@@ -492,11 +492,7 @@ int cWorld::GetDefaultWeatherInterval(eWeather a_Weather)
return Random.RandInt(m_MinThunderStormTicks, m_MaxThunderStormTicks);
}
}
#ifndef __clang__
ASSERT(!"Unknown weather");
return -1;
#endif
UNREACHABLE("Unsupported weather");
}
@@ -851,19 +847,17 @@ eWeather cWorld::ChooseNewWeather()
switch (m_Weather)
{
case eWeather_Sunny:
case eWeather_ThunderStorm: return eWeather_Rain;
case eWeather_ThunderStorm:
{
return eWeather_Rain;
}
case eWeather_Rain:
{
// 1 / 8 chance of turning into a thunderstorm
return GetRandomProvider().RandBool(0.125) ? eWeather_ThunderStorm : eWeather_Sunny;
}
}
#ifndef __clang__
ASSERT(!"Unknown weather");
return eWeather_Sunny;
#endif
UNREACHABLE("Unsupported weather");
}