L L4D2node

CNetChan::CreateFragmentsFromBuffer

0x001b3540 · 668 bytes · __thiscall

_ZN8CNetChan25CreateFragmentsFromBufferEP8bf_writei

Decompiled

undefined (3 params)

/* CNetChan::CreateFragmentsFromBuffer(bf_write*, int) */

undefined4 __thiscall
CNetChan::CreateFragmentsFromBuffer(CNetChan *this,bf_write *param_1,int param_2)

{
  dataFragments_s *pdVar1;
  void *pvVar2;
  uint *puVar3;
  int iVar4;
  int iVar5;
  uint uVar6;
  uint uVar7;
  dataFragments_s *local_38;
  int local_34 [2];
  int local_2c;
  uint local_28;
  
  bf_write::bf_write((bf_write *)local_34);
  local_38 = (dataFragments_s *)0x0;
  iVar4 = param_2 * 0x14;
  if (*(int *)(this + iVar4 + 200) < 2) {
LAB_001b3788:
    iVar5 = *(int *)(param_1 + 0xc);
  }
  else {
    local_38 = *(dataFragments_s **)
                (*(int *)(this + iVar4 + 0xbc) + -4 + *(int *)(this + iVar4 + 200) * 4);
    iVar5 = *(int *)(param_1 + 0xc);
    uVar7 = ((uint)(iVar5 + 7 + *(int *)(local_38 + 0x110)) >> 3) + 3 & 0x3ffffffc;
    if ((uVar7 < 0x37aa0) && (*(int *)(local_38 + 0x108) != 0)) {
      pvVar2 = operator_new__(uVar7);
      _V_memcpy(pvVar2,*(void **)(local_38 + 0x108),*(int *)(local_38 + 0x10c));
      if (*(void **)(local_38 + 0x108) != (void *)0x0) {
        operator_delete__(*(void **)(local_38 + 0x108));
      }
      *(void **)(local_38 + 0x108) = pvVar2;
      bf_write::StartWriting((bf_write *)local_34,pvVar2,uVar7,*(int *)(local_38 + 0x110),-1);
      if (local_38 != (dataFragments_s *)0x0) goto LAB_001b365f;
      goto LAB_001b3788;
    }
    local_38 = (dataFragments_s *)0x0;
  }
  iVar5 = iVar5 + 7 >> 3;
  uVar6 = iVar5 + 3;
  uVar7 = iVar5 + 6;
  if (-1 < (int)uVar6) {
    uVar7 = uVar6;
  }
  pdVar1 = operator_new(0x130);
  *(undefined4 *)(pdVar1 + 0x10c) = 0;
  *(undefined4 *)(pdVar1 + 0x110) = 0;
  local_38 = pdVar1;
  pvVar2 = operator_new__(uVar7 & 0xfffffffc);
  *(void **)(pdVar1 + 0x108) = pvVar2;
  *(undefined4 *)local_38 = 0;
  local_38[0x118] = (dataFragments_s)0x0;
  *(undefined4 *)(local_38 + 0x11c) = 0;
  local_38[4] = (dataFragments_s)0x0;
  bf_write::StartWriting((bf_write *)local_34,*(void **)(local_38 + 0x108),uVar7 & 0xfffffffc,0,-1);
  CUtlVector<CNetChan::dataFragments_s*,CUtlMemory<CNetChan::dataFragments_s*,int>>::InsertBefore
            ((CUtlVector<CNetChan::dataFragments_s*,CUtlMemory<CNetChan::dataFragments_s*,int>> *)
             (this + iVar4 + 0xbc),*(int *)(this + iVar4 + 200),&local_38);
LAB_001b365f:
  bf_write::WriteBits((bf_write *)local_34,*(void **)param_1,*(int *)(param_1 + 0xc));
  if (((int)local_28 % 8 - 1U < 2) && ((int)(local_28 + 6) <= local_2c)) {
    iVar5 = ((int)local_28 >> 5) * 4;
    puVar3 = (uint *)(local_34[0] + iVar5);
    *puVar3 = *puVar3 & *(uint *)(&DAT_003f2db8 + (local_28 & 0x1f) * 0x84);
    iVar4 = 0x20 - (local_28 & 0x1f);
    if (iVar4 < 6) {
      puVar3 = (uint *)(local_34[0] + 4 + iVar5);
      *puVar3 = *puVar3 & (&g_BitWriteMasks)[6 - iVar4];
    }
  }
  iVar4 = *(int *)(param_1 + 0xc);
  local_38[0x120] = (dataFragments_s)0x0;
  *(undefined4 *)(local_38 + 0x128) = 0;
  iVar5 = *(int *)(local_38 + 0x110);
  *(undefined4 *)(local_38 + 300) = 0;
  *(int *)(local_38 + 0x110) = iVar4 + iVar5;
  uVar7 = iVar4 + iVar5 + 7U >> 3;
  *(uint *)(local_38 + 0x10c) = uVar7;
  *(uint *)(local_38 + 0x124) = uVar7 + 0xff >> 8;
  return 1;
}

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)