Auto party friend

This commit is contained in:
LightCat 2019-03-21 18:23:38 +01:00
parent 8aa3c8765d
commit 43f068c659

View File

@ -6,6 +6,7 @@
#include "ChIRC.hpp" #include "ChIRC.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "ucccccp.hpp" #include "ucccccp.hpp"
#include "PlayerTools.hpp"
namespace IRC namespace IRC
{ {
@ -320,33 +321,51 @@ CatCommand debug_steamids("debug_steamids", "Debug steamids", []() {
logging::Info("%u", i.second.steamid); logging::Info("%u", i.second.steamid);
}); });
static Timer resize_party{}; static Timer resize_party{};
static Timer pass_leader{};
void party_leader_pass() static Timer friend_party_t{};
void friend_party()
{ {
re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); if (friend_party_t.test_and_set(10000))
re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient();
if (gc && !gc->BHaveLiveMatch() && pc->GetNumMembers() > 1)
{ {
CSteamID steamid; re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient();
pc->GetCurrentPartyLeader(steamid); if (pc)
if (steamid.GetAccountID() == g_ISteamUser->GetSteamID().GetAccountID())
{ {
std::vector<unsigned> valid_steam_ids = pc->GetPartySteamIDs(); std::vector<unsigned> valid_steam_ids = pc->GetPartySteamIDs();
bool found = false; for (auto steamid : valid_steam_ids)
for (auto &peer : irc.getPeers()) 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))
{
re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem();
re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient();
if (gc && !gc->BHaveLiveMatch() && pc->GetNumMembers() > 1)
{
CSteamID steamid;
pc->GetCurrentPartyLeader(steamid);
if (steamid.GetAccountID() == g_ISteamUser->GetSteamID().GetAccountID())
{ {
if (found) std::vector<unsigned> valid_steam_ids = pc->GetPartySteamIDs();
break; bool found = false;
if (peer.second.is_ingame) for (auto &peer : irc.getPeers())
{ {
for (auto &id : valid_steam_ids) if (found)
if (id == peer.second.steamid) break;
{ if (peer.second.is_ingame)
CSteamID steam(id, EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual); {
pc->PromotePlayerToLeader(steam); for (auto &id : valid_steam_ids)
found = true; if (id == peer.second.steamid)
break; {
} CSteamID steam(id, EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual);
pc->PromotePlayerToLeader(steam);
found = true;
break;
}
}
} }
} }
} }