diff --git a/CMakeLists.txt b/CMakeLists.txt index 2236f4b..990bcff 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.10) +option(OP_COMPILE_WITH_IRRLICHT "compile irrnet with native irrlicht datatypes" ON) + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -10,7 +12,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/lib") set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) #irrnet stuff -add_definitions(-DCOMPILE_WITH_IRRLICHT) set(IRRNET_TARGET irrnet) set(IRRNET_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/source") set(IRRNET_INC_DIR "${CMAKE_CURRENT_LIST_DIR}/include") @@ -27,15 +28,27 @@ set(ZLIB_DIR "${CMAKE_CURRENT_LIST_DIR}/zlib") set(ZLIB_INC_DIR ${ZLIB_DIR}/include) add_subdirectory(${ZLIB_DIR} EXCLUDE_FROM_ALL) +#irrlicht stuff +set(IRRLICHT_INC_DIR /usr/include/irrlicht) + project(irrnet) -include_directories(/usr/include/irrlicht) - add_library(${IRRNET_TARGET} STATIC + ${IRRNET_INC_DIR}/CEncryption.h + ${IRRNET_INC_DIR}/CNetManager.h + ${IRRNET_INC_DIR}/INetManager.h + ${IRRNET_INC_DIR}/irrNet.h + ${IRRNET_INC_DIR}/SPacket.h ${IRRNET_SRC_DIR}/CNetManager.cpp ${IRRNET_SRC_DIR}/SPacket.cpp ) +if (OP_COMPILE_WITH_IRRLICHT) + message(STATUS "compile with native irrlicht") + add_definitions(-DCOMPILE_WITH_IRRLICHT) + target_include_directories(${IRRNET_TARGET} PUBLIC ${IRRLICHT_INC_DIR}) +endif() + target_include_directories(${IRRNET_TARGET} PUBLIC ${IRRNET_INC_DIR} ${ENET_INC_DIR} ${ZLIB_INC_DIR}) diff --git a/include/SPacket.h b/include/SPacket.h index e4d4725..303c0a3 100644 --- a/include/SPacket.h +++ b/include/SPacket.h @@ -49,8 +49,10 @@ class SOutPacket SOutPacket& operator << (const f64 data); /// Adds data to the packet. SOutPacket& operator << (const core::vector3df& data); +#ifdef COMPILE_WITH_IRRLICHT /// Adds a quaternion to the packet SOutPacket& operator << (const core::quaternion&); +#endif /// Adds data to the packet. SOutPacket& operator << (const c8* string); /// Adds data to the packet. @@ -116,8 +118,10 @@ class SInPacket void operator >> (f64& data); /// Gets the next item in the packet based on the size of the variable. void operator >> (core::vector3df& data); +#ifdef COMPILE_WITH_IRRLICHT /// Gets the next item in the packet based on the size of the variable. void operator >> (core::quaternion& data); +#endif /// Gets the next item in the packet based on the size of the variable. void operator >> (char* string); /// Gets the next item in the packet based on the size of the variable. diff --git a/source/SPacket.cpp b/source/SPacket.cpp index e9eaa26..83ebd64 100644 --- a/source/SPacket.cpp +++ b/source/SPacket.cpp @@ -106,13 +106,14 @@ SOutPacket& SOutPacket::operator << (const core::vector3df& data) memcpy(buff.pointer() + buff.size() - 12, &data.X, 12); return *this; } - +#ifdef COMPILE_WITH_IRRLICHT SOutPacket& SOutPacket::operator << (const core::quaternion& data) { enlargeBuffer(16); memcpy(buff.pointer() + buff.size() - 16, &data.X, 16); return *this; } +#endif SOutPacket& SOutPacket::operator << (const c8* string) { @@ -304,12 +305,13 @@ void SInPacket::operator >> (core::vector3df &data) memcpy(&data.X,getData()+pos,12); pos+=12; } - +#ifdef COMPILE_WITH_IRRLICHT void SInPacket::operator >> (core::quaternion &data) { memcpy(&data.X,getData()+pos,16); pos+=16; } +#endif void SInPacket::operator >> (char *string) {