From 3fd3e7926cf5434fe423465705ee3311f9d873ed Mon Sep 17 00:00:00 2001 From: Sachin Date: Sun, 26 May 2024 11:52:20 +0530 Subject: [PATCH] optimize: Call PostEventAbstract once per loop --- fakeranks.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fakeranks.cpp b/fakeranks.cpp index 11bbca7..a3fd6ff 100644 --- a/fakeranks.cpp +++ b/fakeranks.cpp @@ -107,6 +107,7 @@ void FakeRank_RevealAll::Hook_GameFrame(bool simulating, bool bFirstTick, bool b return; int maxClients = g_pGlobals->maxClients > 64 ? 64 : g_pGlobals->maxClients; + CRecipientFilter filter; for(int i = 0; i < maxClients; i++) { @@ -119,15 +120,17 @@ void FakeRank_RevealAll::Hook_GameFrame(bool simulating, bool bFirstTick, bool b uint64_t iButtons = pPlayerController->m_hPawn()->m_pMovementServices()->m_nButtons().m_pButtonStates()[0]; if(std::to_string(iButtons).find("858993") != std::string::npos && !(std::to_string(iOldButtons[i]).find("858993") != std::string::npos)) { - CRecipientFilter filter; - CPlayerSlot PlayerSlot = CPlayerSlot(i); - filter.AddRecipient(PlayerSlot); - static INetworkSerializable* message_type = g_pNetworkMessages->FindNetworkMessagePartial("CCSUsrMsg_ServerRankRevealAll"); - CCSUsrMsg_ServerRankRevealAll message; - g_pGameEventSystem->PostEventAbstract(0, false, &filter, message_type, &message, 0); + filter.AddRecipient(CPlayerSlot(i)); } iOldButtons[i] = iButtons; } + + if(filter.GetRecipientCount() > 0) + { + static INetworkSerializable* message_type = g_pNetworkMessages->FindNetworkMessagePartial("CCSUsrMsg_ServerRankRevealAll"); + CCSUsrMsg_ServerRankRevealAll message; + g_pGameEventSystem->PostEventAbstract(0, false, &filter, message_type, &message, 0); + } } void FakeRank_RevealAll::AllPluginsLoaded() @@ -164,7 +167,7 @@ const char *FakeRank_RevealAll::GetLicense() const char *FakeRank_RevealAll::GetVersion() { - return "1.0.4Fix"; + return "1.0.4Fix2"; } const char *FakeRank_RevealAll::GetDate() @@ -195,4 +198,4 @@ const char *FakeRank_RevealAll::GetName() const char *FakeRank_RevealAll::GetURL() { return "https://github.com/cruze03"; -} +} \ No newline at end of file