L L4D2node

Mod_LoadFaces

0x001973b0 · 1946 bytes · unknown

_Z13Mod_LoadFacesv

Decompiled

undefined (0 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* WARNING: Unknown calling convention -- yet parameter storage is locked */
/* Mod_LoadFaces() */

void Mod_LoadFaces(void)

{
  float *pfVar1;
  float fVar2;
  byte bVar3;
  short sVar4;
  ushort uVar5;
  uint uVar6;
  int *piVar7;
  char cVar8;
  int iVar9;
  char *pcVar10;
  undefined1 *puVar11;
  undefined4 uVar12;
  int iVar13;
  int iVar14;
  int iVar15;
  uint uVar16;
  uint uVar17;
  int iVar18;
  uint *puVar19;
  int in_GS_OFFSET;
  float fVar20;
  float fVar21;
  float fVar22;
  float fVar23;
  float fVar24;
  int local_180;
  msurfacelighting_t *local_17c;
  uint local_178;
  int local_174;
  dface_t *local_164;
  int local_160;
  float local_150 [4];
  uint local_140 [3];
  int local_134;
  dface_t *local_130;
  int local_128;
  undefined1 local_124 [260];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  iVar9 = (**(code **)(*g_pMaterialSystemHardwareConfig + 0x8c))(g_pMaterialSystemHardwareConfig);
  iVar15 = 7;
  if (iVar9 != 0) {
    iVar9 = _DAT_003a83cc;
    if (_DAT_003a83b8 == 0) {
      iVar9 = _DAT_003a8ab0;
    }
    if (0 < iVar9) {
      iVar15 = 0x3a;
    }
  }
  CMapLoadHelper::CMapLoadHelper((CMapLoadHelper *)local_140,iVar15);
  local_164 = local_130;
  if (local_140[0] != (local_140[0] / 0x38) * 0x38) {
                    /* try { // try from 00197b47 to 00197b4b has its CatchHandler @ 00197b5c */
    Host_Error("Mod_LoadFaces: funny lump size in %s",s_szMapPathName);
  }
  uVar16 = local_140[0] / 0x38;
  puVar11 = s_szMapPathName;
  if ((&s_MapLumpFiles)[local_128 * 7] != 0) {
    puVar11 = local_124;
  }
                    /* try { // try from 00197486 to 00197ad2 has its CatchHandler @ 00197b5c */
  pcVar10 = (char *)va("%s [%s]",puVar11,"surface1");
  local_180 = Hunk_AllocNameAlignedClear_(uVar16 * 0x10 + 0x10,0x10,pcVar10);
  puVar11 = s_szMapPathName;
  if ((&s_MapLumpFiles)[local_128 * 7] != 0) {
    puVar11 = local_124;
  }
  pcVar10 = (char *)va("%s [%s]",puVar11,"surface2");
  iVar9 = uVar16 * 0x20 + 0x20;
  local_174 = Hunk_AllocNameAlignedClear_(iVar9,0x20,pcVar10);
  puVar11 = s_szMapPathName;
  if ((&s_MapLumpFiles)[local_128 * 7] != 0) {
    puVar11 = local_124;
  }
  pcVar10 = (char *)va("%s [%s]",puVar11,"surfacelighting");
  local_17c = (msurfacelighting_t *)Hunk_AllocNameAlignedClear_(iVar9,0x20,pcVar10);
  iVar9 = s_pMap;
  *(int *)(s_pMap + 0x74) = local_180;
  *(msurfacelighting_t **)(iVar9 + 0x7c) = local_17c;
  *(int *)(iVar9 + 0x78) = local_174;
  puVar11 = s_szMapPathName;
  if ((&s_MapLumpFiles)[local_128 * 7] != 0) {
    puVar11 = local_124;
  }
  pcVar10 = (char *)va("%s [%s]",puVar11,"surfacenormal");
  uVar12 = Hunk_AllocNameAlignedClear_(uVar16 * 4 + 2,2,pcVar10);
  *(undefined4 *)(iVar9 + 0x80) = uVar12;
  iVar9 = s_pMap;
  local_178 = 0;
  *(uint *)(s_pMap + 0x70) = uVar16;
  local_160 = iVar9;
  if (uVar16 != 0) {
    while( true ) {
      puVar19 = (uint *)(local_178 * 0x20 + *(int *)(iVar9 + 0x78));
      puVar19[2] = *(uint *)(local_164 + 4);
      sVar4 = *(short *)(local_164 + 8);
      *puVar19 = (int)sVar4 << 0x18;
      uVar5 = *(ushort *)local_164;
      if (local_164[3] != (dface_t)0x0) {
        *puVar19 = (int)sVar4 << 0x18 | 2;
      }
      if (local_164[2] != (dface_t)0x0) {
        *puVar19 = *puVar19 | 0x40;
      }
      *(uint *)(local_174 + 4) = *(int *)(local_160 + 8) + (uint)uVar5 * 0x14;
      sVar4 = *(short *)(local_164 + 10);
      iVar15 = (int)sVar4;
      if ((iVar15 < 0) || (*(int *)(local_160 + 0x58) <= iVar15)) {
        Host_Error("Mod_LoadFaces: bad texinfo number");
        local_160 = s_pMap;
      }
      *(ushort *)((int)puVar19 + 0x16) = *(ushort *)((int)puVar19 + 0x16) & 1 | sVar4 * 2;
      *(byte *)((int)puVar19 + 0x16) =
           *(byte *)((int)puVar19 + 0x16) & 0xfe |
           (byte)~(byte)((ushort)*(undefined2 *)(local_164 + 0x30) >> 8) >> 7;
      piVar7 = g_materialEmpty;
      iVar15 = iVar15 * 0x50 + *(int *)(local_160 + 0x5c);
      if (*(int *)(iVar15 + 0x4c) == 0) {
        *(int **)(iVar15 + 0x4c) = g_materialEmpty;
        (**(code **)(*piVar7 + 0x30))(piVar7);
        local_160 = s_pMap;
      }
      cVar8 = Mod_LoadSurfaceLightingV1(local_17c,local_164,*(ColorRGBExp32 **)(local_160 + 0x94));
      if (cVar8 != '\0') {
        *puVar19 = *puVar19 | 0x400;
      }
      uVar5 = *(ushort *)(iVar15 + 0x48);
      if ((uVar5 & 0x400) != 0) {
        *puVar19 = *puVar19 | 1;
        uVar5 = *(ushort *)(iVar15 + 0x48);
      }
      if ((uVar5 & 0x1000) != 0) {
        *puVar19 = *puVar19 | 0x2000;
        uVar5 = *(ushort *)(iVar15 + 0x48);
      }
      if ((uVar5 & 8) != 0) {
        *puVar19 = *puVar19 | 0x10000;
        uVar5 = *(ushort *)(iVar15 + 0x48);
      }
      if ((uVar5 & 4) != 0) {
        *puVar19 = *puVar19 | 4;
      }
      sVar4 = *(short *)(local_164 + 0xc);
      *(undefined4 *)(local_174 + 0x18) = 0;
      if (sVar4 == -1) {
        *(ushort *)(local_180 + 0xc) = *(ushort *)(local_164 + 0x30) & 0x7fff;
        *(undefined2 *)(local_180 + 0xe) = *(undefined2 *)(local_164 + 0x32);
        if ((*(ushort *)(local_164 + 0x30) & 0x7fff) != 0) {
          uVar6 = *puVar19;
          *puVar19 = uVar6 | 0x8000;
          if (*(short *)((uint)*(ushort *)(local_164 + 0x32) * 0xc + *(int *)(iVar9 + 0xa8) + 10) !=
              0) {
            *puVar19 = uVar6 | 0x8080;
          }
        }
      }
      else {
        uVar6 = *puVar19;
        *puVar19 = uVar6 | 0x800;
        if ((*(byte *)(iVar15 + 0x48) & 0x80) != 0) {
          *puVar19 = uVar6 | 0x810;
        }
      }
      local_150[1] = 999999.0;
      *(undefined2 *)(local_174 + 0xe) = 0xffff;
      *(undefined2 *)(local_174 + 0xc) = 0xffff;
      *(undefined2 *)(local_174 + 0x10) = 0xffff;
      local_150[0] = 999999.0;
      local_150[3] = -99999.0;
      local_150[2] = -99999.0;
      iVar15 = (uint)(*(ushort *)((int)puVar19 + 0x16) >> 1) * 0x50 + *(int *)(local_160 + 0x5c);
      bVar3 = *(byte *)((int)puVar19 + 3);
      if (*(char *)((int)puVar19 + 3) != '\0') {
        uVar6 = puVar19[2];
        iVar18 = *(int *)(local_160 + 0x20);
        iVar14 = *(int *)(local_160 + 0x88);
        uVar17 = 0;
        do {
          pfVar1 = (float *)(iVar18 + (uint)*(ushort *)(iVar14 + uVar6 * 2 + uVar17 * 2) * 0xc);
          fVar23 = *pfVar1;
          fVar21 = pfVar1[1];
          fVar2 = pfVar1[2];
          iVar13 = 0;
          fVar22 = local_150[2];
          fVar24 = local_150[0];
          while( true ) {
            fVar20 = *(float *)(iVar15 + iVar13 * 4) * fVar23 +
                     *(float *)(iVar15 + 4 + iVar13 * 4) * fVar21 +
                     *(float *)(iVar15 + 0xc + iVar13 * 4) +
                     *(float *)(iVar15 + 8 + iVar13 * 4) * fVar2;
            if (fVar20 < fVar24) {
              *(float *)((int)local_150 + iVar13) = fVar20;
            }
            if (fVar22 < fVar20) {
              *(float *)((int)local_150 + iVar13 + 8) = fVar20;
            }
            if (iVar13 + 4 == 8) break;
            fVar24 = *(float *)((int)local_150 + iVar13 + 4);
            fVar22 = *(float *)((int)local_140 + iVar13 + -4);
            iVar13 = iVar13 + 4;
          }
          uVar17 = uVar17 + 1;
        } while (uVar17 != bVar3);
      }
      iVar18 = 0;
      fVar21 = local_150[2];
      fVar23 = local_150[0];
      while( true ) {
        iVar14 = ((int)puVar19 - *(int *)(local_160 + 0x78) & 0xffffffe0U) +
                 *(int *)(local_160 + 0x7c);
        if ((*(short *)(iVar14 + 4 + iVar18) == 0) && (*(int *)(iVar14 + 0x1c) == 0)) {
          *puVar19 = *puVar19 | 1;
        }
        *(int *)(((int)puVar19 - *(int *)(local_160 + 0x78) >> 5) * 0x10 + iVar18 * 2 +
                *(int *)(local_160 + 0x74)) = (int)fVar23;
        *(ushort *)
         (iVar18 + 8 +
         ((int)puVar19 - *(int *)(local_160 + 0x78) >> 5) * 0x10 + *(int *)(local_160 + 0x74)) =
             ((ushort)((float)(int)ROUND(fVar21) < fVar21) + (short)(int)ROUND(fVar21)) -
             (short)(int)fVar23;
        if (((*(byte *)(iVar15 + 0x49) & 4) == 0) &&
           ((short)((-(ushort)((*puVar19 & 0x800) == 0) & 0xffa3) + 0x80) <
            *(short *)(iVar18 + 4 +
                      ((int)puVar19 - *(int *)(local_160 + 0x78) & 0xffffffe0U) +
                      *(int *)(local_160 + 0x7c)))) {
          uVar12 = (**(code **)**(undefined4 **)(iVar15 + 0x4c))(*(undefined4 **)(iVar15 + 0x4c));
          Sys_Error("Bad surface extents on texture %s",uVar12);
        }
        iVar18 = iVar18 + 2;
        if (iVar18 == 4) break;
        fVar23 = *(float *)((int)local_150 + iVar18 * 2);
        fVar21 = *(float *)((int)local_150 + iVar18 * 2 + 8);
      }
      local_178 = local_178 + 1;
      local_164 = local_164 + 0x38;
      local_180 = local_180 + 0x10;
      local_174 = local_174 + 0x20;
      local_17c = local_17c + 0x20;
      if (uVar16 == local_178) break;
      local_160 = s_pMap;
    }
  }
  s_nMapSurfacesLoaded = uVar16;
  if (local_134 != 0) {
    (**(code **)(*g_pFileSystem + 0x150))(g_pFileSystem,local_134);
  }
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)