working weapon concealment
This commit is contained in:
@@ -13,7 +13,7 @@ extern bool g_enabled;
|
||||
extern bool g_armed;
|
||||
|
||||
using SendSnapshotFn = void (*)(void*, void*);
|
||||
using PackEntitiesFn = void (*)(void*, void*, int, void*, void*, void*, void*, void*, void*);
|
||||
using PackEntitiesFn = void (*)(void*, void*, int, void*, void*, void*, void*);
|
||||
using PackEntityFn = void (*)(void*, void*, int, void*, void*, void*, void*, void*, void*, void*);
|
||||
static SendSnapshotFn g_sendSnapshot = nullptr;
|
||||
static PackEntitiesFn g_packEntities = nullptr;
|
||||
@@ -26,8 +26,11 @@ static uint64_t g_packCalls = 0;
|
||||
static uint64_t g_packEntityCalls = 0;
|
||||
static uint64_t g_packEntityGenericSpoofs = 0;
|
||||
static uint64_t g_fullUpdateWrites = 0;
|
||||
static uint64_t g_packEntitiesDebugLogs = 0;
|
||||
static uint64_t g_packEntityRuleDebugLogs = 0;
|
||||
static int g_fullUpdateBudget = 0;
|
||||
static thread_local CPlayerSlot g_currentRecipient(-1);
|
||||
static thread_local CPlayerSlot g_lastSnapshotRecipient(-1);
|
||||
|
||||
static CPlayerSlot SlotFromClient(void* client)
|
||||
{
|
||||
@@ -55,7 +58,9 @@ struct ScopedRecipient
|
||||
static void Detour_SendSnapshot(void* client, void* snapshot)
|
||||
{
|
||||
++g_snapshotCalls;
|
||||
ScopedRecipient recipient(client ? SlotFromClient(client) : CPlayerSlot(-1));
|
||||
CPlayerSlot slot(client ? SlotFromClient(client) : CPlayerSlot(-1));
|
||||
g_lastSnapshotRecipient = slot;
|
||||
ScopedRecipient recipient(slot);
|
||||
if (client && g_fullUpdateBudget > 0)
|
||||
{
|
||||
int offset = g_gameConfig ? g_gameConfig->GetOffset("CServerSideClient_DeltaTick") : -1;
|
||||
@@ -70,10 +75,26 @@ static void Detour_SendSnapshot(void* client, void* snapshot)
|
||||
g_sendSnapshot(client, snapshot);
|
||||
}
|
||||
|
||||
static void Detour_PackEntities(void* self, void* arg1, int arg2, void* arg3, void* arg4, void* arg5, void* arg6, void* arg7, void* arg8)
|
||||
static void Detour_PackEntities(void* self, void* arg1, int arg2, void* arg3, void* arg4, void* arg5, void* arg6)
|
||||
{
|
||||
++g_packCalls;
|
||||
g_packEntities(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
CPlayerSlot recipient((arg2 >= 0 && arg2 < 64) ? arg2 : -1);
|
||||
if (g_packEntitiesDebugLogs < 16)
|
||||
{
|
||||
SPMessage("pack_entities call %llu self=%p arg1=%p arg2=%d recipient=%d args=[%p %p %p %p]\n",
|
||||
static_cast<unsigned long long>(g_packCalls),
|
||||
self,
|
||||
arg1,
|
||||
arg2,
|
||||
recipient.Get(),
|
||||
arg3,
|
||||
arg4,
|
||||
arg5,
|
||||
arg6);
|
||||
++g_packEntitiesDebugLogs;
|
||||
}
|
||||
ScopedRecipient scopedRecipient(recipient);
|
||||
g_packEntities(self, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
static void Detour_PackEntity(void* self, void* arg1, int entityIndex, void* entityData, void* arg4, void* arg5, void* arg6, void* arg7, void* arg8, void* arg9)
|
||||
@@ -87,6 +108,26 @@ static void Detour_PackEntity(void* self, void* arg1, int entityIndex, void* ent
|
||||
}
|
||||
|
||||
CPlayerSlot recipient = g_currentRecipient;
|
||||
if (recipient.Get() < 0 && g_lastSnapshotRecipient.Get() >= 0)
|
||||
recipient = g_lastSnapshotRecipient;
|
||||
if (g_packEntityRuleDebugLogs < 64 && g_overrides.HasRulesForEntity(entityIndex))
|
||||
{
|
||||
SPMessage("pack_entity ruled call %llu entity=%d current=%d lastSnapshot=%d args self=%p arg1=%p data=%p arg4=%p arg5=%p arg6=%p arg7=%p arg8=%p arg9=%p\n",
|
||||
static_cast<unsigned long long>(g_packEntityCalls),
|
||||
entityIndex,
|
||||
g_currentRecipient.Get(),
|
||||
g_lastSnapshotRecipient.Get(),
|
||||
self,
|
||||
arg1,
|
||||
entityData,
|
||||
arg4,
|
||||
arg5,
|
||||
arg6,
|
||||
arg7,
|
||||
arg8,
|
||||
arg9);
|
||||
++g_packEntityRuleDebugLogs;
|
||||
}
|
||||
auto applied = g_overrides.ApplyForPackedEntity(recipient, entityIndex, entityData);
|
||||
g_packEntityGenericSpoofs += applied.size();
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
|
||||
Reference in New Issue
Block a user