1
0

Merge pull request #2169 from linnemannr/master

Fix FreeBSD/clang errors caused by -Werror
This commit is contained in:
worktycho 2015-05-30 10:32:35 +01:00
commit 2ce405883a
4 changed files with 20 additions and 2 deletions

View File

@ -12,6 +12,7 @@ jasperarmstrong
keyboard keyboard
Lapayo Lapayo
Luksor Luksor
linnemannr (Reid Linnemann)
M10360 M10360
marmot21 marmot21
Masy98 Masy98

View File

@ -1375,8 +1375,12 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
return mtInvalidType; return mtInvalidType;
} }
size_t RandMob = static_cast<size_t>((m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)) % ListOfSpawnables.size();
auto MobIter = ListOfSpawnables.begin(); auto MobIter = ListOfSpawnables.begin();
using diff_type =
std::iterator_traits<decltype(MobIter)>::difference_type;
diff_type RandMob = static_cast<diff_type>
((unsigned long)(m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)
% ListOfSpawnables.size());
std::advance(MobIter, RandMob); std::advance(MobIter, RandMob);
return *MobIter; return *MobIter;

View File

@ -12,6 +12,13 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
// FreeBSD uses size_t for the return type of backtrace()
#if defined(__FreeBSD__) && (__FreeBSD__ >= 10)
#define btsize size_t
#else
#define btsize int
#endif
@ -34,7 +41,7 @@ void PrintStackTrace(void)
// Use the backtrace() function to get and output the stackTrace: // Use the backtrace() function to get and output the stackTrace:
// Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes // Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
void * stackTrace[30]; void * stackTrace[30];
int numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace)); btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO); backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO);
#endif #endif
} }

View File

@ -168,6 +168,12 @@ bool StringToInteger(const AString & a_str, T & a_Num)
} }
else else
{ {
// Unsigned result cannot be signed!
if (!std::numeric_limits<T>::is_signed)
{
return false;
}
for (size_t size = a_str.size(); i < size; i++) for (size_t size = a_str.size(); i < size; i++)
{ {
if ((a_str[i] < '0') || (a_str[i] > '9')) if ((a_str[i] < '0') || (a_str[i] > '9'))