Browse Source

Fix building on linux and use unchanged SFML

pull/7983/head
Anders Jenbo 11 months ago
parent
commit
95d1b93bd2
  1. 14
      CMake/Dependencies.cmake
  2. 44
      Source/CMakeLists.txt
  3. 2
      Source/dapi/Backend/DAPIBackendCore/DAPIProtoClient.cpp
  4. 2
      Source/dapi/Backend/DAPIBackendCore/DAPIProtoClient.h
  5. 183
      Source/dapi/Backend/DAPIBackendCore/SFML/Config.hpp
  6. 50
      Source/dapi/Backend/DAPIBackendCore/SFML/Network.hpp
  7. 219
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/IpAddress.cpp
  8. 296
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/IpAddress.hpp
  9. 476
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Packet.cpp
  10. 512
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Packet.hpp
  11. 131
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Socket.cpp
  12. 211
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Socket.hpp
  13. 54
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketHandle.hpp
  14. 38
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketImpl.hpp
  15. 188
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketSelector.cpp
  16. 255
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketSelector.hpp
  17. 119
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpListener.cpp
  18. 158
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpListener.hpp
  19. 365
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpSocket.cpp
  20. 307
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpSocket.hpp
  21. 184
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/UdpSocket.cpp
  22. 282
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/UdpSocket.hpp
  23. 105
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Unix/SocketImpl.hpp
  24. 102
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Unix/SocketImplUnix.cpp
  25. 252
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SFML_Winsock.hpp
  26. 108
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SocketImpl.hpp
  27. 167
      Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SocketImplWin32.cpp
  28. 9501
      Source/dapi/Backend/Messages/generated/command.pb.cc
  29. 10429
      Source/dapi/Backend/Messages/generated/command.pb.h
  30. 5512
      Source/dapi/Backend/Messages/generated/data.pb.cc
  31. 6992
      Source/dapi/Backend/Messages/generated/data.pb.h
  32. 1115
      Source/dapi/Backend/Messages/generated/game.pb.cc
  33. 1609
      Source/dapi/Backend/Messages/generated/game.pb.h
  34. 467
      Source/dapi/Backend/Messages/generated/init.pb.cc
  35. 466
      Source/dapi/Backend/Messages/generated/init.pb.h
  36. 818
      Source/dapi/Backend/Messages/generated/message.pb.cc
  37. 924
      Source/dapi/Backend/Messages/generated/message.pb.h
  38. 5
      Source/dapi/Item.h
  39. 6
      Source/dapi/Player.h
  40. 30
      Source/dapi/Server.cpp
  41. 3
      vcpkg.json

14
CMake/Dependencies.cmake

@ -56,20 +56,6 @@ if(SCREEN_READER_INTEGRATION)
endif()
endif()
#find_package(Protobuf REQUIRED)
#target_link_libraries(${NAME} PRIVATE protobuf::libprotobuf-lite)
#find_package(Protobuf CONFIG REQUIRED)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS "Source/dapi/Backend/Messages/command.proto")
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS Source/dapi/Backend/Messages/data.proto)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS Source/dapi/Backend/Messages/game.proto)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS Source/dapi/Backend/Messages/init.proto)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS Source/dapi/Backend/Messages/message.proto)
#target_link_libraries(${NAME} PRIVATE protobuf)#::libprotobuf)
if(EMSCRIPTEN)
# We use `USE_PTHREADS=1` here to get a version of SDL2 that supports threads.
emscripten_system_library("SDL2" SDL2::SDL2 USE_SDL=2 USE_PTHREADS=1)

44
Source/CMakeLists.txt

