From 392c85ee968478d5490e7af1c5505cd5e73e74b3 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Fri, 22 Mar 2019 12:11:20 +0100 Subject: [PATCH] TFMM: Autofriend clients in party Fixes #715 --- src/irc.cpp | 16 +--------------- src/tfmm.cpp | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/irc.cpp b/src/irc.cpp index a5cccb6f..b4a242d0 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -322,21 +322,7 @@ CatCommand debug_steamids("debug_steamids", "Debug steamids", []() { }); static Timer resize_party{}; static Timer pass_leader{}; -static Timer friend_party_t{}; -void friend_party() -{ - if (friend_party_t.test_and_set(10000)) - { - re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient(); - if (pc) - { - std::vector valid_steam_ids = pc->GetPartySteamIDs(); - for (auto steamid : valid_steam_ids) - if (steamid && player_tools::shouldTargetSteamId(steamid)) - playerlist::AccessData(steamid).state = playerlist::k_EState::CAT; - } - } -} + void party_leader_pass() { if (pass_leader.test_and_set(10000)) diff --git a/src/tfmm.cpp b/src/tfmm.cpp index b2313a1e..484e31b3 100644 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -82,8 +82,8 @@ static bool old_isMMBanned() } static bool getMMBanData(int type, int *time, int *time2) { - typedef bool (*GetMMBanData_t)(int, int*, int*); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 5D 08 8B 75 0C 8B 7D 10 83 FB FF"); + typedef bool (*GetMMBanData_t)(int, int *, int *); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 5D 08 8B 75 0C 8B 7D 10 83 FB FF"); static GetMMBanData_t GetMMBanData_fn = GetMMBanData_t(addr); if (!addr) @@ -96,14 +96,12 @@ static bool getMMBanData(int type, int *time, int *time2) return GetMMBanData_fn(type, time, time2); } -static CatCommand mm_debug_banned("mm_debug_banned", - "Prints if your are MM banned and extra data if you are banned", -[]() { +static CatCommand mm_debug_banned("mm_debug_banned", "Prints if your are MM banned and extra data if you are banned", []() { int i, time, left, banned; for (i = 0; i < 1; ++i) { time = left = 0; - banned = getMMBanData(0, &time, &left); + banned = getMMBanData(0, &time, &left); logging::Info("%d: banned %d, time %d, left %d", banned, time, left); } }); @@ -163,4 +161,23 @@ void abandon() else logging::Info("abandon: CTFGCClientSystem == null!"); } + +static Timer friend_party_t{}; +void friend_party() +{ + if (friend_party_t.test_and_set(10000)) + { + re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient(); + if (pc) + { + std::vector valid_steam_ids = pc->GetPartySteamIDs(); + for (auto steamid : valid_steam_ids) + if (steamid && playerlist::IsDefault(steamid)) + playerlist::AccessData(steamid).state = playerlist::k_EState::FRIEND; + } + } +} + +static InitRoutine init([]() { EC::Register(EC::Paint, friend_party, "paint_friendparty"); }); + } // namespace tfmm