diff --git a/steam-multiplayer-peer/steam_packet_peer.cpp b/steam-multiplayer-peer/steam_packet_peer.cpp index f674258..aa7d01f 100644 --- a/steam-multiplayer-peer/steam_packet_peer.cpp +++ b/steam-multiplayer-peer/steam_packet_peer.cpp @@ -1,10 +1,8 @@ #include "steam_packet_peer.h" -void SteamPacketPeer::_bind_methods() { -} SteamPacketPeer::SteamPacketPeer(const void *p_buffer, uint32_t p_buffer_size, int transferMode) { - ERR_FAIL_COND_MSG(p_buffer_size > MAX_STEAM_PACKET_SIZE, "Error: Tried to send a packet larger than MAX_STEAM_PACKET_SIZE"); + ERR_FAIL_COND_MSG(p_buffer_size > MAX_STEAM_PACKET_SIZE, "Error: Tried to send a packet larger than MAX_STEAM_PACKET_SIZE: %d", p_buffer_size); memcpy(this->data, p_buffer, p_buffer_size); this->size = p_buffer_size; this->transfer_mode = transferMode; diff --git a/steam-multiplayer-peer/steam_packet_peer.h b/steam-multiplayer-peer/steam_packet_peer.h index a73b5aa..6cd32c6 100644 --- a/steam-multiplayer-peer/steam_packet_peer.h +++ b/steam-multiplayer-peer/steam_packet_peer.h @@ -1,27 +1,40 @@ #ifndef STEAM_PACKET_PEER_H #define STEAM_PACKET_PEER_H + #include "steam/steam_api.h" #include #include + #define MAX_STEAM_PACKET_SIZE k_cbMaxSteamNetworkingSocketsMessageSizeSend + using namespace godot; class SteamPacketPeer : public RefCounted { GDCLASS(SteamPacketPeer, RefCounted) + public: + enum SteamNetworkingSend { + SEND_UNRELIABLE = k_nSteamNetworkingSend_Unreliable, + SEND_NO_NAGLE = k_nSteamNetworkingSend_NoNagle, + SEND_URELIABLE_NO_NAGLE = k_nSteamNetworkingSend_UnreliableNoNagle, + SEND_NO_DELAY = k_nSteamNetworkingSend_NoDelay, + SEND_UNRELIABLE_NO_DELAY = k_nSteamNetworkingSend_UnreliableNoDelay, + SEND_RELIABLE = k_nSteamNetworkingSend_Reliable, + SEND_RELIABLE_NO_NAGLE = k_nSteamNetworkingSend_ReliableNoNagle, + SEND_USE_CURRENT_THREAD = k_nSteamNetworkingSend_UseCurrentThread, + SEND_AUTORESTART_BROKEN_SESSION = k_nSteamNetworkingSend_AutoRestartBrokenSession + } + uint8_t data[MAX_STEAM_PACKET_SIZE]; uint32_t size = 0; uint64_t sender; - int transfer_mode = k_nSteamNetworkingSend_Reliable; //Looks like a spot that might be served by an enum, eventually. + int transfer_mode = SteamNetworkingSend.SEND_RELIABLE; SteamPacketPeer() {} SteamPacketPeer(const void *p_buffer, uint32_t p_buffer_size, int transferMode); -protected: - static void _bind_methods(); -}; #endif // STEAM_PACKET_PEER_H \ No newline at end of file diff --git a/steam-multiplayer-peer/steam_peer_config.cpp b/steam-multiplayer-peer/steam_peer_config.cpp index 80455f4..8cf9e48 100644 --- a/steam-multiplayer-peer/steam_peer_config.cpp +++ b/steam-multiplayer-peer/steam_peer_config.cpp @@ -13,6 +13,7 @@ int SteamPeerConfig::size() const { SteamNetworkingConfigValue_t *SteamPeerConfig::get_convert_options() const { int options_size = options.size(); SteamNetworkingConfigValue_t *option_array = new SteamNetworkingConfigValue_t[options_size]; + if (options_size > 0) { for (int i = 0; i < options_size; i++) { SteamNetworkingConfigValue_t this_option; diff --git a/steam-multiplayer-peer/steam_peer_config.h b/steam-multiplayer-peer/steam_peer_config.h index 0826ca2..67f4122 100644 --- a/steam-multiplayer-peer/steam_peer_config.h +++ b/steam-multiplayer-peer/steam_peer_config.h @@ -1,7 +1,7 @@ #ifndef STEAM_PEER_CONFIG #define STEAM_PEER_CONFIG -#include "steam/steam_api.h" +#include "steam/steam_api_flat.h" #include #include @@ -88,7 +88,9 @@ class SteamPeerConfig : public RefCounted { NETWORKING_CONFIG_ECN = k_ESteamNetworkingConfig_ECN, NETWORKING_CONFIG_VALUE_FORCE32BIT = k_ESteamNetworkingConfigValue__Force32Bit }; + SteamPeerConfig() {} + Dictionary get_options() const; int size() const; SteamNetworkingConfigValue_t *get_convert_options() const;