L L4D2node

CStaticPropMgr::UnserializeModels

0x001e6d40 · 801 bytes · __thiscall

_ZN14CStaticPropMgr17UnserializeModelsER10CUtlBuffer

Decompiled

undefined (2 params)

/* CStaticPropMgr::UnserializeModels(CUtlBuffer&) */

void __thiscall CStaticPropMgr::UnserializeModels(CStaticPropMgr *this,CUtlBuffer *param_1)

{
  char cVar1;
  int iVar2;
  void *pvVar3;
  int iVar4;
  int *piVar5;
  int iVar6;
  int local_74;
  int local_68;
  undefined4 local_64;
  ushort local_4c;
  undefined4 local_2c;
  undefined1 local_28;
  undefined1 local_27;
  undefined1 local_26;
  undefined1 local_25;
  undefined1 local_24;
  undefined1 local_23;
  undefined1 local_22;
  undefined1 local_21;
  undefined1 local_20;
  
  iVar2 = Mod_GameLumpVersion(0x73707270);
  if (iVar2 < 4) {
    Warning("Really old map format %d < 4! Static props can\'t be loaded...\n",iVar2);
    return;
  }
  if (((byte)param_1[0x15] & 1) == 0) {
    cVar1 = CUtlBuffer::CheckGet(param_1,4);
    local_74 = 0;
    if (cVar1 == '\0') goto LAB_001e6dcd;
    if (((byte)param_1[0x34] & 1) == 0) {
      iVar6 = *(int *)(param_1 + 0xc);
      local_74 = *(int *)(*(int *)param_1 + (iVar6 - *(int *)(param_1 + 0x20)));
    }
    else {
      piVar5 = (int *)((*(int *)(param_1 + 0xc) - *(int *)(param_1 + 0x20)) + *(int *)param_1);
      if (piVar5 == (int *)0x0) {
        piVar5 = &local_68;
      }
      local_64 = local_68;
      local_64 = CONCAT31((int3)((uint)local_68 >> 8),*(undefined1 *)((int)piVar5 + 3));
      local_64._2_2_ = (undefined2)((uint)local_68 >> 0x10);
      local_64._0_2_ = CONCAT11(*(undefined1 *)((int)piVar5 + 2),*(undefined1 *)((int)piVar5 + 3));
      local_64._3_1_ = (undefined1)((uint)local_68 >> 0x18);
      local_64._0_3_ = CONCAT12(*(undefined1 *)((int)piVar5 + 1),(undefined2)local_64);
      local_64 = CONCAT13((char)*piVar5,(undefined3)local_64);
      _V_memcpy(&local_68,&local_64,4);
      iVar6 = *(int *)(param_1 + 0xc);
      local_74 = local_68;
    }
    *(int *)(param_1 + 0xc) = iVar6 + 4;
  }
  else {
    local_68 = 0;
    CUtlBuffer::Scanf(param_1,"%d",&local_68);
    local_74 = local_68;
  }
  if (0x1000 < local_74) {
    Warning("Trying to unserialize %d static prop models. The current limit on the number of static props is %u. Ignoring %d last instances."
            ,local_74,0x1000,local_74 + -0x1000);
    local_74 = 0x1000;
  }
LAB_001e6dcd:
  if ((*(int *)(this + 0x24) < local_74) && (-1 < *(int *)(this + 0x28))) {
    *(int *)(this + 0x24) = local_74;
    if (*(void **)(this + 0x20) == (void *)0x0) {
      pvVar3 = malloc(local_74 * 0xd8);
      *(void **)(this + 0x20) = pvVar3;
    }
    else {
      pvVar3 = realloc(*(void **)(this + 0x20),local_74 * 0xd8);
      *(void **)(this + 0x20) = pvVar3;
    }
  }
  else {
    pvVar3 = *(void **)(this + 0x20);
  }
  *(void **)(this + 0x30) = pvVar3;
  if (0 < local_74) {
    iVar6 = 0;
    do {
      switch(iVar2) {
      case 4:
        CUtlBuffer::Get(param_1,(StaticPropLump_t *)&local_64,0x38);
        local_2c = 0x3f800000;
        goto LAB_001e6f2a;
      case 5:
        iVar4 = 0x3c;
        goto LAB_001e6f18;
      case 6:
        iVar4 = 0x40;
LAB_001e6f18:
        CUtlBuffer::Get(param_1,(StaticPropLump_t *)&local_64,iVar4);
LAB_001e6f2a:
        local_25 = 0;
        local_26 = 0;
        local_27 = 0;
        local_28 = 0;
        local_21 = 0xff;
        local_22 = 0xff;
        local_23 = 0xff;
        local_24 = 0xff;
        local_20 = 0;
        break;
      case 7:
        CUtlBuffer::Get(param_1,(StaticPropLump_t *)&local_64,0x44);
        local_25 = 0;
        local_26 = 0;
        local_27 = 0;
        local_28 = 0;
        local_20 = 0;
        break;
      case 8:
        CUtlBuffer::Get(param_1,(StaticPropLump_t *)&local_64,0x44);
        local_20 = 0;
        break;
      case 9:
        CUtlBuffer::Get(param_1,(StaticPropLump_t *)&local_64,0x48);
      }
      iVar6 = iVar6 + 1;
      iVar4 = CUtlVector<CStaticProp,CUtlMemory<CStaticProp,int>>::InsertBefore
                        ((CUtlVector<CStaticProp,CUtlMemory<CStaticProp,int>> *)(this + 0x20),
                         *(int *)(this + 0x2c));
      CStaticProp::Init((CStaticProp *)(*(int *)(this + 0x20) + iVar4 * 0xd8),iVar4,
                        (StaticPropLump_t *)&local_64,
                        *(model_t **)(*(int *)(this + 0xc) + (uint)local_4c * 4));
      CStaticProp::InsertPropIntoKDTree((CStaticProp *)(iVar4 * 0xd8 + *(int *)(this + 0x20)));
    } while (iVar6 != local_74);
  }
  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)