Merge pull request #419 from BenCat07/master

IPC changes, cat_disconnect_and_abandon
This commit is contained in:
BenCat07 2018-05-05 12:55:17 +02:00 committed by GitHub
commit 73b384ccf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 14 deletions

View File

@ -8,6 +8,7 @@
#include "common.hpp" #include "common.hpp"
// This is a temporary file to put code that needs moving/refactoring in. // This is a temporary file to put code that needs moving/refactoring in.
extern CatVar no_steps;
extern bool *bSendPackets; extern bool *bSendPackets;
extern CatVar no_zoom; extern CatVar no_zoom;
extern CatVar clean_screenshots; extern CatVar clean_screenshots;

View File

@ -211,7 +211,8 @@ template <condition cond> inline bool CondBitCheck(condition_data_s &data)
} }
if (cond < 32) if (cond < 32)
{ {
return data.cond_0 & (1u << (cond)); if (data.cond_0)
return data.cond_0 & (1u << (cond));
} }
return false; return false;
} }
@ -257,7 +258,8 @@ inline void CondBitSet(condition_data_s &data)
} }
else else
{ {
data.cond_0 |= (1 << (cond)); if (data.cond_0)
data.cond_0 |= (1 << (cond));
} }
} }
else else
@ -276,7 +278,8 @@ inline void CondBitSet(condition_data_s &data)
} }
else else
{ {
data.cond_0 &= ~(1u << (cond)); if (data.cond_0)
data.cond_0 &= ~(1u << (cond));
} }
} }
} }

View File

@ -54,6 +54,7 @@ public:
}; };
extern VMTHook panel; extern VMTHook panel;
extern VMTHook localbaseent;
extern VMTHook clientmode; extern VMTHook clientmode;
extern VMTHook clientmode4; extern VMTHook clientmode4;
extern VMTHook client; extern VMTHook client;

View File

@ -93,6 +93,7 @@ void VMTHook::Apply()
} }
VMTHook input{}; VMTHook input{};
VMTHook localbaseent{};
VMTHook steamfriends{}; VMTHook steamfriends{};
VMTHook baseclientstate{}; VMTHook baseclientstate{};
VMTHook baseclientstate8{}; VMTHook baseclientstate8{};

View File

