From 41f0f1f538049f70b849df0b3ec57969903403d5 Mon Sep 17 00:00:00 2001 From: Angad <66992519+ThirdEyeSqueegee@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:10:02 -0700 Subject: [PATCH] chore: cleanup --- CommonLibSF/include/RE/B/BSLog.h | 7 +- CommonLibSF/include/RE/B/BSSystemFile.h | 7 +- CommonLibSF/include/RE/E/ErrorLogger.h | 72 +++++++++---------- .../include/RE/I/ICachedErrorMessage.h | 22 +++--- .../include/RE/I/ISavePatcherInterface.h | 28 ++++---- CommonLibSF/include/RE/I/IVMDebugInterface.h | 28 ++++---- .../include/RE/I/IVMFunctionMessageDispatch.h | 2 +- .../include/RE/I/IVMRemoteDebuggerInterface.h | 23 +++--- .../include/RE/I/IVMSaveLoadInterface.h | 3 +- CommonLibSF/include/RE/I/IVirtualMachine.h | 5 +- CommonLibSF/include/RE/I/idLogging.h | 8 ++- CommonLibSF/include/RE/I/idTCP.h | 3 +- CommonLibSF/include/RE/L/Logger.h | 6 +- CommonLibSF/include/RE/S/SavePatcher.h | 5 +- CommonLibSF/include/SFSE/Impl/WinAPI.h | 5 ++ CommonLibSF/src/RE/B/BSLog.cpp | 13 ++-- CommonLibSF/src/RE/B/BSSystemFile.cpp | 20 +++--- CommonLibSF/src/RE/I/idLogging.cpp | 2 +- CommonLibSF/src/RE/I/idTCP.cpp | 17 ++--- 19 files changed, 137 insertions(+), 139 deletions(-) diff --git a/CommonLibSF/include/RE/B/BSLog.h b/CommonLibSF/include/RE/B/BSLog.h index 9388096e..128c8d9f 100644 --- a/CommonLibSF/include/RE/B/BSLog.h +++ b/CommonLibSF/include/RE/B/BSLog.h @@ -1,4 +1,5 @@ #pragma once + #include "RE/B/BSFixedString.h" #include "RE/B/BSLock.h" #include "RE/B/BSSystemFile.h" @@ -8,9 +9,12 @@ namespace RE class BSLog { ~BSLog(); + BSLog() = delete; + BSLog(const BSLog&) = delete; BSLog(BSLog&&) = delete; + BSLog( const char* a_logName, const char* a_logFolderPath, @@ -36,6 +40,7 @@ namespace RE std::uint32_t a_logNumber, std::uint32_t a_bufferSize, std::uint32_t a_blocks_allocated); + void dtor(); public: @@ -62,4 +67,4 @@ namespace RE std::byte unk248[0x38]; // 248 }; static_assert(sizeof(BSLog) == 0x280); -} \ No newline at end of file +} diff --git a/CommonLibSF/include/RE/B/BSSystemFile.h b/CommonLibSF/include/RE/B/BSSystemFile.h index 9c6b45ea..fdd5b04b 100644 --- a/CommonLibSF/include/RE/B/BSSystemFile.h +++ b/CommonLibSF/include/RE/B/BSSystemFile.h @@ -15,12 +15,14 @@ namespace RE kAccessDenied = 5, kOtherFileError = 6 }; + enum class AccessMode : std::uint32_t { kRead = 0, kReadWrite = 1, kWriteOnly = 2 }; + enum class OpenMode : std::uint32_t { kOpenExisting = 0, @@ -29,6 +31,7 @@ namespace RE kTruncateExisting = 3, kCreateIfNotExist = 4 }; + enum class ShareMode : std::uint32_t { kExclusive = 0, @@ -43,9 +46,11 @@ namespace RE kCurrent = 1, kEnd = 2 }; + + BSSystemFile(); ~BSSystemFile(); - BSSystemFile(); + BSSystemFile( const char* a_path, AccessMode a_accessMode, diff --git a/CommonLibSF/include/RE/E/ErrorLogger.h b/CommonLibSF/include/RE/E/ErrorLogger.h index c6d166e2..fa7f79f8 100644 --- a/CommonLibSF/include/RE/E/ErrorLogger.h +++ b/CommonLibSF/include/RE/E/ErrorLogger.h @@ -5,50 +5,46 @@ #include "RE/B/BSTEvent.h" #include "RE/I/ICachedErrorMessage.h" -namespace RE +namespace RE::BSScript { - namespace BSScript + class ICachedErrorMessage; + + struct LogEvent; + + class __declspec(novtable) ErrorLogger : + public BSTEventSource // 08 { - class ICachedErrorMessage; + public: + SF_RTTI_VTABLE(BSScript__ErrorLogger); - struct LogEvent; + enum class Severity + { + kInfo, + kWarning, + kError, + kFatal + }; - class __declspec(novtable) ErrorLogger : - public BSTEventSource // 08 + struct PerThreadErrorCounts { public: - static constexpr auto RTTI{ RTTI::BSScript__ErrorLogger }; - static constexpr auto VTABLE{ VTABLE::BSScript__ErrorLogger }; - - enum class Severity - { - kInfo, - kWarning, - kError, - kFatal - }; - - struct PerThreadErrorCounts - { - public: - // members - std::uint32_t fatalCount; // 0 - std::uint32_t errorCount; // 4 - std::uint32_t warningCount; // 8 - }; - static_assert(sizeof(PerThreadErrorCounts) == 0xC); - - virtual ~ErrorLogger(); // 00 - - // add - virtual void PostErrorImpl(const ICachedErrorMessage* a_errMsg, Severity a_severity) = 0; // 01 - virtual void ResetImpl() { return; } // 02 - // members - const BSFixedString logName; // 28 - BSSpinLock dataLock; // 30 - /*BSTHashMap*/ std::byte threadErrors[0x38]; // 38 + std::uint32_t fatalCount; // 0 + std::uint32_t errorCount; // 4 + std::uint32_t warningCount; // 8 }; - static_assert(sizeof(ErrorLogger) == 0x70); - } + static_assert(sizeof(PerThreadErrorCounts) == 0xC); + + virtual ~ErrorLogger(); // 00 + + // add + virtual void PostErrorImpl(const ICachedErrorMessage* a_errMsg, Severity a_severity) = 0; // 01 + virtual void ResetImpl() { return; } // 02 + + // members + const BSFixedString logName; // 28 + BSSpinLock dataLock; // 30 + /*BSTHashMap*/ std::byte threadErrors[0x38]; // 38 + }; + static_assert(sizeof(ErrorLogger) == 0x70); } diff --git a/CommonLibSF/include/RE/I/ICachedErrorMessage.h b/CommonLibSF/include/RE/I/ICachedErrorMessage.h index c8cb45bb..0022ff21 100644 --- a/CommonLibSF/include/RE/I/ICachedErrorMessage.h +++ b/CommonLibSF/include/RE/I/ICachedErrorMessage.h @@ -2,21 +2,17 @@ #include "RE/B/BSFixedString.h" -namespace RE +namespace RE::BSScript { - namespace BSScript + class __declspec(novtable) ICachedErrorMessage { - class __declspec(novtable) ICachedErrorMessage - { - public: - static constexpr auto RTTI{ RTTI::BSScript__ICachedErrorMessage }; - static constexpr auto VTABLE{ VTABLE::BSScript__ICachedErrorMessage }; + public: + SF_RTTI_VTABLE(BSScript__ICachedErrorMessage); - virtual ~ICachedErrorMessage() = default; // 00 + virtual ~ICachedErrorMessage() = default; // 00 - // add - virtual void GetErrorMsg(BSFixedString& a_message) const = 0; // 01 - }; - static_assert(sizeof(ICachedErrorMessage) == 0x8); - } + // add + virtual void GetErrorMsg(BSFixedString& a_message) const = 0; // 01 + }; + static_assert(sizeof(ICachedErrorMessage) == 0x8); } diff --git a/CommonLibSF/include/RE/I/ISavePatcherInterface.h b/CommonLibSF/include/RE/I/ISavePatcherInterface.h index 72ec5e9d..5b41d7e5 100644 --- a/CommonLibSF/include/RE/I/ISavePatcherInterface.h +++ b/CommonLibSF/include/RE/I/ISavePatcherInterface.h @@ -1,23 +1,19 @@ #pragma once -namespace RE +namespace RE::BSScript { - namespace BSScript - { - class IVirtualMachine; - class StackFrame; + class IVirtualMachine; + class StackFrame; - class ISavePatcherInterface - { - public: - static constexpr auto RTTI{ RTTI::BSScript__ISavePatcherInterface }; - static constexpr auto VTABLE{ VTABLE::BSScript__ISavePatcherInterface }; + class ISavePatcherInterface + { + public: + SF_RTTI_VTABLE(BSScript__ISavePatcherInterface); - virtual ~ISavePatcherInterface() = default; // 00 + virtual ~ISavePatcherInterface() = default; // 00 - // add - virtual void PatchStackFrame(StackFrame&, IVirtualMachine&) = 0; // 01 - }; - static_assert(sizeof(ISavePatcherInterface) == 0x8); - } + // add + virtual void PatchStackFrame(StackFrame&, IVirtualMachine&) = 0; // 01 + }; + static_assert(sizeof(ISavePatcherInterface) == 0x8); } diff --git a/CommonLibSF/include/RE/I/IVMDebugInterface.h b/CommonLibSF/include/RE/I/IVMDebugInterface.h index 361809db..1752a730 100644 --- a/CommonLibSF/include/RE/I/IVMDebugInterface.h +++ b/CommonLibSF/include/RE/I/IVMDebugInterface.h @@ -2,24 +2,20 @@ #include "RE/B/BSFixedString.h" -namespace RE +namespace RE::BSScript { - namespace BSScript + class __declspec(novtable) IVMDebugInterface { - class __declspec(novtable) IVMDebugInterface - { - public: - static constexpr auto RTTI{ RTTI::BSScript__IVMDebugInterface }; - static constexpr auto VTABLE{ VTABLE::BSScript__IVMDebugInterface }; + public: + SF_RTTI_VTABLE(BSScript__IVMDebugInterface); - virtual ~IVMDebugInterface(); // 00 + virtual ~IVMDebugInterface(); // 00 - virtual void DumpRunningStacksToLog() = 0; // 01 - virtual void DumpStackFrameToLog(unsigned int a_v, unsigned int b_v, bool a_flag) = 0; // 02 - virtual void GetStackFrame(unsigned int a_v, unsigned int b_v, bool a_flag, BSFixedString& a_identifier) = 0; // 03 - virtual void DumpPersistenceInformationToLog(char const* logfile, uint64_t a_v) const = 0; // 04 - virtual void DumpEventRelayInformationToLog(char const* logfile, uint64_t a_v, BSFixedString const& a_string) const = 0; // 05 - }; - static_assert(sizeof(IVMDebugInterface) == 0x8); - } + virtual void DumpRunningStacksToLog() = 0; // 01 + virtual void DumpStackFrameToLog(unsigned int a_v, unsigned int b_v, bool a_flag) = 0; // 02 + virtual void GetStackFrame(unsigned int a_v, unsigned int b_v, bool a_flag, BSFixedString& a_identifier) = 0; // 03 + virtual void DumpPersistenceInformationToLog(char const* logfile, uint64_t a_v) const = 0; // 04 + virtual void DumpEventRelayInformationToLog(char const* logfile, uint64_t a_v, BSFixedString const& a_string) const = 0; // 05 + }; + static_assert(sizeof(IVMDebugInterface) == 0x8); } diff --git a/CommonLibSF/include/RE/I/IVMFunctionMessageDispatch.h b/CommonLibSF/include/RE/I/IVMFunctionMessageDispatch.h index 8cb9dab1..7fdb9b9a 100644 --- a/CommonLibSF/include/RE/I/IVMFunctionMessageDispatch.h +++ b/CommonLibSF/include/RE/I/IVMFunctionMessageDispatch.h @@ -5,7 +5,7 @@ namespace RE::BSScript::Internal class __declspec(novtable) IVMFunctionMessageDispatch { public: - static constexpr auto RTTI{ RTTI::BSScript__Internal__IVMFunctionMessageDispatch }; + SF_RTTI(BSScript__Internal__IVMFunctionMessageDispatch); // VTable got optimized out? virtual void Unk00(); // 00 diff --git a/CommonLibSF/include/RE/I/IVMRemoteDebuggerInterface.h b/CommonLibSF/include/RE/I/IVMRemoteDebuggerInterface.h index 78c0d9b6..2ff821a3 100644 --- a/CommonLibSF/include/RE/I/IVMRemoteDebuggerInterface.h +++ b/CommonLibSF/include/RE/I/IVMRemoteDebuggerInterface.h @@ -2,21 +2,18 @@ #include "RE/B/BSFixedString.h" -namespace RE +namespace RE::BSScript { - namespace BSScript + class __declspec(novtable) IVMRemoteDebuggerInterface { - class __declspec(novtable) IVMRemoteDebuggerInterface - { - public: - SF_RTTI_VTABLE(BSScript__IVMRemoteDebuggerInterface); + public: + SF_RTTI_VTABLE(BSScript__IVMRemoteDebuggerInterface); - ~IVMRemoteDebuggerInterface() = delete; + ~IVMRemoteDebuggerInterface() = delete; - virtual void Unk00(); // 00 -- calls Unk05 in IVirtualMachine - virtual void Unk01(); // 01 - virtual void Unk02(); // 02 - }; - static_assert(sizeof(IVMRemoteDebuggerInterface) == 0x8); - } + virtual void Unk00(); // 00 -- calls Unk05 in IVirtualMachine + virtual void Unk01(); // 01 + virtual void Unk02(); // 02 + }; + static_assert(sizeof(IVMRemoteDebuggerInterface) == 0x8); } diff --git a/CommonLibSF/include/RE/I/IVMSaveLoadInterface.h b/CommonLibSF/include/RE/I/IVMSaveLoadInterface.h index 5bd9cfdc..06e8a4e9 100644 --- a/CommonLibSF/include/RE/I/IVMSaveLoadInterface.h +++ b/CommonLibSF/include/RE/I/IVMSaveLoadInterface.h @@ -28,8 +28,7 @@ namespace RE class __declspec(novtable) IVMSaveLoadInterface { public: - static constexpr auto RTTI{ RTTI::BSScript__IVMSaveLoadInterface }; - static constexpr auto VTABLE{ VTABLE::BSScript__IVMSaveLoadInterface }; + SF_RTTI_VTABLE(BSScript__IVMSaveLoadInterface); virtual ~IVMSaveLoadInterface(); // 00 diff --git a/CommonLibSF/include/RE/I/IVirtualMachine.h b/CommonLibSF/include/RE/I/IVirtualMachine.h index d90a3616..c219e6eb 100644 --- a/CommonLibSF/include/RE/I/IVirtualMachine.h +++ b/CommonLibSF/include/RE/I/IVirtualMachine.h @@ -1,6 +1,8 @@ #pragma once + #include "RE/B/BSIntrusiveRefCounted.h" #include "RE/B/BSTSmartPointer.h" + namespace RE { template @@ -39,8 +41,7 @@ namespace RE public BSIntrusiveRefCounted // 08 { public: - static constexpr auto RTTI{ RTTI::BSScript__IVirtualMachine }; - static constexpr auto VTABLE{ VTABLE::BSScript__IVirtualMachine }; + SF_RTTI_VTABLE(BSScript__IVirtualMachine); virtual ~IVirtualMachine() = default; // 00 diff --git a/CommonLibSF/include/RE/I/idLogging.h b/CommonLibSF/include/RE/I/idLogging.h index 8cd3eeef..e608083e 100644 --- a/CommonLibSF/include/RE/I/idLogging.h +++ b/CommonLibSF/include/RE/I/idLogging.h @@ -17,9 +17,12 @@ namespace RE struct ILogger { SF_RTTI_VTABLE(idLogging__ILogger); + ~ILogger() = default; // 00 + virtual bool ShouldLog(Severity severity) = 0; // 01 virtual void Log(const char* a_fileName, int a_line_number, Severity severity, const char* msg) = 0; // 02 + void Printf(const char* a_fileName, int a_line_number, Severity severity, const char* a_fmt, ...) { va_list args; @@ -38,9 +41,12 @@ namespace RE struct NetSocketLogger : public idLogging::ILogger { SF_RTTI_VTABLE(__NetSocketLogger); + ~NetSocketLogger() = default; // 00 + // override idLogging::ILogger bool ShouldLog([[maybe_unused]] idLogging::Severity severity) override { return false; } // 01 + void Log(const char* a_fileName, int a_line_number, idLogging::Severity severity, const char* msg) override // 02 { const char* severitystr; @@ -74,4 +80,4 @@ namespace RE WinAPI::OutputDebugString(outputString); } }; -} \ No newline at end of file +} diff --git a/CommonLibSF/include/RE/I/idTCP.h b/CommonLibSF/include/RE/I/idTCP.h index 98f28140..2e8c092e 100644 --- a/CommonLibSF/include/RE/I/idTCP.h +++ b/CommonLibSF/include/RE/I/idTCP.h @@ -28,6 +28,7 @@ namespace RE SF_RTTI_VTABLE(idTCP); virtual ~idTCP(); // 00 + bool Listen(std::uint16_t port, bool blocking); // 'blocking' is ignored bool Accept(const idTCP& listener); std::int32_t Close(); @@ -40,4 +41,4 @@ namespace RE }; static_assert(sizeof(idTCP) == 0x20); -} \ No newline at end of file +} diff --git a/CommonLibSF/include/RE/L/Logger.h b/CommonLibSF/include/RE/L/Logger.h index 1beaf201..c8f4e0a1 100644 --- a/CommonLibSF/include/RE/L/Logger.h +++ b/CommonLibSF/include/RE/L/Logger.h @@ -4,15 +4,13 @@ namespace RE::GameScript { - class BSLog; class __declspec(novtable) Logger : public BSScript::ErrorLogger // 00 { public: - static constexpr auto RTTI{ RTTI::GameScript__Logger }; - static constexpr auto VTABLE{ VTABLE::GameScript__Logger }; + SF_RTTI_VTABLE(GameScript__Logger); // override (BSScript::ErrorLogger) void PostErrorImpl(const BSScript::ICachedErrorMessage* a_errMsg, Severity a_severity) override; // 01 @@ -23,4 +21,4 @@ namespace RE::GameScript std::uint64_t unk80; // 80 }; static_assert(sizeof(Logger) == 0x88); -} \ No newline at end of file +} diff --git a/CommonLibSF/include/RE/S/SavePatcher.h b/CommonLibSF/include/RE/S/SavePatcher.h index 02b0186c..bf83c4b1 100644 --- a/CommonLibSF/include/RE/S/SavePatcher.h +++ b/CommonLibSF/include/RE/S/SavePatcher.h @@ -8,11 +8,10 @@ namespace RE::GameScript public BSScript::ISavePatcherInterface // 0 { public: - static constexpr auto RTTI{ RTTI::GameScript__SavePatcher }; - static constexpr auto VTABLE{ VTABLE::GameScript__SavePatcher }; + SF_RTTI_VTABLE(GameScript__SavePatcher); // override (BSScript::ISavePatcherInterface) void PatchStackFrame(BSScript::StackFrame&, BSScript::IVirtualMachine&) override { return; } // 01 }; static_assert(sizeof(SavePatcher) == 0x8); -} \ No newline at end of file +} diff --git a/CommonLibSF/include/SFSE/Impl/WinAPI.h b/CommonLibSF/include/SFSE/Impl/WinAPI.h index 106de25b..a8179c86 100644 --- a/CommonLibSF/include/SFSE/Impl/WinAPI.h +++ b/CommonLibSF/include/SFSE/Impl/WinAPI.h @@ -489,12 +489,15 @@ namespace SFSE::WinAPI { std::uint8_t s_b1, s_b2, s_b3, s_b4; } S_un_b; + struct { std::uint16_t s_w1, s_w2; } S_un_w; + std::uint32_t S_addr; } S_un; + // getting around the #DEFINEs in inaddr.h struct { @@ -503,10 +506,12 @@ namespace SFSE::WinAPI std::uint8_t s_lh; std::uint8_t s_impno; }; + struct { std::uint16_t _s_w1, s_imp; }; + std::uint32_t s_addr; }; diff --git a/CommonLibSF/src/RE/B/BSLog.cpp b/CommonLibSF/src/RE/B/BSLog.cpp index f1a57149..b56d3c0c 100644 --- a/CommonLibSF/src/RE/B/BSLog.cpp +++ b/CommonLibSF/src/RE/B/BSLog.cpp @@ -2,11 +2,6 @@ namespace RE { - BSLog::~BSLog() - { - dtor(); - } - BSLog::BSLog( const char* a_logName, const char* a_logFolderPath, @@ -18,6 +13,11 @@ namespace RE ctor(a_logName, a_logFolderPath, a_timeStamped, a_logNumber, a_bufferSize, a_blocks_allocated); } + BSLog::~BSLog() + { + dtor(); + } + BSLog* BSLog::ctor(const char* a_logName, const char* a_logFolderPath, bool a_timeStamped, std::uint32_t a_logNumber, std::uint32_t a_bufferSize, std::uint32_t a_blocks_allocated) { using func_t = decltype(&BSLog::ctor); @@ -80,5 +80,4 @@ namespace RE REL::Relocation func{ ID::BSLog::GenerateTimeStamp }; return func(a_buffer); } - -} \ No newline at end of file +} diff --git a/CommonLibSF/src/RE/B/BSSystemFile.cpp b/CommonLibSF/src/RE/B/BSSystemFile.cpp index 4e1f2b75..4d87cb74 100644 --- a/CommonLibSF/src/RE/B/BSSystemFile.cpp +++ b/CommonLibSF/src/RE/B/BSSystemFile.cpp @@ -2,15 +2,14 @@ namespace RE { - BSSystemFile::~BSSystemFile() - { - DoClose(); - } - BSSystemFile::BSSystemFile() : flags(1), file(WinAPI::INVALID_HANDLE_VALUE) + {} + + BSSystemFile::~BSSystemFile() { + DoClose(); } BSSystemFile::BSSystemFile( @@ -35,15 +34,15 @@ namespace RE } BSSystemFile::BSSystemFile(BSSystemFile& a_lhs) : - file(a_lhs.file), - flags(a_lhs.flags) + flags(a_lhs.flags), + file(a_lhs.file) { a_lhs.Invalidate(); } BSSystemFile::BSSystemFile(BSSystemFile&& a_rhs) : - file(a_rhs.file), - flags(a_rhs.flags) + flags(a_rhs.flags), + file(a_rhs.file) { a_rhs.Invalidate(); } @@ -82,7 +81,7 @@ namespace RE BSSystemFile::ErrorCode BSSystemFile::GetErrorCode() { - return static_cast(flags & 0x3FFFFFFF); + return static_cast(flags & 0x3FFFFFFF); } BSSystemFile::ErrorCode BSSystemFile::Read(void* a_buffer, std::uint64_t a_toRead, std::uint64_t& r_read) @@ -158,5 +157,4 @@ namespace RE REL::Relocation func{ ID::BSSystemFile::DoSeek }; return func(this, a_offset, a_seekMode, r_newPosition); } - } diff --git a/CommonLibSF/src/RE/I/idLogging.cpp b/CommonLibSF/src/RE/I/idLogging.cpp index 61b101c4..2e9a0a34 100644 --- a/CommonLibSF/src/RE/I/idLogging.cpp +++ b/CommonLibSF/src/RE/I/idLogging.cpp @@ -7,4 +7,4 @@ namespace RE::idLogging REL::Relocation singleton{ ID::idLogging::singleton }; return *singleton; } -} \ No newline at end of file +} diff --git a/CommonLibSF/src/RE/I/idTCP.cpp b/CommonLibSF/src/RE/I/idTCP.cpp index 117946c7..f4927432 100644 --- a/CommonLibSF/src/RE/I/idTCP.cpp +++ b/CommonLibSF/src/RE/I/idTCP.cpp @@ -2,10 +2,11 @@ namespace RE { - const char* NET_ErrorString(void) + const char* NET_ErrorString() { using WSAError = WinAPI::WSAError; - WSAError code = static_cast(WinAPI::WSAGetLastError()); + + const auto code = static_cast(WinAPI::WSAGetLastError()); switch (code) { case WSAError::WSAEINTR: return "WSAEINTR"; @@ -100,18 +101,18 @@ namespace RE } } - void Net_SockadrToNetadr(struct WinAPI::sockaddr* s, netadr_t* a) + void Net_SockadrToNetadr(WinAPI::sockaddr* s, netadr_t* a) { using AFType = WinAPI::AFType; using sockaddr_in = WinAPI::sockaddr_in; - unsigned int ip; if (s->sa_family == AFType::AF_INET) { - sockaddr_in* sin = reinterpret_cast(s); - ip = sin->sin_addr.s_addr; - *(unsigned int*)&a->ip = ip; + const auto sin = reinterpret_cast(s); + auto ip = sin->sin_addr.s_addr; + *reinterpret_cast(&a->ip) = ip; a->port = WinAPI::htons(sin->sin_port); ip = WinAPI::ntohl(ip); + if (ip == WinAPI::INADDR_LOOPBACK) { a->type = netadrtype_t::NA_LOOPBACK; } else { @@ -133,6 +134,7 @@ namespace RE REL::Relocation func{ ID::Sys_InitNetworking }; return func(); } + bool idTCP::Listen(std::uint16_t port, bool blocking) { using func_t = decltype(&idTCP::Listen); @@ -167,5 +169,4 @@ namespace RE REL::Relocation func{ ID::idTCP::Write }; return func(this, buffer, size, timeoutMs); } - }