L L4D2node

Cmd_ExecuteCommand

0x001177f0 · 1256 bytes · __cdecl

_Z18Cmd_ExecuteCommand16ECommandTarget_tRK8CCommand12cmd_source_ti

Decompiled

undefined (4 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* Cmd_ExecuteCommand(ECommandTarget_t, CCommand const&, cmd_source_t, int) */

int * Cmd_ExecuteCommand(int param_1,CCommand *param_2,int param_3,undefined4 param_4)

{
  undefined4 *puVar1;
  char cVar2;
  char cVar3;
  byte bVar4;
  char *pcVar5;
  int iVar6;
  long lVar7;
  int *piVar8;
  undefined4 uVar9;
  undefined1 *puVar10;
  int local_14 [2];
  
  if (*(int *)param_2 == 0) {
    return (int *)0x0;
  }
  pcVar5 = "";
  if (0 < *(int *)param_2) {
    pcVar5 = *(char **)(param_2 + 0x408);
  }
  iVar6 = _V_strcmp(pcVar5,"[$&*,`]");
  puVar1 = cmd_alias;
  if (iVar6 == 0) {
    if (*(int *)param_2 != 3) {
      Warning("WARNING: INVALID EXECUTION MARKER.\n");
      return (int *)0x0;
    }
    cVar3 = **(char **)(param_2 + 0x40c);
    lVar7 = strtol(*(char **)(param_2 + 0x410),(char **)0x0,10);
    cVar2 = FindAndRemoveExecutionMarker(lVar7);
    if (cVar2 == '\0') {
      HandleExecutionMarker(char_const*,char_const*)::cnt =
           HandleExecutionMarker(char_const*,char_const*)::cnt + 1;
      if (HandleExecutionMarker(char_const*,char_const*)::cnt < 3) {
        Warning("Invalid execution marker code.\n");
        return (int *)0x0;
      }
      return (int *)0x0;
    }
    if (cVar3 == 'a') {
      g_iFilterCommandsByServerCanExecute = g_iFilterCommandsByServerCanExecute + 1;
      return (int *)0x0;
    }
    if (cVar3 != 'b') {
      if (cVar3 == 'c') {
        g_iFilterCommandsByClientCmdCanExecute = g_iFilterCommandsByClientCmdCanExecute + 1;
        return (int *)0x0;
      }
      if (cVar3 == 'd') {
        g_iFilterCommandsByClientCmdCanExecute = g_iFilterCommandsByClientCmdCanExecute + -1;
        return (int *)0x0;
      }
      return (int *)0x0;
    }
    g_iFilterCommandsByServerCanExecute = g_iFilterCommandsByServerCanExecute + -1;
    return (int *)0x0;
  }
  for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)*puVar1) {
    pcVar5 = "";
    if (0 < *(int *)param_2) {
      pcVar5 = *(char **)(param_2 + 0x408);
    }
    iVar6 = V_strcasecmp(pcVar5,(char *)(puVar1 + 1));
    if (iVar6 == 0) {
      Cbuf_InsertText(0,puVar1[9],0);
      return (int *)0x0;
    }
  }
  cmd_source = param_3;
  cmd_clientslot = param_4;
  puVar10 = &DAT_002c79d4;
  if (0 < *(int *)param_2) {
    puVar10 = *(undefined1 **)(param_2 + 0x408);
  }
  piVar8 = (int *)(**(code **)(*g_pCVar + 0x28))(g_pCVar,puVar10);
  cVar3 = Host_IsSinglePlayerGame();
  if (cVar3 == '\0') {
    if (g_iFilterCommandsByServerCanExecute < 1) goto LAB_00117964;
    if (piVar8 == (int *)0x0) goto LAB_00117b50;
    cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,0x10000000);
    if (cVar3 == '\0') {
      uVar9 = (**(code **)(*piVar8 + 0x1c))(piVar8);
      Warning("FCVAR_SERVER_CAN_EXECUTE prevented server running command: %s\n",uVar9);
      return (int *)0x0;
    }
  }
  else {
    if (DAT_003b7f64 < 2) {
      return (int *)0x0;
    }
LAB_00117964:
    if (piVar8 == (int *)0x0) goto LAB_00117b50;
  }
  cVar3 = (**(code **)(*piVar8 + 8))(piVar8);
  if (cVar3 == '\0') {
LAB_00117b50:
    cVar3 = CCvarUtilities::IsCommand((CCvarUtilities *)cv,param_2,param_1);
    if (cVar3 != '\0') {
      return piVar8;
    }
    puVar10 = &DAT_002c79d4;
    if (0 < *(int *)param_2) {
      puVar10 = *(undefined1 **)(param_2 + 0x408);
    }
    Msg("Unknown command \"%s\"\n",puVar10);
    return (int *)0x0;
  }
  if (((0 < g_iFilterCommandsByClientCmdCanExecute) &&
      (cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,0x40000000), cVar3 == '\0')) &&
     ((iVar6 = (**(code **)(*piVar8 + 0x1c))(piVar8), iVar6 == 0 ||
      (local_14[0] = iVar6,
      iVar6 = CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
              ::Find((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                      *)g_ExtraClientCmdCanExecuteCvars,(Node_t *)local_14), iVar6 == -1)))) {
    cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,4);
    if (cVar3 == '\0') {
      uVar9 = (**(code **)(*piVar8 + 0x1c))(piVar8);
      Warning("FCVAR_CLIENTCMD_CAN_EXECUTE prevented running command: %s\n",uVar9);
    }
    goto LAB_00117b50;
  }
  cVar3 = (**(code **)(*piVar8 + 8))(piVar8);
  if (cVar3 == '\0') goto LAB_00117b50;
  cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,4);
  bVar4 = 0;
  if ((cVar3 != '\0') && (bVar4 = 0, cmd_source == 1)) {
    bVar4 = DAT_003b8088 ^ 1;
  }
  if (serverGameClients != 0) {
    if (DAT_003b7f64 < 2) {
      if (bVar4 != 0) {
        return (int *)0x0;
      }
    }
    else {
      uVar9 = 0xffffffff;
      if (cmd_source == 0) {
        uVar9 = param_4;
      }
      (**(code **)(*(int *)g_pServerPluginHandler + 0x28))(g_pServerPluginHandler,uVar9);
    }
  }
  cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,0x4000);
  if ((cVar3 == '\0') || (cVar3 = Host_IsSinglePlayerGame(), cVar3 != '\0')) goto LAB_00117a2d;
  cVar3 = ConVar::IsFlagSet((ConVar *)sv_hosting_lobby,2);
  if (cVar3 == '\0') {
    puVar10 = sv_cheats;
LAB_00117c4c:
    if (*(int *)(*(int *)(puVar10 + 0x1c) + 0x30) != 0) goto LAB_00117a2d;
  }
  else {
    if ((g_pMatchFramework == (int *)0x0) ||
       (iVar6 = (**(code **)(*g_pMatchFramework + 0x24))(g_pMatchFramework), iVar6 == 0)) {
      puVar10 = sv_cheats;
    }
    else {
      puVar10 = (undefined1 *)0x0;
    }
    if (((DAT_003b80d0 == 0 && _DAT_003b80cc == 0) &&
        (*(int *)(sv_hosting_lobby._28_4_ + 0x30) == 0)) && (puVar10 != (undefined1 *)0x0))
    goto LAB_00117c4c;
  }
  if ((g_bRPTActive == '\0') &&
     ((g_iFilterCommandsByServerCanExecute == 0 ||
      (cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,0x10000000), cVar3 == '\0')))) {
    uVar9 = (**(code **)(*piVar8 + 0x1c))(piVar8);
    Msg("Can\'t use cheat command %s in multiplayer, unless the server has sv_cheats set to 1.\n",
        uVar9);
    return (int *)0x0;
  }
LAB_00117a2d:
  cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,0x40);
  if ((cVar3 != '\0') && (cVar3 = Host_IsSinglePlayerGame(), cVar3 == '\0')) {
    uVar9 = (**(code **)(*piVar8 + 0x1c))(piVar8);
    Msg("Can\'t use command %s in multiplayer.\n",uVar9);
    return (int *)0x0;
  }
  cVar3 = (**(code **)(*piVar8 + 0xc))(piVar8,2);
  if (cVar3 == '\0') {
    (**(code **)(*piVar8 + 0x3c))(piVar8,param_2);
    return piVar8;
  }
  uVar9 = (**(code **)(*piVar8 + 0x1c))(piVar8);
  Msg("Unknown command \"%s\"\n",uVar9);
  return (int *)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)