L L4D2node

CScriptJournal::Journal

0x00907740 · 3816 bytes · __thiscall

_ZN14CScriptJournal7JournalEv

Decompiled

undefined (1 param)

/* CScriptJournal::Journal() */

void __thiscall CScriptJournal::Journal(CScriptJournal *this)

{
  float fVar1;
  float fVar2;
  code *pcVar3;
  int *piVar4;
  CBaseEntity *pCVar5;
  char cVar6;
  undefined4 uVar7;
  undefined4 uVar8;
  char *pcVar9;
  uint uVar10;
  undefined4 *puVar11;
  uint uVar12;
  undefined *puVar13;
  uint *puVar14;
  uint *puVar15;
  undefined1 *puVar16;
  int iVar17;
  int iVar18;
  int iVar19;
  int in_GS_OFFSET;
  bool bVar20;
  undefined2 in_FPUControlWord;
  longdouble lVar21;
  double dVar22;
  float fVar23;
  undefined4 uVar24;
  undefined4 local_8a0;
  short local_898;
  ushort local_896;
  undefined4 local_894;
  int local_890 [5];
  undefined4 local_87c;
  undefined4 local_878;
  undefined4 local_874;
  undefined4 local_870;
  undefined4 local_86c;
  undefined4 local_868;
  undefined4 local_864;
  int local_860;
  undefined4 local_85c;
  undefined4 local_858;
  undefined4 local_854;
  undefined4 local_850;
  undefined4 local_84c;
  int local_848 [2];
  undefined4 local_840;
  char acStack_83e [2];
  int local_83c;
  int local_838;
  uint local_834 [5];
  char local_820 [2048];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  iVar18 = 0;
  if (*(int *)(this + 0x10) == -1) {
    local_834[0] = 0x6c2f3a63;
    local_834[1] = 0x756f6a34;
    local_834[2] = 0x6c616e72;
    local_834[3] = 0x2e303030;
    local_834[4] = 0x74756e;
    do {
      cVar6 = (**(code **)(*(int *)(g_pFullFileSystem + 4) + 0x28))
                        (g_pFullFileSystem + 4,local_834,0);
      if (cVar6 == '\0') break;
      iVar18 = iVar18 + 1;
      puVar15 = local_834;
      do {
        puVar14 = puVar15;
        uVar12 = *puVar14 + 0xfefefeff & ~*puVar14;
        uVar10 = uVar12 & 0x80808080;
        puVar15 = puVar14 + 1;
      } while (uVar10 == 0);
      if ((uVar12 & 0x8080) == 0) {
        puVar15 = (uint *)((int)puVar14 + 6);
        uVar10 = uVar10 >> 0x10;
      }
      *(char *)((int)puVar15 +
               (int)(acStack_83e + (-(int)local_834 - (uint)CARRY1((byte)uVar10,(byte)uVar10)))) =
           (char)(iVar18 / 100) + '0';
      puVar15 = local_834;
      do {
        puVar14 = puVar15;
        uVar12 = *puVar14 + 0xfefefeff & ~*puVar14;
        uVar10 = uVar12 & 0x80808080;
        puVar15 = puVar14 + 1;
      } while (uVar10 == 0);
      if ((uVar12 & 0x8080) == 0) {
        puVar15 = (uint *)((int)puVar14 + 6);
        uVar10 = uVar10 >> 0x10;
      }
      *(char *)((int)puVar15 +
               (int)(acStack_83e + (-(int)local_834 - (uint)CARRY1((byte)uVar10,(byte)uVar10)) + 1))
           = (char)((iVar18 % 100) / 10) + '0';
      puVar15 = local_834;
      do {
        puVar14 = puVar15;
        uVar12 = *puVar14 + 0xfefefeff & ~*puVar14;
        uVar10 = uVar12 & 0x80808080;
        puVar15 = puVar14 + 1;
      } while (uVar10 == 0);
      if ((uVar12 & 0x8080) == 0) {
        puVar15 = (uint *)((int)puVar14 + 6);
        uVar10 = uVar10 >> 0x10;
      }
      *(char *)((int)puVar15 +
               (int)&local_83c + (-(int)local_834 - (uint)CARRY1((byte)uVar10,(byte)uVar10))) =
           (char)iVar18 + (char)(iVar18 / 10) * -10 + '0';
    } while (iVar18 != 999);
    DevMsg("Journaling to %s\n",local_834);
    uVar7 = (**(code **)(*(int *)(g_pFullFileSystem + 4) + 8))
                      (g_pFullFileSystem + 4,local_834,"w",0);
    *(undefined4 *)(this + 0x10) = uVar7;
    puVar16 = &DAT_00d539c2;
    if (*(undefined1 **)(gpGlobals + 0x3c) != (undefined1 *)0x0) {
      puVar16 = *(undefined1 **)(gpGlobals + 0x3c);
    }
    puVar13 = (undefined *)CDirector::GetGameMode();
    V_sprintf_safe<2048u>
              (local_820,"JournalModeName <- \"%s\"\nJournalMapName <- \"%s\"\n",puVar13,puVar16);
    local_848[0] = 0;
    local_848[1] = 0;
    local_840 = 0;
    local_83c = 0;
    local_838 = 0;
    local_858 = 2;
    local_854 = 2;
    local_850 = 3;
    local_84c = 9;
                    /* try { // try from 00908444 to 009085af has its CatchHandler @ 009086ce */
    ForEachTerrorPlayer<PlayerCollector>((PlayerCollector *)&local_858);
    V_sprintfcat_safe<2048u>(local_820,"JournalPlayers <- [");
    iVar18 = 0;
    if (0 < local_83c) {
      do {
        piVar4 = *(int **)(local_848[0] + iVar18 * 4);
        uVar7 = (**(code **)(*piVar4 + 0xb8))(piVar4);
        if (piVar4[0xc] == 0) {
          puVar16 = (undefined1 *)0x0;
        }
        else {
          puVar16 = (undefined1 *)(piVar4[0xc] - *(int *)(gpGlobals + 0x58) >> 4);
        }
        puVar13 = &DAT_00d539c2;
        if (iVar18 != 0) {
          puVar13 = &DAT_00c8fd1f;
        }
        V_sprintfcat_safe<2048u>(local_820,"%s {idx=%d,name=\"%s\"}",puVar13,puVar16,uVar7);
        iVar18 = iVar18 + 1;
      } while (iVar18 < local_83c);
    }
    V_sprintfcat_safe<2048u>(local_820," ]\n\n",puVar13,puVar16);
    V_sprintfcat_safe<2048u>(local_820,"JournalDataStream <-\n[\n");
    uVar7 = *(undefined4 *)(this + 0x10);
    pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
    uVar8 = _V_strlen(local_820);
    (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
    puVar11 = (undefined4 *)CDirector::GetScriptScope(TheDirector,*(undefined4 *)(this + 0x1c));
    uVar7 = (**(code **)(*g_pScriptVM + 0x48))(g_pScriptVM,"JournalFunc",*puVar11,1);
    *(undefined4 *)(this + 0x14) = uVar7;
    local_83c = 0;
    CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_848);
    local_838 = local_848[0];
    CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_848);
  }
  local_86c = 0;
  local_868 = 0;
  local_864 = 0;
  local_860 = 0;
  local_85c = 0;
  local_87c = 3;
  local_878 = 2;
  local_874 = 3;
  local_870 = 9;
                    /* try { // try from 009077ce to 0090799d has its CatchHandler @ 0090864d */
  ForEachTerrorPlayer<PlayerCollector>((PlayerCollector *)&local_87c);
  lVar21 = (longdouble)CTerrorGameRules::GetHoldoutCooldownEndTime(g_pGameRules);
  fVar23 = (float)lVar21 - *(float *)(gpGlobals + 0xc);
  dVar22 = (double)*(float *)(gpGlobals + 0xc);
  V_sprintf_safe<2048u>
            (local_820,"\t{ Time = %.2f\n",SUB84(dVar22,0),(int)((ulonglong)dVar22 >> 0x20));
  dVar22 = (double)fVar23;
  if (fVar23 <= 0.0) {
    dVar22 = -1.0;
  }
  V_sprintfcat_safe<2048u>
            (local_820,"\t\tCooldown = %.2f\n",SUB84(dVar22,0),(int)((ulonglong)dVar22 >> 0x20));
  uVar7 = CDirectorTacticalServices::GetCommonInfectedCount
                    (*(CDirectorTacticalServices **)(TheDirector + 0x628),0);
  V_sprintfcat_safe<2048u>(local_820,"\t\tCommons = %d\n",uVar7);
  V_sprintfcat_safe<2048u>(local_820,"\t\tSpecials = %d\n",local_860);
  uVar7 = (**(code **)(*(int *)TheDirector + 0x30))(TheDirector);
  uVar8 = CDirector::GetCommonInfectedLimit(TheDirector);
  V_sprintfcat_safe<2048u>(local_820,"\t\tLimits = [ %d, %d ]\n",uVar8,uVar7);
  V_sprintfcat_safe<2048u>(local_820,"\t\tWave = %d\n",0);
  V_sprintfcat_safe<2048u>
            (local_820,"\t\tStageType = %d\n",*(undefined4 *)(*(int *)(TheDirector + 0x638) + 4));
  lVar21 = (longdouble)
           CDirectorScriptedEventManager::GetScriptedEventStageRemainingTime
                     (*(CDirectorScriptedEventManager **)(TheDirector + 0x638));
  V_sprintfcat_safe<2048u>
            (local_820,"\t\tStageTimer = %.2f\n",SUB84((double)(float)lVar21,0),
             (int)((ulonglong)(double)(float)lVar21 >> 0x20));
  uVar7 = *(undefined4 *)(this + 0x10);
  pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
  uVar8 = _V_strlen(local_820);
  (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
  local_848[0] = 0;
  local_848[1] = 0;
  local_840 = 0;
  local_83c = 0;
  local_838 = 0;
  local_858 = 2;
  local_854 = 2;
  local_850 = 3;
  local_84c = 9;
                    /* try { // try from 00907a19 to 00907c37 has its CatchHandler @ 009086af */
  ForEachTerrorPlayer<PlayerCollector>((PlayerCollector *)&local_858);
  DumpEntityInfoToSq(this,"players",(CUtlVector *)local_848,true);
  iVar18 = 0;
  DumpEntityInfoToSq(this,"mobs",(CUtlVector *)&local_86c,false);
  pcVar9 = ",";
  if (local_860 < 1) {
    pcVar9 = "";
  }
  V_sprintf_safe<2048u>(local_820,"%s",pcVar9);
  if (0 < DAT_01025eac) {
    iVar19 = 0;
    iVar17 = 0;
    do {
      piVar4 = *(int **)(TheWitches + iVar17 * 4);
      cVar6 = (**(code **)(*piVar4 + 300))(piVar4);
      if (cVar6 != '\0') {
        pCVar5 = *(CBaseEntity **)(TheWitches + iVar17 * 4);
        if (((byte)pCVar5[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition(pCVar5);
        }
        uVar7 = *(undefined4 *)(pCVar5 + 0x100);
        fVar23 = *(float *)(pCVar5 + 0x2e8);
        fVar1 = *(float *)(pCVar5 + 0x2e4);
        fVar2 = *(float *)(pCVar5 + 0x2e0);
        uVar8 = (**(code **)(*(int *)pCVar5 + 0x544))(pCVar5);
        if (*(int *)(pCVar5 + 0x30) == 0) {
          iVar18 = 0;
        }
        else {
          iVar18 = *(int *)(pCVar5 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
        }
        bVar20 = iVar19 != 0;
        pcVar9 = "";
        iVar19 = iVar19 + 1;
        if (bVar20) {
          pcVar9 = ", ";
        }
        V_sprintfcat_safe<2048u>
                  (local_820,"%s[%d, %d, %.1f, %.1f, %.1f, %d] ",pcVar9,iVar18,uVar8,(double)fVar2,
                   (double)fVar1,(double)fVar23,uVar7);
      }
      iVar17 = iVar17 + 1;
    } while (iVar17 < DAT_01025eac);
  }
  V_sprintfcat_safe<2048u>(local_820,"]\n",pcVar9,iVar18);
  pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
  iVar18 = *(int *)(this + 0x10);
  uVar7 = _V_strlen(local_820);
  (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar7,iVar18);
  local_890[0] = 0;
  local_890[1] = 0;
  local_890[2] = 0;
  local_890[3] = 0;
  local_890[4] = 0;
  local_894 = 0;
                    /* try { // try from 00907c74 to 0090804d has its CatchHandler @ 00908671 */
  iVar19 = TheNextBots();
  uVar10 = (uint)*(ushort *)(iVar19 + 0x10);
  if (uVar10 != 0xffff) {
    iVar17 = *(int *)(iVar19 + 4);
    do {
      cVar6 = CommonInfectedCollector::operator()
                        ((CommonInfectedCollector *)&local_894,*(INextBot **)(iVar17 + uVar10 * 8));
      if (cVar6 == '\0') break;
      iVar17 = *(int *)(iVar19 + 4);
      uVar10 = (uint)*(ushort *)(iVar17 + 6 + uVar10 * 8);
    } while (uVar10 != 0xffff);
  }
  pcVar9 = "commons";
  V_sprintf_safe<2048u>(local_820,"\t\t%s = [ ","commons");
  iVar19 = 0;
  if (0 < local_890[3]) {
    do {
      pCVar5 = *(CBaseEntity **)(local_890[0] + iVar19 * 4);
      if (((byte)pCVar5[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition(pCVar5);
      }
      pcVar9 = "";
      if (iVar19 != 0) {
        pcVar9 = ", ";
      }
      iVar18 = (int)*(float *)(pCVar5 + 0x2e0);
      V_sprintfcat_safe<2048u>
                (local_820,"%s[%d,%d,%d] ",pcVar9,iVar18,(int)*(float *)(pCVar5 + 0x2e4),
                 (int)*(float *)(pCVar5 + 0x2e8));
      iVar19 = iVar19 + 1;
    } while (iVar19 < local_890[3]);
  }
  V_sprintfcat_safe<2048u>(local_820,"]\n",pcVar9,iVar18);
  pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
  uVar7 = *(undefined4 *)(this + 0x10);
  uVar8 = _V_strlen(local_820);
  (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
  V_sprintf_safe<2048u>(local_820,"\t\tTimers = [ ");
  iVar18 = 0;
  do {
    lVar21 = (longdouble)CDirector::GetSpecialInhibitSpawnTimeRemaining(TheDirector,iVar18);
    local_8a0 = (void *)(CONCAT22(local_8a0._2_2_,in_FPUControlWord) & 0xfffff3ff | 0x800);
    if (0.0 <= (float)ROUND(lVar21)) {
      lVar21 = (longdouble)CDirector::GetSpecialInhibitSpawnTimeRemaining(TheDirector,iVar18);
      local_8a0 = (void *)(CONCAT22(local_8a0._2_2_,in_FPUControlWord) & 0xfffff3ff | 0x800);
      dVar22 = (double)(float)ROUND(lVar21);
    }
    else {
      dVar22 = 0.0;
    }
    pcVar9 = "";
    uVar7 = (undefined4)((ulonglong)dVar22 >> 0x20);
    if (iVar18 != 0) {
      pcVar9 = ", ";
    }
    V_sprintfcat_safe<2048u>(local_820,"%s%.2f",pcVar9,SUB84(dVar22,0),uVar7);
    iVar18 = iVar18 + 1;
  } while (iVar18 != 6);
  iVar18 = 0;
  do {
    if (iVar18 < *(int *)(TheDirector + 0x370)) {
      lVar21 = (longdouble)CDirector::GetSpecialSlotTimeRemaining(TheDirector,iVar18);
      dVar22 = (double)(float)lVar21;
    }
    else {
      dVar22 = -1.0;
    }
    uVar8 = SUB84(dVar22,0);
    uVar24 = (undefined4)((ulonglong)dVar22 >> 0x20);
    V_sprintfcat_safe<2048u>(local_820,",%.2f",uVar8,uVar24,uVar7);
    iVar18 = iVar18 + 1;
  } while (iVar18 != 0x14);
  V_sprintfcat_safe<2048u>(local_820,"]\n",uVar8,uVar24,uVar7);
  uVar7 = *(undefined4 *)(this + 0x10);
  pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
  uVar8 = _V_strlen(local_820);
  (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
  iVar18 = *(int *)(this + 0x14);
  if (iVar18 != 0) {
    puVar11 = (undefined4 *)CDirector::GetScriptScope(TheDirector,*(undefined4 *)(this + 0x1c));
    iVar18 = (**(code **)(*g_pScriptVM + 0x50))(g_pScriptVM,iVar18,0,0,0,*puVar11,1);
    if (iVar18 == 0) {
      local_8a0 = (void *)0x0;
      local_898 = 0;
      local_896 = 0;
      iVar18 = 0;
      if (*(int *)(TheDirector + 0x4b8) != -1) {
        iVar18 = *(int *)(TheDirector + 0x4b8);
      }
                    /* try { // try from 00908180 to 00908181 has its CatchHandler @ 009086b3 */
      cVar6 = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,iVar18,"JournalString",&local_8a0);
      if ((cVar6 != '\0') && (local_898 == 0x1f)) {
                    /* try { // try from 00908601 to 00908647 has its CatchHandler @ 009086b3 */
        V_sprintf_safe<2048u>(local_820,"\t\tcustom = %s\n",local_8a0);
        pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
        uVar7 = *(undefined4 *)(this + 0x10);
        uVar8 = _V_strlen(local_820);
        (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
      }
      if ((local_896 & 1) != 0) {
        free(local_8a0);
      }
    }
  }
  V_sprintf_safe<2048u>(local_820,"\t\t}\n");
  uVar7 = *(undefined4 *)(this + 0x10);
  pcVar3 = *(code **)(*(int *)(g_pFullFileSystem + 4) + 4);
  uVar8 = _V_strlen(local_820);
  (*pcVar3)(g_pFullFileSystem + 4,local_820,uVar8,uVar7);
  lVar21 = (longdouble)CountdownTimer::Now();
  if ((float)lVar21 + 0.5 != *(float *)(this + 0xc)) {
                    /* try { // try from 009085ce to 009085d0 has its CatchHandler @ 00908671 */
    (**(code **)(*(int *)(this + 4) + 4))(this + 4,this + 0xc);
    *(float *)(this + 0xc) = (float)lVar21 + 0.5;
  }
  if (*(float *)(this + 8) != 0.5) {
                    /* try { // try from 009081c3 to 009081c5 has its CatchHandler @ 00908671 */
    (**(code **)(*(int *)(this + 4) + 4))(this + 4,this + 8);
    *(undefined4 *)(this + 8) = 0x3f000000;
  }
  local_890[3] = 0;
  CUtlMemory<Infected*,int>::Purge((CUtlMemory<Infected*,int> *)local_890);
  local_890[4] = local_890[0];
  CUtlMemory<Infected*,int>::Purge((CUtlMemory<Infected*,int> *)local_890);
  local_83c = 0;
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_848);
  local_838 = local_848[0];
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_848);
  local_860 = 0;
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)&local_86c);
  local_85c = local_86c;
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)&local_86c);
  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)