From 4ec8e67d9b00c35652693a92db036e8cabd5d9e3 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 30 Apr 2023 01:24:45 +0200 Subject: [PATCH] CNetChan: Getters improvements * Allow for requesting address base only. * Added new getter 'GetPort'. --- r5dev/engine/net_chan.cpp | 13 +++++++++++-- r5dev/engine/net_chan.h | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index 59fef3a9..b084b4e1 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -28,9 +28,18 @@ const char* CNetChan::GetName(void) const // Purpose: gets the netchannel address // Output : const char* //----------------------------------------------------------------------------- -const char* CNetChan::GetAddress(void) const +const char* CNetChan::GetAddress(bool onlyBase) const { - return this->remote_address.ToString(); + return this->remote_address.ToString(onlyBase); +} + +//----------------------------------------------------------------------------- +// Purpose: gets the netchannel port in host byte order +// Output : int +//----------------------------------------------------------------------------- +int CNetChan::GetPort(void) const +{ + return int(ntohs(this->remote_address.GetPort())); } //----------------------------------------------------------------------------- diff --git a/r5dev/engine/net_chan.h b/r5dev/engine/net_chan.h index ea110911..430ffe4d 100644 --- a/r5dev/engine/net_chan.h +++ b/r5dev/engine/net_chan.h @@ -81,7 +81,8 @@ class CNetChan { public: const char* GetName(void) const; - const char* GetAddress(void) const; + const char* GetAddress(bool onlyBase = false) const; + int GetPort(void) const; int GetDataRate(void) const; int GetBufferSize(void) const;