Fix AutoParty Stuff and add Anti-kick
This commit is contained in:
parent
492a9eff4a
commit
65173084fa
@ -13,7 +13,9 @@
|
|||||||
<AutoVariable width="fill" target="autoparty.ipc_count" label="IPC host count" tooltip="How many IPC members to use as party hosts."/>
|
<AutoVariable width="fill" target="autoparty.ipc_count" label="IPC host count" tooltip="How many IPC members to use as party hosts."/>
|
||||||
<AutoVariable width="fill" target="autoparty.log" label="Log party leaves and kicks"/>
|
<AutoVariable width="fill" target="autoparty.log" label="Log party leaves and kicks"/>
|
||||||
<AutoVariable width="fill" target="autoparty.message-kicks" label="Log to chat" tooltip="Log kick notifications to party chat."/>
|
<AutoVariable width="fill" target="autoparty.message-kicks" label="Log to chat" tooltip="Log kick notifications to party chat."/>
|
||||||
|
<AutoVariable width="fill" target="autoparty.kick-bypass" label="Party kick bypass" tooltip="Makes your party unkickable ingame (with autovote no enabled), also allows you to nullify any vote with f1/f2."/>
|
||||||
<AutoVariable width="fill" target="autoparty.debug" label="Log locks/unlocks"/>
|
<AutoVariable width="fill" target="autoparty.debug" label="Log locks/unlocks"/>
|
||||||
|
<AutoVariable width="fill" target="misc.remove_invite_timer" label="Remove Match join Timer" tooltip="Removes the match join timer, allowing to bypass kicks. Do not touch unless you know what you are doing."/>
|
||||||
</List>
|
</List>
|
||||||
</Box>
|
</Box>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
4
include/hacks/AutoParty.hpp
Normal file
4
include/hacks/AutoParty.hpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
namespace hacks::tf2::autoparty
|
||||||
|
{
|
||||||
|
void joinMatch();
|
||||||
|
}
|
@ -82,11 +82,15 @@ static settings::Boolean ipc_mode{ "autoparty.ipc-mode", "false" };
|
|||||||
static settings::Int ipc_count{ "autoparty.ipc-count", "0" };
|
static settings::Int ipc_count{ "autoparty.ipc-count", "0" };
|
||||||
// How often to run the autoparty routine, in seconds
|
// How often to run the autoparty routine, in seconds
|
||||||
static settings::Int timeout{ "autoparty.run-frequency", "60" };
|
static settings::Int timeout{ "autoparty.run-frequency", "60" };
|
||||||
|
// Should we have bots bypass kicks?
|
||||||
|
static settings::Boolean kickbypass{ "autoparty.kick-bypass", "false" };
|
||||||
// Only run the autoparty routine once every N seconds
|
// Only run the autoparty routine once every N seconds
|
||||||
static Timer routine_timer{};
|
static Timer routine_timer{};
|
||||||
// Populated by the routine when empty and by configuration changes
|
// Populated by the routine when empty and by configuration changes
|
||||||
static std::vector<uint32> party_hosts = {};
|
static std::vector<uint32> party_hosts = {};
|
||||||
|
|
||||||
|
static settings::Boolean no_autojoin("misc.remove_invite_timer", "false");
|
||||||
|
|
||||||
// ha ha macros go brr
|
// ha ha macros go brr
|
||||||
#define log(...) \
|
#define log(...) \
|
||||||
if (*autoparty_log) \
|
if (*autoparty_log) \
|
||||||
@ -225,6 +229,10 @@ void party_routine()
|
|||||||
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
|
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
|
// Toggle anti-kick as needed
|
||||||
|
if (kickbypass)
|
||||||
|
no_autojoin = !is_host();
|
||||||
|
|
||||||
int members = client->GetNumMembers();
|
int members = client->GetNumMembers();
|
||||||
// Are we in a party?
|
// Are we in a party?
|
||||||
if (members == 1)
|
if (members == 1)
|
||||||
@ -255,16 +263,9 @@ void party_routine()
|
|||||||
// Get a list of party members, then check each one to determine the leader
|
// Get a list of party members, then check each one to determine the leader
|
||||||
std::vector<unsigned> members = client->GetPartySteamIDs();
|
std::vector<unsigned> members = client->GetPartySteamIDs();
|
||||||
uint32 leader_id = 0;
|
uint32 leader_id = 0;
|
||||||
for (int i = 0; i < members.size(); i++)
|
CSteamID id;
|
||||||
{
|
client->GetCurrentPartyLeader(id);
|
||||||
CSteamID id = CSteamID(members[i], EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual);
|
leader_id = id.GetAccountID();
|
||||||
// Are you my mummy?
|
|
||||||
if (client->GetCurrentPartyLeader(id))
|
|
||||||
{
|
|
||||||
leader_id = members[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (leader_id == g_ISteamUser->GetSteamID().GetAccountID())
|
if (leader_id == g_ISteamUser->GetSteamID().GetAccountID())
|
||||||
{
|
{
|
||||||
// Great, let's manage it
|
// Great, let's manage it
|
||||||
@ -286,7 +287,7 @@ void party_routine()
|
|||||||
if (pl.state == playerlist::k_EState::RAGE)
|
if (pl.state == playerlist::k_EState::RAGE)
|
||||||
{
|
{
|
||||||
std::string message = "Kicking Steam32 ID " + std::to_string(members[i]) + " from the party because they are set to RAGE";
|
std::string message = "Kicking Steam32 ID " + std::to_string(members[i]) + " from the party because they are set to RAGE";
|
||||||
logging::Info("AutoParty: %s", message);
|
logging::Info("AutoParty: %s", message.c_str());
|
||||||
if (*message_kicks)
|
if (*message_kicks)
|
||||||
client->SendPartyChat(message.c_str());
|
client->SendPartyChat(message.c_str());
|
||||||
CSteamID id = CSteamID(members[i], EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual);
|
CSteamID id = CSteamID(members[i], EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual);
|
||||||
@ -310,7 +311,7 @@ void party_routine()
|
|||||||
{
|
{
|
||||||
int num_to_kick = members.size() - *max_size;
|
int num_to_kick = members.size() - *max_size;
|
||||||
std::string message = "Kicking " + std::to_string(num_to_kick) + " party members because there are " + std::to_string(members.size()) + " out of " + std::to_string(*max_size) + " allowed members";
|
std::string message = "Kicking " + std::to_string(num_to_kick) + " party members because there are " + std::to_string(members.size()) + " out of " + std::to_string(*max_size) + " allowed members";
|
||||||
logging::Info("AutoParty: %s", message);
|
logging::Info("AutoParty: %s", message.c_str());
|
||||||
if (*message_kicks)
|
if (*message_kicks)
|
||||||
client->SendPartyChat(message.c_str());
|
client->SendPartyChat(message.c_str());
|
||||||
for (int i = 0; i < num_to_kick; i++)
|
for (int i = 0; i < num_to_kick; i++)
|
||||||
@ -352,9 +353,109 @@ void party_routine()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static InitRoutine init([]() {
|
#define IP_STARTSTR "PB_IP"
|
||||||
|
|
||||||
|
// Received party message
|
||||||
|
void partyChatMessage(IGameEvent *event)
|
||||||
|
{
|
||||||
|
if (!event->GetString("text"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Only parse actual chat messages
|
||||||
|
if (event->GetInt("type") != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
|
||||||
|
|
||||||
|
if (!client)
|
||||||
|
return;
|
||||||
|
// And are we actually the leader?
|
||||||
|
// Get a list of party members, then check each one to determine the leader
|
||||||
|
uint32 leader_id = 0;
|
||||||
|
CSteamID id;
|
||||||
|
client->GetCurrentPartyLeader(id);
|
||||||
|
leader_id = id.GetAccountID();
|
||||||
|
|
||||||
|
// Party leader doesn't care, they just join
|
||||||
|
if (leader_id == g_ISteamUser->GetSteamID().GetAccountID() || client->GetNumMembers() == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string chat_message = event->GetString("text");
|
||||||
|
// Found Message about server IP
|
||||||
|
if (chat_message.find(IP_STARTSTR) == 0)
|
||||||
|
{
|
||||||
|
auto ip_string = "connect " + chat_message.substr(sizeof(IP_STARTSTR) - 1);
|
||||||
|
g_IEngine->ClientCmd_Unrestricted(ip_string.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PartyEventListener : public IGameEventListener2
|
||||||
|
{
|
||||||
|
virtual void FireGameEvent(IGameEvent *event)
|
||||||
|
{
|
||||||
|
if (enabled && kickbypass)
|
||||||
|
partyChatMessage(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static PartyEventListener party_listener;
|
||||||
|
|
||||||
|
void joinMatch()
|
||||||
|
{
|
||||||
|
if (!enabled || !kickbypass)
|
||||||
|
return;
|
||||||
|
|
||||||
|
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
|
||||||
|
|
||||||
|
if (!client)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CSteamID id;
|
||||||
|
client->GetCurrentPartyLeader(id);
|
||||||
|
if (id.GetAccountID() != g_ISteamUser->GetSteamID().GetAccountID())
|
||||||
|
return;
|
||||||
|
|
||||||
|
INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
|
||||||
|
std::string party_string = IP_STARTSTR;
|
||||||
|
party_string.append(ch->GetAddress());
|
||||||
|
|
||||||
|
client->SendPartyChat(party_string.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
static InitRoutine init(
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
static BytePatch removeInviteTime(gSignatures.GetClientSignature, "55 89 e5 57 56 53 83 ec ? 8b ? ? 89 1c ? e8 ? ? ? ? f7 ? ? ? ? ? fd", 0x00, { 0xC3 });
|
||||||
|
if (*no_autojoin)
|
||||||
|
removeInviteTime.Patch();
|
||||||
|
no_autojoin.installChangeCallback(
|
||||||
|
[](settings::VariableBase<bool> &, bool new_val)
|
||||||
|
{
|
||||||
|
if (new_val)
|
||||||
|
removeInviteTime.Patch();
|
||||||
|
else
|
||||||
|
removeInviteTime.Shutdown();
|
||||||
|
});
|
||||||
|
|
||||||
host_list.installChangeCallback([](settings::VariableBase<std::string> &var, std::string after) { repopulate(after); });
|
host_list.installChangeCallback([](settings::VariableBase<std::string> &var, std::string after) { repopulate(after); });
|
||||||
ipc_mode.installChangeCallback([](settings::VariableBase<bool> &var, bool after) { party_hosts.clear(); });
|
ipc_mode.installChangeCallback([](settings::VariableBase<bool> &var, bool after) { party_hosts.clear(); });
|
||||||
|
kickbypass.installChangeCallback(
|
||||||
|
[](settings::VariableBase<bool> &var, bool after)
|
||||||
|
{
|
||||||
|
if (*var && !after)
|
||||||
|
no_autojoin = false;
|
||||||
|
});
|
||||||
EC::Register(EC::Paint, party_routine, "paint_autoparty", EC::average);
|
EC::Register(EC::Paint, party_routine, "paint_autoparty", EC::average);
|
||||||
|
|
||||||
|
g_IEventManager2->AddListener(&party_listener, "party_chat", false);
|
||||||
|
|
||||||
|
EC::Register(
|
||||||
|
EC::Shutdown,
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
removeInviteTime.Shutdown();
|
||||||
|
g_IEventManager2->RemoveListener(&party_listener);
|
||||||
|
},
|
||||||
|
"shutdown_autoparty");
|
||||||
});
|
});
|
||||||
} // namespace hacks::tf2::autoparty
|
} // namespace hacks::tf2::autoparty
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <hacks/hacklist.hpp>
|
#include <hacks/hacklist.hpp>
|
||||||
#include <settings/Bool.hpp>
|
#include <settings/Bool.hpp>
|
||||||
|
#include "AutoParty.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "hitrate.hpp"
|
#include "hitrate.hpp"
|
||||||
#include "hack.hpp"
|
#include "hack.hpp"
|
||||||
@ -41,6 +42,7 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
|
|||||||
#if ENABLE_IPC
|
#if ENABLE_IPC
|
||||||
ipc::UpdateServerAddress();
|
ipc::UpdateServerAddress();
|
||||||
#endif
|
#endif
|
||||||
|
hacks::tf2::autoparty::joinMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & PaintMode_t::PAINT_UIPANELS)
|
if (mode & PaintMode_t::PAINT_UIPANELS)
|
||||||
|
@ -160,7 +160,7 @@ int re::CTFPartyClient::KickPlayer(CSteamID steamid)
|
|||||||
}
|
}
|
||||||
bool re::CTFPartyClient::GetCurrentPartyLeader(CSteamID &id)
|
bool re::CTFPartyClient::GetCurrentPartyLeader(CSteamID &id)
|
||||||
{
|
{
|
||||||
uintptr_t party = *reinterpret_cast<uintptr_t *>(reinterpret_cast<uintptr_t>(this) + 0x30);
|
uintptr_t party = *reinterpret_cast<uintptr_t *>(reinterpret_cast<uintptr_t>(this) + 0x18);
|
||||||
if (!party)
|
if (!party)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user