L L4D2node

CPhysSaveRestoreBlockHandler::Restore

0x00482100 · 1628 bytes · __cdecl

_ZN28CPhysSaveRestoreBlockHandler7RestoreEP8IRestoreb

Decompiled

undefined (2 params)

/* CPhysSaveRestoreBlockHandler::Restore(IRestore*, bool) */

void CPhysSaveRestoreBlockHandler::Restore(IRestore *param_1,bool param_2)

{
  int *piVar1;
  int *piVar2;
  bool bVar3;
  int *piVar4;
  char cVar5;
  ushort uVar6;
  int *piVar7;
  ushort *puVar8;
  int iVar9;
  undefined *puVar10;
  int iVar11;
  int *piVar12;
  byte bVar13;
  undefined3 in_stack_00000009;
  undefined4 local_c8;
  int local_c4;
  int *local_c0;
  int *local_b0;
  int *local_ac;
  int local_a8;
  undefined4 local_a4;
  undefined1 *local_a0;
  undefined4 local_9c;
  int *local_98;
  undefined *local_94;
  int *local_90;
  int *local_8c;
  int local_88;
  undefined4 local_84;
  undefined1 *local_80;
  int local_7c;
  int *local_78;
  undefined *local_74;
  int *local_70;
  int *local_6c;
  int local_68;
  undefined4 local_64;
  undefined1 *local_60;
  undefined4 local_5c;
  int *local_58;
  undefined *local_54;
  int local_50;
  uint local_4c;
  int local_48;
  int local_44;
  undefined1 *local_40;
  float local_3c;
  float local_38;
  float local_34;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  int local_20;
  
  bVar13 = 0;
  if (param_1[0x40] != (IRestore)0x0) {
    if (physenv != (int *)0x0) {
      local_50 = 1;
      local_48 = g_PhysWorldObject;
      local_4c = *(uint *)(param_1 + 0x9c);
      (**(code **)(*physenv + 0xd4))(physenv,&local_50);
    }
    piVar7 = &local_50;
    for (iVar9 = 0xd; iVar9 != 0; iVar9 = iVar9 + -1) {
      *piVar7 = 0;
      piVar7 = piVar7 + (uint)bVar13 * -2 + 1;
    }
    iVar9 = *(int *)(param_1 + 0x98);
    *(int *)(param_1 + 0x98) = iVar9 + -1;
    while (iVar9 != 0) {
      (**(code **)(*_param_2 + 8))(_param_2,&local_50,PhysObjectHeader_t::m_DataMap);
      (**(code **)(*_param_2 + 0x1c))(_param_2);
      if ((((local_4c != 0xffffffff) &&
           (puVar10 = g_pEntityList + (local_4c & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)
           ) && (*(uint *)(puVar10 + 8) == local_4c >> 0xc)) &&
         ((piVar7 = *(int **)(puVar10 + 4), piVar7 != (int *)0x0 &&
          (local_70 = piVar7,
          uVar6 = CUtlRBTree<CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::Node_t,unsigned_short,CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
                  ::Find((CUtlRBTree<CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::Node_t,unsigned_short,CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<CBaseEntity*,CPhysSaveRestoreBlockHandler::CEntityRestoreSet*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
                          *)(param_1 + 0x24),(Node_t *)&local_70), piVar4 = mdlcache,
          uVar6 != 0xffff)))) {
        (**(code **)(*mdlcache + 0x68))(mdlcache);
                    /* try { // try from 0048224f to 00482254 has its CatchHandler @ 004825b8 */
        cVar5 = (**(code **)(*piVar7 + 0xcc))(piVar7);
        if ((cVar5 == '\0') || (local_44 < 1)) {
                    /* try { // try from 004822c3 to 004822c8 has its CatchHandler @ 004825b8 */
          (**(code **)(*piVar7 + 0x290))(piVar7);
          (**(code **)(*piVar4 + 0x6c))(piVar4);
        }
        else {
          piVar12 = *(int **)((uint)uVar6 * 0x10 + *(int *)(param_1 + 0x28) + 0xc);
          iVar9 = piVar12[3];
          if (0 < iVar9) {
            piVar12 = (int *)*piVar12;
            if (local_48 != piVar12[2]) {
              iVar11 = 0;
              piVar2 = piVar12;
              do {
                piVar12 = piVar2 + 0xe;
                iVar11 = iVar11 + 1;
                if (iVar11 == iVar9) goto LAB_004822a1;
                piVar1 = piVar2 + 0x10;
                piVar2 = piVar12;
              } while (local_48 != *piVar1);
            }
            iVar9 = piVar12[3];
            if (local_44 < piVar12[3]) {
              iVar9 = local_44;
            }
            if ((*piVar12 == 1) && (iVar9 == 1)) {
              (**(code **)(*_param_2 + 0x1c))(_param_2);
              if (local_40 == (undefined1 *)0x0) {
                if (((vec3_origin != local_3c) || (DAT_01053d4c != local_38)) ||
                   ((DAT_01053d50 != local_34 ||
                    (((vec3_origin != local_30 || (DAT_01053d4c != local_2c)) ||
                     (DAT_01053d50 != local_28)))))) {
                  local_c0 = (int *)PhysCreateBbox((Vector *)&local_3c,(Vector *)&local_30);
                  iVar9 = -1;
                  bVar3 = true;
                  goto LAB_00482527;
                }
                if (local_24 == 0.0) goto LAB_004824b7;
                if ((*(int *)piVar12[0xd] == 0) && (physenv != (int *)0x0)) {
                  local_a4 = 0;
                  local_b0 = _param_2;
                  local_a8 = local_50;
                  if ((local_4c != 0xffffffff) &&
                     ((puVar10 = g_pEntityList + (local_4c & 0xfff) * 0x10,
                      puVar10 != (undefined *)0xfffffffc &&
                      (*(uint *)(puVar10 + 8) == local_4c >> 0xc)))) {
                    local_a4 = *(undefined4 *)(puVar10 + 4);
                  }
                  local_a0 = &DAT_00d539c2;
                  local_9c = 0;
                  local_98 = physenv;
                  local_94 = physgametrace;
                  local_ac = (int *)piVar12[0xd];
                  (**(code **)(*physenv + 0xd8))(physenv,&local_b0);
                }
              }
              else {
                piVar7 = (int *)0x0;
                if (((local_4c != 0xffffffff) &&
                    (puVar10 = g_pEntityList + (local_4c & 0xfff) * 0x10,
                    puVar10 != (undefined *)0xfffffffc)) &&
                   (*(uint *)(puVar10 + 8) == local_4c >> 0xc)) {
                  piVar7 = *(int **)(puVar10 + 4);
                }
                if (piVar7[0x20] == 0) {
                  iVar9 = (**(code **)(*modelinfo + 0xc))(modelinfo,local_40);
                }
                else {
                  iVar9 = (**(code **)(*piVar7 + 0x1c))(piVar7);
                }
                if (((iVar9 == -1) ||
                    (puVar8 = (ushort *)(**(code **)(*modelinfo + 0x18))(modelinfo,iVar9),
                    puVar8 == (ushort *)0x0)) ||
                   (((*puVar8 & 0x7fff) == 0 ||
                    ((*(int *)(puVar8 + 2) == 0 || ((int)(*puVar8 & 0x7fff) <= local_20)))))) {
LAB_004824b7:
                  DevMsg("Failed to reestablish collision model for object\n");
                }
                else {
                  local_c0 = *(int **)(*(int *)(puVar8 + 2) + local_20 * 4);
                  bVar3 = false;
LAB_00482527:
                  if (local_c0 == (int *)0x0) goto LAB_004824b7;
                  if (*(int *)piVar12[0xd] == 0) {
                    if (physenv != (int *)0x0) {
                      local_90 = _param_2;
                      local_c8 = 0;
                      local_88 = local_50;
                      if (((local_4c != 0xffffffff) &&
                          (puVar10 = g_pEntityList + (local_4c & 0xfff) * 0x10,
                          puVar10 != (undefined *)0xfffffffc)) &&
                         (*(uint *)(puVar10 + 8) == local_4c >> 0xc)) {
                        local_c8 = *(undefined4 *)(puVar10 + 4);
                      }
                      local_84 = local_c8;
                      local_80 = &DAT_00d539c2;
                      if (local_40 != (undefined1 *)0x0) {
                        local_80 = local_40;
                      }
                      local_7c = (int)local_c0;
                      local_78 = physenv;
                      local_74 = physgametrace;
                    /* try { // try from 0048267f to 00482790 has its CatchHandler @ 004825b8 */
                      local_8c = (int *)piVar12[0xd];
                      (**(code **)(*physenv + 0xd8))(physenv,&local_90);
                      iVar11 = *(int *)piVar12[0xd];
                      if (iVar11 != 0) {
                        if (bVar3) {
                          (**(code **)(*(int *)param_1 + 0x34))(param_1,iVar11,local_c0);
                        }
                        else {
                          (**(code **)(*(int *)param_1 + 0x30))(param_1,iVar11,iVar9);
                        }
                        goto LAB_004824c3;
                      }
                    }
                    DevMsg("Failed to restore physics object\n");
                  }
                  else {
                    DevMsg(
                          "Physics object pointer unexpectedly non-null before restore. Should be creating physics object in CreatePhysics()?\n"
                          );
                  }
                }
LAB_004824c3:
                (**(code **)(*_param_2 + 0x20))(_param_2);
              }
            }
            else {
              local_c0 = (int *)piVar12[0xd];
              if (0 < iVar9) {
                local_c4 = 0;
                do {
                    /* try { // try from 00482355 to 004825a0 has its CatchHandler @ 004825b8 */
                  (**(code **)(*_param_2 + 0x1c))(_param_2);
                  if (physenv != (int *)0x0) {
                    local_70 = _param_2;
                    local_68 = local_50;
                    local_6c = local_c0;
                    local_64 = 0;
                    if (((local_4c != 0xffffffff) &&
                        (puVar10 = g_pEntityList + (local_4c & 0xfff) * 0x10,
                        puVar10 != (undefined *)0xfffffffc)) &&
                       (*(uint *)(puVar10 + 8) == local_4c >> 0xc)) {
                      local_64 = *(undefined4 *)(puVar10 + 4);
                    }
                    local_5c = 0;
                    local_58 = physenv;
                    local_60 = local_40;
                    if (local_40 == (undefined1 *)0x0) {
                      local_60 = &DAT_00d539c2;
                    }
                    local_54 = physgametrace;
                    (**(code **)(*physenv + 0xd8))(physenv,&local_70);
                  }
                  (**(code **)(*_param_2 + 0x20))(_param_2);
                  if (((local_50 == 8) && (piVar12 = (int *)*local_c0, piVar12 != (int *)0x0)) &&
                     (iVar11 = __dynamic_cast(piVar7,&CBaseEntity::typeinfo,&IMotionEvent::typeinfo,
                                              0xfffffffe), iVar11 != 0)) {
                    (**(code **)(*piVar12 + 8))(piVar12,iVar11);
                  }
                  local_c4 = local_c4 + 1;
                  local_c0 = local_c0 + 1;
                } while (local_c4 != iVar9);
              }
            }
          }
LAB_004822a1:
          (**(code **)(*piVar4 + 0x6c))(piVar4);
        }
      }
      (**(code **)(*_param_2 + 0x20))(_param_2);
      iVar9 = *(int *)(param_1 + 0x98);
      *(int *)(param_1 + 0x98) = iVar9 + -1;
    }
  }
  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)