remake - v2
This commit is contained in:
@@ -36,6 +36,7 @@ static uint64_t g_packChanged = 0;
|
||||
static uint64_t g_packEntityCalls = 0;
|
||||
static uint64_t g_packEntitySpoofs = 0;
|
||||
static uint64_t g_packEntityScopedWrites = 0;
|
||||
static uint64_t g_packEntityGenericSpoofs = 0;
|
||||
static uint64_t g_packEntitySelfSkips = 0;
|
||||
static uint64_t g_packEntityNoRecipient = 0;
|
||||
static uint64_t g_fullUpdateWrites = 0;
|
||||
@@ -162,51 +163,51 @@ static void Detour_PackEntity(void* self, void* arg1, int entityIndex, void* ent
|
||||
{
|
||||
++g_packEntityCalls;
|
||||
|
||||
if (!g_enabled || !g_armed || !entityData)
|
||||
{
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
return;
|
||||
}
|
||||
|
||||
CEntityIdentity* identity = PlayerIdentityFromInstance(entityData);
|
||||
if (!identity)
|
||||
if (!g_enabled || !g_armed || !entityData || !g_overrides.HasPackedOverrides())
|
||||
{
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
return;
|
||||
}
|
||||
|
||||
CPlayerSlot recipient = g_currentRecipient;
|
||||
auto applied = g_overrides.ApplyForPackedEntity(recipient, entityIndex, entityData);
|
||||
g_packEntityGenericSpoofs += applied.size();
|
||||
|
||||
bool spoofedHealth = false;
|
||||
int savedHealth = 0;
|
||||
int* healthAddress = nullptr;
|
||||
int spoofHealth = 42;
|
||||
if (!g_overrides.TryGetHealth42Value(recipient, spoofHealth))
|
||||
if (g_overrides.TryGetHealth42Value(recipient, spoofHealth))
|
||||
{
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
return;
|
||||
CEntityIdentity* identity = PlayerIdentityFromInstance(entityData);
|
||||
if (identity)
|
||||
{
|
||||
if (recipient.Get() < 0)
|
||||
++g_packEntityNoRecipient;
|
||||
else if (OwnerSlotForPawn(identity) == recipient.Get())
|
||||
{
|
||||
++g_packEntitySelfSkips;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto healthField = schema::FindField("CBaseEntity", "m_iHealth");
|
||||
if (healthField.found && healthField.offset >= 0)
|
||||
{
|
||||
healthAddress = reinterpret_cast<int*>(reinterpret_cast<uint8_t*>(entityData) + healthField.offset);
|
||||
savedHealth = *healthAddress;
|
||||
*healthAddress = spoofHealth;
|
||||
spoofedHealth = true;
|
||||
++g_packEntitySpoofs;
|
||||
++g_packEntityScopedWrites;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recipient.Get() < 0)
|
||||
++g_packEntityNoRecipient;
|
||||
else if (OwnerSlotForPawn(identity) == recipient.Get())
|
||||
{
|
||||
++g_packEntitySelfSkips;
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
return;
|
||||
}
|
||||
|
||||
auto healthField = schema::FindField("CBaseEntity", "m_iHealth");
|
||||
if (!healthField.found || healthField.offset < 0)
|
||||
{
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* healthAddress = reinterpret_cast<int*>(reinterpret_cast<uint8_t*>(entityData) + healthField.offset);
|
||||
int savedHealth = *healthAddress;
|
||||
*healthAddress = spoofHealth;
|
||||
|
||||
++g_packEntitySpoofs;
|
||||
++g_packEntityScopedWrites;
|
||||
g_packEntity(self, arg1, entityIndex, entityData, arg4, arg5, arg6, arg7, arg8, arg9);
|
||||
*healthAddress = savedHealth;
|
||||
if (spoofedHealth)
|
||||
*healthAddress = savedHealth;
|
||||
g_overrides.Restore(applied);
|
||||
}
|
||||
|
||||
static bool InitPackEntityDetour(CGameConfig* config)
|
||||
@@ -303,7 +304,7 @@ void ShutdownSnapshotDetour()
|
||||
|
||||
void DumpDetourStats()
|
||||
{
|
||||
SPMessage("hooks: snapshot calls=%llu applied=%llu changed=%llu; pack calls=%llu applied=%llu changed=%llu; pack_entity calls=%llu spoofs=%llu scoped_writes=%llu self_skips=%llu no_recipient=%llu; fullupdate writes=%llu budget=%d\n",
|
||||
SPMessage("hooks: snapshot calls=%llu applied=%llu changed=%llu; pack calls=%llu applied=%llu changed=%llu; pack_entity calls=%llu health_spoofs=%llu generic_spoofs=%llu scoped_writes=%llu self_skips=%llu no_recipient=%llu; fullupdate writes=%llu budget=%d\n",
|
||||
static_cast<unsigned long long>(g_snapshotCalls),
|
||||
static_cast<unsigned long long>(g_snapshotApplied),
|
||||
static_cast<unsigned long long>(g_snapshotChanged),
|
||||
@@ -312,6 +313,7 @@ void DumpDetourStats()
|
||||
static_cast<unsigned long long>(g_packChanged),
|
||||
static_cast<unsigned long long>(g_packEntityCalls),
|
||||
static_cast<unsigned long long>(g_packEntitySpoofs),
|
||||
static_cast<unsigned long long>(g_packEntityGenericSpoofs),
|
||||
static_cast<unsigned long long>(g_packEntityScopedWrites),
|
||||
static_cast<unsigned long long>(g_packEntitySelfSkips),
|
||||
static_cast<unsigned long long>(g_packEntityNoRecipient),
|
||||
|
||||
Reference in New Issue
Block a user