L L4D2node

CServerTools::RespawnEntitiesWithEdits

0x006813e0 · 574 bytes · __thiscall

_ZN12CServerTools24RespawnEntitiesWithEditsEP18CEntityRespawnInfoi

Decompiled

undefined (3 params)

/* CServerTools::RespawnEntitiesWithEdits(CEntityRespawnInfo*, int) */

undefined4 __thiscall
CServerTools::RespawnEntitiesWithEdits(CServerTools *this,CEntityRespawnInfo *param_1,int param_2)

{
  CFoundryEntitySpawnRecord *pCVar1;
  CBaseEntity *pCVar2;
  uint *puVar3;
  int iVar4;
  void *pvVar5;
  int iVar6;
  size_t __size;
  size_t sVar7;
  int iVar8;
  int local_30;
  CFoundryEntitySpawnRecord *local_20 [4];
  
  local_30 = 0;
  if (0 < param_2) {
    do {
      local_20[0] = ::operator_new(0x24);
      *(undefined4 *)local_20[0] = 0;
      *(undefined4 *)(local_20[0] + 4) = 0;
      *(undefined4 *)(local_20[0] + 8) = 0;
      *(undefined4 *)(local_20[0] + 0xc) = 0;
      *(undefined4 *)(local_20[0] + 0x10) = 0;
      iVar4 = _V_strlen(*(char **)(param_1 + 4));
      pCVar1 = local_20[0];
      iVar6 = 0;
      iVar8 = iVar4 + 1;
      *(undefined4 *)(local_20[0] + 0xc) = 0;
      if (iVar8 != 0) {
        sVar7 = *(size_t *)(local_20[0] + 4);
        if ((int)sVar7 < iVar8) {
          iVar6 = *(int *)(local_20[0] + 8);
          if (iVar6 < 0) goto LAB_00681511;
          if (iVar6 == 0) {
            if (sVar7 == 0) {
              if (iVar8 < 0x21) {
                __size = 0x20;
                goto LAB_0068155f;
              }
              sVar7 = 0x20;
            }
            do {
              __size = sVar7 * 2;
              if (iVar8 <= (int)__size) break;
              __size = sVar7 * 4;
              sVar7 = __size;
            } while ((int)__size < iVar8);
          }
          else {
            for (__size = iVar6 * (iVar4 / iVar6 + 1); (int)__size < iVar8;
                __size = (int)(__size + iVar8) / 2) {
            }
          }
LAB_0068155f:
          *(size_t *)(local_20[0] + 4) = __size;
          if (*(void **)local_20[0] == (void *)0x0) {
            pvVar5 = malloc(__size);
            *(void **)pCVar1 = pvVar5;
            goto LAB_00681513;
          }
          pvVar5 = realloc(*(void **)local_20[0],__size);
          iVar6 = *(int *)(pCVar1 + 0xc);
          *(void **)pCVar1 = pvVar5;
          *(void **)(pCVar1 + 0x10) = pvVar5;
          *(int *)(pCVar1 + 0xc) = iVar8 + iVar6;
          if ((0 < iVar8) && (0 < iVar6)) {
            _V_memmove((void *)(iVar8 + (int)pvVar5),pvVar5,iVar6);
            iVar6 = *(int *)(local_20[0] + 0xc);
            goto LAB_00681408;
          }
        }
        else {
LAB_00681511:
          pvVar5 = *(void **)local_20[0];
LAB_00681513:
          *(int *)(pCVar1 + 0xc) = iVar8;
          *(void **)(pCVar1 + 0x10) = pvVar5;
        }
        iVar6 = *(int *)(local_20[0] + 0xc);
      }
LAB_00681408:
      V_strncpy(*(char **)local_20[0],*(char **)(param_1 + 4),iVar6);
      *(undefined4 *)(local_20[0] + 0x18) = *(undefined4 *)param_1;
      pCVar2 = (CBaseEntity *)(**(code **)(*(int *)this + 0x28))(this,*(undefined4 *)param_1);
      pCVar1 = local_20[0];
      if (pCVar2 == (CBaseEntity *)0x0) {
        *(undefined4 *)(local_20[0] + 0x14) = 0xffffffff;
        *(undefined4 *)(local_20[0] + 0x1c) = 0xffffffff;
        *(undefined4 *)(local_20[0] + 0x20) = 0xffffffff;
      }
      else {
        if (*(int *)(pCVar2 + 0x30) == 0) {
          iVar6 = 0;
        }
        else {
          iVar6 = *(int *)(pCVar2 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
        }
        *(int *)(local_20[0] + 0x14) = iVar6;
        puVar3 = (uint *)(**(code **)(*(int *)pCVar2 + 0xc))(pCVar2);
        *(uint *)(pCVar1 + 0x1c) = *puVar3 >> 0xc;
        *(undefined4 *)(local_20[0] + 0x20) = *(undefined4 *)(pCVar2 + 0x110);
        UTIL_Remove(pCVar2);
      }
      param_1 = param_1 + 8;
      CUtlLinkedList<CFoundryEntitySpawnRecord*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CFoundryEntitySpawnRecord*,int>,int>>
      ::InsertBefore((CUtlLinkedList<CFoundryEntitySpawnRecord*,int,false,int,CUtlMemory<UtlLinkedListElem_t<CFoundryEntitySpawnRecord*,int>,int>>
                      *)&g_FoundryEntitySpawnRecords,-1,local_20);
      local_30 = local_30 + 1;
    } while (local_30 != param_2);
  }
  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)