L L4D2node

VScriptServerCompileScript

0x00b46120 · 1180 bytes · __cdecl

_Z26VScriptServerCompileScriptPKcb

Decompiled

undefined (2 params)

/* VScriptServerCompileScript(char const*, bool) */

int VScriptServerCompileScript(char *param_1,bool param_2)

{
  char *pcVar1;
  bool bVar2;
  bool bVar3;
  char cVar4;
  int iVar5;
  char *pcVar6;
  char *pcVar7;
  int in_GS_OFFSET;
  char *local_384;
  uchar *local_380;
  uchar *local_374 [4];
  int local_364;
  char local_33c [260];
  undefined **local_238;
  undefined1 local_234;
  char local_233 [259];
  undefined4 local_130;
  undefined **local_12c;
  undefined1 local_128;
  char local_127 [259];
  undefined4 local_24;
  int local_20;
  
  g_ScriptLastCompileScriptMissing = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (g_pScriptVM == (int *)0x0) {
    iVar5 = 0;
    goto LAB_00b46470;
  }
  iVar5 = (**(code **)(*g_pScriptVM + 0x10))(g_pScriptVM);
  pcVar7 = *(char **)(VScriptServerCompileScript(char_const*,bool)::pszClearExtensions + iVar5 * 4);
  iVar5 = (**(code **)(*g_pScriptVM + 0x10))(g_pScriptVM);
  pcVar1 = *(char **)(VScriptServerCompileScript(char_const*,bool)::pszEncryptedExtensions +
                     iVar5 * 4);
  pcVar6 = (char *)_V_strrchr(param_1,'.');
  if (pcVar6 == (char *)0x0) {
    cVar4 = V_IsAbsolutePath(param_1);
    local_234 = 1;
    local_238 = &PTR_InitQuietTruncation_00c08ee8;
    local_233[0] = '\0';
    local_130 = 0;
    local_12c = &PTR_InitQuietTruncation_00c08ee8;
    local_128 = 1;
    local_127[0] = '\0';
    local_24 = 0;
    if (cVar4 == '\0') {
      CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_238,"scripts/vscripts/%s%s",param_1,pcVar7);
      CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_12c,"scripts/vscripts/%s%s",param_1,pcVar1);
      bVar3 = false;
    }
    else {
LAB_00b462d0:
      local_24 = 0;
      local_127[0] = '\0';
      local_128 = 1;
      local_12c = &PTR_InitQuietTruncation_00c08ee8;
      local_130 = 0;
      local_233[0] = '\0';
      local_234 = 1;
      local_238 = &PTR_InitQuietTruncation_00c08ee8;
      CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_238,"%s",param_1);
      CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_12c,"%s",param_1);
      bVar3 = true;
    }
  }
  else {
    iVar5 = _V_strcmp(pcVar6,pcVar7);
    if ((iVar5 != 0) && (iVar5 = _V_strcmp(pcVar6,pcVar1), iVar5 != 0)) {
      iVar5 = 0;
      Msg("Script file type does not match VM type\n");
      goto LAB_00b46470;
    }
    cVar4 = V_IsAbsolutePath(param_1);
    local_234 = 1;
    local_238 = &PTR_InitQuietTruncation_00c08ee8;
    local_233[0] = '\0';
    local_130 = 0;
    local_12c = &PTR_InitQuietTruncation_00c08ee8;
    local_128 = 1;
    local_127[0] = '\0';
    local_24 = 0;
    if (cVar4 != '\0') goto LAB_00b462d0;
    CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_238,"scripts/vscripts/%s",param_1);
    CFmtStrN<256>::sprintf((CFmtStrN<256> *)&local_12c,"scripts/vscripts/%s",param_1);
    bVar3 = false;
  }
  CUtlBuffer::CUtlBuffer((CUtlBuffer *)local_374,0,0,0);
                    /* try { // try from 00b4629b to 00b4629d has its CatchHandler @ 00b4653a */
  cVar4 = (**(code **)(filesystem[1] + 0x38))
                    (filesystem + 1,local_233,"GAME",(CUtlBuffer *)local_374,0,0,0);
  if (cVar4 == '\0') {
                    /* try { // try from 00b4634c to 00b46438 has its CatchHandler @ 00b4653a */
    cVar4 = (**(code **)(filesystem[1] + 0x38))
                      (filesystem + 1,local_127,"GAME",(CUtlBuffer *)local_374,0,0,0);
    if (cVar4 == '\0') {
      if (param_2) {
        DevMsg("Script not found (%s) \n",param_1);
      }
    }
    else {
      local_380 = local_374[0];
      if (local_364 != 0) {
        UTIL_DecodeICE(local_374[0],local_364,(uchar *)"SDhfi878");
        bVar2 = true;
        goto LAB_00b46392;
      }
    }
LAB_00b4649d:
    g_ScriptLastCompileScriptMissing = 1;
    iVar5 = 0;
  }
  else {
    local_380 = local_374[0];
    if (local_364 == 0) goto LAB_00b4649d;
    bVar2 = false;
LAB_00b46392:
    if ((local_380 == (uchar *)0x0) || (*local_380 == '\0')) {
LAB_00b46440:
      iVar5 = 0;
    }
    else {
      if (!bVar3) {
        pcVar7 = local_127;
        if (!bVar2) {
          pcVar7 = local_233;
        }
                    /* try { // try from 00b46506 to 00b4652f has its CatchHandler @ 00b4653a */
        (**(code **)(*filesystem + 0x30))(filesystem,pcVar7,"GAME",local_33c,0x104,0,0);
      }
      local_384 = local_33c;
      pcVar7 = local_127;
      if (!bVar2) {
        pcVar7 = local_233;
      }
      V_strncpy(local_384,pcVar7,0x104);
      V_FixSlashes(local_384,'/');
      iVar5 = (**(code **)(*g_pScriptVM + 0x2c))(g_pScriptVM,local_380,local_384);
      if (iVar5 == 0) {
        DevMsg("FAILED to compile and execute script file named %s\n",param_1);
        goto LAB_00b46440;
      }
    }
  }
  CUtlMemory<unsigned_char,int>::Purge((CUtlMemory<unsigned_char,int> *)local_374);
LAB_00b46470:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  return iVar5;
}

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)