updated IPC
This commit is contained in:
parent
d446b4704a
commit
114f53beb3
@ -1 +1 @@
|
||||
Subproject commit eccb7cc43302b1c391b431d4415a7cdaf043fe6b
|
||||
Subproject commit b12839017432cb2bf9125f969c47edc3bc7a4b71
|
@ -17,10 +17,17 @@ float lost_time { 0 };
|
||||
float idle_time { 0 };
|
||||
int following_idx { 0 };
|
||||
|
||||
void AddMessageHandlers(ipc::peer_t* peer) {
|
||||
peer->SetCommandHandler(ipc::commands::set_follow_steamid, [](cat_ipc::command_s& command, void* payload) {
|
||||
logging::Info("IPC Message: now following %ld", *(unsigned*)&command.cmd_data);
|
||||
hacks::shared::followbot::follow_steamid = *(unsigned*)&command.cmd_data;
|
||||
});
|
||||
}
|
||||
|
||||
CatCommand follow_me("fb_follow_me", "Makes all bots follow you", []() {
|
||||
if (ipc::peer) {
|
||||
unsigned id = g_ISteamUser->GetSteamID().GetAccountID();
|
||||
ipc::peer->SendMessage("owner", 0, &id, sizeof(id));
|
||||
ipc::peer->SendMessage((const char*)&id, 0, ipc::commands::set_follow_steamid, 0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
class CatCommand;
|
||||
class CatVar;
|
||||
|
||||
#include "../ipc.h"
|
||||
|
||||
namespace hacks { namespace shared { namespace followbot {
|
||||
|
||||
extern CatCommand move_to_crosshair;
|
||||
@ -23,6 +25,7 @@ extern int following_idx;
|
||||
|
||||
void DoWalking();
|
||||
void PrintDebug();
|
||||
void AddMessageHandlers(ipc::peer_t* peer);
|
||||
|
||||
}}}
|
||||
|
||||
|
19
src/ipc.cpp
19
src/ipc.cpp
@ -17,8 +17,6 @@ void CommandCallback(cat_ipc::command_s& command, void* payload) {
|
||||
//std::lock_guard<std::mutex> lock(hack::command_stack_mutex);
|
||||
hack::command_stack().push(std::string((const char*)payload));
|
||||
} else if (!strcmp("owner", (const char*)command.cmd_data) && payload) {
|
||||
logging::Info("Bot owner set to %ld", *(unsigned*)payload);
|
||||
hacks::shared::followbot::follow_steamid = *(unsigned*)payload;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +50,7 @@ CatCommand connect("ipc_connect", "Connect to IPC server", []() {
|
||||
logging::Info("peer count: %i", peer->memory->peer_count);
|
||||
logging::Info("magic number: 0x%08x", peer->memory->global_data.magic_number);
|
||||
logging::Info("magic number offset: 0x%08x", (uintptr_t)&peer->memory->global_data.magic_number - (uintptr_t)peer->memory);
|
||||
peer->SetCallback(CommandCallback);
|
||||
hacks::shared::followbot::AddMessageHandlers(peer);
|
||||
StoreClientData();
|
||||
thread_running = true;
|
||||
pthread_create(&listener_thread, nullptr, listen, nullptr);
|
||||
@ -87,10 +85,21 @@ CatCommand exec("ipc_exec", "Execute command (first argument = bot ID)", [](cons
|
||||
}
|
||||
std::string command = std::string(args.ArgS());
|
||||
command = command.substr(command.find(' ', 0) + 1);
|
||||
peer->SendMessage("exec", (1 << target_id), command.c_str(), command.length() + 1);
|
||||
ReplaceString(command, " && ", " ; ");
|
||||
if (command.length() >= 63) {
|
||||
peer->SendMessage(0, (1 << target_id), ipc::commands::execute_client_cmd_long, command.c_str(), command.length() + 1);
|
||||
} else {
|
||||
peer->SendMessage(command.c_str(), (1 << target_id), ipc::commands::execute_client_cmd, 0, 0);
|
||||
}
|
||||
});
|
||||
CatCommand exec_all("ipc_exec_all", "Execute command (on every peer)", [](const CCommand& args) {
|
||||
peer->SendMessage("exec", 0, args.ArgS(), strlen(args.ArgS()) + 1);
|
||||
std::string command = args.ArgS();
|
||||
ReplaceString(command, " && ", " ; ");
|
||||
if (command.length() >= 63) {
|
||||
peer->SendMessage(0, 0, ipc::commands::execute_client_cmd_long, command.c_str(), command.length() + 1);
|
||||
} else {
|
||||
peer->SendMessage(command.c_str(), 0, ipc::commands::execute_client_cmd, 0, 0);
|
||||
}
|
||||
});
|
||||
CatVar server_name(CV_STRING, "ipc_server", "cathook_followbot_server", "IPC server name");
|
||||
|
||||
|
10
src/ipc.h
10
src/ipc.h
@ -8,14 +8,24 @@
|
||||
#ifndef IPC_H_
|
||||
#define IPC_H_
|
||||
|
||||
#include "beforecheaders.h"
|
||||
#include "ipcb.hpp"
|
||||
#include "pthread.h"
|
||||
#include "aftercheaders.h"
|
||||
|
||||
class CatCommand;
|
||||
class CatVar;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
namespace commands {
|
||||
|
||||
constexpr unsigned execute_client_cmd = 1;
|
||||
constexpr unsigned set_follow_steamid = 2;
|
||||
constexpr unsigned execute_client_cmd_long = 3;
|
||||
|
||||
}
|
||||
|
||||
extern CatCommand connect;
|
||||
extern CatCommand disconnect;
|
||||
extern CatCommand exec;
|
||||
|
Reference in New Issue
Block a user