L L4D2node

SV_PackEntity

0x00205e00 · 1693 bytes · __regparm3

_ZL13SV_PackEntityiP7edict_tP11ServerClassP14CFrameSnapshot

Decompiled

undefined (4 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* SV_PackEntity(int, edict_t*, ServerClass*, CFrameSnapshot*) */

void __regparm3
SV_PackEntity(int param_1,edict_t *param_2,ServerClass *param_3,CFrameSnapshot *param_4)

{
  SendTable *pSVar1;
  int iVar2;
  char cVar3;
  int iVar4;
  PackedEntity *pPVar5;
  undefined1 *puVar6;
  undefined4 uVar7;
  int *piVar8;
  int iVar9;
  int in_GS_OFFSET;
  int local_80e0;
  undefined4 local_80dc;
  undefined4 local_80d8;
  undefined4 local_80d0;
  undefined4 local_80cc;
  int local_80c8;
  undefined1 *local_80c4;
  undefined4 local_80c0;
  undefined4 local_80bc;
  undefined4 local_80b8 [3];
  int local_80ac;
  int local_80a0 [4096];
  undefined1 local_40a0 [128];
  undefined1 local_4020 [16384];
  int local_20;
  
  local_80dc = 0;
  local_80d8 = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (_g_Telemetry == 0) {
    local_80c8 = 0;
  }
  else {
    (**(code **)(_g_Telemetry + 0x50))
              (_g_Telemetry,&local_80dc,0,0x32,0,0,"/data/src/engine/./sv_packedentities.cpp",99,
               &SV_PackEntity(int,edict_t*,ServerClass*,CFrameSnapshot*)::tm_fmt,&DAT_002c48a3,
               "SV_PackEntity");
    local_80c8 = _g_Telemetry;
  }
  iVar9 = *(int *)(*(int *)(param_4 + 8) + 4 + param_1 * 0xc);
  local_80d0 = local_80dc;
  local_80cc = local_80d8;
                    /* try { // try from 00206326 to 00206356 has its CatchHandler @ 002064e4 */
  if (((((byte)*param_2 & 1) == 0) &&
      (cVar3 = CFrameSnapshotManager::UsePreviouslySentPacket
                         ((CFrameSnapshotManager *)framesnapshotmanager,param_4,param_1,iVar9),
      cVar3 != '\0')) && (*(int *)(sv_debugmanualmode._28_4_ + 0x30) == 0)) {
    *(uint *)param_2 = *(uint *)param_2 & 0xfffffefe;
    iVar9 = CBaseEdict::GetChangeAccessor((CBaseEdict *)param_2);
    *(undefined2 *)(iVar9 + 2) = 0;
LAB_0020635d:
    if (local_80c8 != 0) {
      (**(code **)(local_80c8 + 0x54))(local_80c8,local_80d0,local_80cc,0,0,0);
    }
  }
  else {
                    /* try { // try from 00205f2c to 00205f30 has its CatchHandler @ 002064e4 */
    bf_write::bf_write((bf_write *)local_80b8,"SV_PackEntity->writeBuf",local_4020,0x4000,-1);
    local_80c4 = local_40a0;
    local_80bc = 0xffffffff;
    pSVar1 = *(SendTable **)(param_3 + 4);
    local_80c0 = *(undefined4 *)(*(int *)(pSVar1 + 0xc) + 0xf8);
                    /* try { // try from 00205f8f to 00206281 has its CatchHandler @ 002064be */
    cVar3 = SendTable_Encode(pSVar1,*(void **)(param_2 + 0xc),(bf_write *)local_80b8,param_1,
                             (CUtlMemory *)&local_80c4,false);
    if (cVar3 == '\0') {
                    /* try { // try from 002063b9 to 0020649f has its CatchHandler @ 002064be */
      Host_Error("SV_PackEntity: SendTable_Encode returned false (ent %d).\n",param_1);
      if (*(int *)(vcr_verbose._28_4_ + 0x30) != 0) goto LAB_00206110;
LAB_00205fac:
      iVar4 = local_80ac + 7 >> 3;
    }
    else {
      if (*(int *)(vcr_verbose._28_4_ + 0x30) == 0) goto LAB_00205fac;
LAB_00206110:
      iVar4 = local_80ac + 7 >> 3;
      if (0 < iVar4) {
        (**(code **)(_g_pVCR + 0x90))("writebuf",local_80b8[0],iVar4 + -1);
        goto LAB_00205fac;
      }
    }
    SV_EnsureInstanceBaseline(param_3,param_1,local_4020,iVar4);
    iVar4 = SendTable_GetNumFlatProps(pSVar1);
    pPVar5 = (PackedEntity *)
             CFrameSnapshotManager::GetPreviouslySentPacket
                       ((CFrameSnapshotManager *)framesnapshotmanager,param_1,
                        *(int *)(*(int *)(param_4 + 8) + 4 + param_1 * 0xc));
    if (pPVar5 == (PackedEntity *)0x0) {
      piVar8 = (int *)AllocChangeFrameList(iVar4,*(int *)(param_4 + 4));
    }
    else {
      local_80e0 = SendTable_CalcDelta(pSVar1,*(void **)(pPVar5 + 0x24),
                                       *(uint *)(pPVar5 + 0x28) & 0x7fffffff,local_4020,local_80ac,
                                       local_80a0,0x1000,param_1);
      if (*(int *)(vcr_verbose._28_4_ + 0x30) != 0) {
        (**(code **)(_g_pVCR + 0x90))("nChanges",&local_80e0,4);
      }
      if (local_80e0 == 0) {
        cVar3 = PackedEntity::CompareRecipients(pPVar5,(CUtlMemory *)&local_80c4);
        if ((cVar3 != '\0') &&
           (cVar3 = CFrameSnapshotManager::UsePreviouslySentPacket
                              ((CFrameSnapshotManager *)framesnapshotmanager,param_4,param_1,iVar9),
           cVar3 != '\0')) {
          *(uint *)param_2 = *(uint *)param_2 & 0xfffffefe;
          iVar9 = CBaseEdict::GetChangeAccessor((CBaseEdict *)param_2);
          *(undefined2 *)(iVar9 + 2) = 0;
          CUtlMemory<CSendProxyRecipients,int>::Purge
                    ((CUtlMemory<CSendProxyRecipients,int> *)&local_80c4);
          goto LAB_0020635d;
        }
      }
      else if ((((byte)*param_2 & 1) == 0) && (0 < local_80e0)) {
        iVar9 = 0;
        do {
          iVar2 = *(int *)(*(int *)(*(int *)(pSVar1 + 0xc) + 0x2c) + local_80a0[iVar9] * 4);
          if ((*(uint *)(iVar2 + 0x3c) & 0x180000) == 0) {
            uVar7 = *(undefined4 *)(iVar2 + 0x30);
            if (*(int *)(param_2 + 0xc) == 0) {
              puVar6 = &DAT_002c79d4;
            }
            else {
              puVar6 = (undefined1 *)
                       (**(code **)(**(int **)(param_2 + 8) + 0xc))(*(int **)(param_2 + 8));
            }
            Msg("Entity %d (class \'%s\') reported ENTITY_CHANGE_NONE but \'%s\' changed.\n",param_1
                ,puVar6,uVar7);
          }
          iVar9 = iVar9 + 1;
        } while (iVar9 < local_80e0);
      }
      if ((hltv == 0) || (cVar3 = (**(code **)(*(int *)(hltv + 4) + 0x58))(hltv + 4), cVar3 == '\0')
         ) {
        piVar8 = *(int **)(pPVar5 + 0x2c);
        *(undefined4 *)(pPVar5 + 0x2c) = 0;
      }
      else {
        piVar8 = (int *)(**(code **)(**(int **)(pPVar5 + 0x2c) + 0x10))(*(int **)(pPVar5 + 0x2c));
      }
      if (piVar8 == (int *)0x0) {
        Error("SV_PackEntity: SnagChangeFrameList returned null");
      }
      iVar9 = (**(code **)(*piVar8 + 4))(piVar8);
      if (iVar4 != iVar9) {
        uVar7 = (**(code **)(*piVar8 + 4))(piVar8);
        Error("SV_PackEntity: SnagChangeFrameList mismatched number of props[%d vs %d]",iVar4,uVar7)
        ;
      }
      (**(code **)(*piVar8 + 8))(piVar8,local_80a0,local_80e0,*(undefined4 *)(param_4 + 4));
    }
    pPVar5 = (PackedEntity *)
             CFrameSnapshotManager::CreatePackedEntity
                       ((CFrameSnapshotManager *)framesnapshotmanager,param_4,param_1);
    *(int **)(pPVar5 + 0x2c) = piVar8;
    PackedEntity::SetServerAndClientClass(pPVar5,param_3,(ClientClass *)0x0);
    PackedEntity::AllocAndCopyPadded(pPVar5,local_4020,local_80ac + 7 >> 3);
    PackedEntity::SetRecipients(pPVar5,(CUtlMemory *)&local_80c4);
    *(uint *)param_2 = *(uint *)param_2 & 0xfffffefe;
    iVar9 = CBaseEdict::GetChangeAccessor((CBaseEdict *)param_2);
    *(undefined2 *)(iVar9 + 2) = 0;
    CUtlMemory<CSendProxyRecipients,int>::Purge((CUtlMemory<CSendProxyRecipients,int> *)&local_80c4)
    ;
    if (local_80c8 != 0) {
      (**(code **)(local_80c8 + 0x54))(local_80c8,local_80d0,local_80cc,0,0,0);
    }
  }
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)