L L4D2node

CBaseServer::WriteTempEntities

0x0010f9c0 · 2558 bytes · __thiscall

_ZN11CBaseServer17WriteTempEntitiesEP11CBaseClientP14CFrameSnapshotS3_R8bf_writei

Decompiled

undefined (6 params)

/* CBaseServer::WriteTempEntities(CBaseClient*, CFrameSnapshot*, CFrameSnapshot*, bf_write&, int) */

void __thiscall
CBaseServer::WriteTempEntities
          (CBaseServer *this,CBaseClient *param_1,CFrameSnapshot *param_2,CFrameSnapshot *param_3,
          bf_write *param_4,int param_5)

{
  ushort *puVar1;
  short sVar2;
  char cVar3;
  uchar *puVar4;
  uint uVar5;
  uint uVar6;
  int iVar7;
  uint uVar8;
  ushort uVar9;
  uint *puVar10;
  byte *pbVar11;
  int iVar12;
  int iVar13;
  ushort uVar14;
  short *psVar15;
  bool bVar16;
  int local_f8;
  short *local_f4;
  CEventInfo *local_e0;
  int local_dc;
  undefined4 local_d8;
  undefined4 local_d4;
  int local_d0;
  int local_cc;
  code *local_c8;
  void *local_c4;
  int local_c0;
  undefined4 local_bc;
  undefined2 local_b8;
  ushort local_b6;
  ushort local_b4;
  ushort local_b2;
  void *local_b0;
  undefined **local_ac;
  undefined1 local_a8;
  undefined4 local_a4;
  undefined4 local_a0;
  undefined4 local_9c;
  undefined8 local_98;
  undefined4 local_90;
  undefined4 local_8c;
  undefined8 local_88;
  undefined4 local_80;
  undefined4 local_7c;
  undefined1 local_78;
  undefined8 local_74;
  undefined4 local_6c;
  undefined4 local_68;
  uint local_60;
  undefined4 local_58;
  undefined1 local_54;
  undefined4 local_50;
  undefined4 local_4c;
  int local_34 [2];
  uint local_2c;
  uint local_28;
  char local_24;
  
  puVar4 = (uchar *)NET_AllocPayload();
  local_78 = 0;
  local_74 = 0;
  local_a0 = 0;
  local_9c = 0;
  local_98 = 0;
  local_90 = 0;
  local_8c = 0;
  local_88 = 0;
  local_80 = 0;
  local_7c = 0;
  local_6c = 0;
  local_68 = 0;
  local_a8 = 1;
  local_a4 = 0;
  local_ac = &PTR__SVC_TempEntities_002a1e88;
  local_54 = 0;
  local_58 = 0;
  local_50 = 0xffffffff;
  local_4c = 0;
                    /* try { // try from 0010fa7a to 0010fa7e has its CatchHandler @ 0011046d */
  bf_write::bf_write((bf_write *)local_34);
  local_a8 = 0;
                    /* try { // try from 0010faa8 to 0010faac has its CatchHandler @ 00110444 */
  bf_write::StartWriting((bf_write *)local_34,puVar4,0x37aa0,0,-1);
  local_dc = 0;
  local_d8 = 0;
  local_d4 = 0;
  local_d0 = 0;
  local_cc = 0;
  iVar12 = *(int *)(sv_debugtempentities._28_4_ + 0x30);
                    /* try { // try from 0010fb0d to 0010fb11 has its CatchHandler @ 00110466 */
  CFrameSnapshotManager::BuildSnapshotList
            ((CFrameSnapshotManager *)framesnapshotmanager,param_2,param_3,
             (CReferencedSnapshotList *)&local_dc);
  local_c8 = CEventInfo_LessFunc;
  if (0xff < param_5) {
    param_5 = 0xff;
  }
  local_c4 = (void *)0x0;
  local_bc = 0;
  local_c0 = param_5;
  if (param_5 == 0) {
    local_b8 = 0xffff;
    local_b6 = 0;
    local_b4 = 0xffff;
    local_b2 = 0xffff;
    local_b0 = (void *)0x0;
  }
  else {
    local_c4 = malloc(param_5 * 0xc);
    local_b6 = 0;
    local_b8 = 0xffff;
    local_b4 = 0xffff;
    local_b2 = 0xffff;
    local_b0 = local_c4;
    if ((0 < local_d0) && (0 < param_5)) {
      local_f8 = 0;
      do {
        iVar13 = 0;
        iVar7 = *(int *)(local_dc + local_f8 * 4);
        if (0 < *(int *)(iVar7 + 0x20)) {
          do {
            local_e0 = *(CEventInfo **)(*(int *)(iVar7 + 0x1c) + iVar13 * 4);
                    /* try { // try from 0010fd8d to 00110206 has its CatchHandler @ 001103d6 */
            cVar3 = (**(code **)(*(int *)param_1 + 0x104))(param_1,local_e0);
            if ((cVar3 == '\0') &&
               (CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                ::Insert((CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                          *)&local_c8,&local_e0), param_5 <= (int)(uint)local_b6)) break;
            iVar13 = iVar13 + 1;
          } while (iVar13 < *(int *)(iVar7 + 0x20));
        }
        local_f8 = local_f8 + 1;
      } while ((local_f8 < local_d0) && ((int)(uint)local_b6 < param_5));
      if (local_b6 != 0) {
        uVar5 = CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                ::FirstInorder((CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                *)&local_c8);
        uVar5 = uVar5 & 0xffff;
        if (uVar5 != 0xffff) {
          local_f4 = (short *)0x0;
          bVar16 = iVar12 != 0;
          do {
            psVar15 = *(short **)((int)local_c4 + uVar5 * 0xc + 8);
            if (*(float *)(psVar15 + 2) == 0.0) {
              if ((int)local_28 < (int)local_2c) {
                if (local_24 == '\0') {
                  pbVar11 = (byte *)(((int)local_28 >> 3) + local_34[0]);
                  *pbVar11 = *pbVar11 & ~(byte)(1 << ((byte)local_28 & 7));
                  local_28 = local_28 + 1;
                }
              }
              else {
                local_24 = '\x01';
              }
            }
            else {
              if ((int)local_28 < (int)local_2c) {
                if (local_24 == '\0') {
                  pbVar11 = (byte *)(((int)local_28 >> 3) + local_34[0]);
                  *pbVar11 = *pbVar11 | (byte)(1 << ((byte)local_28 & 7));
                  local_28 = local_28 + 1;
                }
              }
              else {
                local_24 = '\x01';
              }
              bf_write::WriteSBitLong((bf_write *)local_34,(int)(*(float *)(psVar15 + 2) * 100.0),8)
              ;
            }
            if ((local_f4 == (short *)0x0) || (*local_f4 != *psVar15)) {
              if ((int)local_28 < (int)local_2c) {
                if (local_24 == '\0') {
                  pbVar11 = (byte *)(((int)local_28 >> 3) + local_34[0]);
                  *pbVar11 = *pbVar11 | (byte)(1 << ((byte)local_28 & 7));
                  local_28 = local_28 + 1;
                }
              }
              else {
                local_24 = '\x01';
              }
              uVar6 = 0;
              if (bVar16) {
                uVar6 = local_28;
              }
              iVar12 = (**(code **)(*(int *)this + 0x48))(this);
              sVar2 = *psVar15;
              if ((int)local_2c < (int)(iVar12 + local_28)) {
                local_28 = local_2c;
                local_24 = '\x01';
              }
              else {
                iVar7 = ((int)local_28 >> 5) * 4;
                puVar10 = (uint *)(iVar7 + local_34[0]);
                uVar8 = local_28 & 0x1f;
                *puVar10 = (&g_BitWriteMasks)[uVar8 * 0x21 + iVar12] & *puVar10 |
                           (int)sVar2 << (sbyte)uVar8;
                iVar13 = 0x20 - uVar8;
                if (iVar13 < iVar12) {
                  puVar10 = (uint *)(local_34[0] + 4 + iVar7);
                  *puVar10 = (&g_BitWriteMasks)[iVar12 - iVar13] & *puVar10 |
                             (uint)(int)sVar2 >> ((byte)iVar13 & 0x1f);
                }
                local_28 = local_28 + iVar12;
              }
              cVar3 = (**(code **)(*(int *)this + 0x68))(this);
              if (cVar3 == '\0') {
                bf_write::WriteBits((bf_write *)local_34,*(void **)(psVar15 + 10),
                                    *(int *)(psVar15 + 8));
              }
              else {
                SendTable_WriteAllDeltaProps
                          (*(SendTable **)(psVar15 + 4),(void *)0x0,0,*(void **)(psVar15 + 10),
                           *(int *)(psVar15 + 8),-1,(bf_write *)local_34);
              }
              if (bVar16) {
                DevMsg("TE %s full bits: %i\n",*(undefined4 *)(*(int *)(psVar15 + 4) + 8),
                       local_28 - uVar6);
              }
            }
            else {
              if ((int)local_28 < (int)local_2c) {
                if (local_24 == '\0') {
                  pbVar11 = (byte *)(((int)local_28 >> 3) + local_34[0]);
                  *pbVar11 = *pbVar11 & ~(byte)(1 << ((byte)local_28 & 7));
                  local_28 = local_28 + 1;
                }
              }
              else {
                local_24 = '\x01';
              }
              uVar6 = 0;
              if (bVar16) {
                uVar6 = local_28;
              }
              SendTable_WriteAllDeltaProps
                        (*(SendTable **)(psVar15 + 4),*(void **)(local_f4 + 10),
                         *(int *)(local_f4 + 8),*(void **)(psVar15 + 10),*(int *)(psVar15 + 8),-1,
                         (bf_write *)local_34);
              if (bVar16) {
                DevMsg("TE %s delta bits: %i\n",*(undefined4 *)(*(int *)(psVar15 + 4) + 8),
                       local_28 - uVar6);
              }
            }
            cVar3 = (**(code **)(*(int *)this + 0x68))(this);
            if (cVar3 == '\0') {
              psVar15 = local_f4;
            }
            uVar5 = CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                    ::NextInorder((CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                   *)&local_c8,(ushort)uVar5);
            uVar5 = uVar5 & 0xffff;
            local_f4 = psVar15;
          } while (uVar5 != 0xffff);
        }
        local_60 = (uint)local_b6;
        SVC_TempEntities::WriteToBuffer((SVC_TempEntities *)&local_ac,param_4);
        if (local_b2 != 0xffff) {
          iVar12 = 0;
          uVar9 = local_b2;
          if (0 < local_c0) {
            do {
              uVar14 = (ushort)iVar12;
              if ((iVar12 < local_c0) && (uVar14 <= uVar9)) {
                if ((CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                     ::Links(unsigned_short)::s_Sentinel == '\0') &&
                   (iVar7 = __cxa_guard_acquire(&CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                                 ::Links(unsigned_short)::s_Sentinel), iVar7 != 0))
                {
                  CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                  ::Links(unsigned_short)::s_Sentinel = 0xffff;
                  DAT_00340c0e = 0xffff;
                  DAT_00340c10 = 0xffff;
                  __cxa_guard_release(&CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                       ::Links(unsigned_short)::s_Sentinel);
                }
                puVar1 = (ushort *)((int)local_c4 + iVar12 * 0xc);
                uVar9 = local_b2;
                if (uVar14 != *puVar1) {
                  puVar1[1] = local_b4;
                  *(ushort *)((int)local_c4 + iVar12 * 0xc) = uVar14;
                  local_b4 = uVar14;
                }
              }
            } while (((uVar14 != uVar9) && ((int)(iVar12 + 1U & 0xffff) < local_c0)) &&
                    (iVar12 = iVar12 + 1, iVar12 != 0xffff));
          }
          local_b8 = 0xffff;
          local_b6 = 0;
        }
        local_b4 = 0xffff;
        CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>::Purge
                  ((CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short> *)
                   &local_c4);
        iVar12 = 0;
        local_b2 = 0xffff;
        CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>::Purge
                  ((CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short> *)
                   &local_c4);
        if (0 < local_d0) {
          do {
            iVar7 = iVar12 * 4;
            iVar12 = iVar12 + 1;
            CFrameSnapshot::ReleaseReference(*(CFrameSnapshot **)(local_dc + iVar7));
          } while (iVar12 < local_d0);
        }
        local_d0 = 0;
        CUtlMemory<CFrameSnapshot*,int>::Purge((CUtlMemory<CFrameSnapshot*,int> *)&local_dc);
        local_cc = local_dc;
        CUtlMemory<CFrameSnapshot*,int>::Purge((CUtlMemory<CFrameSnapshot*,int> *)&local_dc);
        local_ac = &PTR__INetMessage_002a1188;
        NET_FreePayload(puVar4);
        return;
      }
    }
  }
  if (local_b2 != 0xffff) {
    iVar12 = 0;
    uVar9 = local_b2;
    if (0 < local_c0) {
      do {
        uVar14 = (ushort)iVar12;
        if ((iVar12 < local_c0) && (uVar14 <= uVar9)) {
          if ((CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
               ::Links(unsigned_short)::s_Sentinel == '\0') &&
             (iVar7 = __cxa_guard_acquire(&CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                           ::Links(unsigned_short)::s_Sentinel), iVar7 != 0)) {
            CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
            ::Links(unsigned_short)::s_Sentinel = 0xffff;
            DAT_00340c0e = 0xffff;
            DAT_00340c10 = 0xffff;
            __cxa_guard_release(&CUtlRBTree<CEventInfo*,unsigned_short,bool(*)(CEventInfo*const&,CEventInfo*const&),CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>>
                                 ::Links(unsigned_short)::s_Sentinel);
          }
          puVar1 = (ushort *)((int)local_c4 + iVar12 * 0xc);
          uVar9 = local_b2;
          if (uVar14 != *puVar1) {
            puVar1[1] = local_b4;
            *(ushort *)((int)local_c4 + iVar12 * 0xc) = uVar14;
            local_b4 = uVar14;
          }
        }
      } while (((uVar14 != uVar9) && ((int)(iVar12 + 1U & 0xffff) < local_c0)) &&
              (iVar12 = iVar12 + 1, iVar12 != 0xffff));
    }
    local_b8 = 0xffff;
    local_b6 = 0;
  }
  local_b4 = 0xffff;
  CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>::Purge
            ((CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short> *)&local_c4);
  local_b2 = 0xffff;
  iVar12 = 0;
  CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short>::Purge
            ((CUtlMemory<UtlRBTreeNode_t<CEventInfo*,unsigned_short>,unsigned_short> *)&local_c4);
  if (0 < local_d0) {
    do {
      iVar7 = iVar12 * 4;
      iVar12 = iVar12 + 1;
      CFrameSnapshot::ReleaseReference(*(CFrameSnapshot **)(local_dc + iVar7));
    } while (iVar12 < local_d0);
  }
  local_d0 = 0;
  CUtlMemory<CFrameSnapshot*,int>::Purge((CUtlMemory<CFrameSnapshot*,int> *)&local_dc);
  local_cc = local_dc;
  CUtlMemory<CFrameSnapshot*,int>::Purge((CUtlMemory<CFrameSnapshot*,int> *)&local_dc);
  local_ac = &PTR__INetMessage_002a1188;
  NET_FreePayload(puVar4);
  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)