@ -642,29 +642,16 @@ if(DISCORD_INTEGRATION)
)
endif()
list(APPEND libdevilutionx_SRCS
list(APPEND libdevilutionx_SRCS
dapi/Server.cpp
dapi/Backend/DAPIBackendCore/DAPIProtoClient.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/IpAddress.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/Packet.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/Socket.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/SocketSelector.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/TcpListener.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/TcpSocket.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/UdpSocket.cpp
dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SocketImplWin32.cpp
dapi/Backend/Messages/generated/command.pb.cc
dapi/Backend/Messages/generated/data.pb.cc
dapi/Backend/Messages/generated/game.pb.cc
dapi/Backend/Messages/generated/init.pb.cc
dapi/Backend/Messages/generated/message.pb.cc
dapi/Backend/Messages/command.proto
dapi/Backend/Messages/data.proto
dapi/Backend/Messages/game.proto
dapi/Backend/Messages/init.proto
dapi/Backend/Messages/message.proto)
if(SCREEN_READER_INTEGRATION)
if(SCREEN_READER_INTEGRATION)
list(APPEND libdevilutionx_SRCS
utils/screen_reader.cpp
)
@ -816,16 +803,25 @@ find_package(Protobuf REQUIRED)
target_link_libraries(libdevilutionx PUBLIC protobuf::libprotobuf-lite)
find_package(absl REQUIRED)
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Source/dapi/Backend/Messages/generated")
target_include_directories(libdevilutionx PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
set(PROTO_BINARY_DIR "${CMAKE_BINARY_DIR}/generated")
file(MAKE_DIRECTORY ${PROTO_BINARY_DIR})
target_include_directories(libdevilutionx PRIVATE ${Protobuf_INCLUDE_DIRS})
#this was generating the .pb.cc/.pb.hh files for protobuf messages earlier but breaks in this current setup
#files are already generated at the moment so commenting this allows project to build.
#protobuf_generate(
# TARGET libdevilutionx
# IMPORT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/Source/dapi/Backend/Messages"
# PROTOC_OUT_DIR "${PROTO_BINARY_DIR}")
# Generate the protobuf files into the 'generated' directory within the build tree
protobuf_generate(
TARGET libdevilutionx
IMPORT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dapi/Backend/Messages"
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
)
#include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Source/dapi/Backend/DAPIBackendCore")
# Make sure the generated protobuf files are correctly included in the build
target_include_directories(libdevilutionx PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
include_directories("${PROTO_BINARY_DIR}/dapi/Backend/Messages")
target_include_directories(libdevilutionx PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/dapi/Backend/DAPIBackendCore")
find_package(SFML 2.5 REQUIRED network system)
target_link_libraries(libdevilutionx PUBLIC sfml-network sfml-system)

2
Source/dapi/Backend/DAPIBackendCore/DAPIProtoClient.cpp

@ -1,3 +1,5 @@
#include <thread>
#include "DAPIProtoClient.h"
namespace DAPI {

2
Source/dapi/Backend/DAPIBackendCore/DAPIProtoClient.h

@ -6,7 +6,7 @@
#include <SFML/Network.hpp>
#pragma warning(push, 0)
#include "..\Messages\generated\message.pb.h"
#include "message.pb.h"
#pragma warning(pop)
namespace DAPI {

183
Source/dapi/Backend/DAPIBackendCore/SFML/Config.hpp

@ -1,183 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_CONFIG_HPP
#define SFML_CONFIG_HPP
////////////////////////////////////////////////////////////
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 2
#define SFML_VERSION_MINOR 5
#define SFML_VERSION_PATCH 1
////////////////////////////////////////////////////////////
// Identify the operating system
// see http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
////////////////////////////////////////////////////////////
#if defined(_WIN32)
// Windows
#define SFML_SYSTEM_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX
#endif
#elif defined(__APPLE__) && defined(__MACH__)
// Apple platform, see which one it is
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
// iOS
#define SFML_SYSTEM_IOS
#elif TARGET_OS_MAC
// MacOS
#define SFML_SYSTEM_MACOS
#else
// Unsupported Apple system
#error This Apple operating system is not supported by SFML library
#endif
#elif defined(__unix__)
// UNIX system, see which one it is
#if defined(__ANDROID__)
// Android
#define SFML_SYSTEM_ANDROID
#elif defined(__linux__)
// Linux
#define SFML_SYSTEM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define SFML_SYSTEM_FREEBSD
#elif defined(__OpenBSD__)
// OpenBSD
#define SFML_SYSTEM_OPENBSD
#else
// Unsupported UNIX system
#error This UNIX operating system is not supported by SFML library
#endif
#else
// Unsupported system
#error This operating system is not supported by SFML library
#endif
////////////////////////////////////////////////////////////
// Define a portable debug macro
////////////////////////////////////////////////////////////
#if !defined(NDEBUG)
#define SFML_DEBUG
#endif
////////////////////////////////////////////////////////////
// Cross-platform warning for deprecated functions and classes
//
// Usage:
// class SFML_DEPRECATED MyClass
// {
// SFML_DEPRECATED void memberFunc();
// };
//
// SFML_DEPRECATED void globalFunc();
////////////////////////////////////////////////////////////
#if defined(SFML_NO_DEPRECATED_WARNINGS)
// User explicitly requests to disable deprecation warnings
#define SFML_DEPRECATED
#elif defined(_MSC_VER)
// Microsoft C++ compiler
// Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to
// trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.
#define SFML_DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
// g++ and Clang
#define SFML_DEPRECATED __attribute__((deprecated))
#else
// Other compilers are not supported, leave class or function as-is.
// With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.
#pragma message("SFML_DEPRECATED is not supported for your compiler, please contact the SFML team")
#define SFML_DEPRECATED
#endif
////////////////////////////////////////////////////////////
// Define portable fixed-size types
////////////////////////////////////////////////////////////
namespace sf {
// All "common" platforms use the same size for char, short and int
// (basically there are 3 types for 3 sizes, so no other match is possible),
// we can use them without doing any kind of check
// 8 bits integer types
typedef signed char Int8;
typedef unsigned char Uint8;
// 16 bits integer types
typedef signed short Int16;
typedef unsigned short Uint16;
// 32 bits integer types
typedef signed int Int32;
typedef unsigned int Uint32;
// 64 bits integer types
#if defined(_MSC_VER)
typedef signed __int64 Int64;
typedef unsigned __int64 Uint64;
#else
typedef signed long long Int64;
typedef unsigned long long Uint64;
#endif
} // namespace sf
#endif // SFML_CONFIG_HPP

50
Source/dapi/Backend/DAPIBackendCore/SFML/Network.hpp

@ -1,50 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_NETWORK_HPP
#define SFML_NETWORK_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/SocketHandle.hpp>
#include <SFML/Network/SocketSelector.hpp>
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/Network/UdpSocket.hpp>
#endif // SFML_NETWORK_HPP
////////////////////////////////////////////////////////////
/// \defgroup network Network module
///
/// Socket-based communication, utilities and higher-level
/// network protocols (HTTP, FTP).
///
////////////////////////////////////////////////////////////

219
Source/dapi/Backend/DAPIBackendCore/SFML/Network/IpAddress.cpp

@ -1,219 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <cstring>
#include <utility>
namespace sf {
////////////////////////////////////////////////////////////
const IpAddress IpAddress::None;
const IpAddress IpAddress::Any(0, 0, 0, 0);
const IpAddress IpAddress::LocalHost(127, 0, 0, 1);
const IpAddress IpAddress::Broadcast(255, 255, 255, 255);
////////////////////////////////////////////////////////////
IpAddress::IpAddress()
: m_address(0)
, m_valid(false)
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const std::string &address)
: m_address(0)
, m_valid(false)
{
resolve(address);
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const char *address)
: m_address(0)
, m_valid(false)
{
resolve(address);
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3)
: m_address(htonl((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3))
, m_valid(true)
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint32 address)
: m_address(htonl(address))
, m_valid(true)
{
}
////////////////////////////////////////////////////////////
std::string IpAddress::toString() const
{
in_addr address;
address.s_addr = m_address;
return inet_ntoa(address);
}
////////////////////////////////////////////////////////////
Uint32 IpAddress::toInteger() const
{
return ntohl(m_address);
}
////////////////////////////////////////////////////////////
IpAddress IpAddress::getLocalAddress()
{
// The method here is to connect a UDP socket to anyone (here to localhost),
// and get the local socket address with the getsockname function.
// UDP connection will not send anything to the network, so this function won't cause any overhead.
IpAddress localAddress;
// Create the socket
SocketHandle sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock == priv::SocketImpl::invalidSocket())
return localAddress;
// Connect the socket to localhost on any port
sockaddr_in address = priv::SocketImpl::createAddress(ntohl(INADDR_LOOPBACK), 9);
if (connect(sock, reinterpret_cast<sockaddr *>(&address), sizeof(address)) == -1) {
priv::SocketImpl::close(sock);
return localAddress;
}
// Get the local address of the socket connection
priv::SocketImpl::AddrLength size = sizeof(address);
if (getsockname(sock, reinterpret_cast<sockaddr *>(&address), &size) == -1) {
priv::SocketImpl::close(sock);
return localAddress;
}
// Close the socket
priv::SocketImpl::close(sock);
// Finally build the IP address
localAddress = IpAddress(ntohl(address.sin_addr.s_addr));
return localAddress;
}
////////////////////////////////////////////////////////////
void IpAddress::resolve(const std::string &address)
{
m_address = 0;
m_valid = false;
if (address == "255.255.255.255") {
// The broadcast address needs to be handled explicitly,
// because it is also the value returned by inet_addr on error
m_address = INADDR_BROADCAST;
m_valid = true;
} else if (address == "0.0.0.0") {
m_address = INADDR_ANY;
m_valid = true;
} else {
// Try to convert the address as a byte representation ("xxx.xxx.xxx.xxx")
Uint32 ip = inet_addr(address.c_str());
if (ip != INADDR_NONE) {
m_address = ip;
m_valid = true;
} else {
// Not a valid address, try to convert it as a host name
addrinfo hints;
std::memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
addrinfo *result = NULL;
if (getaddrinfo(address.c_str(), NULL, &hints, &result) == 0) {
if (result) {
ip = reinterpret_cast<sockaddr_in *>(result->ai_addr)->sin_addr.s_addr;
freeaddrinfo(result);
m_address = ip;
m_valid = true;
}
}
}
}
}
////////////////////////////////////////////////////////////
bool operator==(const IpAddress &left, const IpAddress &right)
{
return !(left < right) && !(right < left);
}
////////////////////////////////////////////////////////////
bool operator!=(const IpAddress &left, const IpAddress &right)
{
return !(left == right);
}
////////////////////////////////////////////////////////////
bool operator<(const IpAddress &left, const IpAddress &right)
{
return std::make_pair(left.m_valid, left.m_address) < std::make_pair(right.m_valid, right.m_address);
}
////////////////////////////////////////////////////////////
bool operator>(const IpAddress &left, const IpAddress &right)
{
return right < left;
}
////////////////////////////////////////////////////////////
bool operator<=(const IpAddress &left, const IpAddress &right)
{
return !(right < left);
}
////////////////////////////////////////////////////////////
bool operator>=(const IpAddress &left, const IpAddress &right)
{
return !(left < right);
}
////////////////////////////////////////////////////////////
std::istream &operator>>(std::istream &stream, IpAddress &address)
{
std::string str;
stream >> str;
address = IpAddress(str);
return stream;
}
////////////////////////////////////////////////////////////
std::ostream &operator<<(std::ostream &stream, const IpAddress &address)
{
return stream << address.toString();
}
} // namespace sf

296
Source/dapi/Backend/DAPIBackendCore/SFML/Network/IpAddress.hpp

@ -1,296 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_IPADDRESS_HPP
#define SFML_IPADDRESS_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <istream>
#include <ostream>
#include <string>
namespace sf {
////////////////////////////////////////////////////////////
/// \brief Encapsulate an IPv4 network address
///
////////////////////////////////////////////////////////////
class IpAddress {
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// This constructor creates an empty (invalid) address
///
////////////////////////////////////////////////////////////
IpAddress();
////////////////////////////////////////////////////////////
/// \brief Construct the address from a string
///
/// Here \a address can be either a decimal address
/// (ex: "192.168.1.56") or a network name (ex: "localhost").
///
/// \param address IP address or network name
///
////////////////////////////////////////////////////////////
IpAddress(const std::string &address);
////////////////////////////////////////////////////////////
/// \brief Construct the address from a string
///
/// Here \a address can be either a decimal address
/// (ex: "192.168.1.56") or a network name (ex: "localhost").
/// This is equivalent to the constructor taking a std::string
/// parameter, it is defined for convenience so that the
/// implicit conversions from literal strings to IpAddress work.
///
/// \param address IP address or network name
///
////////////////////////////////////////////////////////////
IpAddress(const char *address);
////////////////////////////////////////////////////////////
/// \brief Construct the address from 4 bytes
///
/// Calling IpAddress(a, b, c, d) is equivalent to calling
/// IpAddress("a.b.c.d"), but safer as it doesn't have to
/// parse a string to get the address components.
///
/// \param byte0 First byte of the address
/// \param byte1 Second byte of the address
/// \param byte2 Third byte of the address
/// \param byte3 Fourth byte of the address
///
////////////////////////////////////////////////////////////
IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3);
////////////////////////////////////////////////////////////
/// \brief Construct the address from a 32-bits integer
///
/// This constructor uses the internal representation of
/// the address directly. It should be used for optimization
/// purposes, and only if you got that representation from
/// IpAddress::toInteger().
///
/// \param address 4 bytes of the address packed into a 32-bits integer
///
/// \see toInteger
///
////////////////////////////////////////////////////////////
explicit IpAddress(Uint32 address);
////////////////////////////////////////////////////////////
/// \brief Get a string representation of the address
///
/// The returned string is the decimal representation of the
/// IP address (like "192.168.1.56"), even if it was constructed
/// from a host name.
///
/// \return String representation of the address
///
/// \see toInteger
///
////////////////////////////////////////////////////////////
std::string toString() const;
////////////////////////////////////////////////////////////
/// \brief Get an integer representation of the address
///
/// The returned number is the internal representation of the
/// address, and should be used for optimization purposes only
/// (like sending the address through a socket).
/// The integer produced by this function can then be converted
/// back to a sf::IpAddress with the proper constructor.
///
/// \return 32-bits unsigned integer representation of the address
///
/// \see toString
///
////////////////////////////////////////////////////////////
Uint32 toInteger() const;
////////////////////////////////////////////////////////////
/// \brief Get the computer's local address
///
/// The local address is the address of the computer from the
/// LAN point of view, i.e. something like 192.168.1.56. It is
/// meaningful only for communications over the local network.
/// Unlike getPublicAddress, this function is fast and may be
/// used safely anywhere.
///
/// \return Local IP address of the computer
///
/// \see getPublicAddress
///
////////////////////////////////////////////////////////////
static IpAddress getLocalAddress();
////////////////////////////////////////////////////////////
// Static member data
////////////////////////////////////////////////////////////
static const IpAddress None; ///< Value representing an empty/invalid address
static const IpAddress Any; ///< Value representing any address (0.0.0.0)
static const IpAddress LocalHost; ///< The "localhost" address (for connecting a computer to itself locally)
static const IpAddress Broadcast; ///< The "broadcast" address (for sending UDP messages to everyone on a local network)
private:
friend bool operator<(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Resolve the given address string
///
/// \param address Address string
///
////////////////////////////////////////////////////////////
void resolve(const std::string &address);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Uint32 m_address; ///< Address stored as an unsigned 32 bits integer
bool m_valid; ///< Is the address valid?
};
////////////////////////////////////////////////////////////
/// \brief Overload of == operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if both addresses are equal
///
////////////////////////////////////////////////////////////
bool operator==(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of != operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if both addresses are different
///
////////////////////////////////////////////////////////////
bool operator!=(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of < operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if \a left is lesser than \a right
///
////////////////////////////////////////////////////////////
bool operator<(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of > operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if \a left is greater than \a right
///
////////////////////////////////////////////////////////////
bool operator>(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of <= operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if \a left is lesser or equal than \a right
///
////////////////////////////////////////////////////////////
bool operator<=(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of >= operator to compare two IP addresses
///
/// \param left Left operand (a IP address)
/// \param right Right operand (a IP address)
///
/// \return True if \a left is greater or equal than \a right
///
////////////////////////////////////////////////////////////
bool operator>=(const IpAddress &left, const IpAddress &right);
////////////////////////////////////////////////////////////
/// \brief Overload of >> operator to extract an IP address from an input stream
///
/// \param stream Input stream
/// \param address IP address to extract
///
/// \return Reference to the input stream
///
////////////////////////////////////////////////////////////
std::istream &operator>>(std::istream &stream, IpAddress &address);
////////////////////////////////////////////////////////////
/// \brief Overload of << operator to print an IP address to an output stream
///
/// \param stream Output stream
/// \param address IP address to print
///
/// \return Reference to the output stream
///
////////////////////////////////////////////////////////////
std::ostream &operator<<(std::ostream &stream, const IpAddress &address);
} // namespace sf
#endif // SFML_IPADDRESS_HPP
////////////////////////////////////////////////////////////
/// \class sf::IpAddress
/// \ingroup network
///
/// sf::IpAddress is a utility class for manipulating network
/// addresses. It provides a set a implicit constructors and
/// conversion functions to easily build or transform an IP
/// address from/to various representations.
///
/// Usage example:
/// \code
/// sf::IpAddress a0; // an invalid address
/// sf::IpAddress a1 = sf::IpAddress::None; // an invalid address (same as a0)
/// sf::IpAddress a2("127.0.0.1"); // the local host address
/// sf::IpAddress a3 = sf::IpAddress::Broadcast; // the broadcast address
/// sf::IpAddress a4(192, 168, 1, 56); // a local address
/// sf::IpAddress a5("my_computer"); // a local address created from a network name
/// sf::IpAddress a6("89.54.1.169"); // a distant address
/// sf::IpAddress a7("www.google.com"); // a distant address created from a network name
/// sf::IpAddress a8 = sf::IpAddress::getLocalAddress(); // my address on the local network
/// sf::IpAddress a9 = sf::IpAddress::getPublicAddress(); // my address on the internet
/// \endcode
///
/// Note that sf::IpAddress currently doesn't support IPv6
/// nor other types of network addresses.
///
////////////////////////////////////////////////////////////

476
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Packet.cpp

@ -1,476 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <cstring>
#include <cwchar>
namespace sf {
////////////////////////////////////////////////////////////
Packet::Packet()
: m_readPos(0)
, m_sendPos(0)
, m_isValid(true)
{
}
////////////////////////////////////////////////////////////
Packet::~Packet()
{
}
////////////////////////////////////////////////////////////
void Packet::append(const void *data, std::size_t sizeInBytes)
{
if (data && (sizeInBytes > 0)) {
std::size_t start = m_data.size();
m_data.resize(start + sizeInBytes);
std::memcpy(&m_data[start], data, sizeInBytes);
}
}
////////////////////////////////////////////////////////////
void Packet::clear()
{
m_data.clear();
m_readPos = 0;
m_isValid = true;
}
////////////////////////////////////////////////////////////
const void *Packet::getData() const
{
return !m_data.empty() ? &m_data[0] : NULL;
}
////////////////////////////////////////////////////////////
std::size_t Packet::getDataSize() const
{
return m_data.size();
}
////////////////////////////////////////////////////////////
bool Packet::endOfPacket() const
{
return m_readPos >= m_data.size();
}
////////////////////////////////////////////////////////////
Packet::operator BoolType() const
{
return m_isValid ? &Packet::checkSize : NULL;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(bool &data)
{
Uint8 value;
if (*this >> value)
data = (value != 0);
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Int8 &data)
{
if (checkSize(sizeof(data))) {
data = *reinterpret_cast<const Int8 *>(&m_data[m_readPos]);
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Uint8 &data)
{
if (checkSize(sizeof(data))) {
data = *reinterpret_cast<const Uint8 *>(&m_data[m_readPos]);
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Int16 &data)
{
if (checkSize(sizeof(data))) {
data = ntohs(*reinterpret_cast<const Int16 *>(&m_data[m_readPos]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Uint16 &data)
{
if (checkSize(sizeof(data))) {
data = ntohs(*reinterpret_cast<const Uint16 *>(&m_data[m_readPos]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Int32 &data)
{
if (checkSize(sizeof(data))) {
data = ntohl(*reinterpret_cast<const Int32 *>(&m_data[m_readPos]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Uint32 &data)
{
if (checkSize(sizeof(data))) {
data = ntohl(*reinterpret_cast<const Uint32 *>(&m_data[m_readPos]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Int64 &data)
{
if (checkSize(sizeof(data))) {
// Since ntohll is not available everywhere, we have to convert
// to network byte order (big endian) manually
const Uint8 *bytes = reinterpret_cast<const Uint8 *>(&m_data[m_readPos]);
data = (static_cast<Int64>(bytes[0]) << 56) | (static_cast<Int64>(bytes[1]) << 48) | (static_cast<Int64>(bytes[2]) << 40) | (static_cast<Int64>(bytes[3]) << 32) | (static_cast<Int64>(bytes[4]) << 24) | (static_cast<Int64>(bytes[5]) << 16) | (static_cast<Int64>(bytes[6]) << 8) | (static_cast<Int64>(bytes[7]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(Uint64 &data)
{
if (checkSize(sizeof(data))) {
// Since ntohll is not available everywhere, we have to convert
// to network byte order (big endian) manually
const Uint8 *bytes = reinterpret_cast<const Uint8 *>(&m_data[m_readPos]);
data = (static_cast<Uint64>(bytes[0]) << 56) | (static_cast<Uint64>(bytes[1]) << 48) | (static_cast<Uint64>(bytes[2]) << 40) | (static_cast<Uint64>(bytes[3]) << 32) | (static_cast<Uint64>(bytes[4]) << 24) | (static_cast<Uint64>(bytes[5]) << 16) | (static_cast<Uint64>(bytes[6]) << 8) | (static_cast<Uint64>(bytes[7]));
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(float &data)
{
if (checkSize(sizeof(data))) {
data = *reinterpret_cast<const float *>(&m_data[m_readPos]);
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(double &data)
{
if (checkSize(sizeof(data))) {
data = *reinterpret_cast<const double *>(&m_data[m_readPos]);
m_readPos += sizeof(data);
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(char *data)
{
// First extract string length
Uint32 length = 0;
*this >> length;
if ((length > 0) && checkSize(length)) {
// Then extract characters
std::memcpy(data, &m_data[m_readPos], length);
data[length] = '\0';
// Update reading position
m_readPos += length;
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(std::string &data)
{
// First extract string length
Uint32 length = 0;
*this >> length;
data.clear();
if ((length > 0) && checkSize(length)) {
// Then extract characters
data.assign(&m_data[m_readPos], length);
// Update reading position
m_readPos += length;
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(wchar_t *data)
{
// First extract string length
Uint32 length = 0;
*this >> length;
if ((length > 0) && checkSize(length * sizeof(Uint32))) {
// Then extract characters
for (Uint32 i = 0; i < length; ++i) {
Uint32 character = 0;
*this >> character;
data[i] = static_cast<wchar_t>(character);
}
data[length] = L'\0';
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator>>(std::wstring &data)
{
// First extract string length
Uint32 length = 0;
*this >> length;
data.clear();
if ((length > 0) && checkSize(length * sizeof(Uint32))) {
// Then extract characters
for (Uint32 i = 0; i < length; ++i) {
Uint32 character = 0;
*this >> character;
data += static_cast<wchar_t>(character);
}
}
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(bool data)
{
*this << static_cast<Uint8>(data);
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Int8 data)
{
append(&data, sizeof(data));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Uint8 data)
{
append(&data, sizeof(data));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Int16 data)
{
Int16 toWrite = htons(data);
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Uint16 data)
{
Uint16 toWrite = htons(data);
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Int32 data)
{
Int32 toWrite = htonl(data);
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Uint32 data)
{
Uint32 toWrite = htonl(data);
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Int64 data)
{
// Since htonll is not available everywhere, we have to convert
// to network byte order (big endian) manually
Uint8 toWrite[] = {
static_cast<Uint8>((data >> 56) & 0xFF),
static_cast<Uint8>((data >> 48) & 0xFF),
static_cast<Uint8>((data >> 40) & 0xFF),
static_cast<Uint8>((data >> 32) & 0xFF),
static_cast<Uint8>((data >> 24) & 0xFF),
static_cast<Uint8>((data >> 16) & 0xFF),
static_cast<Uint8>((data >> 8) & 0xFF),
static_cast<Uint8>((data)&0xFF)
};
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(Uint64 data)
{
// Since htonll is not available everywhere, we have to convert
// to network byte order (big endian) manually
Uint8 toWrite[] = {
static_cast<Uint8>((data >> 56) & 0xFF),
static_cast<Uint8>((data >> 48) & 0xFF),
static_cast<Uint8>((data >> 40) & 0xFF),
static_cast<Uint8>((data >> 32) & 0xFF),
static_cast<Uint8>((data >> 24) & 0xFF),
static_cast<Uint8>((data >> 16) & 0xFF),
static_cast<Uint8>((data >> 8) & 0xFF),
static_cast<Uint8>((data)&0xFF)
};
append(&toWrite, sizeof(toWrite));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(float data)
{
append(&data, sizeof(data));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(double data)
{
append(&data, sizeof(data));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(const char *data)
{
// First insert string length
Uint32 length = static_cast<Uint32>(std::strlen(data));
*this << length;
// Then insert characters
append(data, length * sizeof(char));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(const std::string &data)
{
// First insert string length
Uint32 length = static_cast<Uint32>(data.size());
*this << length;
// Then insert characters
if (length > 0)
append(data.c_str(), length * sizeof(std::string::value_type));
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(const wchar_t *data)
{
// First insert string length
Uint32 length = static_cast<Uint32>(std::wcslen(data));
*this << length;
// Then insert characters
for (const wchar_t *c = data; *c != L'\0'; ++c)
*this << static_cast<Uint32>(*c);
return *this;
}
////////////////////////////////////////////////////////////
Packet &Packet::operator<<(const std::wstring &data)
{
// First insert string length
Uint32 length = static_cast<Uint32>(data.size());
*this << length;
// Then insert characters
if (length > 0) {
for (std::wstring::const_iterator c = data.begin(); c != data.end(); ++c)
*this << static_cast<Uint32>(*c);
}
return *this;
}
////////////////////////////////////////////////////////////
bool Packet::checkSize(std::size_t size)
{
m_isValid = m_isValid && (m_readPos + size <= m_data.size());
return m_isValid;
}
////////////////////////////////////////////////////////////
const void *Packet::onSend(std::size_t &size)
{
size = getDataSize();
return getData();
}
////////////////////////////////////////////////////////////
void Packet::onReceive(const void *data, std::size_t size)
{
append(data, size);
}
} // namespace sf

512
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Packet.hpp

@ -1,512 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_PACKET_HPP
#define SFML_PACKET_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <string>
#include <vector>
namespace sf {
class TcpSocket;
class UdpSocket;
////////////////////////////////////////////////////////////
/// \brief Utility class to build blocks of data to transfer
/// over the network
///
////////////////////////////////////////////////////////////
class Packet {
// A bool-like type that cannot be converted to integer or pointer types
typedef bool (Packet::*BoolType)(std::size_t);
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Creates an empty packet.
///
////////////////////////////////////////////////////////////
Packet();
////////////////////////////////////////////////////////////
/// \brief Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~Packet();
////////////////////////////////////////////////////////////
/// \brief Append data to the end of the packet
///
/// \param data Pointer to the sequence of bytes to append
/// \param sizeInBytes Number of bytes to append
///
/// \see clear
///
////////////////////////////////////////////////////////////
void append(const void *data, std::size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// \brief Clear the packet
///
/// After calling Clear, the packet is empty.
///
/// \see append
///
////////////////////////////////////////////////////////////
void clear();
////////////////////////////////////////////////////////////
/// \brief Get a pointer to the data contained in the packet
///
/// Warning: the returned pointer may become invalid after
/// you append data to the packet, therefore it should never
/// be stored.
/// The return pointer is NULL if the packet is empty.
///
/// \return Pointer to the data
///
/// \see getDataSize
///
////////////////////////////////////////////////////////////
const void *getData() const;
////////////////////////////////////////////////////////////
/// \brief Get the size of the data contained in the packet
///
/// This function returns the number of bytes pointed to by
/// what getData returns.
///
/// \return Data size, in bytes
///
/// \see getData
///
////////////////////////////////////////////////////////////
std::size_t getDataSize() const;
////////////////////////////////////////////////////////////
/// \brief Tell if the reading position has reached the
/// end of the packet
///
/// This function is useful to know if there is some data
/// left to be read, without actually reading it.
///
/// \return True if all data was read, false otherwise
///
/// \see operator bool
///
////////////////////////////////////////////////////////////
bool endOfPacket() const;
public:
////////////////////////////////////////////////////////////
/// \brief Test the validity of the packet, for reading
///
/// This operator allows to test the packet as a boolean
/// variable, to check if a reading operation was successful.
///
/// A packet will be in an invalid state if it has no more
/// data to read.
///
/// This behavior is the same as standard C++ streams.
///
/// Usage example:
/// \code
/// float x;
/// packet >> x;
/// if (packet)
/// {
/// // ok, x was extracted successfully
/// }
///
/// // -- or --
///
/// float x;
/// if (packet >> x)
/// {
/// // ok, x was extracted successfully
/// }
/// \endcode
///
/// Don't focus on the return type, it's equivalent to bool but
/// it disallows unwanted implicit conversions to integer or
/// pointer types.
///
/// \return True if last data extraction from packet was successful
///
/// \see endOfPacket
///
////////////////////////////////////////////////////////////
operator BoolType() const;
////////////////////////////////////////////////////////////
/// Overload of operator >> to read data from the packet
///
////////////////////////////////////////////////////////////
Packet &operator>>(bool &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Int8 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Uint8 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Int16 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Uint16 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Int32 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Uint32 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Int64 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(Uint64 &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(float &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(double &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(char *data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(std::string &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(wchar_t *data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator>>(std::wstring &data);
////////////////////////////////////////////////////////////
/// Overload of operator << to write data into the packet
///
////////////////////////////////////////////////////////////
Packet &operator<<(bool data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Int8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Uint8 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Int16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Uint16 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Int32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Uint32 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Int64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(Uint64 data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(float data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(double data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(const char *data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(const std::string &data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(const wchar_t *data);
////////////////////////////////////////////////////////////
/// \overload
////////////////////////////////////////////////////////////
Packet &operator<<(const std::wstring &data);
protected:
friend class TcpSocket;
friend class UdpSocket;
////////////////////////////////////////////////////////////
/// \brief Called before the packet is sent over the network
///
/// This function can be defined by derived classes to
/// transform the data before it is sent; this can be
/// used for compression, encryption, etc.
/// The function must return a pointer to the modified data,
/// as well as the number of bytes pointed.
/// The default implementation provides the packet's data
/// without transforming it.
///
/// \param size Variable to fill with the size of data to send
///
/// \return Pointer to the array of bytes to send
///
/// \see onReceive
///
////////////////////////////////////////////////////////////
virtual const void *onSend(std::size_t &size);
////////////////////////////////////////////////////////////
/// \brief Called after the packet is received over the network
///
/// This function can be defined by derived classes to
/// transform the data after it is received; this can be
/// used for decompression, decryption, etc.
/// The function receives a pointer to the received data,
/// and must fill the packet with the transformed bytes.
/// The default implementation fills the packet directly
/// without transforming the data.
///
/// \param data Pointer to the received bytes
/// \param size Number of bytes
///
/// \see onSend
///
////////////////////////////////////////////////////////////
virtual void onReceive(const void *data, std::size_t size);
private:
////////////////////////////////////////////////////////////
/// Disallow comparisons between packets
///
////////////////////////////////////////////////////////////
bool operator==(const Packet &right) const;
bool operator!=(const Packet &right) const;
////////////////////////////////////////////////////////////
/// \brief Check if the packet can extract a given number of bytes
///
/// This function updates accordingly the state of the packet.
///
/// \param size Size to check
///
/// \return True if \a size bytes can be read from the packet
///
////////////////////////////////////////////////////////////
bool checkSize(std::size_t size);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::vector<char> m_data; ///< Data stored in the packet
std::size_t m_readPos; ///< Current reading position in the packet
std::size_t m_sendPos; ///< Current send position in the packet (for handling partial sends)
bool m_isValid; ///< Reading state of the packet
};
} // namespace sf
#endif // SFML_PACKET_HPP
////////////////////////////////////////////////////////////
/// \class sf::Packet
/// \ingroup network
///
/// Packets provide a safe and easy way to serialize data,
/// in order to send it over the network using sockets
/// (sf::TcpSocket, sf::UdpSocket).
///
/// Packets solve 2 fundamental problems that arise when
/// transferring data over the network:
/// \li data is interpreted correctly according to the endianness
/// \li the bounds of the packet are preserved (one send == one receive)
///
/// The sf::Packet class provides both input and output modes.
/// It is designed to follow the behavior of standard C++ streams,
/// using operators >> and << to extract and insert data.
///
/// It is recommended to use only fixed-size types (like sf::Int32, etc.),
/// to avoid possible differences between the sender and the receiver.
/// Indeed, the native C++ types may have different sizes on two platforms
/// and your data may be corrupted if that happens.
///
/// Usage example:
/// \code
/// sf::Uint32 x = 24;
/// std::string s = "hello";
/// double d = 5.89;
///
/// // Group the variables to send into a packet
/// sf::Packet packet;
/// packet << x << s << d;
///
/// // Send it over the network (socket is a valid sf::TcpSocket)
/// socket.send(packet);
///
/// -----------------------------------------------------------------
///
/// // Receive the packet at the other end
/// sf::Packet packet;
/// socket.receive(packet);
///
/// // Extract the variables contained in the packet
/// sf::Uint32 x;
/// std::string s;
/// double d;
/// if (packet >> x >> s >> d)
/// {
/// // Data extracted successfully...
/// }
/// \endcode
///
/// Packets have built-in operator >> and << overloads for
/// standard types:
/// \li bool
/// \li fixed-size integer types (sf::Int8/16/32, sf::Uint8/16/32)
/// \li floating point numbers (float, double)
/// \li string types (char*, wchar_t*, std::string, std::wstring, sf::String)
///
/// Like standard streams, it is also possible to define your own
/// overloads of operators >> and << in order to handle your
/// custom types.
///
/// \code
/// struct MyStruct
/// {
/// float number;
/// sf::Int8 integer;
/// std::string str;
/// };
///
/// sf::Packet& operator <<(sf::Packet& packet, const MyStruct& m)
/// {
/// return packet << m.number << m.integer << m.str;
/// }
///
/// sf::Packet& operator >>(sf::Packet& packet, MyStruct& m)
/// {
/// return packet >> m.number >> m.integer >> m.str;
/// }
/// \endcode
///
/// Packets also provide an extra feature that allows to apply
/// custom transformations to the data before it is sent,
/// and after it is received. This is typically used to
/// handle automatic compression or encryption of the data.
/// This is achieved by inheriting from sf::Packet, and overriding
/// the onSend and onReceive functions.
///
/// Here is an example:
/// \code
/// class ZipPacket : public sf::Packet
/// {
/// virtual const void* onSend(std::size_t& size)
/// {
/// const void* srcData = getData();
/// std::size_t srcSize = getDataSize();
///
/// return MySuperZipFunction(srcData, srcSize, &size);
/// }
///
/// virtual void onReceive(const void* data, std::size_t size)
/// {
/// std::size_t dstSize;
/// const void* dstData = MySuperUnzipFunction(data, size, &dstSize);
///
/// append(dstData, dstSize);
/// }
/// };
///
/// // Use like regular packets:
/// ZipPacket packet;
/// packet << x << s << d;
/// ...
/// \endcode
///
/// \see sf::TcpSocket, sf::UdpSocket
///
////////////////////////////////////////////////////////////

131
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Socket.cpp

@ -1,131 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <iostream>
namespace sf {
////////////////////////////////////////////////////////////
Socket::Socket(Type type)
: m_type(type)
, m_socket(priv::SocketImpl::invalidSocket())
, m_isBlocking(true)
{
}
////////////////////////////////////////////////////////////
Socket::~Socket()
{
// Close the socket before it gets destructed
close();
}
////////////////////////////////////////////////////////////
void Socket::setBlocking(bool blocking)
{
// Apply if the socket is already created
if (m_socket != priv::SocketImpl::invalidSocket())
priv::SocketImpl::setBlocking(m_socket, blocking);
m_isBlocking = blocking;
}
////////////////////////////////////////////////////////////
bool Socket::isBlocking() const
{
return m_isBlocking;
}
////////////////////////////////////////////////////////////
SocketHandle Socket::getHandle() const
{
return m_socket;
}
////////////////////////////////////////////////////////////
void Socket::create()
{
// Don't create the socket if it already exists
if (m_socket == priv::SocketImpl::invalidSocket()) {
SocketHandle handle = socket(PF_INET, m_type == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
if (handle == priv::SocketImpl::invalidSocket()) {
std::cerr << "Failed to create socket" << std::endl;
return;
}
create(handle);
}
}
////////////////////////////////////////////////////////////
void Socket::create(SocketHandle handle)
{
// Don't create the socket if it already exists
if (m_socket == priv::SocketImpl::invalidSocket()) {
// Assign the new handle
m_socket = handle;
// Set the current blocking state
setBlocking(m_isBlocking);
if (m_type == Tcp) {
// Disable the Nagle algorithm (i.e. removes buffering of TCP packets)
int yes = 1;
if (setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char *>(&yes), sizeof(yes)) == -1) {
std::cerr << "Failed to set socket option \"TCP_NODELAY\" ; "
<< "all your TCP packets will be buffered" << std::endl;
}
// On Mac OS X, disable the SIGPIPE signal on disconnection
#ifdef SFML_SYSTEM_MACOS
if (setsockopt(m_socket, SOL_SOCKET, SO_NOSIGPIPE, reinterpret_cast<char *>(&yes), sizeof(yes)) == -1) {
std::cerr << "Failed to set socket option \"SO_NOSIGPIPE\"" << std::endl;
}
#endif
} else {
// Enable broadcast by default for UDP sockets
int yes = 1;
if (setsockopt(m_socket, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<char *>(&yes), sizeof(yes)) == -1) {
std::cerr << "Failed to enable broadcast on UDP socket" << std::endl;
}
}
}
}
////////////////////////////////////////////////////////////
void Socket::close()
{
// Close the socket
if (m_socket != priv::SocketImpl::invalidSocket()) {
priv::SocketImpl::close(m_socket);
m_socket = priv::SocketImpl::invalidSocket();
}
}
} // namespace sf

211
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Socket.hpp

@ -1,211 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKET_HPP
#define SFML_SOCKET_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/SocketHandle.hpp>
#include <vector>
namespace sf {
class SocketSelector;
////////////////////////////////////////////////////////////
/// \brief Base class for all the socket types
///
////////////////////////////////////////////////////////////
class Socket {
public:
////////////////////////////////////////////////////////////
/// \brief Status codes that may be returned by socket functions
///
////////////////////////////////////////////////////////////
enum Status {
Done, ///< The socket has sent / received the data
NotReady, ///< The socket is not ready to send / receive data yet
Partial, ///< The socket sent a part of the data
Disconnected, ///< The TCP socket has been disconnected
Error ///< An unexpected error happened
};
////////////////////////////////////////////////////////////
/// \brief Some special values used by sockets
///
////////////////////////////////////////////////////////////
enum {
AnyPort = 0 ///< Special value that tells the system to pick any available port
};
public:
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
virtual ~Socket();
// NonCopyable
Socket(const Socket &) = delete;
Socket(Socket &&) = delete;
Socket &operator=(const Socket &) = delete;
Socket &operator=(Socket &&) = delete;
////////////////////////////////////////////////////////////
/// \brief Set the blocking state of the socket
///
/// In blocking mode, calls will not return until they have
/// completed their task. For example, a call to Receive in
/// blocking mode won't return until some data was actually
/// received.
/// In non-blocking mode, calls will always return immediately,
/// using the return code to signal whether there was data
/// available or not.
/// By default, all sockets are blocking.
///
/// \param blocking True to set the socket as blocking, false for non-blocking
///
/// \see isBlocking
///
////////////////////////////////////////////////////////////
void setBlocking(bool blocking);
////////////////////////////////////////////////////////////
/// \brief Tell whether the socket is in blocking or non-blocking mode
///
/// \return True if the socket is blocking, false otherwise
///
/// \see setBlocking
///
////////////////////////////////////////////////////////////
bool isBlocking() const;
protected:
////////////////////////////////////////////////////////////
/// \brief Types of protocols that the socket can use
///
////////////////////////////////////////////////////////////
enum Type {
Tcp, ///< TCP protocol
Udp ///< UDP protocol
};
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// This constructor can only be accessed by derived classes.
///
/// \param type Type of the socket (TCP or UDP)
///
////////////////////////////////////////////////////////////
Socket(Type type);
////////////////////////////////////////////////////////////
/// \brief Return the internal handle of the socket
///
/// The returned handle may be invalid if the socket
/// was not created yet (or already destroyed).
/// This function can only be accessed by derived classes.
///
/// \return The internal (OS-specific) handle of the socket
///
////////////////////////////////////////////////////////////
SocketHandle getHandle() const;
////////////////////////////////////////////////////////////
/// \brief Create the internal representation of the socket
///
/// This function can only be accessed by derived classes.
///
////////////////////////////////////////////////////////////
void create();
////////////////////////////////////////////////////////////
/// \brief Create the internal representation of the socket
/// from a socket handle
///
/// This function can only be accessed by derived classes.
///
/// \param handle OS-specific handle of the socket to wrap
///
////////////////////////////////////////////////////////////
void create(SocketHandle handle);
////////////////////////////////////////////////////////////
/// \brief Close the socket gracefully
///
/// This function can only be accessed by derived classes.
///
////////////////////////////////////////////////////////////
void close();
private:
friend class SocketSelector;
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Type m_type; ///< Type of the socket (TCP or UDP)
SocketHandle m_socket; ///< Socket descriptor
bool m_isBlocking; ///< Current blocking mode of the socket
};
} // namespace sf
#endif // SFML_SOCKET_HPP
////////////////////////////////////////////////////////////
/// \class sf::Socket
/// \ingroup network
///
/// This class mainly defines internal stuff to be used by
/// derived classes.
///
/// The only public features that it defines, and which
/// is therefore common to all the socket classes, is the
/// blocking state. All sockets can be set as blocking or
/// non-blocking.
///
/// In blocking mode, socket functions will hang until
/// the operation completes, which means that the entire
/// program (well, in fact the current thread if you use
/// multiple ones) will be stuck waiting for your socket
/// operation to complete.
///
/// In non-blocking mode, all the socket functions will
/// return immediately. If the socket is not ready to complete
/// the requested operation, the function simply returns
/// the proper status code (Socket::NotReady).
///
/// The default mode, which is blocking, is the one that is
/// generally used, in combination with threads or selectors.
/// The non-blocking mode is rather used in real-time
/// applications that run an endless loop that can poll
/// the socket often enough, and cannot afford blocking
/// this loop.
///
/// \see sf::TcpListener, sf::TcpSocket, sf::UdpSocket
///
////////////////////////////////////////////////////////////

54
Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketHandle.hpp

@ -1,54 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKETHANDLE_HPP
#define SFML_SOCKETHANDLE_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#if defined(SFML_SYSTEM_WINDOWS)
#include <basetsd.h>
#endif
namespace sf {
////////////////////////////////////////////////////////////
// Define the low-level socket handle type, specific to
// each platform
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
typedef UINT_PTR SocketHandle;
#else
typedef int SocketHandle;
#endif
} // namespace sf
#endif // SFML_SOCKETHANDLE_HPP

38
Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketImpl.hpp

@ -1,38 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#if defined(SFML_SYSTEM_WINDOWS)
#include <SFML/Network/Win32/SocketImpl.hpp>
#else
#include <SFML/Network/Unix/SocketImpl.hpp>
#endif

188
Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketSelector.cpp

@ -1,188 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Socket.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <SFML/Network/SocketSelector.hpp>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <utility>
#ifdef _MSC_VER
#pragma warning(disable : 4127) // "conditional expression is constant" generated by the FD_SET macro
#endif
namespace sf {
////////////////////////////////////////////////////////////
struct SocketSelector::SocketSelectorImpl {
fd_set allSockets; ///< Set containing all the sockets handles
fd_set socketsReady; ///< Set containing handles of the sockets that are ready
int maxSocket; ///< Maximum socket handle
int socketCount; ///< Number of socket handles
};
////////////////////////////////////////////////////////////
SocketSelector::SocketSelector()
: m_impl(new SocketSelectorImpl)
{
clear();
}
////////////////////////////////////////////////////////////
SocketSelector::SocketSelector(const SocketSelector &copy)
: m_impl(new SocketSelectorImpl(*copy.m_impl))
{
}
////////////////////////////////////////////////////////////
SocketSelector::~SocketSelector()
{
delete m_impl;
}
////////////////////////////////////////////////////////////
void SocketSelector::add(Socket &socket)
{
SocketHandle handle = socket.getHandle();
if (handle != priv::SocketImpl::invalidSocket()) {
#if defined(SFML_SYSTEM_WINDOWS)
if (m_impl->socketCount >= FD_SETSIZE) {
std::cerr << "The socket can't be added to the selector because the "
<< "selector is full. This is a limitation of your operating "
<< "system's FD_SETSIZE setting.";
return;
}
if (FD_ISSET(handle, &m_impl->allSockets))
return;
m_impl->socketCount++;
#else
if (handle >= FD_SETSIZE) {
std::cerr << "The socket can't be added to the selector because its "
<< "ID is too high. This is a limitation of your operating "
<< "system's FD_SETSIZE setting.";
return;
}
// SocketHandle is an int in POSIX
m_impl->maxSocket = std::max(m_impl->maxSocket, handle);
#endif
FD_SET(handle, &m_impl->allSockets);
}
}
////////////////////////////////////////////////////////////
void SocketSelector::remove(Socket &socket)
{
SocketHandle handle = socket.getHandle();
if (handle != priv::SocketImpl::invalidSocket()) {
#if defined(SFML_SYSTEM_WINDOWS)
if (!FD_ISSET(handle, &m_impl->allSockets))
return;
m_impl->socketCount--;
#else
if (handle >= FD_SETSIZE)
return;
#endif
FD_CLR(handle, &m_impl->allSockets);
FD_CLR(handle, &m_impl->socketsReady);
}
}
////////////////////////////////////////////////////////////
void SocketSelector::clear()
{
FD_ZERO(&m_impl->allSockets);
FD_ZERO(&m_impl->socketsReady);
m_impl->maxSocket = 0;
m_impl->socketCount = 0;
}
////////////////////////////////////////////////////////////
bool SocketSelector::wait(std::chrono::microseconds timeout)
{
// Setup the timeout
timeval time;
time.tv_sec = static_cast<long>(std::chrono::duration_cast<std::chrono::seconds>(timeout).count());
time.tv_usec = static_cast<long>(std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
// Initialize the set that will contain the sockets that are ready
m_impl->socketsReady = m_impl->allSockets;
// Wait until one of the sockets is ready for reading, or timeout is reached
// The first parameter is ignored on Windows
int count = select(m_impl->maxSocket + 1, &m_impl->socketsReady, NULL, NULL, timeout != std::chrono::microseconds::zero() ? &time : NULL);
return count > 0;
}
////////////////////////////////////////////////////////////
bool SocketSelector::isReady(Socket &socket) const
{
SocketHandle handle = socket.getHandle();
if (handle != priv::SocketImpl::invalidSocket()) {
#if !defined(SFML_SYSTEM_WINDOWS)
if (handle >= FD_SETSIZE)
return false;
#endif
return FD_ISSET(handle, &m_impl->socketsReady) != 0;
}
return false;
}
////////////////////////////////////////////////////////////
SocketSelector &SocketSelector::operator=(const SocketSelector &right)
{
SocketSelector temp(right);
std::swap(m_impl, temp.m_impl);
return *this;
}
} // namespace sf

255
Source/dapi/Backend/DAPIBackendCore/SFML/Network/SocketSelector.hpp

@ -1,255 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKETSELECTOR_HPP
#define SFML_SOCKETSELECTOR_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <chrono>
namespace sf {
class Socket;
////////////////////////////////////////////////////////////
/// \brief Multiplexer that allows to read from multiple sockets
///
////////////////////////////////////////////////////////////
class SocketSelector {
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
SocketSelector();
////////////////////////////////////////////////////////////
/// \brief Copy constructor
///
/// \param copy Instance to copy
///
////////////////////////////////////////////////////////////
SocketSelector(const SocketSelector &copy);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~SocketSelector();
////////////////////////////////////////////////////////////
/// \brief Add a new socket to the selector
///
/// This function keeps a weak reference to the socket,
/// so you have to make sure that the socket is not destroyed
/// while it is stored in the selector.
/// This function does nothing if the socket is not valid.
///
/// \param socket Reference to the socket to add
///
/// \see remove, clear
///
////////////////////////////////////////////////////////////
void add(Socket &socket);
////////////////////////////////////////////////////////////
/// \brief Remove a socket from the selector
///
/// This function doesn't destroy the socket, it simply
/// removes the reference that the selector has to it.
///
/// \param socket Reference to the socket to remove
///
/// \see add, clear
///
////////////////////////////////////////////////////////////
void remove(Socket &socket);
////////////////////////////////////////////////////////////
/// \brief Remove all the sockets stored in the selector
///
/// This function doesn't destroy any instance, it simply
/// removes all the references that the selector has to
/// external sockets.
///
/// \see add, remove
///
////////////////////////////////////////////////////////////
void clear();
////////////////////////////////////////////////////////////
/// \brief Wait until one or more sockets are ready to receive
///
/// This function returns as soon as at least one socket has
/// some data available to be received. To know which sockets are
/// ready, use the isReady function.
/// If you use a timeout and no socket is ready before the timeout
/// is over, the function returns false.
///
/// \param timeout Maximum time to wait, (use Time::Zero for infinity)
///
/// \return True if there are sockets ready, false otherwise
///
/// \see isReady
///
////////////////////////////////////////////////////////////
bool wait(std::chrono::microseconds timeout = std::chrono::microseconds::zero());
////////////////////////////////////////////////////////////
/// \brief Test a socket to know if it is ready to receive data
///
/// This function must be used after a call to Wait, to know
/// which sockets are ready to receive data. If a socket is
/// ready, a call to receive will never block because we know
/// that there is data available to read.
/// Note that if this function returns true for a TcpListener,
/// this means that it is ready to accept a new connection.
///
/// \param socket Socket to test
///
/// \return True if the socket is ready to read, false otherwise
///
/// \see isReady
///
////////////////////////////////////////////////////////////
bool isReady(Socket &socket) const;
////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
/// \param right Instance to assign
///
/// \return Reference to self
///
////////////////////////////////////////////////////////////
SocketSelector &operator=(const SocketSelector &right);
private:
struct SocketSelectorImpl;
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
SocketSelectorImpl *m_impl; ///< Opaque pointer to the implementation (which requires OS-specific types)
};
} // namespace sf
#endif // SFML_SOCKETSELECTOR_HPP
////////////////////////////////////////////////////////////
/// \class sf::SocketSelector
/// \ingroup network
///
/// Socket selectors provide a way to wait until some data is
/// available on a set of sockets, instead of just one. This
/// is convenient when you have multiple sockets that may
/// possibly receive data, but you don't know which one will
/// be ready first. In particular, it avoids to use a thread
/// for each socket; with selectors, a single thread can handle
/// all the sockets.
///
/// All types of sockets can be used in a selector:
/// \li sf::TcpListener
/// \li sf::TcpSocket
/// \li sf::UdpSocket
///
/// A selector doesn't store its own copies of the sockets
/// (socket classes are not copyable anyway), it simply keeps
/// a reference to the original sockets that you pass to the
/// "add" function. Therefore, you can't use the selector as a
/// socket container, you must store them outside and make sure
/// that they are alive as long as they are used in the selector.
///
/// Using a selector is simple:
/// \li populate the selector with all the sockets that you want to observe
/// \li make it wait until there is data available on any of the sockets
/// \li test each socket to find out which ones are ready
///
/// Usage example:
/// \code
/// // Create a socket to listen to new connections
/// sf::TcpListener listener;
/// listener.listen(55001);
///
/// // Create a list to store the future clients
/// std::list<sf::TcpSocket*> clients;
///
/// // Create a selector
/// sf::SocketSelector selector;
///
/// // Add the listener to the selector
/// selector.add(listener);
///
/// // Endless loop that waits for new connections
/// while (running)
/// {
/// // Make the selector wait for data on any socket
/// if (selector.wait())
/// {
/// // Test the listener
/// if (selector.isReady(listener))
/// {
/// // The listener is ready: there is a pending connection
/// sf::TcpSocket* client = new sf::TcpSocket;
/// if (listener.accept(*client) == sf::Socket::Done)
/// {
/// // Add the new client to the clients list
/// clients.push_back(client);
///
/// // Add the new client to the selector so that we will
/// // be notified when he sends something
/// selector.add(*client);
/// }
/// else
/// {
/// // Error, we won't get a new connection, delete the socket
/// delete client;
/// }
/// }
/// else
/// {
/// // The listener socket is not ready, test all other sockets (the clients)
/// for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
/// {
/// sf::TcpSocket& client = **it;
/// if (selector.isReady(client))
/// {
/// // The client has sent some data, we can receive it
/// sf::Packet packet;
/// if (client.receive(packet) == sf::Socket::Done)
/// {
/// ...
/// }
/// }
/// }
/// }
/// }
/// }
/// \endcode
///
/// \see sf::Socket
///
////////////////////////////////////////////////////////////

119
Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpListener.cpp

@ -1,119 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/SocketImpl.hpp>
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <iostream>
namespace sf {
////////////////////////////////////////////////////////////
TcpListener::TcpListener()
: Socket(Tcp)
{
}
////////////////////////////////////////////////////////////
unsigned short TcpListener::getLocalPort() const
{
if (getHandle() != priv::SocketImpl::invalidSocket()) {
// Retrieve informations about the local end of the socket
sockaddr_in address;
priv::SocketImpl::AddrLength size = sizeof(address);
if (getsockname(getHandle(), reinterpret_cast<sockaddr *>(&address), &size) != -1) {
return ntohs(address.sin_port);
}
}
// We failed to retrieve the port
return 0;
}
////////////////////////////////////////////////////////////
Socket::Status TcpListener::listen(unsigned short port, const IpAddress &address)
{
// Close the socket if it is already bound
close();
// Create the internal socket if it doesn't exist
create();
// Check if the address is valid
if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
return Error;
// Bind the socket to the specified port
sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
if (bind(getHandle(), reinterpret_cast<sockaddr *>(&addr), sizeof(addr)) == -1) {
// Not likely to happen, but...
std::cerr << "Failed to bind listener socket to port " << port << std::endl;
return Error;
}
// Listen to the bound port
if (::listen(getHandle(), SOMAXCONN) == -1) {
// Oops, socket is deaf
std::cerr << "Failed to listen to port " << port << std::endl;
return Error;
}
return Done;
}
////////////////////////////////////////////////////////////
void TcpListener::close()
{
// Simply close the socket
Socket::close();
}
////////////////////////////////////////////////////////////
Socket::Status TcpListener::accept(TcpSocket &socket)
{
// Make sure that we're listening
if (getHandle() == priv::SocketImpl::invalidSocket()) {
std::cerr << "Failed to accept a new connection, the socket is not listening" << std::endl;
return Error;
}
// Accept a new connection
sockaddr_in address;
priv::SocketImpl::AddrLength length = sizeof(address);
SocketHandle remote = ::accept(getHandle(), reinterpret_cast<sockaddr *>(&address), &length);
// Check for errors
if (remote == priv::SocketImpl::invalidSocket())
return priv::SocketImpl::getErrorStatus();
// Initialize the new connected socket
socket.close();
socket.create(remote);
return Done;
}
} // namespace sf

158
Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpListener.hpp

@ -1,158 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_TCPLISTENER_HPP
#define SFML_TCPLISTENER_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Socket.hpp>
namespace sf {
class TcpSocket;
////////////////////////////////////////////////////////////
/// \brief Socket that listens to new TCP connections
///
////////////////////////////////////////////////////////////
class TcpListener : public Socket {
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
TcpListener();
////////////////////////////////////////////////////////////
/// \brief Get the port to which the socket is bound locally
///
/// If the socket is not listening to a port, this function
/// returns 0.
///
/// \return Port to which the socket is bound
///
/// \see listen
///
////////////////////////////////////////////////////////////
unsigned short getLocalPort() const;
////////////////////////////////////////////////////////////
/// \brief Start listening for incoming connection attempts
///
/// This function makes the socket start listening on the
/// specified port, waiting for incoming connection attempts.
///
/// If the socket is already listening on a port when this
/// function is called, it will stop listening on the old
/// port before starting to listen on the new port.
///
/// \param port Port to listen on for incoming connection attempts
/// \param address Address of the interface to listen on
///
/// \return Status code
///
/// \see accept, close
///
////////////////////////////////////////////////////////////
Status listen(unsigned short port, const IpAddress &address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Stop listening and close the socket
///
/// This function gracefully stops the listener. If the
/// socket is not listening, this function has no effect.
///
/// \see listen
///
////////////////////////////////////////////////////////////
void close();
////////////////////////////////////////////////////////////
/// \brief Accept a new connection
///
/// If the socket is in blocking mode, this function will
/// not return until a connection is actually received.
///
/// \param socket Socket that will hold the new connection
///
/// \return Status code
///
/// \see listen
///
////////////////////////////////////////////////////////////
Status accept(TcpSocket &socket);
};
} // namespace sf
#endif // SFML_TCPLISTENER_HPP
////////////////////////////////////////////////////////////
/// \class sf::TcpListener
/// \ingroup network
///
/// A listener socket is a special type of socket that listens to
/// a given port and waits for connections on that port.
/// This is all it can do.
///
/// When a new connection is received, you must call accept and
/// the listener returns a new instance of sf::TcpSocket that
/// is properly initialized and can be used to communicate with
/// the new client.
///
/// Listener sockets are specific to the TCP protocol,
/// UDP sockets are connectionless and can therefore communicate
/// directly. As a consequence, a listener socket will always
/// return the new connections as sf::TcpSocket instances.
///
/// A listener is automatically closed on destruction, like all
/// other types of socket. However if you want to stop listening
/// before the socket is destroyed, you can call its close()
/// function.
///
/// Usage example:
/// \code
/// // Create a listener socket and make it wait for new
/// // connections on port 55001
/// sf::TcpListener listener;
/// listener.listen(55001);
///
/// // Endless loop that waits for new connections
/// while (running)
/// {
/// sf::TcpSocket client;
/// if (listener.accept(client) == sf::Socket::Done)
/// {
/// // A new client just connected!
/// std::cout << "New connection received from " << client.getRemoteAddress() << std::endl;
/// doSomethingWith(client);
/// }
/// }
/// \endcode
///
/// \see sf::TcpSocket, sf::Socket
///
////////////////////////////////////////////////////////////

365
Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpSocket.cpp

@ -1,365 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <algorithm>
#include <cstring>
#include <iostream>
#ifdef _MSC_VER
#pragma warning(disable : 4127) // "conditional expression is constant" generated by the FD_SET macro
#endif
namespace {
// Define the low-level send/receive flags, which depend on the OS
#ifdef SFML_SYSTEM_LINUX
const int flags = MSG_NOSIGNAL;
#else
const int flags = 0;
#endif
} // namespace
namespace sf {
////////////////////////////////////////////////////////////
TcpSocket::TcpSocket()
: Socket(Tcp)
{
}
////////////////////////////////////////////////////////////
unsigned short TcpSocket::getLocalPort() const
{
if (getHandle() != priv::SocketImpl::invalidSocket()) {
// Retrieve informations about the local end of the socket
sockaddr_in address;
priv::SocketImpl::AddrLength size = sizeof(address);
if (getsockname(getHandle(), reinterpret_cast<sockaddr *>(&address), &size) != -1) {
return ntohs(address.sin_port);
}
}
// We failed to retrieve the port
return 0;
}
////////////////////////////////////////////////////////////
IpAddress TcpSocket::getRemoteAddress() const
{
if (getHandle() != priv::SocketImpl::invalidSocket()) {
// Retrieve informations about the remote end of the socket
sockaddr_in address;
priv::SocketImpl::AddrLength size = sizeof(address);
if (getpeername(getHandle(), reinterpret_cast<sockaddr *>(&address), &size) != -1) {
return IpAddress(ntohl(address.sin_addr.s_addr));
}
}
// We failed to retrieve the address
return IpAddress::None;
}
////////////////////////////////////////////////////////////
unsigned short TcpSocket::getRemotePort() const
{
if (getHandle() != priv::SocketImpl::invalidSocket()) {
// Retrieve informations about the remote end of the socket
sockaddr_in address;
priv::SocketImpl::AddrLength size = sizeof(address);
if (getpeername(getHandle(), reinterpret_cast<sockaddr *>(&address), &size) != -1) {
return ntohs(address.sin_port);
}
}
// We failed to retrieve the port
return 0;
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::connect(const IpAddress &remoteAddress, unsigned short remotePort, std::chrono::microseconds timeout)
{
// Disconnect the socket if it is already connected
disconnect();
// Create the internal socket if it doesn't exist
create();
// Create the remote address
sockaddr_in address = priv::SocketImpl::createAddress(remoteAddress.toInteger(), remotePort);
if (timeout <= std::chrono::microseconds::zero()) {
// ----- We're not using a timeout: just try to connect -----
// Connect the socket
if (::connect(getHandle(), reinterpret_cast<sockaddr *>(&address), sizeof(address)) == -1)
return priv::SocketImpl::getErrorStatus();
// Connection succeeded
return Done;
} else {
// ----- We're using a timeout: we'll need a few tricks to make it work -----
// Save the previous blocking state
bool blocking = isBlocking();
// Switch to non-blocking to enable our connection timeout
if (blocking)
setBlocking(false);
// Try to connect to the remote address
if (::connect(getHandle(), reinterpret_cast<sockaddr *>(&address), sizeof(address)) >= 0) {
// We got instantly connected! (it may no happen a lot...)
setBlocking(blocking);
return Done;
}
// Get the error status
Status status = priv::SocketImpl::getErrorStatus();
// If we were in non-blocking mode, return immediately
if (!blocking)
return status;
// Otherwise, wait until something happens to our socket (success, timeout or error)
if (status == Socket::NotReady) {
// Setup the selector
fd_set selector;
FD_ZERO(&selector);
FD_SET(getHandle(), &selector);
// Setup the timeout
timeval time;
time.tv_sec = static_cast<long>(std::chrono::duration_cast<std::chrono::seconds>(timeout).count());
time.tv_usec = static_cast<long>(std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
// Wait for something to write on our socket (which means that the connection request has returned)
if (select(static_cast<int>(getHandle() + 1), NULL, &selector, NULL, &time) > 0) {
// At this point the connection may have been either accepted or refused.
// To know whether it's a success or a failure, we must check the address of the connected peer
if (getRemoteAddress() != IpAddress::None) {
// Connection accepted
status = Done;
} else {
// Connection refused
status = priv::SocketImpl::getErrorStatus();
}
} else {
// Failed to connect before timeout is over
status = priv::SocketImpl::getErrorStatus();
}
}
// Switch back to blocking mode
setBlocking(true);
return status;
}
}
////////////////////////////////////////////////////////////
void TcpSocket::disconnect()
{
// Close the socket
close();
// Reset the pending packet data
m_pendingPacket = PendingPacket();
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::send(const void *data, std::size_t size)
{
if (!isBlocking())
std::cerr << "Warning: Partial sends might not be handled properly." << std::endl;
std::size_t sent;
return send(data, size, sent);
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::send(const void *data, std::size_t size, std::size_t &sent)
{
// Check the parameters
if (!data || (size == 0)) {
std::cerr << "Cannot send data over the network (no data to send)" << std::endl;
return Error;
}
// Loop until every byte has been sent
int result = 0;
for (sent = 0; sent < size; sent += result) {
// Send a chunk of data
result = ::send(getHandle(), static_cast<const char *>(data) + sent, static_cast<int>(size - sent), flags);
// Check for errors
if (result < 0) {
Status status = priv::SocketImpl::getErrorStatus();
if ((status == NotReady) && sent)
return Partial;
return status;
}
}
return Done;
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::receive(void *data, std::size_t size, std::size_t &received)
{
// First clear the variables to fill
received = 0;
// Check the destination buffer
if (!data) {
std::cerr << "Cannot receive data from the network (the destination buffer is invalid)" << std::endl;
return Error;
}
// Receive a chunk of bytes
int sizeReceived = recv(getHandle(), static_cast<char *>(data), static_cast<int>(size), flags);
// Check the number of bytes received
if (sizeReceived > 0) {
received = static_cast<std::size_t>(sizeReceived);
return Done;
} else if (sizeReceived == 0) {
return Socket::Disconnected;
} else {
return priv::SocketImpl::getErrorStatus();
}
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::send(Packet &packet)
{
// TCP is a stream protocol, it doesn't preserve messages boundaries.
// This means that we have to send the packet size first, so that the
// receiver knows the actual end of the packet in the data stream.
// We allocate an extra memory block so that the size can be sent
// together with the data in a single call. This may seem inefficient,
// but it is actually required to avoid partial send, which could cause
// data corruption on the receiving end.
// Get the data to send from the packet
std::size_t size = 0;
const void *data = packet.onSend(size);
// First convert the packet size to network byte order
Uint32 packetSize = htonl(static_cast<Uint32>(size));
// Allocate memory for the data block to send
std::vector<char> blockToSend(sizeof(packetSize) + size);
// Copy the packet size and data into the block to send
std::memcpy(&blockToSend[0], &packetSize, sizeof(packetSize));
if (size > 0)
std::memcpy(&blockToSend[0] + sizeof(packetSize), data, size);
// Send the data block
std::size_t sent;
Status status = send(&blockToSend[0] + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent);
// In the case of a partial send, record the location to resume from
if (status == Partial) {
packet.m_sendPos += sent;
} else if (status == Done) {
packet.m_sendPos = 0;
}
return status;
}
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::receive(Packet &packet)
{
// First clear the variables to fill
packet.clear();
// We start by getting the size of the incoming packet
Uint32 packetSize = 0;
std::size_t received = 0;
if (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size)) {
// Loop until we've received the entire size of the packet
// (even a 4 byte variable may be received in more than one call)
while (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size)) {
char *data = reinterpret_cast<char *>(&m_pendingPacket.Size) + m_pendingPacket.SizeReceived;
Status status = receive(data, sizeof(m_pendingPacket.Size) - m_pendingPacket.SizeReceived, received);
m_pendingPacket.SizeReceived += received;
if (status != Done)
return status;
}
// The packet size has been fully received
packetSize = ntohl(m_pendingPacket.Size);
} else {
// The packet size has already been received in a previous call
packetSize = ntohl(m_pendingPacket.Size);
}
// Loop until we receive all the packet data
char buffer[1024];
while (m_pendingPacket.Data.size() < packetSize) {
// Receive a chunk of data
std::size_t sizeToGet = std::min(static_cast<std::size_t>(packetSize - m_pendingPacket.Data.size()), sizeof(buffer));
Status status = receive(buffer, sizeToGet, received);
if (status != Done)
return status;
// Append it into the packet
if (received > 0) {
m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received);
char *begin = &m_pendingPacket.Data[0] + m_pendingPacket.Data.size() - received;
std::memcpy(begin, buffer, received);
}
}
// We have received all the packet data: we can copy it to the user packet
if (!m_pendingPacket.Data.empty())
packet.onReceive(&m_pendingPacket.Data[0], m_pendingPacket.Data.size());
// Clear the pending packet data
m_pendingPacket = PendingPacket();
return Done;
}
////////////////////////////////////////////////////////////
TcpSocket::PendingPacket::PendingPacket()
: Size(0)
, SizeReceived(0)
, Data()
{
}
} // namespace sf

307
Source/dapi/Backend/DAPIBackendCore/SFML/Network/TcpSocket.hpp

@ -1,307 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_TCPSOCKET_HPP
#define SFML_TCPSOCKET_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Socket.hpp>
#include <chrono>
namespace sf {
class TcpListener;
class IpAddress;
class Packet;
////////////////////////////////////////////////////////////
/// \brief Specialized socket using the TCP protocol
///
////////////////////////////////////////////////////////////
class TcpSocket : public Socket {
public:
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
TcpSocket();
////////////////////////////////////////////////////////////
/// \brief Get the port to which the socket is bound locally
///
/// If the socket is not connected, this function returns 0.
///
/// \return Port to which the socket is bound
///
/// \see connect, getRemotePort
///
////////////////////////////////////////////////////////////
unsigned short getLocalPort() const;
////////////////////////////////////////////////////////////
/// \brief Get the address of the connected peer
///
/// It the socket is not connected, this function returns
/// sf::IpAddress::None.
///
/// \return Address of the remote peer
///
/// \see getRemotePort
///
////////////////////////////////////////////////////////////
IpAddress getRemoteAddress() const;
////////////////////////////////////////////////////////////
/// \brief Get the port of the connected peer to which
/// the socket is connected
///
/// If the socket is not connected, this function returns 0.
///
/// \return Remote port to which the socket is connected
///
/// \see getRemoteAddress
///
////////////////////////////////////////////////////////////
unsigned short getRemotePort() const;
////////////////////////////////////////////////////////////
/// \brief Connect the socket to a remote peer
///
/// In blocking mode, this function may take a while, especially
/// if the remote peer is not reachable. The last parameter allows
/// you to stop trying to connect after a given timeout.
/// If the socket is already connected, the connection is
/// forcibly disconnected before attempting to connect again.
///
/// \param remoteAddress Address of the remote peer
/// \param remotePort Port of the remote peer
/// \param timeout Optional maximum time to wait
///
/// \return Status code
///
/// \see disconnect
///
////////////////////////////////////////////////////////////
Status connect(const IpAddress &remoteAddress, unsigned short remotePort, std::chrono::microseconds timeout = std::chrono::microseconds::zero());
////////////////////////////////////////////////////////////
/// \brief Disconnect the socket from its remote peer
///
/// This function gracefully closes the connection. If the
/// socket is not connected, this function has no effect.
///
/// \see connect
///
////////////////////////////////////////////////////////////
void disconnect();
////////////////////////////////////////////////////////////
/// \brief Send raw data to the remote peer
///
/// To be able to handle partial sends over non-blocking
/// sockets, use the send(const void*, std::size_t, std::size_t&)
/// overload instead.
/// This function will fail if the socket is not connected.
///
/// \param data Pointer to the sequence of bytes to send
/// \param size Number of bytes to send
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(const void *data, std::size_t size);
////////////////////////////////////////////////////////////
/// \brief Send raw data to the remote peer
///
/// This function will fail if the socket is not connected.
///
/// \param data Pointer to the sequence of bytes to send
/// \param size Number of bytes to send
/// \param sent The number of bytes sent will be written here
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(const void *data, std::size_t size, std::size_t &sent);
////////////////////////////////////////////////////////////
/// \brief Receive raw data from the remote peer
///
/// In blocking mode, this function will wait until some
/// bytes are actually received.
/// This function will fail if the socket is not connected.
///
/// \param data Pointer to the array to fill with the received bytes
/// \param size Maximum number of bytes that can be received
/// \param received This variable is filled with the actual number of bytes received
///
/// \return Status code
///
/// \see send
///
////////////////////////////////////////////////////////////
Status receive(void *data, std::size_t size, std::size_t &received);
////////////////////////////////////////////////////////////
/// \brief Send a formatted packet of data to the remote peer
///
/// In non-blocking mode, if this function returns sf::Socket::Partial,
/// you \em must retry sending the same unmodified packet before sending
/// anything else in order to guarantee the packet arrives at the remote
/// peer uncorrupted.
/// This function will fail if the socket is not connected.
///
/// \param packet Packet to send
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(Packet &packet);
////////////////////////////////////////////////////////////
/// \brief Receive a formatted packet of data from the remote peer
///
/// In blocking mode, this function will wait until the whole packet
/// has been received.
/// This function will fail if the socket is not connected.
///
/// \param packet Packet to fill with the received data
///
/// \return Status code
///
/// \see send
///
////////////////////////////////////////////////////////////
Status receive(Packet &packet);
private:
friend class TcpListener;
////////////////////////////////////////////////////////////
/// \brief Structure holding the data of a pending packet
///
////////////////////////////////////////////////////////////
struct PendingPacket {
PendingPacket();
Uint32 Size; ///< Data of packet size
std::size_t SizeReceived; ///< Number of size bytes received so far
std::vector<char> Data; ///< Data of the packet
};
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
PendingPacket m_pendingPacket; ///< Temporary data of the packet currently being received
};
} // namespace sf
#endif // SFML_TCPSOCKET_HPP
////////////////////////////////////////////////////////////
/// \class sf::TcpSocket
/// \ingroup network
///
/// TCP is a connected protocol, which means that a TCP
/// socket can only communicate with the host it is connected
/// to. It can't send or receive anything if it is not connected.
///
/// The TCP protocol is reliable but adds a slight overhead.
/// It ensures that your data will always be received in order
/// and without errors (no data corrupted, lost or duplicated).
///
/// When a socket is connected to a remote host, you can
/// retrieve informations about this host with the
/// getRemoteAddress and getRemotePort functions. You can
/// also get the local port to which the socket is bound
/// (which is automatically chosen when the socket is connected),
/// with the getLocalPort function.
///
/// Sending and receiving data can use either the low-level
/// or the high-level functions. The low-level functions
/// process a raw sequence of bytes, and cannot ensure that
/// one call to Send will exactly match one call to Receive
/// at the other end of the socket.
///
/// The high-level interface uses packets (see sf::Packet),
/// which are easier to use and provide more safety regarding
/// the data that is exchanged. You can look at the sf::Packet
/// class to get more details about how they work.
///
/// The socket is automatically disconnected when it is destroyed,
/// but if you want to explicitly close the connection while
/// the socket instance is still alive, you can call disconnect.
///
/// Usage example:
/// \code
/// // ----- The client -----
///
/// // Create a socket and connect it to 192.168.1.50 on port 55001
/// sf::TcpSocket socket;
/// socket.connect("192.168.1.50", 55001);
///
/// // Send a message to the connected host
/// std::string message = "Hi, I am a client";
/// socket.send(message.c_str(), message.size() + 1);
///
/// // Receive an answer from the server
/// char buffer[1024];
/// std::size_t received = 0;
/// socket.receive(buffer, sizeof(buffer), received);
/// std::cout << "The server said: " << buffer << std::endl;
///
/// // ----- The server -----
///
/// // Create a listener to wait for incoming connections on port 55001
/// sf::TcpListener listener;
/// listener.listen(55001);
///
/// // Wait for a connection
/// sf::TcpSocket socket;
/// listener.accept(socket);
/// std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl;
///
/// // Receive a message from the client
/// char buffer[1024];
/// std::size_t received = 0;
/// socket.receive(buffer, sizeof(buffer), received);
/// std::cout << "The client said: " << buffer << std::endl;
///
/// // Send an answer
/// std::string message = "Welcome, client";
/// socket.send(message.c_str(), message.size() + 1);
/// \endcode
///
/// \see sf::Socket, sf::UdpSocket, sf::Packet
///
////////////////////////////////////////////////////////////

184
Source/dapi/Backend/DAPIBackendCore/SFML/Network/UdpSocket.cpp

@ -1,184 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <SFML/Network/UdpSocket.hpp>
#include <algorithm>
#include <iostream>
namespace sf {
////////////////////////////////////////////////////////////
UdpSocket::UdpSocket()
: Socket(Udp)
, m_buffer(MaxDatagramSize)
{
}
////////////////////////////////////////////////////////////
unsigned short UdpSocket::getLocalPort() const
{
if (getHandle() != priv::SocketImpl::invalidSocket()) {
// Retrieve informations about the local end of the socket
sockaddr_in address;
priv::SocketImpl::AddrLength size = sizeof(address);
if (getsockname(getHandle(), reinterpret_cast<sockaddr *>(&address), &size) != -1) {
return ntohs(address.sin_port);
}
}
// We failed to retrieve the port
return 0;
}
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::bind(unsigned short port, const IpAddress &address)
{
// Close the socket if it is already bound
close();
// Create the internal socket if it doesn't exist
create();
// Check if the address is valid
if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
return Error;
// Bind the socket
sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
if (::bind(getHandle(), reinterpret_cast<sockaddr *>(&addr), sizeof(addr)) == -1) {
std::cerr << "Failed to bind socket to port " << port << std::endl;
return Error;
}
return Done;
}
////////////////////////////////////////////////////////////
void UdpSocket::unbind()
{
// Simply close the socket
close();
}
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::send(const void *data, std::size_t size, const IpAddress &remoteAddress, unsigned short remotePort)
{
// Create the internal socket if it doesn't exist
create();
// Make sure that all the data will fit in one datagram
if (size > MaxDatagramSize) {
std::cerr << "Cannot send data over the network "
<< "(the number of bytes to send is greater than sf::UdpSocket::MaxDatagramSize)" << std::endl;
return Error;
}
// Build the target address
sockaddr_in address = priv::SocketImpl::createAddress(remoteAddress.toInteger(), remotePort);
// Send the data (unlike TCP, all the data is always sent in one call)
int sent = sendto(getHandle(), static_cast<const char *>(data), static_cast<int>(size), 0, reinterpret_cast<sockaddr *>(&address), sizeof(address));
// Check for errors
if (sent < 0)
return priv::SocketImpl::getErrorStatus();
return Done;
}
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::receive(void *data, std::size_t size, std::size_t &received, IpAddress &remoteAddress, unsigned short &remotePort)
{
// First clear the variables to fill
received = 0;
remoteAddress = IpAddress();
remotePort = 0;
// Check the destination buffer
if (!data) {
std::cerr << "Cannot receive data from the network (the destination buffer is invalid)" << std::endl;
return Error;
}
// Data that will be filled with the other computer's address
sockaddr_in address = priv::SocketImpl::createAddress(INADDR_ANY, 0);
// Receive a chunk of bytes
priv::SocketImpl::AddrLength addressSize = sizeof(address);
int sizeReceived = recvfrom(getHandle(), static_cast<char *>(data), static_cast<int>(size), 0, reinterpret_cast<sockaddr *>(&address), &addressSize);
// Check for errors
if (sizeReceived < 0)
return priv::SocketImpl::getErrorStatus();
// Fill the sender informations
received = static_cast<std::size_t>(sizeReceived);
remoteAddress = IpAddress(ntohl(address.sin_addr.s_addr));
remotePort = ntohs(address.sin_port);
return Done;
}
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::send(Packet &packet, const IpAddress &remoteAddress, unsigned short remotePort)
{
// UDP is a datagram-oriented protocol (as opposed to TCP which is a stream protocol).
// Sending one datagram is almost safe: it may be lost but if it's received, then its data
// is guaranteed to be ok. However, splitting a packet into multiple datagrams would be highly
// unreliable, since datagrams may be reordered, dropped or mixed between different sources.
// That's why SFML imposes a limit on packet size so that they can be sent in a single datagram.
// This also removes the overhead associated to packets -- there's no size to send in addition
// to the packet's data.
// Get the data to send from the packet
std::size_t size = 0;
const void *data = packet.onSend(size);
// Send it
return send(data, size, remoteAddress, remotePort);
}
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::receive(Packet &packet, IpAddress &remoteAddress, unsigned short &remotePort)
{
// See the detailed comment in send(Packet) above.
// Receive the datagram
std::size_t received = 0;
Status status = receive(&m_buffer[0], m_buffer.size(), received, remoteAddress, remotePort);
// If we received valid data, we can copy it to the user packet
packet.clear();
if ((status == Done) && (received > 0))
packet.onReceive(&m_buffer[0], received);
return status;
}
} // namespace sf

282
Source/dapi/Backend/DAPIBackendCore/SFML/Network/UdpSocket.hpp

@ -1,282 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_UDPSOCKET_HPP
#define SFML_UDPSOCKET_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Socket.hpp>
#include <vector>
namespace sf {
class Packet;
////////////////////////////////////////////////////////////
/// \brief Specialized socket using the UDP protocol
///
////////////////////////////////////////////////////////////
class UdpSocket : public Socket {
public:
////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////
enum {
MaxDatagramSize = 65507 ///< The maximum number of bytes that can be sent in a single UDP datagram
};
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
UdpSocket();
////////////////////////////////////////////////////////////
/// \brief Get the port to which the socket is bound locally
///
/// If the socket is not bound to a port, this function
/// returns 0.
///
/// \return Port to which the socket is bound
///
/// \see bind
///
////////////////////////////////////////////////////////////
unsigned short getLocalPort() const;
////////////////////////////////////////////////////////////
/// \brief Bind the socket to a specific port
///
/// Binding the socket to a port is necessary for being
/// able to receive data on that port.
/// You can use the special value Socket::AnyPort to tell the
/// system to automatically pick an available port, and then
/// call getLocalPort to retrieve the chosen port.
///
/// Since the socket can only be bound to a single port at
/// any given moment, if it is already bound when this
/// function is called, it will be unbound from the previous
/// port before being bound to the new one.
///
/// \param port Port to bind the socket to
/// \param address Address of the interface to bind to
///
/// \return Status code
///
/// \see unbind, getLocalPort
///
////////////////////////////////////////////////////////////
Status bind(unsigned short port, const IpAddress &address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Unbind the socket from the local port to which it is bound
///
/// The port that the socket was previously bound to is immediately
/// made available to the operating system after this function is called.
/// This means that a subsequent call to bind() will be able to re-bind
/// the port if no other process has done so in the mean time.
/// If the socket is not bound to a port, this function has no effect.
///
/// \see bind
///
////////////////////////////////////////////////////////////
void unbind();
////////////////////////////////////////////////////////////
/// \brief Send raw data to a remote peer
///
/// Make sure that \a size is not greater than
/// UdpSocket::MaxDatagramSize, otherwise this function will
/// fail and no data will be sent.
///
/// \param data Pointer to the sequence of bytes to send
/// \param size Number of bytes to send
/// \param remoteAddress Address of the receiver
/// \param remotePort Port of the receiver to send the data to
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(const void *data, std::size_t size, const IpAddress &remoteAddress, unsigned short remotePort);
////////////////////////////////////////////////////////////
/// \brief Receive raw data from a remote peer
///
/// In blocking mode, this function will wait until some
/// bytes are actually received.
/// Be careful to use a buffer which is large enough for
/// the data that you intend to receive, if it is too small
/// then an error will be returned and *all* the data will
/// be lost.
///
/// \param data Pointer to the array to fill with the received bytes
/// \param size Maximum number of bytes that can be received
/// \param received This variable is filled with the actual number of bytes received
/// \param remoteAddress Address of the peer that sent the data
/// \param remotePort Port of the peer that sent the data
///
/// \return Status code
///
/// \see send
///
////////////////////////////////////////////////////////////
Status receive(void *data, std::size_t size, std::size_t &received, IpAddress &remoteAddress, unsigned short &remotePort);
////////////////////////////////////////////////////////////
/// \brief Send a formatted packet of data to a remote peer
///
/// Make sure that the packet size is not greater than
/// UdpSocket::MaxDatagramSize, otherwise this function will
/// fail and no data will be sent.
///
/// \param packet Packet to send
/// \param remoteAddress Address of the receiver
/// \param remotePort Port of the receiver to send the data to
///
/// \return Status code
///
/// \see receive
///
////////////////////////////////////////////////////////////
Status send(Packet &packet, const IpAddress &remoteAddress, unsigned short remotePort);
////////////////////////////////////////////////////////////
/// \brief Receive a formatted packet of data from a remote peer
///
/// In blocking mode, this function will wait until the whole packet
/// has been received.
///
/// \param packet Packet to fill with the received data
/// \param remoteAddress Address of the peer that sent the data
/// \param remotePort Port of the peer that sent the data
///
/// \return Status code
///
/// \see send
///
////////////////////////////////////////////////////////////
Status receive(Packet &packet, IpAddress &remoteAddress, unsigned short &remotePort);
private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::vector<char> m_buffer; ///< Temporary buffer holding the received data in Receive(Packet)
};
} // namespace sf
#endif // SFML_UDPSOCKET_HPP
////////////////////////////////////////////////////////////
/// \class sf::UdpSocket
/// \ingroup network
///
/// A UDP socket is a connectionless socket. Instead of
/// connecting once to a remote host, like TCP sockets,
/// it can send to and receive from any host at any time.
///
/// It is a datagram protocol: bounded blocks of data (datagrams)
/// are transfered over the network rather than a continuous
/// stream of data (TCP). Therefore, one call to send will always
/// match one call to receive (if the datagram is not lost),
/// with the same data that was sent.
///
/// The UDP protocol is lightweight but unreliable. Unreliable
/// means that datagrams may be duplicated, be lost or
/// arrive reordered. However, if a datagram arrives, its
/// data is guaranteed to be valid.
///
/// UDP is generally used for real-time communication
/// (audio or video streaming, real-time games, etc.) where
/// speed is crucial and lost data doesn't matter much.
///
/// Sending and receiving data can use either the low-level
/// or the high-level functions. The low-level functions
/// process a raw sequence of bytes, whereas the high-level
/// interface uses packets (see sf::Packet), which are easier
/// to use and provide more safety regarding the data that is
/// exchanged. You can look at the sf::Packet class to get
/// more details about how they work.
///
/// It is important to note that UdpSocket is unable to send
/// datagrams bigger than MaxDatagramSize. In this case, it
/// returns an error and doesn't send anything. This applies
/// to both raw data and packets. Indeed, even packets are
/// unable to split and recompose data, due to the unreliability
/// of the protocol (dropped, mixed or duplicated datagrams may
/// lead to a big mess when trying to recompose a packet).
///
/// If the socket is bound to a port, it is automatically
/// unbound from it when the socket is destroyed. However,
/// you can unbind the socket explicitly with the Unbind
/// function if necessary, to stop receiving messages or
/// make the port available for other sockets.
///
/// Usage example:
/// \code
/// // ----- The client -----
///
/// // Create a socket and bind it to the port 55001
/// sf::UdpSocket socket;
/// socket.bind(55001);
///
/// // Send a message to 192.168.1.50 on port 55002
/// std::string message = "Hi, I am " + sf::IpAddress::getLocalAddress().toString();
/// socket.send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
///
/// // Receive an answer (most likely from 192.168.1.50, but could be anyone else)
/// char buffer[1024];
/// std::size_t received = 0;
/// sf::IpAddress sender;
/// unsigned short port;
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
///
/// // ----- The server -----
///
/// // Create a socket and bind it to the port 55002
/// sf::UdpSocket socket;
/// socket.bind(55002);
///
/// // Receive a message from anyone
/// char buffer[1024];
/// std::size_t received = 0;
/// sf::IpAddress sender;
/// unsigned short port;
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
///
/// // Send an answer
/// std::string message = "Welcome " + sender.toString();
/// socket.send(message.c_str(), message.size() + 1, sender, port);
/// \endcode
///
/// \see sf::Socket, sf::TcpSocket, sf::Packet
///
////////////////////////////////////////////////////////////

105
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Unix/SocketImpl.hpp

@ -1,105 +0,0 @@
#ifndef _WIN32
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKETIMPL_HPP
#define SFML_SOCKETIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Socket.hpp>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
namespace sf {
namespace priv {
////////////////////////////////////////////////////////////
/// \brief Helper class implementing all the non-portable
/// socket stuff; this is the Unix version
///
////////////////////////////////////////////////////////////
class SocketImpl {
public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef socklen_t AddrLength;
////////////////////////////////////////////////////////////
/// \brief Create an internal sockaddr_in address
///
/// \param address Target address
/// \param port Target port
///
/// \return sockaddr_in ready to be used by socket functions
///
////////////////////////////////////////////////////////////
static sockaddr_in createAddress(Uint32 address, unsigned short port);
////////////////////////////////////////////////////////////
/// \brief Return the value of the invalid socket
///
/// \return Special value of the invalid socket
///
////////////////////////////////////////////////////////////
static SocketHandle invalidSocket();
////////////////////////////////////////////////////////////
/// \brief Close and destroy a socket
///
/// \param sock Handle of the socket to close
///
////////////////////////////////////////////////////////////
static void close(SocketHandle sock);
////////////////////////////////////////////////////////////
/// \brief Set a socket as blocking or non-blocking
///
/// \param sock Handle of the socket
/// \param block New blocking state of the socket
///
////////////////////////////////////////////////////////////
static void setBlocking(SocketHandle sock, bool block);
////////////////////////////////////////////////////////////
/// Get the last socket error status
///
/// \return Status corresponding to the last socket error
///
////////////////////////////////////////////////////////////
static Socket::Status getErrorStatus();
};
} // namespace priv
} // namespace sf
#endif // SFML_SOCKETIMPL_HPP
#endif

102
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Unix/SocketImplUnix.cpp

@ -1,102 +0,0 @@
#ifndef _WIN32
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Unix/SocketImpl.hpp>
#include <cstring>
#include <errno.h>
#include <fcntl.h>
#include <iostream>
namespace sf {
namespace priv {
////////////////////////////////////////////////////////////
sockaddr_in SocketImpl::createAddress(Uint32 address, unsigned short port)
{
sockaddr_in addr;
std::memset(&addr, 0, sizeof(addr));
addr.sin_addr.s_addr = htonl(address);
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
#if defined(SFML_SYSTEM_MACOS)
addr.sin_len = sizeof(addr);
#endif
return addr;
}
////////////////////////////////////////////////////////////
SocketHandle SocketImpl::invalidSocket()
{
return -1;
}
////////////////////////////////////////////////////////////
void SocketImpl::close(SocketHandle sock)
{
::close(sock);
}
////////////////////////////////////////////////////////////
void SocketImpl::setBlocking(SocketHandle sock, bool block)
{
int status = fcntl(sock, F_GETFL);
if (block) {
if (fcntl(sock, F_SETFL, status & ~O_NONBLOCK) == -1)
std::cerr << "Failed to set file status flags: " << errno << std::endl;
} else {
if (fcntl(sock, F_SETFL, status | O_NONBLOCK) == -1)
std::cerr << "Failed to set file status flags: " << errno << std::endl;
}
}
////////////////////////////////////////////////////////////
Socket::Status SocketImpl::getErrorStatus()
{
// The followings are sometimes equal to EWOULDBLOCK,
// so we have to make a special case for them in order
// to avoid having double values in the switch case
if ((errno == EAGAIN) || (errno == EINPROGRESS))
return Socket::NotReady;
switch (errno) {
case EWOULDBLOCK: return Socket::NotReady;
case ECONNABORTED: return Socket::Disconnected;
case ECONNRESET: return Socket::Disconnected;
case ETIMEDOUT: return Socket::Disconnected;
case ENETRESET: return Socket::Disconnected;
case ENOTCONN: return Socket::Disconnected;
case EPIPE: return Socket::Disconnected;
default: return Socket::Error;
}
}
} // namespace priv
} // namespace sf
#endif

252
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SFML_Winsock.hpp

@ -1,252 +0,0 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOGDICAPMASKS
#define NOGDICAPMASKS
#endif
#ifndef NOVIRTUALKEYCODES
#define NOVIRTUALKEYCODES
#endif
#ifndef NOWINMESSAGES
#define NOWINMESSAGES
#endif
#ifndef NOWINSTYLES
#define NOWINSTYLES
#endif
#ifndef NOSYSMETRICS
#define NOSYSMETRICS
#endif
#ifndef NOMENUS
#define NOMENUS
#endif
#ifndef NOICONS
#define NOICONS
#endif
#ifndef NOKEYSTATES
#define NOKEYSTATES
#endif
#ifndef NOSYSCOMMANDS
#define NOSYSCOMMANDS
#endif
#ifndef NORASTEROPS
#define NORASTEROPS
#endif
#ifndef NOSHOWWINDOW
#define NOSHOWWINDOW
#endif
#ifndef NOATOM
#define NOATOM
#endif
#ifndef NOCLIPBOARD
#define NOCLIPBOARD
#endif
#ifndef NOCOLOR
#define NOCOLOR
#endif
#ifndef NOCTLMGR
#define NOCTLMGR
#endif
#ifndef NODRAWTEXT
#define NODRAWTEXT
#endif
#ifndef NOGDI
#define NOGDI
#endif
#ifndef NOKERNEL
#define NOKERNEL
#endif
#ifndef NOUSER
#define NOUSER
#endif
#ifndef NONLS
#define NONLS
#endif
#ifndef NOMB
#define NOMB
#endif
#ifndef NOMEMMGR
#define NOMEMMGR
#endif
#ifndef NOMETAFILE
#define NOMETAFILE
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#ifndef NOMSG
#define NOMSG
#endif
#ifndef NOOPENFILE
#define NOOPENFILE
#endif
#ifndef NOSCROLL
#define NOSCROLL
#endif
#ifndef NOSERVICE
#define NOSERVICE
#endif
#ifndef NOSOUND
#define NOSOUND
#endif
#ifndef NOTEXTMETRIC
#define NOTEXTMETRIC
#endif
#ifndef NOWH
#define NOWH
#endif
#ifndef NOWINOFFSETS
#define NOWINOFFSETS
#endif
#ifndef NOCOMM
#define NOCOMM
#endif
#ifndef NOKANJI
#define NOKANJI
#endif
#ifndef NOHELP
#define NOHELP
#endif
#ifndef NOPROFILER
#define NOPROFILER
#endif
#ifndef NODEFERWINDOWPOS
#define NODEFERWINDOWPOS
#endif
#ifndef NOMCX
#define NOMCX
#endif
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#define recvfrom recvfrom_original
#define setsockopt setsockopt_original
#define socket socket_original
#define select select_original
#define WSAGetLastError WSAGetLastError_original
#define ioctlsocket ioctlsocket_original
#define htons htons_original
#define htonl htonl_original
#define WSAStartup WSAStartup_original
#define closesocket closesocket_original
#define WSACleanup WSACleanup_original
#define ntohs ntohs_original
#define getsockname getsockname_original
#define listen listen_original
#define bind bind_original
#define accept accept_original
#define ntohl ntohl_original
#define recv recv_original
#define connect connect_original
#define send send_original
#define getpeername getpeername_original
#define freeaddrinfo freeaddrinfo_original
#define inet_ntoa inet_ntoa_original
#define inet_addr inet_addr_original
#define getaddrinfo getaddrinfo_original
#define sendto sendto_original
#define __WSAFDIsSet __WSAFDIsSet_original
#include <winsock2.h>
#include <ws2tcpip.h>
#undef recvfrom
#undef setsockopt
#undef socket
#undef select
#undef WSAGetLastError
#undef ioctlsocket
#undef htons
#undef htonl
#undef WSAStartup
#undef closesocket
#undef WSACleanup
#undef ntohs
#undef getsockname
#undef listen
#undef bind
#undef accept
#undef ntohl
#undef recv
#undef connect
#undef send
#undef getpeername
#undef freeaddrinfo
#undef inet_ntoa
#undef inet_addr
#undef getaddrinfo
#undef sendto
#undef __WSAFDIsSet
extern decltype(recvfrom_original) *recvfrom;
extern decltype(setsockopt_original) *setsockopt;
extern decltype(socket_original) *socket;
extern decltype(select_original) *select;
extern decltype(WSAGetLastError_original) *WSAGetLastError;
extern decltype(ioctlsocket_original) *ioctlsocket;
extern decltype(htons_original) *htons;
extern decltype(htonl_original) *htonl;
extern decltype(WSAStartup_original) *WSAStartup;
extern decltype(closesocket_original) *closesocket;
extern decltype(WSACleanup_original) *WSACleanup;
extern decltype(ntohs_original) *ntohs;
extern decltype(getsockname_original) *getsockname;
extern decltype(listen_original) *listen;
extern decltype(bind_original) *bind;
extern decltype(accept_original) *accept;
extern decltype(ntohl_original) *ntohl;
extern decltype(recv_original) *recv;
extern decltype(connect_original) *connect;
extern decltype(send_original) *send;
extern decltype(getpeername_original) *getpeername;
extern decltype(freeaddrinfo_original) *freeaddrinfo;
extern decltype(inet_ntoa_original) *inet_ntoa;
extern decltype(inet_addr_original) *inet_addr;
extern decltype(getaddrinfo_original) *getaddrinfo;
extern decltype(sendto_original) *sendto;
extern decltype(__WSAFDIsSet_original) *__WSAFDIsSet;
#ifdef FD_ISSET
#undef FD_ISSET
#endif
#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))

108
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SocketImpl.hpp

@ -1,108 +0,0 @@
#ifdef _WIN32
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKETIMPL_HPP
#define SFML_SOCKETIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#ifdef _WIN32_WINDOWS
#undef _WIN32_WINDOWS
#endif
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINDOWS 0x0501
#define _WIN32_WINNT 0x0501
#include "SFML_Winsock.hpp"
#include <SFML/Network/Socket.hpp>
namespace sf {
namespace priv {
////////////////////////////////////////////////////////////
/// \brief Helper class implementing all the non-portable
/// socket stuff; this is the Windows version
///
////////////////////////////////////////////////////////////
class SocketImpl {
public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef int AddrLength;
////////////////////////////////////////////////////////////
/// \brief Create an internal sockaddr_in address
///
/// \param address Target address
/// \param port Target port
///
/// \return sockaddr_in ready to be used by socket functions
///
////////////////////////////////////////////////////////////
static sockaddr_in createAddress(Uint32 address, unsigned short port);
////////////////////////////////////////////////////////////
/// \brief Return the value of the invalid socket
///
/// \return Special value of the invalid socket
///
////////////////////////////////////////////////////////////
static SocketHandle invalidSocket();
////////////////////////////////////////////////////////////
/// \brief Close and destroy a socket
///
/// \param sock Handle of the socket to close
///
////////////////////////////////////////////////////////////
static void close(SocketHandle sock);
////////////////////////////////////////////////////////////
/// \brief Set a socket as blocking or non-blocking
///
/// \param sock Handle of the socket
/// \param block New blocking state of the socket
///
////////////////////////////////////////////////////////////
static void setBlocking(SocketHandle sock, bool block);
////////////////////////////////////////////////////////////
/// Get the last socket error status
///
/// \return Status corresponding to the last socket error
///
////////////////////////////////////////////////////////////
static Socket::Status getErrorStatus();
};
} // namespace priv
} // namespace sf
#endif // SFML_SOCKETIMPL_HPP
#endif

167
Source/dapi/Backend/DAPIBackendCore/SFML/Network/Win32/SocketImplWin32.cpp

@ -1,167 +0,0 @@
#ifdef _WIN32
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Win32/SocketImpl.hpp>
#include <cstring>
decltype(recvfrom_original) *recvfrom;
decltype(setsockopt_original) *setsockopt;
decltype(socket_original) *socket;
decltype(select_original) *select;
decltype(WSAGetLastError_original) *WSAGetLastError;
decltype(ioctlsocket_original) *ioctlsocket;
decltype(htons_original) *htons;
decltype(htonl_original) *htonl;
decltype(WSAStartup_original) *WSAStartup;
decltype(closesocket_original) *closesocket;
decltype(WSACleanup_original) *WSACleanup;
decltype(ntohs_original) *ntohs;
decltype(getsockname_original) *getsockname;
decltype(listen_original) *listen;
decltype(bind_original) *bind;
decltype(accept_original) *accept;
decltype(ntohl_original) *ntohl;
decltype(recv_original) *recv;
decltype(connect_original) *connect;
decltype(send_original) *send;
decltype(getpeername_original) *getpeername;
decltype(freeaddrinfo_original) *freeaddrinfo;
decltype(inet_ntoa_original) *inet_ntoa;
decltype(inet_addr_original) *inet_addr;
decltype(getaddrinfo_original) *getaddrinfo;
decltype(sendto_original) *sendto;
decltype(__WSAFDIsSet_original) *__WSAFDIsSet;
namespace sf {
namespace priv {
////////////////////////////////////////////////////////////
// Windows needs some initialization and cleanup to get
// sockets working properly... so let's create a class that will
// do it automatically
////////////////////////////////////////////////////////////
struct WSock32 {
WSock32()
{
ws2_32 = LoadLibrary(TEXT("ws2_32.dll"));
(FARPROC &)recvfrom = GetProcAddress(ws2_32, "recvfrom");
(FARPROC &)setsockopt = GetProcAddress(ws2_32, "setsockopt");
(FARPROC &)socket = GetProcAddress(ws2_32, "socket");
(FARPROC &)select = GetProcAddress(ws2_32, "select");
(FARPROC &)WSAGetLastError = GetProcAddress(ws2_32, "WSAGetLastError");
(FARPROC &)ioctlsocket = GetProcAddress(ws2_32, "ioctlsocket");
(FARPROC &)htons = GetProcAddress(ws2_32, "htons");
(FARPROC &)htonl = GetProcAddress(ws2_32, "htonl");
(FARPROC &)WSAStartup = GetProcAddress(ws2_32, "WSAStartup");
(FARPROC &)closesocket = GetProcAddress(ws2_32, "closesocket");
(FARPROC &)WSACleanup = GetProcAddress(ws2_32, "WSACleanup");
(FARPROC &)ntohs = GetProcAddress(ws2_32, "ntohs");
(FARPROC &)getsockname = GetProcAddress(ws2_32, "getsockname");
(FARPROC &)listen = GetProcAddress(ws2_32, "listen");
(FARPROC &)bind = GetProcAddress(ws2_32, "bind");
(FARPROC &)accept = GetProcAddress(ws2_32, "accept");
(FARPROC &)ntohl = GetProcAddress(ws2_32, "ntohl");
(FARPROC &)recv = GetProcAddress(ws2_32, "recv");
(FARPROC &)connect = GetProcAddress(ws2_32, "connect");
(FARPROC &)send = GetProcAddress(ws2_32, "send");
(FARPROC &)getpeername = GetProcAddress(ws2_32, "getpeername");
(FARPROC &)freeaddrinfo = GetProcAddress(ws2_32, "freeaddrinfo");
(FARPROC &)inet_ntoa = GetProcAddress(ws2_32, "inet_ntoa");
(FARPROC &)inet_addr = GetProcAddress(ws2_32, "inet_addr");
(FARPROC &)getaddrinfo = GetProcAddress(ws2_32, "getaddrinfo");
(FARPROC &)sendto = GetProcAddress(ws2_32, "sendto");
(FARPROC &)__WSAFDIsSet = GetProcAddress(ws2_32, "__WSAFDIsSet");
WSADATA init;
WSAStartup(MAKEWORD(2, 2), &init);
}
~WSock32()
{
WSACleanup();
FreeLibrary(ws2_32);
}
HMODULE ws2_32;
};
WSock32 wsock32;
////////////////////////////////////////////////////////////
sockaddr_in SocketImpl::createAddress(Uint32 address, unsigned short port)
{
sockaddr_in addr;
std::memset(&addr, 0, sizeof(addr));
addr.sin_addr.s_addr = htonl(address);
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
return addr;
}
////////////////////////////////////////////////////////////
SocketHandle SocketImpl::invalidSocket()
{
return INVALID_SOCKET;
}
////////////////////////////////////////////////////////////
void SocketImpl::close(SocketHandle sock)
{
closesocket(sock);
}
////////////////////////////////////////////////////////////
void SocketImpl::setBlocking(SocketHandle sock, bool block)
{
u_long blocking = block ? 0 : 1;
ioctlsocket(sock, FIONBIO, &blocking);
}
////////////////////////////////////////////////////////////
Socket::Status SocketImpl::getErrorStatus()
{
switch (WSAGetLastError()) {
case WSAEWOULDBLOCK: return Socket::NotReady;
case WSAEALREADY: return Socket::NotReady;
case WSAECONNABORTED: return Socket::Disconnected;
case WSAECONNRESET: return Socket::Disconnected;
case WSAETIMEDOUT: return Socket::Disconnected;
case WSAENETRESET: return Socket::Disconnected;
case WSAENOTCONN: return Socket::Disconnected;
case WSAEISCONN: return Socket::Done; // when connecting a non-blocking socket
default: return Socket::Error;
}
}
} // namespace priv
} // namespace sf
#endif

9501
Source/dapi/Backend/Messages/generated/command.pb.cc

File diff suppressed because it is too large Load Diff

10429
Source/dapi/Backend/Messages/generated/command.pb.h

File diff suppressed because it is too large Load Diff

5512
Source/dapi/Backend/Messages/generated/data.pb.cc

File diff suppressed because it is too large Load Diff

6992
Source/dapi/Backend/Messages/generated/data.pb.h

File diff suppressed because it is too large Load Diff

1115
Source/dapi/Backend/Messages/generated/game.pb.cc

File diff suppressed because it is too large Load Diff

1609
Source/dapi/Backend/Messages/generated/game.pb.h

File diff suppressed because it is too large Load Diff

467
Source/dapi/Backend/Messages/generated/init.pb.cc

@ -1,467 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// NO CHECKED-IN PROTOBUF GENCODE
// source: init.proto
// Protobuf C++ Version: 5.29.3
#include "init.pb.h"
#include <algorithm>
#include <type_traits>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::google::protobuf;
namespace _pbi = ::google::protobuf::internal;
namespace _fl = ::google::protobuf::internal::field_layout;
namespace dapi {
namespace init {
inline constexpr ServerResponse::Impl_::Impl_(
::_pbi::ConstantInitialized) noexcept
: port_{0u},
_cached_size_{0} {}
template <typename>
PROTOBUF_CONSTEXPR ServerResponse::ServerResponse(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(_class_data_.base()),
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct ServerResponseDefaultTypeInternal {
PROTOBUF_CONSTEXPR ServerResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ServerResponseDefaultTypeInternal() {}
union {
ServerResponse _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServerResponseDefaultTypeInternal _ServerResponse_default_instance_;
inline constexpr ClientBroadcast::Impl_::Impl_(
::_pbi::ConstantInitialized) noexcept
: _cached_size_{0} {}
template <typename>
PROTOBUF_CONSTEXPR ClientBroadcast::ClientBroadcast(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(_class_data_.base()),
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct ClientBroadcastDefaultTypeInternal {
PROTOBUF_CONSTEXPR ClientBroadcastDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~ClientBroadcastDefaultTypeInternal() {}
union {
ClientBroadcast _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ClientBroadcastDefaultTypeInternal _ClientBroadcast_default_instance_;
} // namespace init
} // namespace dapi
namespace dapi {
namespace init {
// ===================================================================
class ClientBroadcast::_Internal {
public:
};
ClientBroadcast::ClientBroadcast(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:dapi.init.ClientBroadcast)
}
ClientBroadcast::ClientBroadcast(
::google::protobuf::Arena* arena, const ClientBroadcast& from)
: ClientBroadcast(arena) {
MergeFrom(from);
}
inline PROTOBUF_NDEBUG_INLINE ClientBroadcast::Impl_::Impl_(
::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena)
: _cached_size_{0} {}
inline void ClientBroadcast::SharedCtor(::_pb::Arena* arena) {
new (&_impl_) Impl_(internal_visibility(), arena);
}
ClientBroadcast::~ClientBroadcast() {
// @@protoc_insertion_point(destructor:dapi.init.ClientBroadcast)
SharedDtor(*this);
}
inline void ClientBroadcast::SharedDtor(MessageLite& self) {
ClientBroadcast& this_ = static_cast<ClientBroadcast&>(self);
this_._internal_metadata_.Delete<std::string>();
ABSL_DCHECK(this_.GetArena() == nullptr);
this_._impl_.~Impl_();
}
inline void* ClientBroadcast::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) ClientBroadcast(arena);
}
constexpr auto ClientBroadcast::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(ClientBroadcast),
alignof(ClientBroadcast));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::internal::ClassDataLite<26> ClientBroadcast::_class_data_ = {
{
&_ClientBroadcast_default_instance_._instance,
&_table_.header,
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&ClientBroadcast::MergeImpl,
::google::protobuf::MessageLite::GetNewImpl<ClientBroadcast>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
&ClientBroadcast::SharedDtor,
::google::protobuf::MessageLite::GetClearImpl<ClientBroadcast>(), &ClientBroadcast::ByteSizeLong,
&ClientBroadcast::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(ClientBroadcast, _impl_._cached_size_),
true,
},
"dapi.init.ClientBroadcast",
};
const ::google::protobuf::internal::ClassData* ClientBroadcast::GetClassData() const {
return _class_data_.base();
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<0, 0, 0, 0, 2> ClientBroadcast::_table_ = {
{
0, // no _has_bits_
0, // no _extensions_
0, 0, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967295, // skipmap
offsetof(decltype(_table_), field_names), // no field_entries
0, // num_field_entries
0, // num_aux_entries
offsetof(decltype(_table_), field_names), // no aux_entries
_class_data_.base(),
nullptr, // post_loop_handler
::_pbi::TcParser::GenericFallbackLite, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<::dapi::init::ClientBroadcast>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{
{::_pbi::TcParser::MiniParse, {}},
}}, {{
65535, 65535
}},
// no field_entries, or aux_entries
{{
}},
};
PROTOBUF_NOINLINE void ClientBroadcast::Clear() {
// @@protoc_insertion_point(message_clear_start:dapi.init.ClientBroadcast)
::google::protobuf::internal::TSanWrite(&_impl_);
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_internal_metadata_.Clear<std::string>();
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::uint8_t* ClientBroadcast::_InternalSerialize(
const MessageLite& base, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) {
const ClientBroadcast& this_ = static_cast<const ClientBroadcast&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::uint8_t* ClientBroadcast::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
const ClientBroadcast& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(serialize_to_array_start:dapi.init.ClientBroadcast)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(
this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).data(),
static_cast<int>(this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:dapi.init.ClientBroadcast)
return target;
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::size_t ClientBroadcast::ByteSizeLong(const MessageLite& base) {
const ClientBroadcast& this_ = static_cast<const ClientBroadcast&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ClientBroadcast::ByteSizeLong() const {
const ClientBroadcast& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(message_byte_size_start:dapi.init.ClientBroadcast)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void)cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
total_size += this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size();
}
this_._impl_._cached_size_.Set(::_pbi::ToCachedSize(total_size));
return total_size;
}
void ClientBroadcast::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) {
auto* const _this = static_cast<ClientBroadcast*>(&to_msg);
auto& from = static_cast<const ClientBroadcast&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:dapi.init.ClientBroadcast)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void ClientBroadcast::CopyFrom(const ClientBroadcast& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:dapi.init.ClientBroadcast)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ClientBroadcast::InternalSwap(ClientBroadcast* PROTOBUF_RESTRICT other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
}
// ===================================================================
class ServerResponse::_Internal {
public:
};
ServerResponse::ServerResponse(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:dapi.init.ServerResponse)
}
ServerResponse::ServerResponse(
::google::protobuf::Arena* arena, const ServerResponse& from)
: ServerResponse(arena) {
MergeFrom(from);
}
inline PROTOBUF_NDEBUG_INLINE ServerResponse::Impl_::Impl_(
::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena)
: _cached_size_{0} {}
inline void ServerResponse::SharedCtor(::_pb::Arena* arena) {
new (&_impl_) Impl_(internal_visibility(), arena);
_impl_.port_ = {};
}
ServerResponse::~ServerResponse() {
// @@protoc_insertion_point(destructor:dapi.init.ServerResponse)
SharedDtor(*this);
}
inline void ServerResponse::SharedDtor(MessageLite& self) {
ServerResponse& this_ = static_cast<ServerResponse&>(self);
this_._internal_metadata_.Delete<std::string>();
ABSL_DCHECK(this_.GetArena() == nullptr);
this_._impl_.~Impl_();
}
inline void* ServerResponse::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) ServerResponse(arena);
}
constexpr auto ServerResponse::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(ServerResponse),
alignof(ServerResponse));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::internal::ClassDataLite<25> ServerResponse::_class_data_ = {
{
&_ServerResponse_default_instance_._instance,
&_table_.header,
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&ServerResponse::MergeImpl,
::google::protobuf::MessageLite::GetNewImpl<ServerResponse>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
&ServerResponse::SharedDtor,
::google::protobuf::MessageLite::GetClearImpl<ServerResponse>(), &ServerResponse::ByteSizeLong,
&ServerResponse::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(ServerResponse, _impl_._cached_size_),
true,
},
"dapi.init.ServerResponse",
};
const ::google::protobuf::internal::ClassData* ServerResponse::GetClassData() const {
return _class_data_.base();
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<0, 1, 0, 0, 2> ServerResponse::_table_ = {
{
0, // no _has_bits_
0, // no _extensions_
1, 0, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967294, // skipmap
offsetof(decltype(_table_), field_entries),
1, // num_field_entries
0, // num_aux_entries
offsetof(decltype(_table_), field_names), // no aux_entries
_class_data_.base(),
nullptr, // post_loop_handler
::_pbi::TcParser::GenericFallbackLite, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<::dapi::init::ServerResponse>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{
// uint32 port = 1;
{::_pbi::TcParser::FastV32S1,
{8, 63, 0, PROTOBUF_FIELD_OFFSET(ServerResponse, _impl_.port_)}},
}}, {{
65535, 65535
}}, {{
// uint32 port = 1;
{PROTOBUF_FIELD_OFFSET(ServerResponse, _impl_.port_), 0, 0,
(0 | ::_fl::kFcSingular | ::_fl::kUInt32)},
}},
// no aux_entries
{{
}},
};
PROTOBUF_NOINLINE void ServerResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:dapi.init.ServerResponse)
::google::protobuf::internal::TSanWrite(&_impl_);
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_.port_ = 0u;
_internal_metadata_.Clear<std::string>();
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::uint8_t* ServerResponse::_InternalSerialize(
const MessageLite& base, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) {
const ServerResponse& this_ = static_cast<const ServerResponse&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::uint8_t* ServerResponse::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
const ServerResponse& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(serialize_to_array_start:dapi.init.ServerResponse)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
// uint32 port = 1;
if (this_._internal_port() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteUInt32ToArray(
1, this_._internal_port(), target);
}
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(
this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).data(),
static_cast<int>(this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:dapi.init.ServerResponse)
return target;
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::size_t ServerResponse::ByteSizeLong(const MessageLite& base) {
const ServerResponse& this_ = static_cast<const ServerResponse&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ServerResponse::ByteSizeLong() const {
const ServerResponse& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(message_byte_size_start:dapi.init.ServerResponse)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void)cached_has_bits;
{
// uint32 port = 1;
if (this_._internal_port() != 0) {
total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(
this_._internal_port());
}
}
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
total_size += this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size();
}
this_._impl_._cached_size_.Set(::_pbi::ToCachedSize(total_size));
return total_size;
}
void ServerResponse::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) {
auto* const _this = static_cast<ServerResponse*>(&to_msg);
auto& from = static_cast<const ServerResponse&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:dapi.init.ServerResponse)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (from._internal_port() != 0) {
_this->_impl_.port_ = from._impl_.port_;
}
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void ServerResponse::CopyFrom(const ServerResponse& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:dapi.init.ServerResponse)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void ServerResponse::InternalSwap(ServerResponse* PROTOBUF_RESTRICT other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_.port_, other->_impl_.port_);
}
// @@protoc_insertion_point(namespace_scope)
} // namespace init
} // namespace dapi
namespace google {
namespace protobuf {
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"

466
Source/dapi/Backend/Messages/generated/init.pb.h

@ -1,466 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// NO CHECKED-IN PROTOBUF GENCODE
// source: init.proto
// Protobuf C++ Version: 5.29.3
#ifndef init_2eproto_2epb_2eh
#define init_2eproto_2epb_2eh
#include <limits>
#include <string>
#include <type_traits>
#include <utility>
#include "google/protobuf/runtime_version.h"
#if PROTOBUF_VERSION != 5029003
#error "Protobuf C++ gencode is built with an incompatible version of"
#error "Protobuf C++ headers/runtime. See"
#error "https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp"
#endif
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/generated_message_tctable_decl.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/metadata_lite.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/repeated_field.h" // IWYU pragma: export
#include "google/protobuf/extension_set.h" // IWYU pragma: export
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
#define PROTOBUF_INTERNAL_EXPORT_init_2eproto
namespace google {
namespace protobuf {
namespace internal {
template <typename T>
::absl::string_view GetAnyMessageName();
} // namespace internal
} // namespace protobuf
} // namespace google
// Internal implementation detail -- do not use these members.
struct TableStruct_init_2eproto {
static const ::uint32_t offsets[];
};
namespace dapi {
namespace init {
class ClientBroadcast;
struct ClientBroadcastDefaultTypeInternal;
extern ClientBroadcastDefaultTypeInternal _ClientBroadcast_default_instance_;
class ServerResponse;
struct ServerResponseDefaultTypeInternal;
extern ServerResponseDefaultTypeInternal _ServerResponse_default_instance_;
} // namespace init
} // namespace dapi
namespace google {
namespace protobuf {
} // namespace protobuf
} // namespace google
namespace dapi {
namespace init {
// ===================================================================
// -------------------------------------------------------------------
class ServerResponse final : public ::google::protobuf::MessageLite
/* @@protoc_insertion_point(class_definition:dapi.init.ServerResponse) */ {
public:
inline ServerResponse() : ServerResponse(nullptr) {}
~ServerResponse() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
void operator delete(ServerResponse* msg, std::destroying_delete_t) {
SharedDtor(*msg);
::google::protobuf::internal::SizedDelete(msg, sizeof(ServerResponse));
}
#endif
template <typename = void>
explicit PROTOBUF_CONSTEXPR ServerResponse(
::google::protobuf::internal::ConstantInitialized);
inline ServerResponse(const ServerResponse& from) : ServerResponse(nullptr, from) {}
inline ServerResponse(ServerResponse&& from) noexcept
: ServerResponse(nullptr, std::move(from)) {}
inline ServerResponse& operator=(const ServerResponse& from) {
CopyFrom(from);
return *this;
}
inline ServerResponse& operator=(ServerResponse&& from) noexcept {
if (this == &from) return *this;
if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const ServerResponse& default_instance() {
return *internal_default_instance();
}
static inline const ServerResponse* internal_default_instance() {
return reinterpret_cast<const ServerResponse*>(
&_ServerResponse_default_instance_);
}
static constexpr int kIndexInFileMessages = 1;
friend void swap(ServerResponse& a, ServerResponse& b) { a.Swap(&b); }
inline void Swap(ServerResponse* other) {
if (other == this) return;
if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) {
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(ServerResponse* other) {
if (other == this) return;
ABSL_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
ServerResponse* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::MessageLite::DefaultConstruct<ServerResponse>(arena);
}
void CopyFrom(const ServerResponse& from);
void MergeFrom(const ServerResponse& from) { ServerResponse::MergeImpl(*this, from); }
private:
static void MergeImpl(::google::protobuf::MessageLite& to_msg,
const ::google::protobuf::MessageLite& from_msg);
public:
bool IsInitialized() const {
return true;
}
ABSL_ATTRIBUTE_REINITIALIZES void Clear() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
private:
static ::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg);
static ::uint8_t* _InternalSerialize(
const MessageLite& msg, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream);
public:
::size_t ByteSizeLong() const { return ByteSizeLong(*this); }
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
return _InternalSerialize(*this, target, stream);
}
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ByteSizeLong() const final;
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const final;
#endif // PROTOBUF_CUSTOM_VTABLE
int GetCachedSize() const { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
static void SharedDtor(MessageLite& self);
void InternalSwap(ServerResponse* other);
private:
template <typename T>
friend ::absl::string_view(
::google::protobuf::internal::GetAnyMessageName)();
static ::absl::string_view FullMessageName() { return "dapi.init.ServerResponse"; }
protected:
explicit ServerResponse(::google::protobuf::Arena* arena);
ServerResponse(::google::protobuf::Arena* arena, const ServerResponse& from);
ServerResponse(::google::protobuf::Arena* arena, ServerResponse&& from) noexcept
: ServerResponse(arena) {
*this = ::std::move(from);
}
const ::google::protobuf::internal::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::internal::ClassDataLite<25> _class_data_;
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kPortFieldNumber = 1,
};
// uint32 port = 1;
void clear_port() ;
::uint32_t port() const;
void set_port(::uint32_t value);
private:
::uint32_t _internal_port() const;
void _internal_set_port(::uint32_t value);
public:
// @@protoc_insertion_point(class_scope:dapi.init.ServerResponse)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
0, 1, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
friend class ::google::protobuf::Arena;
template <typename T>
friend class ::google::protobuf::Arena::InternalHelper;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
struct Impl_ {
inline explicit constexpr Impl_(
::google::protobuf::internal::ConstantInitialized) noexcept;
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from,
const ServerResponse& from_msg);
::uint32_t port_;
::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
friend struct ::TableStruct_init_2eproto;
};
// -------------------------------------------------------------------
class ClientBroadcast final : public ::google::protobuf::MessageLite
/* @@protoc_insertion_point(class_definition:dapi.init.ClientBroadcast) */ {
public:
inline ClientBroadcast() : ClientBroadcast(nullptr) {}
~ClientBroadcast() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
void operator delete(ClientBroadcast* msg, std::destroying_delete_t) {
SharedDtor(*msg);
::google::protobuf::internal::SizedDelete(msg, sizeof(ClientBroadcast));
}
#endif
template <typename = void>
explicit PROTOBUF_CONSTEXPR ClientBroadcast(
::google::protobuf::internal::ConstantInitialized);
inline ClientBroadcast(const ClientBroadcast& from) : ClientBroadcast(nullptr, from) {}
inline ClientBroadcast(ClientBroadcast&& from) noexcept
: ClientBroadcast(nullptr, std::move(from)) {}
inline ClientBroadcast& operator=(const ClientBroadcast& from) {
CopyFrom(from);
return *this;
}
inline ClientBroadcast& operator=(ClientBroadcast&& from) noexcept {
if (this == &from) return *this;
if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const ClientBroadcast& default_instance() {
return *internal_default_instance();
}
static inline const ClientBroadcast* internal_default_instance() {
return reinterpret_cast<const ClientBroadcast*>(
&_ClientBroadcast_default_instance_);
}
static constexpr int kIndexInFileMessages = 0;
friend void swap(ClientBroadcast& a, ClientBroadcast& b) { a.Swap(&b); }
inline void Swap(ClientBroadcast* other) {
if (other == this) return;
if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) {
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(ClientBroadcast* other) {
if (other == this) return;
ABSL_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
ClientBroadcast* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::MessageLite::DefaultConstruct<ClientBroadcast>(arena);
}
void CopyFrom(const ClientBroadcast& from);
void MergeFrom(const ClientBroadcast& from) { ClientBroadcast::MergeImpl(*this, from); }
private:
static void MergeImpl(::google::protobuf::MessageLite& to_msg,
const ::google::protobuf::MessageLite& from_msg);
public:
bool IsInitialized() const {
return true;
}
ABSL_ATTRIBUTE_REINITIALIZES void Clear() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
private:
static ::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg);
static ::uint8_t* _InternalSerialize(
const MessageLite& msg, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream);
public:
::size_t ByteSizeLong() const { return ByteSizeLong(*this); }
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
return _InternalSerialize(*this, target, stream);
}
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ByteSizeLong() const final;
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const final;
#endif // PROTOBUF_CUSTOM_VTABLE
int GetCachedSize() const { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
static void SharedDtor(MessageLite& self);
void InternalSwap(ClientBroadcast* other);
private:
template <typename T>
friend ::absl::string_view(
::google::protobuf::internal::GetAnyMessageName)();
static ::absl::string_view FullMessageName() { return "dapi.init.ClientBroadcast"; }
protected:
explicit ClientBroadcast(::google::protobuf::Arena* arena);
ClientBroadcast(::google::protobuf::Arena* arena, const ClientBroadcast& from);
ClientBroadcast(::google::protobuf::Arena* arena, ClientBroadcast&& from) noexcept
: ClientBroadcast(arena) {
*this = ::std::move(from);
}
const ::google::protobuf::internal::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::internal::ClassDataLite<26> _class_data_;
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// @@protoc_insertion_point(class_scope:dapi.init.ClientBroadcast)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
0, 0, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
friend class ::google::protobuf::Arena;
template <typename T>
friend class ::google::protobuf::Arena::InternalHelper;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
struct Impl_ {
inline explicit constexpr Impl_(
::google::protobuf::internal::ConstantInitialized) noexcept;
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from,
const ClientBroadcast& from_msg);
::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
friend struct ::TableStruct_init_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// -------------------------------------------------------------------
// ClientBroadcast
// -------------------------------------------------------------------
// ServerResponse
// uint32 port = 1;
inline void ServerResponse::clear_port() {
::google::protobuf::internal::TSanWrite(&_impl_);
_impl_.port_ = 0u;
}
inline ::uint32_t ServerResponse::port() const {
// @@protoc_insertion_point(field_get:dapi.init.ServerResponse.port)
return _internal_port();
}
inline void ServerResponse::set_port(::uint32_t value) {
_internal_set_port(value);
// @@protoc_insertion_point(field_set:dapi.init.ServerResponse.port)
}
inline ::uint32_t ServerResponse::_internal_port() const {
::google::protobuf::internal::TSanRead(&_impl_);
return _impl_.port_;
}
inline void ServerResponse::_internal_set_port(::uint32_t value) {
::google::protobuf::internal::TSanWrite(&_impl_);
_impl_.port_ = value;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace init
} // namespace dapi
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"
#endif // init_2eproto_2epb_2eh

818
Source/dapi/Backend/Messages/generated/message.pb.cc

@ -1,818 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// NO CHECKED-IN PROTOBUF GENCODE
// source: message.proto
// Protobuf C++ Version: 5.29.3
#include "message.pb.h"
#include <algorithm>
#include <type_traits>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::google::protobuf;
namespace _pbi = ::google::protobuf::internal;
namespace _fl = ::google::protobuf::internal::field_layout;
namespace dapi {
namespace message {
inline constexpr EndofQueue::Impl_::Impl_(
::_pbi::ConstantInitialized) noexcept
: _cached_size_{0} {}
template <typename>
PROTOBUF_CONSTEXPR EndofQueue::EndofQueue(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(_class_data_.base()),
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct EndofQueueDefaultTypeInternal {
PROTOBUF_CONSTEXPR EndofQueueDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~EndofQueueDefaultTypeInternal() {}
union {
EndofQueue _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EndofQueueDefaultTypeInternal _EndofQueue_default_instance_;
inline constexpr Message::Impl_::Impl_(
::_pbi::ConstantInitialized) noexcept
: msg_{},
_cached_size_{0},
_oneof_case_{} {}
template <typename>
PROTOBUF_CONSTEXPR Message::Message(::_pbi::ConstantInitialized)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(_class_data_.base()),
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(),
#endif // PROTOBUF_CUSTOM_VTABLE
_impl_(::_pbi::ConstantInitialized()) {
}
struct MessageDefaultTypeInternal {
PROTOBUF_CONSTEXPR MessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~MessageDefaultTypeInternal() {}
union {
Message _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageDefaultTypeInternal _Message_default_instance_;
} // namespace message
} // namespace dapi
namespace dapi {
namespace message {
// ===================================================================
class EndofQueue::_Internal {
public:
};
EndofQueue::EndofQueue(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:dapi.message.EndofQueue)
}
EndofQueue::EndofQueue(
::google::protobuf::Arena* arena, const EndofQueue& from)
: EndofQueue(arena) {
MergeFrom(from);
}
inline PROTOBUF_NDEBUG_INLINE EndofQueue::Impl_::Impl_(
::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena)
: _cached_size_{0} {}
inline void EndofQueue::SharedCtor(::_pb::Arena* arena) {
new (&_impl_) Impl_(internal_visibility(), arena);
}
EndofQueue::~EndofQueue() {
// @@protoc_insertion_point(destructor:dapi.message.EndofQueue)
SharedDtor(*this);
}
inline void EndofQueue::SharedDtor(MessageLite& self) {
EndofQueue& this_ = static_cast<EndofQueue&>(self);
this_._internal_metadata_.Delete<std::string>();
ABSL_DCHECK(this_.GetArena() == nullptr);
this_._impl_.~Impl_();
}
inline void* EndofQueue::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) EndofQueue(arena);
}
constexpr auto EndofQueue::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(EndofQueue),
alignof(EndofQueue));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::internal::ClassDataLite<24> EndofQueue::_class_data_ = {
{
&_EndofQueue_default_instance_._instance,
&_table_.header,
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&EndofQueue::MergeImpl,
::google::protobuf::MessageLite::GetNewImpl<EndofQueue>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
&EndofQueue::SharedDtor,
::google::protobuf::MessageLite::GetClearImpl<EndofQueue>(), &EndofQueue::ByteSizeLong,
&EndofQueue::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(EndofQueue, _impl_._cached_size_),
true,
},
"dapi.message.EndofQueue",
};
const ::google::protobuf::internal::ClassData* EndofQueue::GetClassData() const {
return _class_data_.base();
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<0, 0, 0, 0, 2> EndofQueue::_table_ = {
{
0, // no _has_bits_
0, // no _extensions_
0, 0, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967295, // skipmap
offsetof(decltype(_table_), field_names), // no field_entries
0, // num_field_entries
0, // num_aux_entries
offsetof(decltype(_table_), field_names), // no aux_entries
_class_data_.base(),
nullptr, // post_loop_handler
::_pbi::TcParser::GenericFallbackLite, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<::dapi::message::EndofQueue>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{
{::_pbi::TcParser::MiniParse, {}},
}}, {{
65535, 65535
}},
// no field_entries, or aux_entries
{{
}},
};
PROTOBUF_NOINLINE void EndofQueue::Clear() {
// @@protoc_insertion_point(message_clear_start:dapi.message.EndofQueue)
::google::protobuf::internal::TSanWrite(&_impl_);
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_internal_metadata_.Clear<std::string>();
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::uint8_t* EndofQueue::_InternalSerialize(
const MessageLite& base, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) {
const EndofQueue& this_ = static_cast<const EndofQueue&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::uint8_t* EndofQueue::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
const EndofQueue& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(serialize_to_array_start:dapi.message.EndofQueue)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(
this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).data(),
static_cast<int>(this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:dapi.message.EndofQueue)
return target;
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::size_t EndofQueue::ByteSizeLong(const MessageLite& base) {
const EndofQueue& this_ = static_cast<const EndofQueue&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::size_t EndofQueue::ByteSizeLong() const {
const EndofQueue& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(message_byte_size_start:dapi.message.EndofQueue)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void)cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
total_size += this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size();
}
this_._impl_._cached_size_.Set(::_pbi::ToCachedSize(total_size));
return total_size;
}
void EndofQueue::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) {
auto* const _this = static_cast<EndofQueue*>(&to_msg);
auto& from = static_cast<const EndofQueue&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:dapi.message.EndofQueue)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void EndofQueue::CopyFrom(const EndofQueue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:dapi.message.EndofQueue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void EndofQueue::InternalSwap(EndofQueue* PROTOBUF_RESTRICT other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
}
// ===================================================================
class Message::_Internal {
public:
static constexpr ::int32_t kOneofCaseOffset =
PROTOBUF_FIELD_OFFSET(::dapi::message::Message, _impl_._oneof_case_);
};
void Message::set_allocated_initbroadcast(::dapi::init::ClientBroadcast* initbroadcast) {
::google::protobuf::Arena* message_arena = GetArena();
clear_msg();
if (initbroadcast) {
::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(initbroadcast)->GetArena();
if (message_arena != submessage_arena) {
initbroadcast = ::google::protobuf::internal::GetOwnedMessage(message_arena, initbroadcast, submessage_arena);
}
set_has_initbroadcast();
_impl_.msg_.initbroadcast_ = initbroadcast;
}
// @@protoc_insertion_point(field_set_allocated:dapi.message.Message.initBroadcast)
}
void Message::clear_initbroadcast() {
::google::protobuf::internal::TSanWrite(&_impl_);
if (msg_case() == kInitBroadcast) {
if (GetArena() == nullptr) {
delete _impl_.msg_.initbroadcast_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.initbroadcast_ != nullptr) {
_impl_.msg_.initbroadcast_->Clear();
}
}
clear_has_msg();
}
}
void Message::set_allocated_initresponse(::dapi::init::ServerResponse* initresponse) {
::google::protobuf::Arena* message_arena = GetArena();
clear_msg();
if (initresponse) {
::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(initresponse)->GetArena();
if (message_arena != submessage_arena) {
initresponse = ::google::protobuf::internal::GetOwnedMessage(message_arena, initresponse, submessage_arena);
}
set_has_initresponse();
_impl_.msg_.initresponse_ = initresponse;
}
// @@protoc_insertion_point(field_set_allocated:dapi.message.Message.initResponse)
}
void Message::clear_initresponse() {
::google::protobuf::internal::TSanWrite(&_impl_);
if (msg_case() == kInitResponse) {
if (GetArena() == nullptr) {
delete _impl_.msg_.initresponse_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.initresponse_ != nullptr) {
_impl_.msg_.initresponse_->Clear();
}
}
clear_has_msg();
}
}
void Message::set_allocated_frameupdate(::dapi::game::FrameUpdate* frameupdate) {
::google::protobuf::Arena* message_arena = GetArena();
clear_msg();
if (frameupdate) {
::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(frameupdate)->GetArena();
if (message_arena != submessage_arena) {
frameupdate = ::google::protobuf::internal::GetOwnedMessage(message_arena, frameupdate, submessage_arena);
}
set_has_frameupdate();
_impl_.msg_.frameupdate_ = frameupdate;
}
// @@protoc_insertion_point(field_set_allocated:dapi.message.Message.frameUpdate)
}
void Message::clear_frameupdate() {
::google::protobuf::internal::TSanWrite(&_impl_);
if (msg_case() == kFrameUpdate) {
if (GetArena() == nullptr) {
delete _impl_.msg_.frameupdate_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.frameupdate_ != nullptr) {
_impl_.msg_.frameupdate_->Clear();
}
}
clear_has_msg();
}
}
void Message::set_allocated_command(::dapi::commands::Command* command) {
::google::protobuf::Arena* message_arena = GetArena();
clear_msg();
if (command) {
::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(command)->GetArena();
if (message_arena != submessage_arena) {
command = ::google::protobuf::internal::GetOwnedMessage(message_arena, command, submessage_arena);
}
set_has_command();
_impl_.msg_.command_ = command;
}
// @@protoc_insertion_point(field_set_allocated:dapi.message.Message.command)
}
void Message::clear_command() {
::google::protobuf::internal::TSanWrite(&_impl_);
if (msg_case() == kCommand) {
if (GetArena() == nullptr) {
delete _impl_.msg_.command_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.command_ != nullptr) {
_impl_.msg_.command_->Clear();
}
}
clear_has_msg();
}
}
void Message::set_allocated_endofqueue(::dapi::message::EndofQueue* endofqueue) {
::google::protobuf::Arena* message_arena = GetArena();
clear_msg();
if (endofqueue) {
::google::protobuf::Arena* submessage_arena = endofqueue->GetArena();
if (message_arena != submessage_arena) {
endofqueue = ::google::protobuf::internal::GetOwnedMessage(message_arena, endofqueue, submessage_arena);
}
set_has_endofqueue();
_impl_.msg_.endofqueue_ = endofqueue;
}
// @@protoc_insertion_point(field_set_allocated:dapi.message.Message.endOfQueue)
}
Message::Message(::google::protobuf::Arena* arena)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:dapi.message.Message)
}
inline PROTOBUF_NDEBUG_INLINE Message::Impl_::Impl_(
::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena,
const Impl_& from, const ::dapi::message::Message& from_msg)
: msg_{},
_cached_size_{0},
_oneof_case_{from._oneof_case_[0]} {}
Message::Message(
::google::protobuf::Arena* arena,
const Message& from)
#if defined(PROTOBUF_CUSTOM_VTABLE)
: ::google::protobuf::MessageLite(arena, _class_data_.base()) {
#else // PROTOBUF_CUSTOM_VTABLE
: ::google::protobuf::MessageLite(arena) {
#endif // PROTOBUF_CUSTOM_VTABLE
Message* const _this = this;
(void)_this;
_internal_metadata_.MergeFrom<std::string>(
from._internal_metadata_);
new (&_impl_) Impl_(internal_visibility(), arena, from._impl_, from);
switch (msg_case()) {
case MSG_NOT_SET:
break;
case kInitBroadcast:
_impl_.msg_.initbroadcast_ = ::google::protobuf::MessageLite::CopyConstruct<::dapi::init::ClientBroadcast>(arena, *from._impl_.msg_.initbroadcast_);
break;
case kInitResponse:
_impl_.msg_.initresponse_ = ::google::protobuf::MessageLite::CopyConstruct<::dapi::init::ServerResponse>(arena, *from._impl_.msg_.initresponse_);
break;
case kFrameUpdate:
_impl_.msg_.frameupdate_ = ::google::protobuf::MessageLite::CopyConstruct<::dapi::game::FrameUpdate>(arena, *from._impl_.msg_.frameupdate_);
break;
case kCommand:
_impl_.msg_.command_ = ::google::protobuf::MessageLite::CopyConstruct<::dapi::commands::Command>(arena, *from._impl_.msg_.command_);
break;
case kEndOfQueue:
_impl_.msg_.endofqueue_ = ::google::protobuf::MessageLite::CopyConstruct<::dapi::message::EndofQueue>(arena, *from._impl_.msg_.endofqueue_);
break;
}
// @@protoc_insertion_point(copy_constructor:dapi.message.Message)
}
inline PROTOBUF_NDEBUG_INLINE Message::Impl_::Impl_(
::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena)
: msg_{},
_cached_size_{0},
_oneof_case_{} {}
inline void Message::SharedCtor(::_pb::Arena* arena) {
new (&_impl_) Impl_(internal_visibility(), arena);
}
Message::~Message() {
// @@protoc_insertion_point(destructor:dapi.message.Message)
SharedDtor(*this);
}
inline void Message::SharedDtor(MessageLite& self) {
Message& this_ = static_cast<Message&>(self);
this_._internal_metadata_.Delete<std::string>();
ABSL_DCHECK(this_.GetArena() == nullptr);
if (this_.has_msg()) {
this_.clear_msg();
}
this_._impl_.~Impl_();
}
void Message::clear_msg() {
// @@protoc_insertion_point(one_of_clear_start:dapi.message.Message)
::google::protobuf::internal::TSanWrite(&_impl_);
switch (msg_case()) {
case kInitBroadcast: {
if (GetArena() == nullptr) {
delete _impl_.msg_.initbroadcast_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.initbroadcast_ != nullptr) {
_impl_.msg_.initbroadcast_->Clear();
}
}
break;
}
case kInitResponse: {
if (GetArena() == nullptr) {
delete _impl_.msg_.initresponse_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.initresponse_ != nullptr) {
_impl_.msg_.initresponse_->Clear();
}
}
break;
}
case kFrameUpdate: {
if (GetArena() == nullptr) {
delete _impl_.msg_.frameupdate_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.frameupdate_ != nullptr) {
_impl_.msg_.frameupdate_->Clear();
}
}
break;
}
case kCommand: {
if (GetArena() == nullptr) {
delete _impl_.msg_.command_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.command_ != nullptr) {
_impl_.msg_.command_->Clear();
}
}
break;
}
case kEndOfQueue: {
if (GetArena() == nullptr) {
delete _impl_.msg_.endofqueue_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.endofqueue_ != nullptr) {
_impl_.msg_.endofqueue_->Clear();
}
}
break;
}
case MSG_NOT_SET: {
break;
}
}
_impl_._oneof_case_[0] = MSG_NOT_SET;
}
inline void* Message::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) Message(arena);
}
constexpr auto Message::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(Message),
alignof(Message));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::internal::ClassDataLite<21> Message::_class_data_ = {
{
&_Message_default_instance_._instance,
&_table_.header,
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&Message::MergeImpl,
::google::protobuf::MessageLite::GetNewImpl<Message>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
&Message::SharedDtor,
::google::protobuf::MessageLite::GetClearImpl<Message>(), &Message::ByteSizeLong,
&Message::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET(Message, _impl_._cached_size_),
true,
},
"dapi.message.Message",
};
const ::google::protobuf::internal::ClassData* Message::GetClassData() const {
return _class_data_.base();
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::_pbi::TcParseTable<0, 5, 5, 0, 2> Message::_table_ = {
{
0, // no _has_bits_
0, // no _extensions_
5, 0, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
4294967264, // skipmap
offsetof(decltype(_table_), field_entries),
5, // num_field_entries
5, // num_aux_entries
offsetof(decltype(_table_), aux_entries),
_class_data_.base(),
nullptr, // post_loop_handler
::_pbi::TcParser::GenericFallbackLite, // fallback
#ifdef PROTOBUF_PREFETCH_PARSE_TABLE
::_pbi::TcParser::GetTable<::dapi::message::Message>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{
{::_pbi::TcParser::MiniParse, {}},
}}, {{
65535, 65535
}}, {{
// .dapi.init.ClientBroadcast initBroadcast = 1;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.msg_.initbroadcast_), _Internal::kOneofCaseOffset + 0, 0,
(0 | ::_fl::kFcOneof | ::_fl::kMessage | ::_fl::kTvTable)},
// .dapi.init.ServerResponse initResponse = 2;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.msg_.initresponse_), _Internal::kOneofCaseOffset + 0, 1,
(0 | ::_fl::kFcOneof | ::_fl::kMessage | ::_fl::kTvTable)},
// .dapi.game.FrameUpdate frameUpdate = 3;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.msg_.frameupdate_), _Internal::kOneofCaseOffset + 0, 2,
(0 | ::_fl::kFcOneof | ::_fl::kMessage | ::_fl::kTvTable)},
// .dapi.commands.Command command = 4;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.msg_.command_), _Internal::kOneofCaseOffset + 0, 3,
(0 | ::_fl::kFcOneof | ::_fl::kMessage | ::_fl::kTvTable)},
// .dapi.message.EndofQueue endOfQueue = 5;
{PROTOBUF_FIELD_OFFSET(Message, _impl_.msg_.endofqueue_), _Internal::kOneofCaseOffset + 0, 4,
(0 | ::_fl::kFcOneof | ::_fl::kMessage | ::_fl::kTvTable)},
}}, {{
{::_pbi::TcParser::GetTable<::dapi::init::ClientBroadcast>()},
{::_pbi::TcParser::GetTable<::dapi::init::ServerResponse>()},
{::_pbi::TcParser::GetTable<::dapi::game::FrameUpdate>()},
{::_pbi::TcParser::GetTable<::dapi::commands::Command>()},
{::_pbi::TcParser::GetTable<::dapi::message::EndofQueue>()},
}}, {{
}},
};
PROTOBUF_NOINLINE void Message::Clear() {
// @@protoc_insertion_point(message_clear_start:dapi.message.Message)
::google::protobuf::internal::TSanWrite(&_impl_);
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
clear_msg();
_internal_metadata_.Clear<std::string>();
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::uint8_t* Message::_InternalSerialize(
const MessageLite& base, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) {
const Message& this_ = static_cast<const Message&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::uint8_t* Message::_InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
const Message& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(serialize_to_array_start:dapi.message.Message)
::uint32_t cached_has_bits = 0;
(void)cached_has_bits;
switch (this_.msg_case()) {
case kInitBroadcast: {
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage(
1, *this_._impl_.msg_.initbroadcast_, this_._impl_.msg_.initbroadcast_->GetCachedSize(), target,
stream);
break;
}
case kInitResponse: {
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage(
2, *this_._impl_.msg_.initresponse_, this_._impl_.msg_.initresponse_->GetCachedSize(), target,
stream);
break;
}
case kFrameUpdate: {
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage(
3, *this_._impl_.msg_.frameupdate_, this_._impl_.msg_.frameupdate_->GetCachedSize(), target,
stream);
break;
}
case kCommand: {
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage(
4, *this_._impl_.msg_.command_, this_._impl_.msg_.command_->GetCachedSize(), target,
stream);
break;
}
case kEndOfQueue: {
target = ::google::protobuf::internal::WireFormatLite::InternalWriteMessage(
5, *this_._impl_.msg_.endofqueue_, this_._impl_.msg_.endofqueue_->GetCachedSize(), target,
stream);
break;
}
default:
break;
}
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(
this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).data(),
static_cast<int>(this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:dapi.message.Message)
return target;
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
::size_t Message::ByteSizeLong(const MessageLite& base) {
const Message& this_ = static_cast<const Message&>(base);
#else // PROTOBUF_CUSTOM_VTABLE
::size_t Message::ByteSizeLong() const {
const Message& this_ = *this;
#endif // PROTOBUF_CUSTOM_VTABLE
// @@protoc_insertion_point(message_byte_size_start:dapi.message.Message)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void)cached_has_bits;
switch (this_.msg_case()) {
// .dapi.init.ClientBroadcast initBroadcast = 1;
case kInitBroadcast: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(*this_._impl_.msg_.initbroadcast_);
break;
}
// .dapi.init.ServerResponse initResponse = 2;
case kInitResponse: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(*this_._impl_.msg_.initresponse_);
break;
}
// .dapi.game.FrameUpdate frameUpdate = 3;
case kFrameUpdate: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(*this_._impl_.msg_.frameupdate_);
break;
}
// .dapi.commands.Command command = 4;
case kCommand: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(*this_._impl_.msg_.command_);
break;
}
// .dapi.message.EndofQueue endOfQueue = 5;
case kEndOfQueue: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(*this_._impl_.msg_.endofqueue_);
break;
}
case MSG_NOT_SET: {
break;
}
}
if (PROTOBUF_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
total_size += this_._internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString).size();
}
this_._impl_._cached_size_.Set(::_pbi::ToCachedSize(total_size));
return total_size;
}
void Message::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) {
auto* const _this = static_cast<Message*>(&to_msg);
auto& from = static_cast<const Message&>(from_msg);
::google::protobuf::Arena* arena = _this->GetArena();
// @@protoc_insertion_point(class_specific_merge_from_start:dapi.message.Message)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (const uint32_t oneof_from_case = from._impl_._oneof_case_[0]) {
const uint32_t oneof_to_case = _this->_impl_._oneof_case_[0];
const bool oneof_needs_init = oneof_to_case != oneof_from_case;
if (oneof_needs_init) {
if (oneof_to_case != 0) {
_this->clear_msg();
}
_this->_impl_._oneof_case_[0] = oneof_from_case;
}
switch (oneof_from_case) {
case kInitBroadcast: {
if (oneof_needs_init) {
_this->_impl_.msg_.initbroadcast_ =
::google::protobuf::MessageLite::CopyConstruct<::dapi::init::ClientBroadcast>(arena, *from._impl_.msg_.initbroadcast_);
} else {
_this->_impl_.msg_.initbroadcast_->MergeFrom(from._internal_initbroadcast());
}
break;
}
case kInitResponse: {
if (oneof_needs_init) {
_this->_impl_.msg_.initresponse_ =
::google::protobuf::MessageLite::CopyConstruct<::dapi::init::ServerResponse>(arena, *from._impl_.msg_.initresponse_);
} else {
_this->_impl_.msg_.initresponse_->MergeFrom(from._internal_initresponse());
}
break;
}
case kFrameUpdate: {
if (oneof_needs_init) {
_this->_impl_.msg_.frameupdate_ =
::google::protobuf::MessageLite::CopyConstruct<::dapi::game::FrameUpdate>(arena, *from._impl_.msg_.frameupdate_);
} else {
_this->_impl_.msg_.frameupdate_->MergeFrom(from._internal_frameupdate());
}
break;
}
case kCommand: {
if (oneof_needs_init) {
_this->_impl_.msg_.command_ =
::google::protobuf::MessageLite::CopyConstruct<::dapi::commands::Command>(arena, *from._impl_.msg_.command_);
} else {
_this->_impl_.msg_.command_->MergeFrom(from._internal_command());
}
break;
}
case kEndOfQueue: {
if (oneof_needs_init) {
_this->_impl_.msg_.endofqueue_ =
::google::protobuf::MessageLite::CopyConstruct<::dapi::message::EndofQueue>(arena, *from._impl_.msg_.endofqueue_);
} else {
_this->_impl_.msg_.endofqueue_->MergeFrom(from._internal_endofqueue());
}
break;
}
case MSG_NOT_SET:
break;
}
}
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void Message::CopyFrom(const Message& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:dapi.message.Message)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Message::InternalSwap(Message* PROTOBUF_RESTRICT other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_.msg_, other->_impl_.msg_);
swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]);
}
// @@protoc_insertion_point(namespace_scope)
} // namespace message
} // namespace dapi
namespace google {
namespace protobuf {
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"

924
Source/dapi/Backend/Messages/generated/message.pb.h

@ -1,924 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// NO CHECKED-IN PROTOBUF GENCODE
// source: message.proto
// Protobuf C++ Version: 5.29.3
#ifndef message_2eproto_2epb_2eh
#define message_2eproto_2epb_2eh
#include <limits>
#include <string>
#include <type_traits>
#include <utility>
#include "google/protobuf/runtime_version.h"
#if PROTOBUF_VERSION != 5029003
#error "Protobuf C++ gencode is built with an incompatible version of"
#error "Protobuf C++ headers/runtime. See"
#error "https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp"
#endif
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/generated_message_tctable_decl.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/metadata_lite.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/repeated_field.h" // IWYU pragma: export
#include "google/protobuf/extension_set.h" // IWYU pragma: export
#include "init.pb.h"
#include "game.pb.h"
#include "command.pb.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
#define PROTOBUF_INTERNAL_EXPORT_message_2eproto
namespace google {
namespace protobuf {
namespace internal {
template <typename T>
::absl::string_view GetAnyMessageName();
} // namespace internal
} // namespace protobuf
} // namespace google
// Internal implementation detail -- do not use these members.
struct TableStruct_message_2eproto {
static const ::uint32_t offsets[];
};
namespace dapi {
namespace message {
class EndofQueue;
struct EndofQueueDefaultTypeInternal;
extern EndofQueueDefaultTypeInternal _EndofQueue_default_instance_;
class Message;
struct MessageDefaultTypeInternal;
extern MessageDefaultTypeInternal _Message_default_instance_;
} // namespace message
} // namespace dapi
namespace google {
namespace protobuf {
} // namespace protobuf
} // namespace google
namespace dapi {
namespace message {
// ===================================================================
// -------------------------------------------------------------------
class EndofQueue final : public ::google::protobuf::MessageLite
/* @@protoc_insertion_point(class_definition:dapi.message.EndofQueue) */ {
public:
inline EndofQueue() : EndofQueue(nullptr) {}
~EndofQueue() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
void operator delete(EndofQueue* msg, std::destroying_delete_t) {
SharedDtor(*msg);
::google::protobuf::internal::SizedDelete(msg, sizeof(EndofQueue));
}
#endif
template <typename = void>
explicit PROTOBUF_CONSTEXPR EndofQueue(
::google::protobuf::internal::ConstantInitialized);
inline EndofQueue(const EndofQueue& from) : EndofQueue(nullptr, from) {}
inline EndofQueue(EndofQueue&& from) noexcept
: EndofQueue(nullptr, std::move(from)) {}
inline EndofQueue& operator=(const EndofQueue& from) {
CopyFrom(from);
return *this;
}
inline EndofQueue& operator=(EndofQueue&& from) noexcept {
if (this == &from) return *this;
if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const EndofQueue& default_instance() {
return *internal_default_instance();
}
static inline const EndofQueue* internal_default_instance() {
return reinterpret_cast<const EndofQueue*>(
&_EndofQueue_default_instance_);
}
static constexpr int kIndexInFileMessages = 0;
friend void swap(EndofQueue& a, EndofQueue& b) { a.Swap(&b); }
inline void Swap(EndofQueue* other) {
if (other == this) return;
if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) {
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(EndofQueue* other) {
if (other == this) return;
ABSL_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
EndofQueue* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::MessageLite::DefaultConstruct<EndofQueue>(arena);
}
void CopyFrom(const EndofQueue& from);
void MergeFrom(const EndofQueue& from) { EndofQueue::MergeImpl(*this, from); }
private:
static void MergeImpl(::google::protobuf::MessageLite& to_msg,
const ::google::protobuf::MessageLite& from_msg);
public:
bool IsInitialized() const {
return true;
}
ABSL_ATTRIBUTE_REINITIALIZES void Clear() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
private:
static ::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg);
static ::uint8_t* _InternalSerialize(
const MessageLite& msg, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream);
public:
::size_t ByteSizeLong() const { return ByteSizeLong(*this); }
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
return _InternalSerialize(*this, target, stream);
}
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ByteSizeLong() const final;
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const final;
#endif // PROTOBUF_CUSTOM_VTABLE
int GetCachedSize() const { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
static void SharedDtor(MessageLite& self);
void InternalSwap(EndofQueue* other);
private:
template <typename T>
friend ::absl::string_view(
::google::protobuf::internal::GetAnyMessageName)();
static ::absl::string_view FullMessageName() { return "dapi.message.EndofQueue"; }
protected:
explicit EndofQueue(::google::protobuf::Arena* arena);
EndofQueue(::google::protobuf::Arena* arena, const EndofQueue& from);
EndofQueue(::google::protobuf::Arena* arena, EndofQueue&& from) noexcept
: EndofQueue(arena) {
*this = ::std::move(from);
}
const ::google::protobuf::internal::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::internal::ClassDataLite<24> _class_data_;
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// @@protoc_insertion_point(class_scope:dapi.message.EndofQueue)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
0, 0, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
friend class ::google::protobuf::Arena;
template <typename T>
friend class ::google::protobuf::Arena::InternalHelper;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
struct Impl_ {
inline explicit constexpr Impl_(
::google::protobuf::internal::ConstantInitialized) noexcept;
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from,
const EndofQueue& from_msg);
::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
friend struct ::TableStruct_message_2eproto;
};
// -------------------------------------------------------------------
class Message final : public ::google::protobuf::MessageLite
/* @@protoc_insertion_point(class_definition:dapi.message.Message) */ {
public:
inline Message() : Message(nullptr) {}
~Message() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
void operator delete(Message* msg, std::destroying_delete_t) {
SharedDtor(*msg);
::google::protobuf::internal::SizedDelete(msg, sizeof(Message));
}
#endif
template <typename = void>
explicit PROTOBUF_CONSTEXPR Message(
::google::protobuf::internal::ConstantInitialized);
inline Message(const Message& from) : Message(nullptr, from) {}
inline Message(Message&& from) noexcept
: Message(nullptr, std::move(from)) {}
inline Message& operator=(const Message& from) {
CopyFrom(from);
return *this;
}
inline Message& operator=(Message&& from) noexcept {
if (this == &from) return *this;
if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.unknown_fields<std::string>(::google::protobuf::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const Message& default_instance() {
return *internal_default_instance();
}
enum MsgCase {
kInitBroadcast = 1,
kInitResponse = 2,
kFrameUpdate = 3,
kCommand = 4,
kEndOfQueue = 5,
MSG_NOT_SET = 0,
};
static inline const Message* internal_default_instance() {
return reinterpret_cast<const Message*>(
&_Message_default_instance_);
}
static constexpr int kIndexInFileMessages = 1;
friend void swap(Message& a, Message& b) { a.Swap(&b); }
inline void Swap(Message* other) {
if (other == this) return;
if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) {
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(Message* other) {
if (other == this) return;
ABSL_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
Message* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::MessageLite::DefaultConstruct<Message>(arena);
}
void CopyFrom(const Message& from);
void MergeFrom(const Message& from) { Message::MergeImpl(*this, from); }
private:
static void MergeImpl(::google::protobuf::MessageLite& to_msg,
const ::google::protobuf::MessageLite& from_msg);
public:
bool IsInitialized() const {
return true;
}
ABSL_ATTRIBUTE_REINITIALIZES void Clear() PROTOBUF_FINAL;
#if defined(PROTOBUF_CUSTOM_VTABLE)
private:
static ::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg);
static ::uint8_t* _InternalSerialize(
const MessageLite& msg, ::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream);
public:
::size_t ByteSizeLong() const { return ByteSizeLong(*this); }
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const {
return _InternalSerialize(*this, target, stream);
}
#else // PROTOBUF_CUSTOM_VTABLE
::size_t ByteSizeLong() const final;
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const final;
#endif // PROTOBUF_CUSTOM_VTABLE
int GetCachedSize() const { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
static void SharedDtor(MessageLite& self);
void InternalSwap(Message* other);
private:
template <typename T>
friend ::absl::string_view(
::google::protobuf::internal::GetAnyMessageName)();
static ::absl::string_view FullMessageName() { return "dapi.message.Message"; }
protected:
explicit Message(::google::protobuf::Arena* arena);
Message(::google::protobuf::Arena* arena, const Message& from);
Message(::google::protobuf::Arena* arena, Message&& from) noexcept
: Message(arena) {
*this = ::std::move(from);
}
const ::google::protobuf::internal::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::internal::ClassDataLite<21> _class_data_;
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kInitBroadcastFieldNumber = 1,
kInitResponseFieldNumber = 2,
kFrameUpdateFieldNumber = 3,
kCommandFieldNumber = 4,
kEndOfQueueFieldNumber = 5,
};
// .dapi.init.ClientBroadcast initBroadcast = 1;
bool has_initbroadcast() const;
private:
bool _internal_has_initbroadcast() const;
public:
void clear_initbroadcast() ;
const ::dapi::init::ClientBroadcast& initbroadcast() const;
PROTOBUF_NODISCARD ::dapi::init::ClientBroadcast* release_initbroadcast();
::dapi::init::ClientBroadcast* mutable_initbroadcast();
void set_allocated_initbroadcast(::dapi::init::ClientBroadcast* value);
void unsafe_arena_set_allocated_initbroadcast(::dapi::init::ClientBroadcast* value);
::dapi::init::ClientBroadcast* unsafe_arena_release_initbroadcast();
private:
const ::dapi::init::ClientBroadcast& _internal_initbroadcast() const;
::dapi::init::ClientBroadcast* _internal_mutable_initbroadcast();
public:
// .dapi.init.ServerResponse initResponse = 2;
bool has_initresponse() const;
private:
bool _internal_has_initresponse() const;
public:
void clear_initresponse() ;
const ::dapi::init::ServerResponse& initresponse() const;
PROTOBUF_NODISCARD ::dapi::init::ServerResponse* release_initresponse();
::dapi::init::ServerResponse* mutable_initresponse();
void set_allocated_initresponse(::dapi::init::ServerResponse* value);
void unsafe_arena_set_allocated_initresponse(::dapi::init::ServerResponse* value);
::dapi::init::ServerResponse* unsafe_arena_release_initresponse();
private:
const ::dapi::init::ServerResponse& _internal_initresponse() const;
::dapi::init::ServerResponse* _internal_mutable_initresponse();
public:
// .dapi.game.FrameUpdate frameUpdate = 3;
bool has_frameupdate() const;
private:
bool _internal_has_frameupdate() const;
public:
void clear_frameupdate() ;
const ::dapi::game::FrameUpdate& frameupdate() const;
PROTOBUF_NODISCARD ::dapi::game::FrameUpdate* release_frameupdate();
::dapi::game::FrameUpdate* mutable_frameupdate();
void set_allocated_frameupdate(::dapi::game::FrameUpdate* value);
void unsafe_arena_set_allocated_frameupdate(::dapi::game::FrameUpdate* value);
::dapi::game::FrameUpdate* unsafe_arena_release_frameupdate();
private:
const ::dapi::game::FrameUpdate& _internal_frameupdate() const;
::dapi::game::FrameUpdate* _internal_mutable_frameupdate();
public:
// .dapi.commands.Command command = 4;
bool has_command() const;
private:
bool _internal_has_command() const;
public:
void clear_command() ;
const ::dapi::commands::Command& command() const;
PROTOBUF_NODISCARD ::dapi::commands::Command* release_command();
::dapi::commands::Command* mutable_command();
void set_allocated_command(::dapi::commands::Command* value);
void unsafe_arena_set_allocated_command(::dapi::commands::Command* value);
::dapi::commands::Command* unsafe_arena_release_command();
private:
const ::dapi::commands::Command& _internal_command() const;
::dapi::commands::Command* _internal_mutable_command();
public:
// .dapi.message.EndofQueue endOfQueue = 5;
bool has_endofqueue() const;
private:
bool _internal_has_endofqueue() const;
public:
void clear_endofqueue() ;
const ::dapi::message::EndofQueue& endofqueue() const;
PROTOBUF_NODISCARD ::dapi::message::EndofQueue* release_endofqueue();
::dapi::message::EndofQueue* mutable_endofqueue();
void set_allocated_endofqueue(::dapi::message::EndofQueue* value);
void unsafe_arena_set_allocated_endofqueue(::dapi::message::EndofQueue* value);
::dapi::message::EndofQueue* unsafe_arena_release_endofqueue();
private:
const ::dapi::message::EndofQueue& _internal_endofqueue() const;
::dapi::message::EndofQueue* _internal_mutable_endofqueue();
public:
void clear_msg();
MsgCase msg_case() const;
// @@protoc_insertion_point(class_scope:dapi.message.Message)
private:
class _Internal;
void set_has_initbroadcast();
void set_has_initresponse();
void set_has_frameupdate();
void set_has_command();
void set_has_endofqueue();
inline bool has_msg() const;
inline void clear_has_msg();
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
0, 5, 5,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
friend class ::google::protobuf::Arena;
template <typename T>
friend class ::google::protobuf::Arena::InternalHelper;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
struct Impl_ {
inline explicit constexpr Impl_(
::google::protobuf::internal::ConstantInitialized) noexcept;
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from,
const Message& from_msg);
union MsgUnion {
constexpr MsgUnion() : _constinit_{} {}
::google::protobuf::internal::ConstantInitialized _constinit_;
::dapi::init::ClientBroadcast* initbroadcast_;
::dapi::init::ServerResponse* initresponse_;
::dapi::game::FrameUpdate* frameupdate_;
::dapi::commands::Command* command_;
::dapi::message::EndofQueue* endofqueue_;
} msg_;
::google::protobuf::internal::CachedSize _cached_size_;
::uint32_t _oneof_case_[1];
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
friend struct ::TableStruct_message_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// -------------------------------------------------------------------
// EndofQueue
// -------------------------------------------------------------------
// Message
// .dapi.init.ClientBroadcast initBroadcast = 1;
inline bool Message::has_initbroadcast() const {
return msg_case() == kInitBroadcast;
}
inline bool Message::_internal_has_initbroadcast() const {
return msg_case() == kInitBroadcast;
}
inline void Message::set_has_initbroadcast() {
_impl_._oneof_case_[0] = kInitBroadcast;
}
inline ::dapi::init::ClientBroadcast* Message::release_initbroadcast() {
// @@protoc_insertion_point(field_release:dapi.message.Message.initBroadcast)
if (msg_case() == kInitBroadcast) {
clear_has_msg();
auto* temp = _impl_.msg_.initbroadcast_;
if (GetArena() != nullptr) {
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp);
}
_impl_.msg_.initbroadcast_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline const ::dapi::init::ClientBroadcast& Message::_internal_initbroadcast() const {
return msg_case() == kInitBroadcast ? *_impl_.msg_.initbroadcast_ : reinterpret_cast<::dapi::init::ClientBroadcast&>(::dapi::init::_ClientBroadcast_default_instance_);
}
inline const ::dapi::init::ClientBroadcast& Message::initbroadcast() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:dapi.message.Message.initBroadcast)
return _internal_initbroadcast();
}
inline ::dapi::init::ClientBroadcast* Message::unsafe_arena_release_initbroadcast() {
// @@protoc_insertion_point(field_unsafe_arena_release:dapi.message.Message.initBroadcast)
if (msg_case() == kInitBroadcast) {
clear_has_msg();
auto* temp = _impl_.msg_.initbroadcast_;
_impl_.msg_.initbroadcast_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline void Message::unsafe_arena_set_allocated_initbroadcast(::dapi::init::ClientBroadcast* value) {
// We rely on the oneof clear method to free the earlier contents
// of this oneof. We can directly use the pointer we're given to
// set the new value.
clear_msg();
if (value) {
set_has_initbroadcast();
_impl_.msg_.initbroadcast_ = value;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:dapi.message.Message.initBroadcast)
}
inline ::dapi::init::ClientBroadcast* Message::_internal_mutable_initbroadcast() {
if (msg_case() != kInitBroadcast) {
clear_msg();
set_has_initbroadcast();
_impl_.msg_.initbroadcast_ =
::google::protobuf::MessageLite::DefaultConstruct<::dapi::init::ClientBroadcast>(GetArena());
}
return _impl_.msg_.initbroadcast_;
}
inline ::dapi::init::ClientBroadcast* Message::mutable_initbroadcast() ABSL_ATTRIBUTE_LIFETIME_BOUND {
::dapi::init::ClientBroadcast* _msg = _internal_mutable_initbroadcast();
// @@protoc_insertion_point(field_mutable:dapi.message.Message.initBroadcast)
return _msg;
}
// .dapi.init.ServerResponse initResponse = 2;
inline bool Message::has_initresponse() const {
return msg_case() == kInitResponse;
}
inline bool Message::_internal_has_initresponse() const {
return msg_case() == kInitResponse;
}
inline void Message::set_has_initresponse() {
_impl_._oneof_case_[0] = kInitResponse;
}
inline ::dapi::init::ServerResponse* Message::release_initresponse() {
// @@protoc_insertion_point(field_release:dapi.message.Message.initResponse)
if (msg_case() == kInitResponse) {
clear_has_msg();
auto* temp = _impl_.msg_.initresponse_;
if (GetArena() != nullptr) {
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp);
}
_impl_.msg_.initresponse_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline const ::dapi::init::ServerResponse& Message::_internal_initresponse() const {
return msg_case() == kInitResponse ? *_impl_.msg_.initresponse_ : reinterpret_cast<::dapi::init::ServerResponse&>(::dapi::init::_ServerResponse_default_instance_);
}
inline const ::dapi::init::ServerResponse& Message::initresponse() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:dapi.message.Message.initResponse)
return _internal_initresponse();
}
inline ::dapi::init::ServerResponse* Message::unsafe_arena_release_initresponse() {
// @@protoc_insertion_point(field_unsafe_arena_release:dapi.message.Message.initResponse)
if (msg_case() == kInitResponse) {
clear_has_msg();
auto* temp = _impl_.msg_.initresponse_;
_impl_.msg_.initresponse_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline void Message::unsafe_arena_set_allocated_initresponse(::dapi::init::ServerResponse* value) {
// We rely on the oneof clear method to free the earlier contents
// of this oneof. We can directly use the pointer we're given to
// set the new value.
clear_msg();
if (value) {
set_has_initresponse();
_impl_.msg_.initresponse_ = value;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:dapi.message.Message.initResponse)
}
inline ::dapi::init::ServerResponse* Message::_internal_mutable_initresponse() {
if (msg_case() != kInitResponse) {
clear_msg();
set_has_initresponse();
_impl_.msg_.initresponse_ =
::google::protobuf::MessageLite::DefaultConstruct<::dapi::init::ServerResponse>(GetArena());
}
return _impl_.msg_.initresponse_;
}
inline ::dapi::init::ServerResponse* Message::mutable_initresponse() ABSL_ATTRIBUTE_LIFETIME_BOUND {
::dapi::init::ServerResponse* _msg = _internal_mutable_initresponse();
// @@protoc_insertion_point(field_mutable:dapi.message.Message.initResponse)
return _msg;
}
// .dapi.game.FrameUpdate frameUpdate = 3;
inline bool Message::has_frameupdate() const {
return msg_case() == kFrameUpdate;
}
inline bool Message::_internal_has_frameupdate() const {
return msg_case() == kFrameUpdate;
}
inline void Message::set_has_frameupdate() {
_impl_._oneof_case_[0] = kFrameUpdate;
}
inline ::dapi::game::FrameUpdate* Message::release_frameupdate() {
// @@protoc_insertion_point(field_release:dapi.message.Message.frameUpdate)
if (msg_case() == kFrameUpdate) {
clear_has_msg();
auto* temp = _impl_.msg_.frameupdate_;
if (GetArena() != nullptr) {
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp);
}
_impl_.msg_.frameupdate_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline const ::dapi::game::FrameUpdate& Message::_internal_frameupdate() const {
return msg_case() == kFrameUpdate ? *_impl_.msg_.frameupdate_ : reinterpret_cast<::dapi::game::FrameUpdate&>(::dapi::game::_FrameUpdate_default_instance_);
}
inline const ::dapi::game::FrameUpdate& Message::frameupdate() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:dapi.message.Message.frameUpdate)
return _internal_frameupdate();
}
inline ::dapi::game::FrameUpdate* Message::unsafe_arena_release_frameupdate() {
// @@protoc_insertion_point(field_unsafe_arena_release:dapi.message.Message.frameUpdate)
if (msg_case() == kFrameUpdate) {
clear_has_msg();
auto* temp = _impl_.msg_.frameupdate_;
_impl_.msg_.frameupdate_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline void Message::unsafe_arena_set_allocated_frameupdate(::dapi::game::FrameUpdate* value) {
// We rely on the oneof clear method to free the earlier contents
// of this oneof. We can directly use the pointer we're given to
// set the new value.
clear_msg();
if (value) {
set_has_frameupdate();
_impl_.msg_.frameupdate_ = value;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:dapi.message.Message.frameUpdate)
}
inline ::dapi::game::FrameUpdate* Message::_internal_mutable_frameupdate() {
if (msg_case() != kFrameUpdate) {
clear_msg();
set_has_frameupdate();
_impl_.msg_.frameupdate_ =
::google::protobuf::MessageLite::DefaultConstruct<::dapi::game::FrameUpdate>(GetArena());
}
return _impl_.msg_.frameupdate_;
}
inline ::dapi::game::FrameUpdate* Message::mutable_frameupdate() ABSL_ATTRIBUTE_LIFETIME_BOUND {
::dapi::game::FrameUpdate* _msg = _internal_mutable_frameupdate();
// @@protoc_insertion_point(field_mutable:dapi.message.Message.frameUpdate)
return _msg;
}
// .dapi.commands.Command command = 4;
inline bool Message::has_command() const {
return msg_case() == kCommand;
}
inline bool Message::_internal_has_command() const {
return msg_case() == kCommand;
}
inline void Message::set_has_command() {
_impl_._oneof_case_[0] = kCommand;
}
inline ::dapi::commands::Command* Message::release_command() {
// @@protoc_insertion_point(field_release:dapi.message.Message.command)
if (msg_case() == kCommand) {
clear_has_msg();
auto* temp = _impl_.msg_.command_;
if (GetArena() != nullptr) {
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp);
}
_impl_.msg_.command_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline const ::dapi::commands::Command& Message::_internal_command() const {
return msg_case() == kCommand ? *_impl_.msg_.command_ : reinterpret_cast<::dapi::commands::Command&>(::dapi::commands::_Command_default_instance_);
}
inline const ::dapi::commands::Command& Message::command() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:dapi.message.Message.command)
return _internal_command();
}
inline ::dapi::commands::Command* Message::unsafe_arena_release_command() {
// @@protoc_insertion_point(field_unsafe_arena_release:dapi.message.Message.command)
if (msg_case() == kCommand) {
clear_has_msg();
auto* temp = _impl_.msg_.command_;
_impl_.msg_.command_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline void Message::unsafe_arena_set_allocated_command(::dapi::commands::Command* value) {
// We rely on the oneof clear method to free the earlier contents
// of this oneof. We can directly use the pointer we're given to
// set the new value.
clear_msg();
if (value) {
set_has_command();
_impl_.msg_.command_ = value;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:dapi.message.Message.command)
}
inline ::dapi::commands::Command* Message::_internal_mutable_command() {
if (msg_case() != kCommand) {
clear_msg();
set_has_command();
_impl_.msg_.command_ =
::google::protobuf::MessageLite::DefaultConstruct<::dapi::commands::Command>(GetArena());
}
return _impl_.msg_.command_;
}
inline ::dapi::commands::Command* Message::mutable_command() ABSL_ATTRIBUTE_LIFETIME_BOUND {
::dapi::commands::Command* _msg = _internal_mutable_command();
// @@protoc_insertion_point(field_mutable:dapi.message.Message.command)
return _msg;
}
// .dapi.message.EndofQueue endOfQueue = 5;
inline bool Message::has_endofqueue() const {
return msg_case() == kEndOfQueue;
}
inline bool Message::_internal_has_endofqueue() const {
return msg_case() == kEndOfQueue;
}
inline void Message::set_has_endofqueue() {
_impl_._oneof_case_[0] = kEndOfQueue;
}
inline void Message::clear_endofqueue() {
::google::protobuf::internal::TSanWrite(&_impl_);
if (msg_case() == kEndOfQueue) {
if (GetArena() == nullptr) {
delete _impl_.msg_.endofqueue_;
} else if (::google::protobuf::internal::DebugHardenClearOneofMessageOnArena()) {
if (_impl_.msg_.endofqueue_ != nullptr) {
_impl_.msg_.endofqueue_->Clear();
}
}
clear_has_msg();
}
}
inline ::dapi::message::EndofQueue* Message::release_endofqueue() {
// @@protoc_insertion_point(field_release:dapi.message.Message.endOfQueue)
if (msg_case() == kEndOfQueue) {
clear_has_msg();
auto* temp = _impl_.msg_.endofqueue_;
if (GetArena() != nullptr) {
temp = ::google::protobuf::internal::DuplicateIfNonNull(temp);
}
_impl_.msg_.endofqueue_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline const ::dapi::message::EndofQueue& Message::_internal_endofqueue() const {
return msg_case() == kEndOfQueue ? *_impl_.msg_.endofqueue_ : reinterpret_cast<::dapi::message::EndofQueue&>(::dapi::message::_EndofQueue_default_instance_);
}
inline const ::dapi::message::EndofQueue& Message::endofqueue() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:dapi.message.Message.endOfQueue)
return _internal_endofqueue();
}
inline ::dapi::message::EndofQueue* Message::unsafe_arena_release_endofqueue() {
// @@protoc_insertion_point(field_unsafe_arena_release:dapi.message.Message.endOfQueue)
if (msg_case() == kEndOfQueue) {
clear_has_msg();
auto* temp = _impl_.msg_.endofqueue_;
_impl_.msg_.endofqueue_ = nullptr;
return temp;
} else {
return nullptr;
}
}
inline void Message::unsafe_arena_set_allocated_endofqueue(::dapi::message::EndofQueue* value) {
// We rely on the oneof clear method to free the earlier contents
// of this oneof. We can directly use the pointer we're given to
// set the new value.
clear_msg();
if (value) {
set_has_endofqueue();
_impl_.msg_.endofqueue_ = value;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:dapi.message.Message.endOfQueue)
}
inline ::dapi::message::EndofQueue* Message::_internal_mutable_endofqueue() {
if (msg_case() != kEndOfQueue) {
clear_msg();
set_has_endofqueue();
_impl_.msg_.endofqueue_ =
::google::protobuf::MessageLite::DefaultConstruct<::dapi::message::EndofQueue>(GetArena());
}
return _impl_.msg_.endofqueue_;
}
inline ::dapi::message::EndofQueue* Message::mutable_endofqueue() ABSL_ATTRIBUTE_LIFETIME_BOUND {
::dapi::message::EndofQueue* _msg = _internal_mutable_endofqueue();
// @@protoc_insertion_point(field_mutable:dapi.message.Message.endOfQueue)
return _msg;
}
inline bool Message::has_msg() const {
return msg_case() != MSG_NOT_SET;
}
inline void Message::clear_has_msg() {
_impl_._oneof_case_[0] = MSG_NOT_SET;
}
inline Message::MsgCase Message::msg_case() const {
return Message::MsgCase(_impl_._oneof_case_[0]);
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace message
} // namespace dapi
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"
#endif // message_2eproto_2epb_2eh

5
Source/dapi/Item.h

@ -1,5 +1,4 @@
#pragma once
#include <Windows.h>
#include "../items.h"
@ -18,7 +17,7 @@ struct ItemData {
int _ix;
int _iy;
BOOL _iIdentified;
uint32_t _iIdentified;
char _iMagical;
char _iName[64];
char _iIName[64];
@ -66,7 +65,7 @@ struct ItemData {
char _iMinStr;
char _iMinMag;
char _iMinDex;
BOOL _iStatFlag;
uint32_t _iStatFlag;
int IDidx;
};
} // namespace DAPI

6
Source/dapi/Player.h

@ -21,9 +21,9 @@ struct PlayerData {
char _pRSplType;
char _pSplLvl[64];
unsigned __int64 _pMemSpells;
unsigned __int64 _pAblSpells;
unsigned __int64 _pScrlSpells;
uint64_t _pMemSpells;
uint64_t _pAblSpells;
uint64_t _pScrlSpells;
char _pName[32];
char _pClass;

30
Source/dapi/Server.cpp

@ -1,3 +1,5 @@
#include <thread>
#include "Server.h"
@ -239,9 +241,9 @@ void Server::updateGameData()
data->itemList[itemID]._iIdentified = item->_iIdentified;
data->itemList[itemID]._iMagical = item->_iMagical;
strcpy_s(data->itemList[itemID]._iName, item->_iName);
strcpy(data->itemList[itemID]._iName, item->_iName);
if (data->itemList[itemID]._iIdentified) {
strcpy_s(data->itemList[itemID]._iIName, item->_iIName);
strcpy(data->itemList[itemID]._iIName, item->_iIName);
data->itemList[itemID]._iFlags = static_cast<int>(item->_iFlags);
data->itemList[itemID]._iPrePower = item->_iPrePower;
@ -267,7 +269,7 @@ void Server::updateGameData()
data->itemList[itemID]._iLMinDam = item->_iLMinDam;
data->itemList[itemID]._iLMaxDam = item->_iLMaxDam;
} else {
strcpy_s(data->itemList[itemID]._iName, item->_iName);
strcpy(data->itemList[itemID]._iName, item->_iName);
data->itemList[itemID]._iFlags = -1;
data->itemList[itemID]._iPrePower = -1;
@ -330,11 +332,11 @@ void Server::updateGameData()
data->itemList[itemID]._iIdentified = item->_iIdentified;
data->itemList[itemID]._iMagical = item->_iMagical;
strcpy_s(data->itemList[itemID]._iName, item->_iName);
strcpy(data->itemList[itemID]._iName, item->_iName);
if (data->itemList[itemID]._iIdentified)
strcpy_s(data->itemList[itemID]._iIName, item->_iIName);
strcpy(data->itemList[itemID]._iIName, item->_iIName);
else
strcpy_s(data->itemList[itemID]._iName, item->_iName);
strcpy(data->itemList[itemID]._iName, item->_iName);
data->itemList[itemID]._iFlags = -1;
data->itemList[itemID]._iPrePower = -1;
data->itemList[itemID]._iSufPower = -1;
@ -901,8 +903,8 @@ void Server::updateGameData()
data->itemList[itemID]._iIdentified = -1;
data->itemList[itemID]._iMagical = -1;
strcpy_s(data->itemList[itemID]._iName, "");
strcpy_s(data->itemList[itemID]._iIName, "");
strcpy(data->itemList[itemID]._iName, "");
strcpy(data->itemList[itemID]._iIName, "");
data->itemList[itemID]._iFlags = -1;
data->itemList[itemID]._iPrePower = -1;
data->itemList[itemID]._iSufPower = -1;
@ -1052,7 +1054,7 @@ void Server::updateGameData()
if (devilution::currlevel != 0) {
for (auto &townerData : data->townerList) {
strcpy_s(townerData._tName, "");
strcpy(townerData._tName, "");
townerData._tx = -1;
townerData._ty = -1;
}
@ -1077,12 +1079,12 @@ void Server::updateGameData()
memcpy(data->townerList[townerID]._tName, devilution::Towners[i].name.data(), devilution::Towners[i].name.size());
data->townerList[townerID]._tName[devilution::Towners[i].name.size()] = '\0';
}
// strcpy_s(data->townerList[townerID]._tName, devilution::Towners[i].name); old code but with devilution subbed in for reference.
// strcpy(data->townerList[townerID]._tName, devilution::Towners[i].name); old code but with devilution subbed in for reference.
} else {
data->townerList[townerID]._ttype = static_cast<devilution::_talker_id>(devilution::Towners[i]._ttype);
data->townerList[townerID]._tx = -1;
data->townerList[townerID]._ty = -1;
strcpy_s(data->townerList[townerID]._tName, "");
strcpy(data->townerList[townerID]._tName, "");
}
}
}
@ -1237,7 +1239,7 @@ void Server::updateGameData()
m->set_sy(-1);
}
};
if (devilution::Players[devilution::MyPlayerId].plrlevel != 0) {
for (int i = 0; i < devilution::ActiveObjectCount; i++) {
if (isOnScreen(devilution::Objects[devilution::ActiveObjects[i]].position.x, devilution::Objects[devilution::ActiveObjects[i]].position.y) && devilution::dObject[devilution::Objects[devilution::ActiveObjects[i]].position.x][devilution::Objects[devilution::ActiveObjects[i]].position.y] == devilution::ActiveObjects[i] + 1) {
@ -1458,7 +1460,7 @@ void Server::buyItem(int itemID)
devilution::OldTextLine = devilution::CurrentTextLine;
devilution::OldScrollPos = devilution::ScrollPos;
devilution::OldActiveStore = devilution::ActiveStore;
if (!devilution::PlayerCanAfford(devilution::WitchItems[idx]._iIvalue)) {
devilution::StartStore(devilution::TalkID::NoMoney);
@ -2308,7 +2310,7 @@ void Server::cancelQText()
if (!data->qtextflag)
return;
devilution::qtextflag = FALSE;
devilution::qtextflag = false;
data->qtextflag = false;
devilution::stream_stop();
}

3
vcpkg.json

@ -5,7 +5,8 @@
"fmt",
"bzip2",
"lua",
"protobuf"
"protobuf",
"sfml"
],
"builtin-baseline": "533a5fda5c0646d1771345fb572e759283444d5f",
"features": {

Loading…
Cancel
Save