L L4D2node

CDemoFile::ReadDemoHeader

0x00131a50 · 303 bytes · __thiscall

_ZN9CDemoFile14ReadDemoHeaderEv

Decompiled

undefined (1 param)

/* CDemoFile::ReadDemoHeader() */

CDemoFile * __thiscall CDemoFile::ReadDemoHeader(CDemoFile *this)

{
  CUtlBuffer *this_00;
  char cVar1;
  int iVar2;
  int iVar3;
  undefined4 uVar4;
  CDemoFile *pCVar5;
  
  pCVar5 = this + 0x104;
  this_00 = (CUtlBuffer *)(this + 0x534);
  _V_memset(pCVar5,0,0x430);
  cVar1 = CUtlStreamBuffer::IsOpen((CUtlStreamBuffer *)this_00);
  if (cVar1 != '\0') {
    CUtlBuffer::SeekGet(this_00,0,0);
    CUtlBuffer::Get(this_00,pCVar5,0x430);
    if (this[0x548] == (CDemoFile)0x0) {
      iVar2 = _V_strcmp((char *)pCVar5,"HL2DEMO");
      if (iVar2 == 0) {
        cVar1 = IsNetworkVersionCompatible(*(int *)(this + 0x110));
        if (cVar1 == '\0') {
          iVar2 = *(int *)(this + 0x110);
        }
        else {
          iVar2 = GetNetworkVersion();
          *(int *)(this + 0x110) = iVar2;
        }
        iVar3 = GetNetworkVersion();
        if (iVar2 == iVar3) {
          if (2 < *(int *)(this + 0x10c) - 2U) {
            ConMsg("ERROR: demo file protocol %i outdated, engine version is %i \n",
                   *(int *)(this + 0x10c),4);
            return (CDemoFile *)0x0;
          }
        }
        else {
          uVar4 = GetNetworkVersion();
          pCVar5 = (CDemoFile *)0x0;
          ConMsg("ERROR: demo network protocol %i outdated, engine version is %i \n",
                 *(undefined4 *)(this + 0x110),uVar4);
        }
      }
      else {
        pCVar5 = (CDemoFile *)0x0;
        ConMsg("%s has invalid demo header ID.\n",this);
      }
      return pCVar5;
    }
  }
  return (CDemoFile *)0x0;
}

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)