L L4D2node

CMatchExtL4D::Initialize

0x00036b80 · 2287 bytes · __thiscall

_ZN12CMatchExtL4D10InitializeEv

Decompiled

undefined (1 param)

/* CMatchExtL4D::Initialize() */

void __thiscall CMatchExtL4D::Initialize(CMatchExtL4D *this)

{
  char cVar1;
  undefined4 uVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  int iVar6;
  KeyValues *pKVar7;
  char *pcVar8;
  KeyValues *pKVar9;
  IBaseFileSystem *pIVar10;
  uint *puVar11;
  uint uVar12;
  uint *puVar13;
  undefined *puVar14;
  int iVar15;
  undefined4 *puVar16;
  int in_GS_OFFSET;
  undefined4 local_1354;
  undefined4 local_1350;
  int local_1348 [70];
  char local_1230 [260];
  CFmtStrN<256> local_112c [5];
  char local_1127 [263];
  char local_1020 [4096];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  DevMsg("Loading Mission Data\n");
  if (*(int *)(this + 4) != 0) {
    KeyValues::deleteThis();
    *(undefined4 *)(this + 4) = 0;
  }
  *(undefined4 *)(this + 0x14) = 0;
  CUtlMemory<KeyValues*,int>::Purge((CUtlMemory<KeyValues*,int> *)(this + 8));
  *(undefined4 *)(this + 0x18) = *(undefined4 *)(this + 8);
  CUtlSymbolTable::RemoveAll((CUtlSymbolTable *)(this + 0x1c));
  *(undefined4 *)(this + 0x60) = 0;
  CUtlMemory<KeyValues*,int>::Purge((CUtlMemory<KeyValues*,int> *)(this + 0x54));
  *(undefined4 *)(this + 100) = *(undefined4 *)(this + 0x54);
  CUtlSymbolTable::RemoveAll((CUtlSymbolTable *)(this + 0x68));
  uVar2 = KeyValues::FromString("Left4Dead2"," GameModes { }  Missions {  } ",(char **)0x0);
  *(undefined4 *)(this + 4) = uVar2;
  LoadGameModesFromFile(this,"scripts/gamemodes.txt");
  LoadCustomGameModes(this);
  ParseMissionFromFile(this,"missions/campaign1.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign2.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign3.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign4.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign5.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign6.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign7.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign8.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign9.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign10.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign11.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign12.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign13.txt",true,0);
  ParseMissionFromFile(this,"missions/campaign14.txt",true,0);
  ParseMissionFromFile(this,"missions/credits.txt",true,0);
  V_snprintf(local_1020,0x1000,"missions/*.txt");
  V_FixSlashes(local_1020,'/');
  local_1348[0] = 0;
  local_1348[1] = 0;
  local_1348[2] = 0;
  local_1348[3] = 0;
  local_1348[4] = 0;
                    /* try { // try from 00036f21 to 00037256 has its CatchHandler @ 000374b6 */
  (**(code **)(*g_pFullFileSystem + 0x84))(g_pFullFileSystem,local_1348,local_1020,"GAME");
  V_snprintf((char *)(local_1348 + 5),0x104,"addons%cworkshop%c",0x2f,0x2f);
  puVar13 = (uint *)(local_1348 + 5);
  do {
    puVar11 = puVar13;
    uVar3 = *puVar11 + 0xfefefeff & ~*puVar11;
    uVar4 = uVar3 & 0x80808080;
    puVar13 = puVar11 + 1;
  } while (uVar4 == 0);
  uVar12 = uVar4 >> 0x10;
  puVar13 = (uint *)((int)puVar11 + 6);
  if ((uVar3 & 0x8080) != 0) {
    puVar13 = puVar11 + 1;
    uVar12 = uVar4;
  }
  if (0 < local_1348[3]) {
    iVar15 = 0;
    do {
      local_1354 = 0;
      local_1350 = 0;
      pcVar5 = CUtlString::operator_cast_to_char_((CUtlString *)(local_1348[0] + iVar15 * 0x10));
      iVar6 = V_stristr(pcVar5,(char *)(local_1348 + 5));
      if (iVar6 != 0) {
        sscanf((char *)((int)puVar13 +
                       iVar6 + ((-3 - (uint)CARRY1((byte)uVar12,(byte)uVar12)) -
                               (int)(local_1348 + 5))),"%llu.vpk",&local_1354);
      }
      pcVar5 = CUtlString::operator_cast_to_char_((CUtlString *)(iVar15 * 0x10 + local_1348[0]));
      V_FileBase(pcVar5,local_1230,0x104);
      V_snprintf((char *)local_112c,0x104,"missions/%s.txt",local_1230);
      ParseMissionFromFile(this,(char *)local_112c,false,CONCAT44(local_1350,local_1354));
      iVar15 = iVar15 + 1;
    } while (iVar15 < local_1348[3]);
  }
  MakeGameModeCopy(this,"coop","realism");
  pKVar7 = (KeyValues *)KeyValues::FindKey(*(KeyValues **)(this + 4),"GameModes",false);
  for (pKVar7 = (KeyValues *)KeyValues::GetFirstTrueSubKey(pKVar7); pKVar7 != (KeyValues *)0x0;
      pKVar7 = (KeyValues *)KeyValues::GetNextTrueSubKey(pKVar7)) {
    pcVar5 = (char *)KeyValues::GetName(pKVar7);
    pcVar8 = (char *)KeyValues::GetString(pKVar7,"base",pcVar5);
    iVar15 = _V_stricmp(pcVar5,pcVar8);
    if (iVar15 != 0) {
      MakeGameModeCopy(this,pcVar8,pcVar5);
    }
    iVar15 = KeyValues::GetInt(pKVar7,"maxplayers",0);
    if ((4 < iVar15) && (iVar15 = StringAfterPrefix(pcVar5,"team"), iVar15 == 0)) {
      CFmtStrN<256>::CFmtStrN(local_112c,"team%s",pcVar5);
      MakeGameModeCopy(this,pcVar5,local_1127);
      iVar15 = KeyValues::GetInt(pKVar7,"x360ctx",0);
      pKVar9 = (KeyValues *)KeyValues::FindKey(*(KeyValues **)(this + 4),"GameModes",false);
      pKVar9 = (KeyValues *)KeyValues::FindKey(pKVar9,local_1127,false);
      KeyValues::SetInt(pKVar9,"x360ctx",iVar15 + 1);
    }
  }
  pcVar5 = "GameModes";
  pKVar7 = (KeyValues *)KeyValues::FindKey(*(KeyValues **)(this + 4),"GameModes",true);
  if (pKVar7 != (KeyValues *)0x0) {
    pKVar9 = KeyValues::operator_new((KeyValues *)0x2c,(uint)pcVar5);
                    /* try { // try from 0003727a to 0003727e has its CatchHandler @ 000374a4 */
    KeyValues::KeyValues(pKVar9,"AddonConfig",(IKeyValuesSystem *)0x0,false);
    pIVar10 = (IBaseFileSystem *)0x0;
    if (g_pFullFileSystem != (int *)0x0) {
      pIVar10 = (IBaseFileSystem *)(g_pFullFileSystem + 1);
    }
                    /* try { // try from 000372a6 to 000372aa has its CatchHandler @ 0003747a */
    cVar1 = KeyValues::LoadFromFile(pKVar9,pIVar10,"cfg/addonconfig.cfg",(char *)0x0);
    if (cVar1 != '\0') {
                    /* try { // try from 00037374 to 0003746a has its CatchHandler @ 0003747a */
      for (pKVar7 = (KeyValues *)KeyValues::GetFirstTrueSubKey(pKVar7); pKVar7 != (KeyValues *)0x0;
          pKVar7 = (KeyValues *)KeyValues::GetNextTrueSubKey(pKVar7)) {
        pcVar5 = (char *)KeyValues::GetName(pKVar7);
        uVar2 = KeyValues::GetString(pKVar7,"base",pcVar5);
        iVar15 = StringAfterPrefix(pcVar5,"team");
        puVar14 = &DAT_000afc16;
        if (iVar15 == 0) {
          puVar14 = &DAT_000b2b65;
        }
        CFmtStrN<256>::CFmtStrN(local_112c,"%s%s",puVar14,uVar2);
        pcVar8 = (char *)KeyValues::GetString(pKVar7,"base",pcVar5);
        iVar15 = KeyValues::GetInt(pKVar9,"default",0);
        iVar15 = KeyValues::GetInt(pKVar9,pcVar8,(uint)(iVar15 != 0));
        iVar15 = KeyValues::GetInt(pKVar9,pcVar5,(uint)(iVar15 != 0));
        KeyValues::SetInt(pKVar7,"vanilla",(uint)(iVar15 != 0));
      }
    }
    if (pKVar9 != (KeyValues *)0x0) {
      KeyValues::deleteThis();
    }
  }
                    /* try { // try from 000372d2 to 000372d6 has its CatchHandler @ 000374b6 */
  DevMsg("Loading Mission Data Finished\n");
  iVar15 = local_1348[3] + -1;
  iVar6 = iVar15 * 0x10;
  for (; -1 < iVar15; iVar15 = iVar15 + -1) {
    puVar16 = (undefined4 *)(local_1348[0] + iVar6);
    if (-1 < (int)puVar16[2]) {
      if ((void *)*puVar16 != (void *)0x0) {
        free((void *)*puVar16);
        *puVar16 = 0;
      }
      puVar16[1] = 0;
    }
    iVar6 = iVar6 + -0x10;
  }
  local_1348[3] = 0;
  CUtlMemory<CUtlString,int>::Purge((CUtlMemory<CUtlString,int> *)local_1348);
  local_1348[4] = local_1348[0];
  CUtlMemory<CUtlString,int>::Purge((CUtlMemory<CUtlString,int> *)local_1348);
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __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)