CServerGameDLL::ApplyGameSettings
0x006cabc0 · 1407 bytes · __thiscall
_ZN14CServerGameDLL17ApplyGameSettingsEP9KeyValues
Decompiled
undefined (2 params)
/* CServerGameDLL::ApplyGameSettings(KeyValues*) */
void __thiscall CServerGameDLL::ApplyGameSettings(CServerGameDLL *this,KeyValues *param_1)
{
code *pcVar1;
bool bVar2;
char cVar3;
char *pcVar4;
int iVar5;
KeyValues *pKVar6;
KeyValues *pKVar7;
undefined4 uVar8;
undefined4 uVar9;
CFmtStrN<256> *pCVar10;
char *pcVar11;
int in_GS_OFFSET;
char *local_13c;
char *local_138;
char *local_134;
char *local_130;
CFmtStrN<256> local_12c [5];
undefined1 local_127 [263];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (param_1 == (KeyValues *)0x0) goto LAB_006cac29;
pcVar4 = (char *)KeyValues::GetName(param_1);
iVar5 = _V_stricmp(pcVar4,"::ExecGameTypeCfg");
if (iVar5 == 0) {
if (((((engine == (int *)0x0) ||
(pcVar4 = (char *)KeyValues::GetString(param_1,"map/mapname",""), pcVar4 == (char *)0x0))
|| (*pcVar4 == '\0')) ||
((pKVar6 = (KeyValues *)(**(code **)(*engine + 0x10))(engine), pKVar6 == (KeyValues *)0x0 ||
(iVar5 = FindLaunchOptionByValue(pKVar6,"changelevel"), iVar5 != 0)))) ||
(iVar5 = FindLaunchOptionByValue(pKVar6,"changelevel2"), iVar5 != 0)) goto LAB_006cac29;
iVar5 = FindLaunchOptionByValue(pKVar6,"map_background");
if (iVar5 != 0) {
ConVar::SetValue(mp_gamemode);
ConVar::SetValue(ZombieDifficulty);
ConVar::SetValue(0xffcce0);
goto LAB_006cac29;
}
iVar5 = FindLaunchOptionByValue(pKVar6,"reserved");
if (iVar5 != 0) {
cVar3 = CTerrorGameRules::HasPlayerControlledZombies();
KeyValues::SetInt(param_1,"Members/numSlots",(-(uint)(cVar3 == '\0') & 0xfffffffc) + 8);
goto LAB_006cac29;
}
pKVar7 = (KeyValues *)(**(code **)(*g_pMatchExtL4D + 0x10))(g_pMatchExtL4D,0);
for (pKVar7 = (KeyValues *)KeyValues::GetFirstTrueSubKey(pKVar7); pKVar7 != (KeyValues *)0x0;
pKVar7 = (KeyValues *)KeyValues::GetNextTrueSubKey(pKVar7)) {
pcVar4 = (char *)KeyValues::GetName(pKVar7);
iVar5 = FindLaunchOptionByValue(pKVar6,pcVar4);
if (iVar5 != 0) goto LAB_006caff7;
}
pcVar4 = "FCVAR_NEVER_AS_STRING";
if ((mp_gamemode[0x15] & 0x10) == 0) {
pcVar4 = "";
if (*(char **)(mp_gamemode._28_4_ + 0x24) != (char *)0x0) {
pcVar4 = *(char **)(mp_gamemode._28_4_ + 0x24);
}
}
pKVar7 = (KeyValues *)(**(code **)(*g_pMatchExtL4D + 0x10))(g_pMatchExtL4D,pcVar4);
if (pKVar7 != (KeyValues *)0x0) {
LAB_006caff7:
pcVar4 = (char *)KeyValues::GetName(pKVar7);
KeyValues::SetString(param_1,"Game/mode",pcVar4);
iVar5 = KeyValues::GetInt(pKVar7,"maxplayers",4);
KeyValues::SetInt(param_1,"Members/numSlots",iVar5);
}
uVar8 = KeyValues::GetInt(param_1,"Members/numSlots",0);
uVar9 = KeyValues::GetString(param_1,"Game/mode","(unknown)");
DevMsg(" Adjusting game mode %s, %d slots.\n",uVar9,uVar8);
pCVar10 = (CFmtStrN<256> *)&local_13c;
local_13c = "easy";
local_138 = "normal";
local_134 = "hard";
local_130 = "impossible";
do {
pcVar4 = *(char **)pCVar10;
iVar5 = FindLaunchOptionByValue(pKVar6,pcVar4);
if (iVar5 != 0) {
KeyValues::SetString(param_1,"Game/difficulty",pcVar4);
DevMsg(" Adjusting difficulty %s.\n",pcVar4);
break;
}
pCVar10 = pCVar10 + 4;
} while (pCVar10 != local_12c);
bVar2 = true;
KeyValues::SetName(param_1,"left4dead2");
}
else {
bVar2 = false;
}
pcVar4 = (char *)KeyValues::GetName(param_1);
iVar5 = _V_stricmp(pcVar4,"left4dead2");
if (iVar5 == 0) {
local_13c = (char *)0x0;
pKVar6 = (KeyValues *)(**(code **)(*g_pMatchExtL4D + 8))(g_pMatchExtL4D,param_1,&local_13c);
pcVar4 = (char *)KeyValues::GetString(param_1,"Game/mode","");
if ((pcVar4 != (char *)0x0) && (*pcVar4 != '\0')) {
ConVar::SetValue(mp_gamemode);
}
DevMsg(" game mode = %s\n",pcVar4);
iVar5 = KeyValues::GetString(param_1,"Game/difficulty",(char *)0x0);
if (iVar5 != 0) {
DevMsg(" difficulty = %s\n",iVar5);
ConVar::SetValue(ZombieDifficulty);
}
iVar5 = KeyValues::GetInt(param_1,"Game/maxrounds",0);
if (iVar5 != 0) {
DevMsg(" roundlimit = %d\n",iVar5);
ConVar::SetValue(0xfa7260);
}
iVar5 = KeyValues::GetInt(param_1,"Members/numPlayers",-1);
if (iVar5 != -1) {
DevMsg(" num players = %d\n",iVar5);
ConVar::SetValue(0xffcce0);
}
if ((pKVar6 != (KeyValues *)0x0) && (!bVar2)) {
cVar3 = ConVar::IsFlagSet((ConVar *)sv_force_transmit_ents,2);
if ((cVar3 != '\0') && ((sv_cheats != (int *)0x0 && (*(int *)(sv_cheats[7] + 0x30) != 0)))) {
(**(code **)(*sv_cheats + 0x44))(sv_cheats,0);
}
pcVar11 = "map";
pcVar4 = (char *)KeyValues::GetString(param_1,"map/mapcommand","map");
iVar5 = V_stristr(pcVar4,"map_commentary");
if (iVar5 != 0) {
pcVar11 = "map_commentary";
}
uVar8 = KeyValues::GetString(pKVar6,"map","");
DevMsg(" starting: %s %s...\n",pcVar11,uVar8);
pcVar1 = *(code **)(*engine + 0x94);
CFmtStrN<256>::CFmtStrN(local_12c,"%s %s reserved\n",pcVar11,uVar8);
(*pcVar1)(engine,local_127);
}
}
LAB_006cac29:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
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.