From cbe46e1d3df1a72c9a7c7967772469937a9fa79f Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Wed, 14 Feb 2024 23:05:11 +0800 Subject: [PATCH] [raknet] Change `RakPeer::vftable_20()` to `RakPeer::Connect(...)` --- raknet/RakPeer.cpp | 21 ++++++++++++++++++++- raknet/RakPeer.h | 14 +++++++++++++- raknet/RakPeerInterface.h | 14 +++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/raknet/RakPeer.cpp b/raknet/RakPeer.cpp index defb5bc..4f71227 100644 --- a/raknet/RakPeer.cpp +++ b/raknet/RakPeer.cpp @@ -96,9 +96,28 @@ void RakPeer::GetIncomingPassword( char* passwordData, int *passwordDataLength memcpy(passwordData, incomingPassword, *passwordDataLength); } -void RakPeer::vftable_20() +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Description: +// Call this to connect to the specified host (ip or domain name) and server port. +// Calling Connect and not calling SetMaximumIncomingConnections acts as a dedicated client. Calling both acts as a true peer. +// This is a non-blocking connection. You know the connection is successful when IsConnected() returns true +// or receive gets a packet with the type identifier ID_CONNECTION_ACCEPTED. If the connection is not +// successful, such as rejected connection or no response then neither of these things will happen. +// Requires that you first call Initialize +// +// Parameters: +// host: Either a dotted IP address or a domain name +// remotePort: Which port to connect to on the remote machine. +// passwordData: A data block that must match the data block on the server. This can be just a password, or can be a stream of data +// passwordDataLength: The length in bytes of passwordData +// +// Returns: +// True on successful initiation. False on incorrect parameters, internal error, or too many existing peers +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +bool RakPeer::Connect( const char* host, unsigned short remotePort, char* passwordData, int passwordDataLength ) { // TODO: RakPeer::vftable_20() (saco W: 10040550) (server W: 457B00 L: 806D230) (bot W: 40B2C0 L: 807306A) + return false; } // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/raknet/RakPeer.h b/raknet/RakPeer.h index 25dd6b4..eafe66b 100644 --- a/raknet/RakPeer.h +++ b/raknet/RakPeer.h @@ -18,7 +18,6 @@ public: void vftable_4(); void vftable_8(); void vftable_C(); - void vftable_20(); /// Sets how many incoming connections are allowed. If this is less than the number of players currently connected, /// no more players will be allowed to connect. If this is greater than the maximum number of peers allowed, @@ -41,6 +40,19 @@ public: /// \param[in,out] passwordDataLength Maximum size of the array passwordData. Modified to hold the number of bytes actually written void GetIncomingPassword( char* passwordData, int *passwordDataLength ); + /// \brief Connect to the specified host (ip or domain name) and server port. + /// Calling Connect and not calling SetMaximumIncomingConnections acts as a dedicated client. + /// Calling both acts as a true peer. This is a non-blocking connection. + /// You know the connection is successful when IsConnected() returns true or Receive() gets a message with the type identifier ID_CONNECTION_ACCEPTED. + /// If the connection is not successful, such as a rejected connection or no response then neither of these things will happen. + /// \pre Requires that you first call Initialize + /// \param[in] host Either a dotted IP address or a domain name + /// \param[in] remotePort Which port to connect to on the remote machine. + /// \param[in] passwordData A data block that must match the data block on the server passed to SetIncomingPassword. This can be a string or can be a stream of data. Use 0 for no password. + /// \param[in] passwordDataLength The length in bytes of passwordData + /// \return True on successful initiation. False on incorrect parameters, internal error, or too many existing peers. Returning true does not mean you connected! + bool Connect( const char* host, unsigned short remotePort, char* passwordData, int passwordDataLength ); + /// \brief Stops the network threads and closes all connections. /// \param[in] blockDuration How long you should wait for all remaining messages to go out, including ID_DISCONNECTION_NOTIFICATION. If 0, it doesn't wait at all. /// \param[in] orderingChannel If blockDuration > 0, ID_DISCONNECTION_NOTIFICATION will be sent on this channel diff --git a/raknet/RakPeerInterface.h b/raknet/RakPeerInterface.h index c3421e9..ad9c621 100644 --- a/raknet/RakPeerInterface.h +++ b/raknet/RakPeerInterface.h @@ -14,7 +14,6 @@ public: virtual void vftable_4()=0; virtual void vftable_8()=0; virtual void vftable_C()=0; - virtual void vftable_20()=0; /// Sets how many incoming connections are allowed. If this is less than the number of players currently connected, /// no more players will be allowed to connect. If this is greater than the maximum number of peers allowed, @@ -37,6 +36,19 @@ public: /// \param[in,out] passwordDataLength Maximum size of the array passwordData. Modified to hold the number of bytes actually written virtual void GetIncomingPassword( char* passwordData, int *passwordDataLength )=0; + /// \brief Connect to the specified host (ip or domain name) and server port. + /// Calling Connect and not calling SetMaximumIncomingConnections acts as a dedicated client. + /// Calling both acts as a true peer. This is a non-blocking connection. + /// You know the connection is successful when IsConnected() returns true or Receive() gets a message with the type identifier ID_CONNECTION_ACCEPTED. + /// If the connection is not successful, such as a rejected connection or no response then neither of these things will happen. + /// \pre Requires that you first call Initialize + /// \param[in] host Either a dotted IP address or a domain name + /// \param[in] remotePort Which port to connect to on the remote machine. + /// \param[in] passwordData A data block that must match the data block on the server passed to SetIncomingPassword. This can be a string or can be a stream of data. Use 0 for no password. + /// \param[in] passwordDataLength The length in bytes of passwordData + /// \return True on successful initiation. False on incorrect parameters, internal error, or too many existing peers. Returning true does not mean you connected! + virtual bool Connect( const char* host, unsigned short remotePort, char* passwordData, int passwordDataLength )=0; + /// \brief Stops the network threads and closes all connections. /// \param[in] blockDuration How long you should wait for all remaining messages to go out, including ID_DISCONNECTION_NOTIFICATION. If 0, it doesn't wait at all. /// \param[in] orderingChannel If blockDuration > 0, ID_DISCONNECTION_NOTIFICATION will be sent on this channel