Skip to content

Commit

Permalink
Merge pull request #25 from Gramps/main
Browse files Browse the repository at this point in the history
Some Minor Tweaks
  • Loading branch information
scriptsengineer authored Sep 26, 2024
2 parents ce539a8 + 406d11d commit 716956a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 1 addition & 3 deletions steam-multiplayer-peer/steam_packet_peer.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
21 changes: 17 additions & 4 deletions steam-multiplayer-peer/steam_packet_peer.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
#ifndef STEAM_PACKET_PEER_H
#define STEAM_PACKET_PEER_H


#include "steam/steam_api.h"
#include <godot_cpp/classes/os.hpp>
#include <godot_cpp/classes/ref_counted.hpp>


#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
1 change: 1 addition & 0 deletions steam-multiplayer-peer/steam_peer_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion steam-multiplayer-peer/steam_peer_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STEAM_PEER_CONFIG
#define STEAM_PEER_CONFIG

#include "steam/steam_api.h"
#include "steam/steam_api_flat.h"
#include <godot_cpp/classes/os.hpp>
#include <godot_cpp/classes/ref_counted.hpp>

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 716956a

Please sign in to comment.