L L4D2node

CRestore::ReadGameField

0x004aa370 · 1240 bytes · __thiscall

_ZN8CRestore13ReadGameFieldERK25SaveRestoreRecordHeader_tPvP9datamap_tP17typedescription_t

Decompiled

undefined (5 params)

/* CRestore::ReadGameField(SaveRestoreRecordHeader_t const&, void*, datamap_t*, typedescription_t*)
    */

void __thiscall
CRestore::ReadGameField
          (CRestore *this,SaveRestoreRecordHeader_t *param_1,void *param_2,datamap_t *param_3,
          typedescription_t *param_4)

{
  ushort uVar1;
  code *pcVar2;
  int iVar3;
  int iVar4;
  undefined1 *puVar5;
  undefined4 uVar6;
  undefined1 *puVar7;
  typedescription_t *ptVar8;
  char *pcVar9;
  int iVar10;
  typedescription_t *ptVar11;
  typedescription_t *ptVar12;
  int in_GS_OFFSET;
  undefined4 uStackY_160;
  undefined1 auStack_140 [4];
  undefined1 *local_13c;
  CRestore *local_138;
  typedescription_t *local_134;
  undefined4 local_130 [3];
  char local_124 [260];
  int local_20;
  
  puVar7 = &stack0xfffffea4;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  switch(*(undefined4 *)param_4) {
  case 0xc:
    uStackY_160 = 0x4aa47b;
    (**(code **)(*(int *)this + 0x78))();
    break;
  case 0xd:
    uStackY_160 = 0x4aa4be;
    (**(code **)(*(int *)this + 0x80))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0xe:
    uStackY_160 = 0x4aa4db;
    (**(code **)(*(int *)this + 0x7c))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0xf:
    uStackY_160 = 0x4aa4fb;
    (**(code **)(*(int *)this + 0x70))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x10:
    uStackY_160 = 0x4aa51b;
    (**(code **)(*(int *)this + 100))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x11:
    uStackY_160 = 0x4aa53b;
    (**(code **)(*(int *)this + 0x68))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x12:
  case 0x13:
    uStackY_160 = 0x4aa55b;
    ptVar11 = (typedescription_t *)(**(code **)(*(int *)this + 0x50))();
    puVar7 = &stack0xfffffea4;
    if (this[0x24] != (CRestore)0x0) {
      if (*(int *)param_4 == 0x12) {
        pcVar9 = *(char **)param_2;
        if (pcVar9 == (char *)0x0) {
          pcVar9 = "";
        }
        uStackY_160 = 0x4aa7ea;
        local_134 = ptVar11;
        iVar10 = V_stristr(pcVar9,".bsp");
        ptVar11 = local_134;
        if (iVar10 != 0) {
          uStackY_160 = 0x4aa81c;
          V_strncpy(local_124,"maps/",0x104);
          pcVar9 = *(char **)(gpGlobals + 0x3c);
          if (pcVar9 == (char *)0x0) {
            pcVar9 = "";
          }
          uStackY_160 = 0x4aa84a;
          V_strncat(local_124,pcVar9,0x104,-1);
          uStackY_160 = 0x4aa86a;
          V_strncat(local_124,".bsp",0x104,-1);
          uStackY_160 = 0x4aa87c;
          AllocPooledString((char *)local_130);
          *(undefined4 *)param_2 = local_130[0];
          ptVar11 = local_134;
        }
      }
      puVar7 = &stack0xfffffea4;
      if (0 < (int)ptVar11) {
        ptVar8 = (typedescription_t *)0x0;
        do {
          pcVar9 = *(char **)((int)param_2 + (int)ptVar8 * 4);
          if (pcVar9 != (char *)0x0) {
            if (*(int *)param_4 == 0x12) {
              uStackY_160 = 0x4aa5b8;
              local_134 = param_4;
              CBaseEntity::PrecacheModel(pcVar9);
              param_4 = local_134;
            }
            else if (*(int *)param_4 == 0x13) {
              uStackY_160 = 0x4aa7b6;
              local_134 = param_4;
              CBaseEntity::PrecacheScriptSound(pcVar9);
              param_4 = local_134;
            }
          }
          ptVar8 = ptVar8 + 1;
          puVar7 = &stack0xfffffea4;
        } while (ptVar8 != ptVar11);
      }
    }
    break;
  default:
    uStackY_160 = 0x4aa79c;
    Warning();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x15:
    uStackY_160 = 0x4aa5df;
    (**(code **)(*(int *)this + 0x74))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x16:
    uStackY_160 = 0x4aa606;
    (**(code **)(*(int *)this + 0x84))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x17:
    uStackY_160 = 0x4aa62e;
    (**(code **)(*(int *)this + 0x88))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x18:
    uStackY_160 = 0x4aa656;
    (**(code **)(*(int *)this + 0x8c))();
    puVar7 = &stack0xfffffea4;
    break;
  case 0x19:
    ptVar8 = (typedescription_t *)(uint)*(ushort *)param_1;
    uVar1 = *(ushort *)(param_4 + 0xc);
    ptVar12 = (typedescription_t *)((uint)uVar1 * 8);
    ptVar11 = ptVar12;
    if ((ptVar8 == (typedescription_t *)0x0) || (ptVar11 = ptVar8, ptVar8 <= ptVar12)) {
      uStackY_160 = 0x4aa78a;
      BufferReadBytes(this,param_2,(int)ptVar11);
      puVar7 = &stack0xfffffea4;
    }
    else {
      uStackY_160 = 0x4aa690;
      local_134 = ptVar8;
      BufferReadBytes(this,param_2,(int)ptVar12);
      uStackY_160 = 0x4aa6ac;
      BufferReadBytes(this,(char *)0x0,(int)(local_134 + (uint)uVar1 * -8));
      puVar7 = &stack0xfffffea4;
    }
    break;
  case 0x1a:
    uVar1 = *(ushort *)(param_4 + 0xc);
    iVar4 = -(((uint)uVar1 * 4 + 0xf & 0xfffffff0) + 0x1e & 0x1ffff0);
    iVar10 = *(int *)this;
    *(uint *)((int)local_130 + iVar4 + -0x20) = (uint)*(ushort *)param_1;
    ptVar11 = (typedescription_t *)0x0;
    local_13c = auStack_140 + iVar4;
    *(uint *)(&stack0xfffffeac + iVar4) = (uint)uVar1;
    *(CRestore **)(&stack0xfffffea4 + iVar4) = this;
    *(undefined1 **)(&stack0xfffffea8 + iVar4) = local_13c;
    pcVar2 = *(code **)(iVar10 + 0x50);
    *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa701;
    local_134 = (typedescription_t *)(*pcVar2)();
    puVar5 = local_13c;
    puVar7 = &stack0xfffffea4 + iVar4;
    if (0 < (int)local_134) {
      local_138 = this;
      do {
        iVar10 = *(int *)(puVar5 + (int)ptVar11 * 4);
        if (iVar10 == 0) {
          *(undefined4 *)((int)param_2 + (int)ptVar11 * 4) = 0xffffffff;
        }
        else {
          iVar3 = *modelinfo;
          *(int *)(&stack0xfffffea8 + iVar4) = iVar10;
          *(int **)(&stack0xfffffea4 + iVar4) = modelinfo;
          pcVar2 = *(code **)(iVar3 + 0xc);
          *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa732;
          uVar6 = (*pcVar2)();
          *(undefined4 *)((int)param_2 + (int)ptVar11 * 4) = uVar6;
          if (local_138[0x24] != (CRestore)0x0) {
            puVar7 = *(undefined1 **)(puVar5 + (int)ptVar11 * 4);
            if (puVar7 == (undefined1 *)0x0) {
              puVar7 = &DAT_00d539c2;
            }
            *(undefined1 **)(&stack0xfffffea4 + iVar4) = puVar7;
            *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa756;
            CBaseEntity::PrecacheModel(*(char **)(&stack0xfffffea4 + iVar4));
          }
        }
        ptVar11 = ptVar11 + 1;
        puVar7 = &stack0xfffffea4 + iVar4;
      } while (ptVar11 != local_134);
    }
    break;
  case 0x1b:
    uVar1 = *(ushort *)(param_4 + 0xc);
    iVar4 = -(((uint)uVar1 * 4 + 0xf & 0xfffffff0) + 0x1e & 0x1ffff0);
    iVar10 = *(int *)this;
    *(uint *)((int)local_130 + iVar4 + -0x20) = (uint)*(ushort *)param_1;
    local_13c = auStack_140 + iVar4;
    *(uint *)(&stack0xfffffeac + iVar4) = (uint)uVar1;
    *(CRestore **)(&stack0xfffffea4 + iVar4) = this;
    *(undefined1 **)(&stack0xfffffea8 + iVar4) = local_13c;
    pcVar2 = *(code **)(iVar10 + 0x50);
    *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa3f7;
    local_134 = (typedescription_t *)(*pcVar2)();
    puVar5 = local_13c;
    puVar7 = &stack0xfffffea4 + iVar4;
    if (0 < (int)local_134) {
      local_138 = this;
      ptVar11 = (typedescription_t *)0x0;
      do {
        iVar10 = *(int *)(puVar5 + (int)ptVar11 * 4);
        if (iVar10 == 0) {
          *(undefined4 *)((int)param_2 + (int)ptVar11 * 4) = 0;
        }
        else {
          *(int *)(&stack0xfffffea4 + iVar4) = iVar10;
          *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa420;
          uVar6 = GetMaterialIndex(*(char **)(&stack0xfffffea4 + iVar4));
          *(undefined4 *)((int)param_2 + (int)ptVar11 * 4) = uVar6;
          if (local_138[0x24] != (CRestore)0x0) {
            puVar7 = *(undefined1 **)(puVar5 + (int)ptVar11 * 4);
            if (puVar7 == (undefined1 *)0x0) {
              puVar7 = &DAT_00d539c2;
            }
            *(undefined1 **)(&stack0xfffffea4 + iVar4) = puVar7;
            *(undefined4 *)((int)&uStackY_160 + iVar4) = 0x4aa444;
            PrecacheMaterial(*(char **)(&stack0xfffffea4 + iVar4));
          }
        }
        ptVar11 = ptVar11 + 1;
        puVar7 = &stack0xfffffea4 + iVar4;
      } while (ptVar11 != local_134);
    }
  }
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  *(undefined **)(puVar7 + -4) = &UNK_004aa897;
  __stack_chk_fail();
}

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)