CMaster::InitConnection
0x00201f60 · 684 bytes · __thiscall
_ZN7CMaster14InitConnectionEv
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CMaster::InitConnection() */
void __thiscall CMaster::InitConnection(CMaster *this)
{
char cVar1;
int *piVar2;
int iVar3;
code *pcVar4;
code *pcVar5;
undefined4 uVar6;
uint uVar7;
int in_GS_OFFSET;
netadr_s *pnVar8;
int local_64;
uint local_50;
netadr_s local_4c [12];
char local_40 [32];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if ((InitConnection()::bInitialized != '\0') ||
(((*(int *)(sv_master_legacy_mode._28_4_ + 0x30) == 0 &&
(cVar1 = IsUsingMasterLegacyMode(), cVar1 == '\0')) || (this[0x18] != (CMaster)0x0))))
goto LAB_00201f92;
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-nomaster");
if (iVar3 != 0) {
ConMsg("Master server communication disabled.\n");
this[0x18] = (CMaster)0x1;
InitConnection()::bInitialized = '\x01';
goto LAB_00201f92;
}
iVar3 = *(int *)(this + 0x24);
if (iVar3 == 0) {
iVar3 = Sys_LoadModule("bin/libsteamvalidateuseridtickets.so",0);
*(int *)(this + 0x24) = iVar3;
if (iVar3 != 0) goto LAB_00201fe0;
}
else {
LAB_00201fe0:
pcVar4 = (code *)dlsym(iVar3,"SteamFindServersNumServers");
pcVar5 = (code *)dlsym(*(undefined4 *)(this + 0x24),"SteamFindServersIterateServer");
if (((*(int *)(this + 0x24) != 0) && (pcVar4 != (code *)0x0)) && (pcVar5 != (code *)0x0)) {
local_50 = 0;
iVar3 = (**(code **)(_g_pVCR + 0xc))();
if (iVar3 != 2) {
local_50 = (*pcVar4)(4);
}
pnVar8 = (netadr_s *)&local_50;
(**(code **)(_g_pVCR + 0x74))(&DAT_002b462c,pnVar8,4);
if (1 < local_50 + 2) {
InitConnection()::bInitialized = 1;
uVar7 = 2;
if (local_50 < 3) {
uVar7 = local_50;
}
local_50 = uVar7;
if (uVar7 == 0) {
local_64 = 0;
}
else {
local_64 = 0;
uVar7 = 0;
do {
netadr_s::SetIP(local_4c,0);
netadr_s::SetPort(local_4c,0);
netadr_s::SetType(local_4c,3);
iVar3 = (**(code **)(_g_pVCR + 0xc))();
if (iVar3 != 2) {
(*pcVar5)(4,uVar7,local_40,0x20);
}
(**(code **)(_g_pVCR + 0x74))(&DAT_002b462c,local_40,0x20);
pnVar8 = local_4c;
cVar1 = NET_StringToAdr(local_40,local_4c);
if (cVar1 != '\0') {
uVar6 = netadr_s::ToString(local_4c,false);
ConMsg("Adding master server %s\n",uVar6);
pnVar8 = local_4c;
(**(code **)(*(int *)this + 0x10))(this,local_4c);
local_64 = local_64 + 1;
}
uVar7 = uVar7 + 1;
} while (uVar7 < local_50);
}
cVar1 = NET_IsDedicated();
if ((cVar1 != '\0') && (*(int *)(sv_region._28_4_ + 0x30) == -1)) {
pnVar8 = (netadr_s *)0xff;
ConVar::SetValue(0x350d00);
}
InitConnection()::bInitialized = '\x01';
if (local_64 == 0) {
ConMsg("No masters loaded\nUsing default master\n",pnVar8);
(**(code **)(*(int *)this + 0x18))(this);
}
}
goto LAB_00201f92;
}
}
ConMsg("Unable to load Steam library.\n");
this[0x18] = (CMaster)0x1;
InitConnection()::bInitialized = '\x01';
LAB_00201f92:
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return;
}
SourceMod gamedata
paste intoaddons/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.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.