L L4D2node

CMaster::SetMaster_Legacy_f

0x00201a50 · 807 bytes · __thiscall

_ZN7CMaster18SetMaster_Legacy_fERK8CCommand

Decompiled

undefined (2 params)

/* CMaster::SetMaster_Legacy_f(CCommand const&) */

void __thiscall CMaster::SetMaster_Legacy_f(CMaster *this,CCommand *param_1)

{
  char cVar1;
  short sVar2;
  char *pcVar3;
  int iVar4;
  netadr_s *this_00;
  undefined4 uVar5;
  int iVar6;
  int in_GS_OFFSET;
  bool bVar7;
  char *local_b4;
  netadr_s local_ac [12];
  char local_a0 [128];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  netadr_s::SetIP(local_ac,0);
  netadr_s::SetPort(local_ac,0);
  netadr_s::SetType(local_ac,3);
  iVar4 = *(int *)param_1;
  (**(code **)(*(int *)this + 8))(this);
  if (iVar4 < 2) {
    ConMsg("Usage:\nsetmaster <add | remove | enable | disable> <IP:port>\n");
    if (*(int *)(this + 0x10) == 0) {
      ConMsg("Current:  None\n");
    }
    else {
      ConMsg("Current:\n");
      if (0 < *(int *)(this + 0x10)) {
        iVar6 = 0;
        iVar4 = 0;
        do {
          iVar4 = iVar4 + 1;
          this_00 = (netadr_s *)(*(int *)(this + 4) + iVar6);
          iVar6 = iVar6 + 0x24;
          uVar5 = netadr_s::ToString(this_00,false);
          ConMsg("  %i:  %s\n",iVar4,uVar5);
        } while (iVar4 < *(int *)(this + 0x10));
      }
    }
  }
  else {
    if (*(int *)param_1 < 2) {
      local_b4 = "";
      bVar7 = true;
    }
    else {
      local_b4 = *(char **)(param_1 + 0x40c);
      if (local_b4 == (char *)0x0) goto LAB_00201ae0;
      bVar7 = *local_b4 == '\0';
    }
    if (!bVar7) {
      local_a0[0] = '\0';
      netadr_s::Clear(local_ac);
      if (iVar4 != 2) {
        iVar6 = 2;
        do {
          pcVar3 = "";
          if (iVar6 < *(int *)param_1) {
            pcVar3 = *(char **)(param_1 + iVar6 * 4 + 0x408);
          }
          iVar6 = iVar6 + 1;
          V_strncat(local_a0,pcVar3,0x80,-1);
        } while (iVar6 != iVar4);
      }
      iVar4 = _V_strlen(local_a0);
      if (0 < iVar4) {
        cVar1 = NET_StringToAdr(local_a0,local_ac);
        if (cVar1 == '\0') {
          ConMsg(" Invalid address \"%s\", setmaster command ignored\n",local_a0);
          goto LAB_00201ae0;
        }
        sVar2 = netadr_s::GetPort(local_ac);
        if (sVar2 == 0) {
          netadr_s::SetPort(local_ac,0x6983);
        }
      }
      iVar4 = _V_stricmp(local_b4,"disable");
      if (iVar4 == 0) {
        this[0x18] = (CMaster)0x1;
      }
      else {
        iVar4 = _V_stricmp(local_b4,"enable");
        if (iVar4 != 0) {
          iVar4 = _V_stricmp(local_b4,"add");
          if (iVar4 != 0) {
            iVar4 = _V_stricmp(local_b4,"remove");
            if (iVar4 == 0) {
              cVar1 = (**(code **)(*(int *)this + 0x14))(this,local_ac);
              if (cVar1 == '\0') {
                uVar5 = netadr_s::ToString(local_ac,false);
                ConMsg("Can\'t remove master %s, not in list\n",uVar5);
              }
            }
            else {
              ConMsg("Invalid setmaster command\n");
            }
            goto LAB_00201ae0;
          }
          cVar1 = (**(code **)(*(int *)this + 0x10))(this,local_ac);
          if (cVar1 == '\0') {
            uVar5 = netadr_s::ToString(local_ac,false);
            ConMsg("Master at %s already in list\n",uVar5);
          }
          else {
            uVar5 = netadr_s::ToString(local_ac,false);
            ConMsg("Adding master at %s\n",uVar5);
          }
        }
        this[0x18] = (CMaster)0x0;
      }
    }
  }
LAB_00201ae0:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)