Browse Source

added quaternions to packet structures

master
Otto Naderer 2 months ago
parent
commit
ed8345550f
  1. 19
      CMakeLists.txt
  2. 7
      include/SPacket.h
  3. 13
      source/SPacket.cpp
  4. 2
      zlib

19
CMakeLists.txt

@ -19,25 +19,17 @@ set(IRRNET_INC_DIR "${CMAKE_CURRENT_LIST_DIR}/include")
set(ENET_TARGET enet)
set(ENET_DIR "${CMAKE_CURRENT_LIST_DIR}/enet")
set(ENET_INC_DIR ${ENET_DIR}/include)
add_subdirectory(${ENET_DIR})
add_subdirectory(${ENET_DIR} EXCLUDE_FROM_ALL)
#zlib stuff
set(ZLIB_TARGET zlib)
set(ZLIB_TARGET zlibstatic)
set(ZLIB_DIR "${CMAKE_CURRENT_LIST_DIR}/zlib")
#set(ZLIB_INC_DIR ${ZLIB_DIR}/include)
add_subdirectory(${ZLIB_DIR})
set(ZLIB_INC_DIR ${ZLIB_DIR}/include)
add_subdirectory(${ZLIB_DIR} EXCLUDE_FROM_ALL)
project(irrnet)
#include_directories(
# /usr/include/irrlicht
# ${IRRNET_INC_DIR}
# ${TESLINK_SRC_DIR}
# ${TESSERVER_REST_INC_DIR}
# ${JSON_INC_DIR}
#)
include_directories(/usr/include/irrlicht)
add_library(${IRRNET_TARGET} STATIC
@ -45,6 +37,5 @@ add_library(${IRRNET_TARGET} STATIC
${IRRNET_SRC_DIR}/SPacket.cpp
)
target_include_directories(${IRRNET_TARGET} PUBLIC ${IRRNET_INC_DIR} ${ENET_INC_DIR})
target_include_directories(${IRRNET_TARGET} PUBLIC ${IRRNET_INC_DIR} ${ENET_INC_DIR} ${ZLIB_INC_DIR})
target_link_libraries(${IRRNET_LIB_TARGET} ${ENET_TARGET})

7
include/SPacket.h

@ -49,6 +49,8 @@ class SOutPacket
SOutPacket& operator << (const f64 data);
/// Adds data to the packet.
SOutPacket& operator << (const core::vector3df& data);
/// Adds a quaternion to the packet
SOutPacket& operator << (const core::quaternion&);
/// Adds data to the packet.
SOutPacket& operator << (const c8* string);
/// Adds data to the packet.
@ -57,7 +59,6 @@ class SOutPacket
SOutPacket& operator << (const std::string& string);
/// Adds data to the packet.
SOutPacket& operator << (const core::stringw& string);
/// Appends another SOutPacket to the packet.
SOutPacket& operator << (const SOutPacket& other);
@ -114,7 +115,9 @@ class SInPacket
/// Gets the next item in the packet based on the size of the variable.
void operator >> (f64& data);
/// Gets the next item in the packet based on the size of the variable.
void operator >> (core::vector3df& data);
void operator >> (core::vector3df& data);
/// Gets the next item in the packet based on the size of the variable.
void operator >> (core::quaternion& data);
/// 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.

13
source/SPacket.cpp

@ -107,6 +107,13 @@ SOutPacket& SOutPacket::operator << (const core::vector3df& data)
return *this;
}
SOutPacket& SOutPacket::operator << (const core::quaternion& data)
{
enlargeBuffer(16);
memcpy(buff.pointer() + buff.size() - 16, &data.X, 16);
return *this;
}
SOutPacket& SOutPacket::operator << (const c8* string)
{
u16 tmp = (u16)strlen(string);
@ -298,6 +305,12 @@ void SInPacket::operator >> (core::vector3df &data)
pos+=12;
}
void SInPacket::operator >> (core::quaternion &data)
{
memcpy(&data.X,getData()+pos,16);
pos+=16;
}
void SInPacket::operator >> (char *string)
{
u16 sz;

2
zlib

@ -1 +1 @@
Subproject commit cacf7f1d4e3d44d871b605da3b647f07d718623f
Subproject commit 21767c654d31d2dccdde4330529775c6c5fd5389
Loading…
Cancel
Save