L L4D2node

UpdateChapterRestrictions

0x006c9880 · 604 bytes · __regparm3

_ZL25UpdateChapterRestrictionsPKc

Decompiled

undefined (1 param)

/* UpdateChapterRestrictions(char const*) */

void __regparm3 UpdateChapterRestrictions(char *param_1)

{
  uint *puVar1;
  char cVar2;
  size_t sVar3;
  int iVar4;
  uint *puVar5;
  long lVar6;
  uint uVar7;
  uint uVar8;
  int iVar9;
  char *pcVar10;
  int in_GS_OFFSET;
  undefined1 *__haystack;
  uint *puVar11;
  char local_1c4 [32];
  char local_1a4 [64];
  uint local_164 [16];
  char local_124 [260];
  int local_20;
  
  iVar9 = 0;
  local_1a4[0] = '\0';
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  do {
    puVar11 = (uint *)(&gTitleComments)[iVar9 * 2];
    sVar3 = strlen((char *)puVar11);
    __haystack = param_1;
    iVar4 = V_strnicmp(param_1,(char *)puVar11,sVar3);
    if (iVar4 == 0) {
      puVar11 = (uint *)(&PTR_s__HL2_Chapter1_Title_00c91ce4)[iVar9 * 2];
      __haystack = local_1a4;
      V_strncpy(__haystack,(char *)puVar11,0x40);
      iVar9 = 0;
      goto LAB_006c990d;
    }
    iVar9 = iVar9 + 1;
  } while (iVar9 != 0x39);
  goto LAB_006c9930;
  while (local_1a4[iVar9] = '\0', iVar9 < 0x40) {
LAB_006c990d:
    cVar2 = local_1a4[iVar9];
    if (cVar2 == '\0') break;
    if ((cVar2 != '\r') && (cVar2 != '\n')) {
      iVar9 = iVar9 + 1;
      if (0x3f < iVar9) break;
      goto LAB_006c990d;
    }
  }
LAB_006c9930:
  puVar5 = g_nCurrentChapterIndex;
  if (local_1a4[0] != '\0') {
    pcVar10 = local_1a4;
    cVar2 = local_1a4[0];
    do {
      iVar9 = tolower((int)cVar2);
      *pcVar10 = (char)iVar9;
      pcVar10 = pcVar10 + 1;
      if (pcVar10 == (char *)0x0) break;
      cVar2 = *pcVar10;
    } while (cVar2 != '\0');
    puVar11 = (uint *)0x104;
    __haystack = local_124;
    cVar2 = UTIL_GetModDir(local_124,0x104);
    puVar5 = g_nCurrentChapterIndex;
    if (cVar2 != '\0') {
      V_snprintf((char *)local_164,0x40,"#%s_chapter",local_124);
      __haystack = local_1a4;
      puVar11 = local_164;
      pcVar10 = strstr(__haystack,(char *)local_164);
      puVar1 = local_164;
      puVar5 = g_nCurrentChapterIndex;
      if (pcVar10 != (char *)0x0) {
        do {
          puVar11 = puVar1;
          uVar7 = *puVar11 + 0xfefefeff & ~*puVar11;
          uVar8 = uVar7 & 0x80808080;
          puVar1 = puVar11 + 1;
        } while (uVar8 == 0);
        puVar5 = puVar11 + 1;
        if ((uVar7 & 0x8080) == 0) {
          puVar5 = (uint *)((int)puVar11 + 6);
          uVar8 = uVar8 >> 0x10;
        }
        V_strncpy(local_1c4,
                  pcVar10 + (int)((int)puVar5 +
                                 ((-3 - (uint)CARRY1((byte)uVar8,(byte)uVar8)) - (int)local_164)),
                  0x20);
        pcVar10 = strstr(local_1c4,"_title");
        if (pcVar10 != (char *)0x0) {
          *pcVar10 = '\0';
        }
        puVar5 = (uint *)strtol(local_1c4,(char **)0x0,10);
        iVar9 = _V_stricmp(local_124,"hl2");
        if (iVar9 == 0) {
          iVar9 = _V_stricmp(local_1c4,"9a");
          if (iVar9 == 0) {
            puVar5 = (uint *)0xa;
          }
          else {
            puVar5 = (uint *)((int)puVar5 + (uint)(9 < (int)puVar5));
          }
        }
        __haystack = "FCVAR_NEVER_AS_STRING";
        if ((sv_unlockedchapters[0x15] & 0x10) == 0) {
          __haystack = "";
          if (*(char **)(sv_unlockedchapters._28_4_ + 0x24) != (char *)0x0) {
            __haystack = *(char **)(sv_unlockedchapters._28_4_ + 0x24);
          }
        }
        puVar11 = (uint *)0x0;
        lVar6 = strtol(__haystack,(char **)0x0,10);
        if (lVar6 < (int)puVar5) {
          __haystack = sv_unlockedchapters;
          puVar11 = puVar5;
          ConVar::SetValue(0xfe2c80);
        }
      }
    }
  }
  g_nCurrentChapterIndex = puVar5;
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail(__haystack,puVar11);
}

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)