L L4D2node

CLog::Open

0x001fa7e0 · 666 bytes · __thiscall

_ZN4CLog4OpenEv

Decompiled

undefined (1 param)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CLog::Open() */

void __thiscall CLog::Open(CLog *this)

{
  uint uVar1;
  char cVar2;
  int iVar3;
  uint uVar4;
  uint uVar5;
  uint uVar6;
  uint uVar7;
  int iVar8;
  undefined4 uVar9;
  char *pcVar10;
  int iVar11;
  int in_GS_OFFSET;
  int iVar12;
  undefined4 uVar13;
  undefined4 uVar14;
  undefined1 local_254 [4];
  undefined4 local_250;
  undefined4 local_24c;
  undefined4 local_248;
  int local_244;
  int local_240;
  char local_228 [260];
  char local_124 [260];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (((this[8] != (CLog)0x0) && (*(int *)(sv_logfile._28_4_ + 0x30) != 0)) &&
     ((*(int *)(this + 0x20) == 0 || (*(int *)(sv_log_onefile._28_4_ + 0x30) == 0)))) {
    pcVar10 = "FCVAR_NEVER_AS_STRING";
    Close(this);
    (**(code **)(_g_pVCR + 0x5c))(local_254);
    if (((sv_logsdir[0x15] & 0x10) == 0) &&
       (pcVar10 = *(char **)(sv_logsdir._28_4_ + 0x24), pcVar10 == (char *)0x0)) {
      pcVar10 = "";
    }
    cVar2 = COM_IsValidPath(pcVar10);
    if (cVar2 == '\0') {
      pcVar10 = "logs";
    }
    iVar3 = (**(code **)(*cvar + 0x30))(cvar,"hostip");
    uVar1 = *(uint *)(*(int *)(iVar3 + 0x1c) + 0x30);
    uVar4 = NET_GetUDPPort(1);
    uVar4 = uVar4 & 0xffff;
    uVar5 = uVar1 & 0xff;
    uVar6 = uVar1 >> 8 & 0xff;
    uVar7 = (int)uVar1 >> 0x10 & 0xff;
    iVar11 = 0;
    iVar3 = local_244 + 1;
    iVar12 = local_240 + 0x76c;
    V_snprintf(local_228,0x104,"%s/L%03i_%03i_%03i_%03i_%i_%04i%02i%02i%02i%02i_",pcVar10,
               uVar1 >> 0x18,uVar7,uVar6,uVar5,uVar4,iVar12,iVar3,local_248,local_24c,local_250);
    uVar9 = local_248;
    uVar13 = local_24c;
    uVar14 = local_250;
    do {
      V_snprintf(local_124,0x104,"%s%03i.log",local_228,iVar11,uVar7,uVar6,uVar5,uVar4,iVar12,iVar3,
                 uVar9,uVar13,uVar14);
      V_FixSlashes(local_124,'/');
      COM_CreatePath(local_124);
      iVar8 = (**(code **)(*(int *)(g_pFileSystem + 4) + 8))
                        (g_pFileSystem + 4,local_124,&DAT_002a9af2,"LOGDIR");
      if (iVar8 == 0) {
        COM_CreatePath(local_124);
        iVar3 = (**(code **)(*(int *)(g_pFileSystem + 4) + 8))
                          (g_pFileSystem + 4,local_124,&DAT_002a5dab,"LOGDIR");
        if (iVar3 != 0) {
          ConMsg("Server logging data to file %s\n",local_124);
          *(int *)(this + 0x20) = iVar3;
          uVar9 = build_number();
          Printf(this,"Log file started (file \"%s\") (game \"%s\") (version \"%i\")\n",local_124,
                 com_gamedir,uVar9);
          goto LAB_001faa38;
        }
        break;
      }
      iVar11 = iVar11 + 1;
      (**(code **)(*(int *)(g_pFileSystem + 4) + 0xc))(g_pFileSystem + 4,iVar8);
    } while (iVar11 != 1000);
    ConMsg("Unable to open logfiles under %s\nLogging disabled\n",local_228);
  }
LAB_001faa38:
  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)