L L4D2node

SV_DetermineUpdateType

0x001ecdf0 · 1863 bytes · __regparm3

_ZL22SV_DetermineUpdateTypeR16CEntityWriteInfo

Decompiled

undefined (1 param)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* SV_DetermineUpdateType(CEntityWriteInfo&) */

void __regparm3 SV_DetermineUpdateType(CEntityWriteInfo *param_1)

{
  PackedEntity *pPVar1;
  PackedEntity *this;
  SendTable *pSVar2;
  undefined8 uVar3;
  char cVar4;
  void *pvVar5;
  int iVar6;
  float *pfVar7;
  float *pfVar8;
  bf_write *pbVar9;
  CSendProxyRecipients *pCVar10;
  int iVar11;
  CSendProxyRecipients *pCVar12;
  void *pvVar13;
  int iVar14;
  byte *pbVar15;
  int *piVar16;
  bool bVar17;
  int *local_8054;
  byte local_8050;
  int local_8048;
  SendTable *local_8044;
  undefined4 local_8040;
  uint local_803c;
  int local_8038;
  int local_8034;
  int local_8030;
  int local_802c;
  int local_8028;
  int local_8024;
  int local_8020;
  int local_801c [4096];
  int local_401c [4099];
  
  iVar6 = *(int *)(param_1 + 0x18);
  if (iVar6 < *(int *)(param_1 + 0x14)) goto LAB_001ece58;
  if (*(int *)(param_1 + 0x14) < iVar6) {
    *(undefined4 *)(param_1 + 0x10) = 1;
    return;
  }
  if (param_1[4] != (CEntityWriteInfo)0x0) {
    if (*(int *)(*(int *)(param_1 + 0x13c) + 0xc) <= iVar6) {
LAB_001ece58:
      *(undefined4 *)(param_1 + 0x10) = 0;
      return;
    }
    piVar16 = (int *)(*(int *)(*(int *)(param_1 + 0x13c) + 8) + iVar6 * 0xc);
    if ((*piVar16 == 0) ||
       (piVar16[1] != *(int *)(iVar6 * 0xc + *(int *)(*(int *)(param_1 + 0x140) + 8) + 4)))
    goto LAB_001ece58;
  }
  iVar14 = *(int *)(param_1 + 0x38);
  if (*(int *)(param_1 + 0x34) == iVar14) goto LAB_001ed060;
  if ((param_1[0x150] == (CEntityWriteInfo)0x0) && (hltv != 0)) {
    pvVar5 = (void *)CDeltaEntityCache::FindDeltaBits
                               ((CDeltaEntityCache *)(hltv + 0x63e0),iVar6,
                                *(int *)(*(int *)(param_1 + 0x13c) + 4),local_401c);
    if (pvVar5 != (void *)0x0) {
      if (local_401c[0] < 1) goto LAB_001ed060;
      iVar6 = *(int *)(param_1 + 0x18);
      pbVar9 = *(bf_write **)(param_1 + 0x2c);
      bf_write::WriteUBitVar(pbVar9,(iVar6 - *(int *)(param_1 + 0x1c)) - 1);
      iVar14 = *(int *)(pbVar9 + 0xc);
      if (iVar14 < *(int *)(pbVar9 + 8)) {
        if (pbVar9[0x10] == (bf_write)0x0) {
          pbVar15 = (byte *)((iVar14 >> 3) + *(int *)pbVar9);
          local_8050 = (byte)(1 << ((byte)iVar14 & 7));
          *pbVar15 = *pbVar15 & ~local_8050;
          iVar14 = *(int *)(pbVar9 + 0xc) + 1;
          *(int *)(pbVar9 + 0xc) = iVar14;
          if (*(int *)(pbVar9 + 8) <= iVar14) goto LAB_001ecf06;
        }
        if (pbVar9[0x10] == (bf_write)0x0) {
          pbVar15 = (byte *)((iVar14 >> 3) + *(int *)pbVar9);
          local_8050 = (byte)(1 << ((byte)iVar14 & 7));
          *pbVar15 = *pbVar15 & ~local_8050;
          *(int *)(pbVar9 + 0xc) = *(int *)(pbVar9 + 0xc) + 1;
        }
      }
      else {
LAB_001ecf06:
        pbVar9[0x10] = (bf_write)0x1;
      }
      *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;
      *(int *)(param_1 + 0x1c) = iVar6;
      bf_write::WriteBits(*(bf_write **)(param_1 + 0x2c),pvVar5,local_401c[0]);
      *(undefined4 *)(param_1 + 0x10) = 2;
      return;
    }
    iVar14 = *(int *)(param_1 + 0x38);
  }
  pvVar5 = (void *)0x1000;
  iVar6 = PackedEntity::GetPropsChangedAfterTick
                    (iVar14,*(int **)(*(int *)(param_1 + 0x13c) + 4),(int)local_801c);
  if (iVar6 == -1) {
    pPVar1 = *(PackedEntity **)(param_1 + 0x34);
    if (*(int *)(pPVar1 + 0x28) < 0) {
      pvVar13 = (void *)CBaseServer::UncompressPackedEntity
                                  (*(CBaseServer **)(param_1 + 0x148),pPVar1,&local_8034);
    }
    else {
      pvVar13 = *(void **)(pPVar1 + 0x24);
      local_8034 = *(int *)(pPVar1 + 0x28);
    }
    pPVar1 = *(PackedEntity **)(param_1 + 0x38);
    if (*(int *)(pPVar1 + 0x28) < 0) {
      pvVar5 = (void *)CBaseServer::UncompressPackedEntity
                                 (*(CBaseServer **)(param_1 + 0x148),pPVar1,local_401c);
    }
    else {
      pvVar5 = *(void **)(pPVar1 + 0x24);
      local_401c[0] = *(int *)(pPVar1 + 0x28);
    }
    iVar6 = SendTable_CalcDelta(*(SendTable **)(**(int **)(param_1 + 0x34) + 4),pvVar13,local_8034,
                                pvVar5,local_401c[0],local_801c,0x1000,*(int *)(param_1 + 0x18));
  }
  if (*(int *)(vcr_verbose._28_4_ + 0x30) != 0) {
    (**(code **)(_g_pVCR + 0x90))("checkProps",local_801c,iVar6 * 4,pvVar5);
  }
  if (iVar6 < 1) {
    if ((param_1[0x150] == (CEntityWriteInfo)0x0) && (hltv != 0)) {
      CDeltaEntityCache::AddDeltaBits
                ((CDeltaEntityCache *)(hltv + 0x63e0),*(int *)(param_1 + 0x18),
                 *(int *)(*(int *)(param_1 + 0x13c) + 4),0,(bf_write *)0x0);
    }
LAB_001ed060:
    *(undefined4 *)(param_1 + 0x10) = 3;
    return;
  }
  iVar11 = *(int *)(param_1 + 0x18);
  pbVar9 = *(bf_write **)(param_1 + 0x2c);
  bf_write::WriteUBitVar(pbVar9,(iVar11 - *(int *)(param_1 + 0x1c)) - 1);
  iVar14 = *(int *)(pbVar9 + 0xc);
  if (iVar14 < *(int *)(pbVar9 + 8)) {
    if (pbVar9[0x10] == (bf_write)0x0) {
      pbVar15 = (byte *)((iVar14 >> 3) + *(int *)pbVar9);
      *pbVar15 = *pbVar15 & ~(byte)(1 << ((byte)iVar14 & 7));
      iVar14 = *(int *)(pbVar9 + 0xc) + 1;
      *(int *)(pbVar9 + 0xc) = iVar14;
      if (*(int *)(pbVar9 + 8) <= iVar14) goto LAB_001ed09a;
    }
    if (pbVar9[0x10] == (bf_write)0x0) {
      pbVar15 = (byte *)((iVar14 >> 3) + *(int *)pbVar9);
      *pbVar15 = *pbVar15 & ~(byte)(1 << ((byte)iVar14 & 7));
      *(int *)(pbVar9 + 0xc) = *(int *)(pbVar9 + 0xc) + 1;
    }
  }
  else {
LAB_001ed09a:
    pbVar9[0x10] = (bf_write)0x1;
  }
  *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;
  pPVar1 = *(PackedEntity **)(param_1 + 0x38);
  bVar17 = g_bServerDTIEnabled != '\0';
  *(int *)(param_1 + 0x1c) = iVar11;
  this = *(PackedEntity **)(param_1 + 0x34);
  pSVar2 = *(SendTable **)(*(int *)pPVar1 + 4);
  local_803c = 0;
  local_8038 = 0;
  if (bVar17) {
    local_8040 = 3;
    uVar3 = rdtsc();
    local_8038 = (int)((ulonglong)uVar3 >> 0x20);
    local_803c = (uint)uVar3;
                    /* try { // try from 001ed10c to 001ed2e6 has its CatchHandler @ 001ed552 */
    local_8044 = pSVar2;
    cVar4 = (**(code **)(**(int **)(param_1 + 0x148) + 0x70))(*(int **)(param_1 + 0x148));
    if (cVar4 == '\0') {
      pbVar15 = (byte *)(*(int *)(pPVar1 + 8) * 0x10 + DAT_003b8174);
      if (((*pbVar15 & 4) == 0) || (piVar16 = *(int **)(pbVar15 + 0xc), piVar16 == (int *)0x0)) {
        local_8054 = (int *)0x0;
      }
      else {
        local_8054 = (int *)(**(code **)(*piVar16 + 0x10))(piVar16);
      }
      pbVar15 = (byte *)(*(int *)(param_1 + 0x30) * 0x10 + DAT_003b8174);
      if (((((*pbVar15 & 4) != 0) && (piVar16 = *(int **)(pbVar15 + 0xc), piVar16 != (int *)0x0)) &&
          (piVar16 = (int *)(**(code **)(*piVar16 + 0x10))(piVar16), piVar16 != (int *)0x0)) &&
         (local_8054 != (int *)0x0)) {
        pfVar7 = (float *)(**(code **)(*piVar16 + 0x20))(piVar16);
        pfVar8 = (float *)(**(code **)(*local_8054 + 0x20))(local_8054);
        ServerDTI_AddEntityEncodeEvent
                  (pSVar2,SQRT((pfVar8[1] - pfVar7[1]) * (pfVar8[1] - pfVar7[1]) +
                               (*pfVar8 - *pfVar7) * (*pfVar8 - *pfVar7) +
                               (pfVar8[2] - pfVar7[2]) * (pfVar8[2] - pfVar7[2])));
      }
    }
  }
  if (*(int *)(pPVar1 + 0x28) < 0) {
    local_8054 = (int *)CBaseServer::UncompressPackedEntity
                                  (*(CBaseServer **)(param_1 + 0x148),pPVar1,&local_8048);
  }
  else {
    local_8054 = *(int **)(pPVar1 + 0x24);
    local_8048 = *(int *)(pPVar1 + 0x28);
  }
  bf_write::bf_write((bf_write *)&local_8034);
  if (param_1[0x150] == (CEntityWriteInfo)0x0) {
    pbVar9 = *(bf_write **)(param_1 + 0x2c);
    local_8034 = *(int *)pbVar9;
    local_8030 = *(int *)(pbVar9 + 4);
    local_802c = *(int *)(pbVar9 + 8);
    local_8028 = *(int *)(pbVar9 + 0xc);
    local_8024 = *(int *)(pbVar9 + 0x10);
    local_8020 = *(int *)(pbVar9 + 0x14);
    piVar16 = local_801c;
  }
  else {
                    /* try { // try from 001ed418 to 001ed4fc has its CatchHandler @ 001ed552 */
    iVar14 = PackedEntity::GetNumRecipients(pPVar1);
    pCVar10 = (CSendProxyRecipients *)PackedEntity::GetRecipients(pPVar1);
    iVar11 = PackedEntity::GetNumRecipients(this);
    pCVar12 = (CSendProxyRecipients *)PackedEntity::GetRecipients(this);
    iVar6 = SendTable_CullPropsFromProxies
                      (pSVar2,local_801c,iVar6,*(int *)(param_1 + 0x30) + -1,pCVar12,iVar11,pCVar10,
                       iVar14,local_401c,0x1000);
    piVar16 = local_401c;
    pbVar9 = *(bf_write **)(param_1 + 0x2c);
  }
  SendTable_WritePropList(pSVar2,local_8054,local_8048,pbVar9,*(int *)(pPVar1 + 8),piVar16,iVar6);
  if ((param_1[0x150] == (CEntityWriteInfo)0x0) && (hltv != 0)) {
    CDeltaEntityCache::AddDeltaBits
              ((CDeltaEntityCache *)(hltv + 0x63e0),*(int *)(pPVar1 + 8),
               *(int *)(*(int *)(param_1 + 0x13c) + 4),
               *(int *)(*(int *)(param_1 + 0x2c) + 0xc) - local_8028,(bf_write *)&local_8034);
  }
  if ((g_bServerDTIEnabled != '\0') && (local_8044 != (SendTable *)0x0)) {
    uVar3 = rdtsc();
    bVar17 = (uint)uVar3 < local_803c;
    local_803c = (uint)uVar3 - local_803c;
    local_8038 = ((int)((ulonglong)uVar3 >> 0x20) - local_8038) - (uint)bVar17;
    _ServerDTI_HookTimer(local_8044,local_8040,&local_803c);
  }
  *(undefined4 *)(param_1 + 0x10) = 2;
  return;
}

SourceMod gamedata

paste into addons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)

Just a Signatures{} block, ready to drop into a gamedata file. Wire it up in your plugin however you like - SDKCall, DHooks, raw memory ops, or anything else.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)