@ -41,7 +41,6 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
float frameTime = g_GlobalVars->frametime; float frameTime = g_GlobalVars->frametime;
float curTime = g_GlobalVars->curtime; float curTime = g_GlobalVars->curtime;
CUserCmd defaultCmd; CUserCmd defaultCmd;
if (ucmd == NULL) if (ucmd == NULL)
{ {

View File

@ -23,7 +23,9 @@ CatCommand fix_deadlock("ipc_fix_deadlock", "Fix deadlock", []() {
pthread_mutex_unlock(&peer->memory->mutex); pthread_mutex_unlock(&peer->memory->mutex);
} }
}); });
CatCommand id("ipc_id", "Echo ipc id", []() {
logging::Info("%d",ipc::peer->client_id);
});
CatCommand connect("ipc_connect", "Connect to IPC server", []() { CatCommand connect("ipc_connect", "Connect to IPC server", []() {
if (peer) if (peer)
{ {

View File

@ -15,7 +15,7 @@ CTFGCClientSystem *CTFGCClientSystem::GTFGCClientSystem()
typedef CTFGCClientSystem *(*GTFGCClientSystem_t)(); typedef CTFGCClientSystem *(*GTFGCClientSystem_t)();
static uintptr_t addr1 = gSignatures.GetClientSignature( static uintptr_t addr1 = gSignatures.GetClientSignature(
"55 B8 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 A1 ? ? ? ? 89 E5 5D C3 " "55 B8 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 A1 ? ? ? ? 89 E5 5D C3 "
"8D B6 00 00 00 00 A1 ? ? ? ?"); "8D B6 00 00 00 00 A1");
static GTFGCClientSystem_t GTFGCClientSystem_fn = static GTFGCClientSystem_t GTFGCClientSystem_fn =
GTFGCClientSystem_t(addr1); GTFGCClientSystem_t(addr1);
@ -26,7 +26,7 @@ void CTFGCClientSystem::AbandonCurrentMatch()
{ {
typedef void *(*AbandonCurrentMatch_t)(CTFGCClientSystem *); typedef void *(*AbandonCurrentMatch_t)(CTFGCClientSystem *);
static uintptr_t addr1 = gSignatures.GetClientSignature( static uintptr_t addr1 = gSignatures.GetClientSignature(
"55 89 E5 57 56 8D 75 ? 53 81 EC ? ? ? ? C7 04 24 ? ? ? ?"); "55 89 E5 57 56 8D 75 ? 53 81 EC ? ? ? ? C7 04 24");
static AbandonCurrentMatch_t AbandonCurrentMatch_fn = static AbandonCurrentMatch_t AbandonCurrentMatch_fn =
AbandonCurrentMatch_t(addr1); AbandonCurrentMatch_t(addr1);
if (AbandonCurrentMatch_fn == nullptr) if (AbandonCurrentMatch_fn == nullptr)
@ -40,7 +40,7 @@ bool CTFGCClientSystem::BConnectedToMatchServer(bool flag)
{ {
typedef bool (*BConnectedToMatchServer_t)(CTFGCClientSystem *, bool); typedef bool (*BConnectedToMatchServer_t)(CTFGCClientSystem *, bool);
static uintptr_t addr = static uintptr_t addr =
gSignatures.GetClientSignature("55 89 E5 53 80 7D ? ? 8B 55 ? 75 ?"); gSignatures.GetClientSignature("55 89 E5 53 80 7D ? ? 8B 55 ? 75");
static BConnectedToMatchServer_t BConnectedToMatchServer_fn = static BConnectedToMatchServer_t BConnectedToMatchServer_fn =
BConnectedToMatchServer_t(addr); BConnectedToMatchServer_t(addr);
@ -51,7 +51,7 @@ bool CTFGCClientSystem::BHaveLiveMatch()
{ {
typedef int (*BHaveLiveMatch_t)(CTFGCClientSystem *); typedef int (*BHaveLiveMatch_t)(CTFGCClientSystem *);
static uintptr_t addr = gSignatures.GetClientSignature( static uintptr_t addr = gSignatures.GetClientSignature(
"55 31 C0 89 E5 53 8B 4D ? 0F B6 91 ? ? ? ?"); "55 31 C0 89 E5 53 8B 4D ? 0F B6 91");
static BHaveLiveMatch_t BHaveLiveMatch_fn = BHaveLiveMatch_t(addr); static BHaveLiveMatch_t BHaveLiveMatch_fn = BHaveLiveMatch_t(addr);
if (BHaveLiveMatch_fn == nullptr) if (BHaveLiveMatch_fn == nullptr)
{ {

View File

@ -52,11 +52,25 @@ void queue_leave()
else else
logging::Info("queue_start: CTFPartyClient == null!"); logging::Info("queue_start: CTFPartyClient == null!");
} }
Timer abandont{};
CatCommand abandoncmd("disconnect_and_abandon", "Disconnect and abandon", []() {
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
if (client) {
abandon();
while (1) {
if (abandont.test_and_set(4000)) {
queue_leave();
break;
}
}
}
else
logging::Info("your party client is gay!");
});
void abandon() void abandon()
{ {
re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem();
if (gc != nullptr) if (gc != nullptr && gc->BConnectedToMatchServer(false))
gc->AbandonCurrentMatch(); gc->AbandonCurrentMatch();
else else
logging::Info("abandon: CTFGCClientSystem == null!"); logging::Info("abandon: CTFGCClientSystem == null!");

View File

@ -129,7 +129,7 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
switch (ent->m_Type) switch (ent->m_Type)
{ {
case ENTITY_BUILDING: case ENTITY_BUILDING:
if (!ent->m_bEnemy && !(teammates || teammate_buildings)) if (!ent->m_bEnemy && !(teammates || teammate_buildings) && (!(chamsR || chamsB || chamsG) && ent != LOCAL_E))
{ {
return colors::empty; return colors::empty;
} }
@ -178,7 +178,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity *entity)
if (ent->m_iHealth == 0 || !ent->m_iHealth) if (ent->m_iHealth == 0 || !ent->m_iHealth)
return false; return false;
if (CE_BYTE(LOCAL_E, netvar.m_bCarryingObject) && if (CE_BYTE(LOCAL_E, netvar.m_bCarryingObject) &&
LOCAL_E->m_vecOrigin.DistTo(ent->m_vecOrigin) <= 85.0f) LOCAL_E->m_vecOrigin.DistTo(ent->m_vecOrigin) <= 100.0f)
return false; return false;
return true; return true;
case ENTITY_PLAYER: case ENTITY_PLAYER: