From 2a57634952f5ad7c7993427d2986e88011486204 Mon Sep 17 00:00:00 2001 From: LynchMus Date: Sun, 17 Aug 2025 21:05:45 +0800 Subject: [PATCH 1/5] upload recipientfilters.h --- src/sdk/recipientfilters.h | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/sdk/recipientfilters.h diff --git a/src/sdk/recipientfilters.h b/src/sdk/recipientfilters.h new file mode 100644 index 0000000..36720a0 --- /dev/null +++ b/src/sdk/recipientfilters.h @@ -0,0 +1,56 @@ +#pragma once +#include "irecipientfilter.h" +#include + +class CRecipientFilter : public IRecipientFilter +{ +public: + CRecipientFilter(NetChannelBufType_t nBufType = BUF_RELIABLE, bool bInitMessage = false) : + m_nBufType(nBufType), m_bInitMessage(bInitMessage) {} + + CRecipientFilter(IRecipientFilter* source, CPlayerSlot exceptSlot = -1) + { + m_Recipients = source->GetRecipients(); + m_nBufType = source->GetNetworkBufType(); + m_bInitMessage = source->IsInitMessage(); + + if (exceptSlot != -1) + m_Recipients.Clear(exceptSlot.Get()); + } + + ~CRecipientFilter() override {} + + NetChannelBufType_t GetNetworkBufType(void) const override { return m_nBufType; } + bool IsInitMessage(void) const override { return m_bInitMessage; } + const CPlayerBitVec& GetRecipients(void) const override { return m_Recipients; } + + void AddRecipient(CPlayerSlot slot) + { + if (slot.Get() >= 0 && slot.Get() < ABSOLUTE_PLAYER_LIMIT) + m_Recipients.Set(slot.Get()); + } + + int GetRecipientCount() + { + const uint64 bits = *reinterpret_cast(&GetRecipients()); + + return std::popcount(bits); + } + +protected: + NetChannelBufType_t m_nBufType; + bool m_bInitMessage; + CPlayerBitVec m_Recipients; +}; + +// Simple filter for when only 1 recipient is needed +class CSingleRecipientFilter : public CRecipientFilter +{ +public: + CSingleRecipientFilter(CPlayerSlot nRecipientSlot, NetChannelBufType_t nBufType = BUF_RELIABLE, bool bInitMessage = false) : + CRecipientFilter(nBufType, bInitMessage) + { + if (nRecipientSlot.Get() >= 0 && nRecipientSlot.Get() < ABSOLUTE_PLAYER_LIMIT) + m_Recipients.Set(nRecipientSlot.Get()); + } +}; From 78aabe4379c70976a2d6d6abe3ee6a18b1789d35 Mon Sep 17 00:00:00 2001 From: LynchMus Date: Sun, 17 Aug 2025 21:08:04 +0800 Subject: [PATCH 2/5] [skip ci]Update AMBuildScript --- AMBuildScript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index dd1264a..5bb72a9 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -136,7 +136,7 @@ class MMSPluginConfig(object): '-fPIC', ] - cxx.cxxflags += ['-std=c++17'] + cxx.cxxflags += ['-std=c++20'] if (cxx.version >= 'gcc-4.0') or cxx.family == 'clang': cxx.cflags += ['-fvisibility=hidden'] cxx.cxxflags += ['-fvisibility-inlines-hidden'] @@ -184,7 +184,7 @@ class MMSPluginConfig(object): cxx.cflags += [ '/W3', '/Zi', - '/std:c++17', + '/std:c++20', ] cxx.cxxflags += ['/TP'] From db7881915357dba001128c3f16d86cab2ca380f7 Mon Sep 17 00:00:00 2001 From: LynchMus Date: Sun, 17 Aug 2025 21:08:20 +0800 Subject: [PATCH 3/5] Fix Crash --- src/client_cvar_value.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client_cvar_value.cpp b/src/client_cvar_value.cpp index 460206e..5c0528a 100644 --- a/src/client_cvar_value.cpp +++ b/src/client_cvar_value.cpp @@ -15,6 +15,7 @@ */ #include "client_cvar_value.h" +#include "sdk/recipientfilters.h" #include #include #include @@ -146,8 +147,8 @@ int ClientCvarValue::SendCvarValueQueryToClient(CPlayerSlot nSlot, const char* p msg->set_cookie(iQueryCvarCookie); msg->set_cvar_name(pszCvarName); - uint64 clients = { 1llu << nSlot.Get() }; - g_pGameEventSystem->PostEventAbstract(-1, false, nSlot.Get() + 1, &clients, pMsg, msg, 0, BUF_RELIABLE); + CSingleRecipientFilter filter(nSlot); + g_pGameEventSystem->PostEventAbstract(0, false, &filter, pMsg, msg, 0); delete msg; @@ -210,7 +211,7 @@ const char* ClientCvarValue::GetLicense() const char* ClientCvarValue::GetVersion() { - return "1.0.8"; + return "1.0.9"; } const char* ClientCvarValue::GetDate() @@ -225,7 +226,7 @@ const char* ClientCvarValue::GetLogTag() const char* ClientCvarValue::GetAuthor() { - return u8"Phoenix (˙·٠●Феникс●٠·˙)"; + return "Phoenix (˙·٠●Феникс●٠·˙)"; } const char* ClientCvarValue::GetDescription() From b7423d0dfdb38b22d4ff6d681803479fc98a4a9c Mon Sep 17 00:00:00 2001 From: LynchMus Date: Sun, 17 Aug 2025 21:15:09 +0800 Subject: [PATCH 4/5] Update build.yml --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a7641f..e927001 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,12 @@ jobs: clang --version clang++ --version + - name: Install Clang 16 + if: matrix.os == 'ubuntu-latest' + run: | + apt update && apt install -y clang-16 + ln -sf /usr/bin/clang-16 /usr/bin/clang && ln -sf /usr/bin/clang++-16 /usr/bin/clang++ + - name: Install AMBuild run: | python -m pip install --upgrade pip setuptools wheel From 3665400cd514ba9d3f440db27cb59147d84e3412 Mon Sep 17 00:00:00 2001 From: LynchMus Date: Sun, 17 Aug 2025 21:16:13 +0800 Subject: [PATCH 5/5] Update build.yml --- .github/workflows/build.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e927001..07daf1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,18 +31,13 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y clang python3-pip + sudo apt-get install -y clang-16 python3-pip + ln -sf /usr/bin/clang-16 /usr/bin/clang && ln -sf /usr/bin/clang++-16 /usr/bin/clang++ echo "CC=clang" >> $GITHUB_ENV echo "CXX=clang++" >> $GITHUB_ENV clang --version clang++ --version - - name: Install Clang 16 - if: matrix.os == 'ubuntu-latest' - run: | - apt update && apt install -y clang-16 - ln -sf /usr/bin/clang-16 /usr/bin/clang && ln -sf /usr/bin/clang++-16 /usr/bin/clang++ - - name: Install AMBuild run: | python -m pip install --upgrade pip setuptools wheel