L L4D2node

CBaseEntity::RunVScripts

0x0060f260 · 1029 bytes · __thiscall

_ZN11CBaseEntity11RunVScriptsEv

Decompiled

undefined (1 param)

/* CBaseEntity::RunVScripts() */

void __thiscall CBaseEntity::RunVScripts(CBaseEntity *this)

{
  code *pcVar1;
  void *pvVar2;
  undefined4 uVar3;
  char *pcVar4;
  HSCRIPT__ *pHVar5;
  int iVar6;
  undefined4 uVar7;
  int iVar8;
  int in_GS_OFFSET;
  int local_258;
  undefined1 local_254 [20];
  int local_240 [5];
  char local_22b [255];
  CFmtStrN<256> local_12c [5];
  undefined1 local_127 [263];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (*(int *)(this + 0x3e0) != 0) {
    iVar8 = 0;
    ValidateScriptScope(this);
    do {
      pcVar1 = *(code **)(*g_pScriptVM + 0x2c);
      CFmtStrN<256>::CFmtStrN
                (local_12c,
                 "%sCallChain <- CSimpleCallChainer(\"%s\", self.GetScriptScope().weakref(), true)",
                 (&RunVScripts()::sCallChainFunctions)[iVar8],
                 (&RunVScripts()::sCallChainFunctions)[iVar8]);
      uVar3 = (*pcVar1)(g_pScriptVM,local_127,0);
      uVar7 = 0;
      if (*(int *)(this + 1000) != -1) {
        uVar7 = *(undefined4 *)(this + 1000);
      }
      iVar8 = iVar8 + 1;
      (**(code **)(*g_pScriptVM + 0x34))(g_pScriptVM,uVar3,uVar7,1);
    } while (iVar8 != 2);
    pcVar4 = "";
    if (*(char **)(this + 0x3e0) != (char *)0x0) {
      pcVar4 = *(char **)(this + 0x3e0);
    }
    _V_strcpy(local_22b,pcVar4);
    local_240[0] = 0;
    local_240[1] = 0;
    local_240[2] = 0;
    local_240[3] = 0;
    local_240[4] = 0;
                    /* try { // try from 0060f382 to 0060f578 has its CatchHandler @ 0060f666 */
    V_SplitString(local_22b," ",(CUtlVector *)local_240);
    if (0 < local_240[3]) {
      local_258 = 0;
      do {
        uVar7 = *(undefined4 *)(local_240[0] + local_258 * 4);
        uVar3 = GetDebugName(this);
        Msg("%s executing script: %s\n",uVar3,uVar7);
        RunScriptFile(this,*(char **)(local_240[0] + local_258 * 4),this == g_WorldEntity);
        iVar8 = 0;
        do {
          pcVar1 = *(code **)(*g_pScriptVM + 0x2c);
          CFmtStrN<256>::CFmtStrN
                    (local_12c,"%sCallChain.PostScriptExecute()",
                     (&RunVScripts()::sCallChainFunctions)[iVar8]);
          uVar3 = (*pcVar1)(g_pScriptVM,local_127,0);
          uVar7 = 0;
          if (*(int *)(this + 1000) != -1) {
            uVar7 = *(undefined4 *)(this + 1000);
          }
          (**(code **)(*g_pScriptVM + 0x34))(g_pScriptVM,uVar3,uVar7,1);
          iVar8 = iVar8 + 1;
        } while (iVar8 != 2);
        local_258 = local_258 + 1;
      } while (local_258 < local_240[3]);
    }
    pHVar5 = (HSCRIPT__ *)0x0;
    if (*(HSCRIPT__ **)(this + 1000) != (HSCRIPT__ *)&DAT_ffffffff) {
      pHVar5 = *(HSCRIPT__ **)(this + 1000);
    }
    CollectGameEventCallbacksInScope(pHVar5);
    if (*(int *)(this + 0x3e4) != 0) {
      ThinkSet((_func_void *)local_254,(float)this,(char *)ScriptThink);
    }
    iVar8 = (**(code **)(*g_pScriptVM + 0x48))
                      (g_pScriptVM,"DispatchPrecache",*(undefined4 *)(this + 1000),0);
    if (iVar8 != 0) {
      iVar6 = 0;
      if (*(int *)(this + 1000) != -1) {
        iVar6 = *(int *)(this + 1000);
      }
      (**(code **)(*g_pScriptVM + 0x50))(g_pScriptVM,iVar8,0,0,0,iVar6,1);
      (**(code **)(*g_pScriptVM + 0x4c))(g_pScriptVM,iVar8);
    }
    iVar8 = 0;
    if (0 < local_240[3]) {
      do {
        pvVar2 = *(void **)(local_240[0] + iVar8 * 4);
        if (pvVar2 != (void *)0x0) {
          operator_delete__(pvVar2);
        }
        iVar8 = iVar8 + 1;
      } while (iVar8 < local_240[3]);
    }
    iVar8 = 0;
    local_240[3] = 0;
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)local_240);
    local_240[4] = local_240[0];
    if (0 < local_240[3]) {
      do {
        iVar6 = iVar8 * 4;
        iVar8 = iVar8 + 1;
        ::operator_delete(*(void **)(local_240[0] + iVar6));
      } while (iVar8 < local_240[3]);
    }
    local_240[3] = 0;
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)local_240);
    local_240[3] = 0;
    local_240[4] = local_240[0];
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)local_240);
    local_240[4] = local_240[0];
    CUtlMemory<char*,int>::Purge((CUtlMemory<char*,int> *)local_240);
  }
  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)