1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 14:15:46 +00:00

Build fixes for clang; little CMake config update

This commit is contained in:
fgenesis 2012-02-10 20:28:35 +01:00
parent f738c19757
commit 9b2c18ecaa
4 changed files with 50 additions and 47 deletions

View file

@ -17,6 +17,34 @@
// ****
namespace ByteBufferTools
{
template<size_t T> inline void convert(char *val)
{
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
}
template<> inline void convert<0>(char *) {}
template<> inline void convert<1>(char *) {}
template<typename T> inline void EndianConvert(T *val)
{
convert<sizeof(T)>((char *)(val));
}
#if BB_IS_BIG_ENDIAN
template<typename T> inline void ToLittleEndian(T& val) { EndianConvert<T>(&val); }
template<typename T> inline void ToBigEndian(T&) { }
#else
template<typename T> inline void ToLittleEndian(T&) { }
template<typename T> inline void ToBigEndian(T& val) { EndianConvert<T>(&val); }
#endif
template<typename T> void ToLittleEndian(T*); // will generate link error
template<typename T> void ToBigEndian(T*); // will generate link error
};
#define BB_MAKE_WRITE_OP(T) inline ByteBuffer& operator<<(T val) { append<T>(val); return *this; }
#define BB_MAKE_READ_OP(T) inline ByteBuffer& operator>>(T &val) { val = read<T>(); return *this; }
@ -285,7 +313,7 @@ public:
if(pos + sizeof(T) > size())
BYTEBUFFER_EXCEPT(this, "read", sizeof(T));
T val = *((T const*)(_buf + pos));
ToLittleEndian<T>(val);
ByteBufferTools::ToLittleEndian<T>(val);
return val;
}
@ -321,7 +349,7 @@ public:
template <typename T> void append(T value)
{
ToLittleEndian<T>(value);
ByteBufferTools::ToLittleEndian<T>(value);
_enlargeIfReq(_wpos + sizeof(T));
*((T*)(_buf + _wpos)) = value;
_wpos += sizeof(T);
@ -354,7 +382,7 @@ public:
if(pos >= size())
BYTEBUFFER_EXCEPT(this, "put", sizeof(T));
ToLittleEndian<T>(value);
ByteBufferTools::ToLittleEndian<T>(value);
*((T*)(_buf + pos)) = value;
}
@ -435,34 +463,6 @@ protected:
}
}
template<size_t T> inline static void convert(char *val)
{
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
}
template<> inline static void convert<0>(char *) {}
template<> inline static void convert<1>(char *) {}
template<typename T> inline static void EndianConvert(T *val)
{
convert<sizeof(T)>((char *)(val));
}
#if BB_IS_BIG_ENDIAN
template<typename T> inline static void ToLittleEndian(T& val) { EndianConvert<T>(&val); }
template<typename T> inline static void ToBigEndian(T&) { }
#else
template<typename T> inline static void ToLittleEndian(T&) { }
template<typename T> inline static void ToBigEndian(T& val) { EndianConvert<T>(&val); }
#endif
template<typename T> static void ToLittleEndian(T*); // will generate link error
template<typename T> static void ToBigEndian(T*); // will generate link error
inline static void ToLittleEndian(uint8&) { }
inline static void ToLittleEndian(int8&) { }
inline static void ToBigEndian(uint8&) { }
inline static void ToBigEndian( int8&) { }
};

View file

@ -169,7 +169,7 @@ void DeflateCompressor::Decompress(void)
if(origsize != rs)
{
char errbuf[256];
sprintf(errbuf, "DeflateCompressor: Inflate error! result=%d cursize=%u origsize=%u realsize=%u",size(),origsize,rs);
sprintf(errbuf, "DeflateCompressor: Inflate error! cursize=%u origsize=%u realsize=%u",size(),origsize,rs);
errorLog(errbuf);
delete [] target;
return;

View file

@ -155,7 +155,7 @@ void *ThreadPool::u_createThread()
th = SDL_CreateThread(threadpool_runner, this);
#endif
if (!th)
return false;
return NULL;
u_addThread(th);
return th;
}

View file

@ -12,9 +12,8 @@ IF(APPLE)
SET(MACOSX TRUE)
ENDIF(APPLE)
IF(WIN32)
OPTION(AQUARIA_NO_CONSOLE "No console window?" FALSE)
ENDIF(WIN32)
OPTION(AQUARIA_DEVELOPER_BUILD "Developer Build?" FALSE)
OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE)
# No Steamworks SDK for Linux at the moment. Roll our own achievements.
ADD_DEFINITIONS(-DBBGE_BUILD_ACHIEVEMENTS_INTERNAL=1)
@ -218,9 +217,20 @@ ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL=1)
ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL_DYNAMIC=1)
ADD_DEFINITIONS(-DBBGE_BUILD_WIDESCREEN=1)
ADD_DEFINITIONS(-DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1)
IF(AQUARIA_DEVELOPER_BUILD)
message(STATUS "Developer build.")
ELSE(AQUARIA_DEVELOPER_BUILD)
ADD_DEFINITIONS(-DAQUARIA_FULL=1)
ENDIF(AQUARIA_DEVELOPER_BUILD)
IF(AQUARIA_DEMO_BUILD)
message(STATUS "Demo build.")
ADD_DEFINITIONS(-DAQUARIA_DEMO=1)
ELSE(AQUARIA_DEMO_BUILD)
ADD_DEFINITIONS(-DAQUARIA_BUILD_CONSOLE=1)
ADD_DEFINITIONS(-DAQUARIA_BUILD_SCENEEDITOR=1)
ENDIF(AQUARIA_DEMO_BUILD)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-D_DEBUG) # MSVC defines this in debug mode by default, gcc/mingw do not
@ -412,13 +422,6 @@ SET(BBGE_SRCS
${EXTLIBDIR}/tinyxmlparser.cpp
)
if(NOT "${PNG_LIBPNG_VER}" LESS 10400)
SET_SOURCE_FILES_PROPERTIES(
${EXTLIBDIR}/glpng/glpng.c
PROPERTIES COMPILE_FLAGS "-DLIBPNG_NEW_API"
)
endif(NOT "${PNG_LIBPNG_VER}" LESS 10400)
SET(ZLIB_SRCS
${ZLIBDIR}/adler32.c
${ZLIBDIR}/crc32.c
@ -460,7 +463,7 @@ SET(BBGE_SRCS_UNUSED
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET_SOURCE_FILES_PROPERTIES(
${BBGEDIR}/FmodOpenALBridge.cpp
${BBGEDIR}/MT.cpp
PROPERTIES COMPILE_FLAGS "-fpermissive"
)
ENDIF()