CMatchTitleGameSettingsMgr::PrepareLobbyForGame
0x0003c2e0 · 3159 bytes · __thiscall
_ZN26CMatchTitleGameSettingsMgr19PrepareLobbyForGameEP9KeyValuesPS1_
Decompiled
undefined (3 params)
/* CMatchTitleGameSettingsMgr::PrepareLobbyForGame(KeyValues*, KeyValues**) */
void __thiscall
CMatchTitleGameSettingsMgr::PrepareLobbyForGame
(CMatchTitleGameSettingsMgr *this,KeyValues *param_1,KeyValues **param_2)
{
char cVar1;
uint uVar2;
KeyValues *pKVar3;
int iVar4;
int iVar5;
KeyValues *pKVar6;
int iVar7;
char *pcVar8;
char *pcVar9;
int iVar10;
KeyValues *pKVar11;
uint uVar12;
char cVar13;
int iVar14;
int iVar15;
uint uVar16;
int in_GS_OFFSET;
bool bVar17;
longlong lVar18;
longlong lVar19;
undefined4 uVar20;
int local_180;
int local_17c;
KeyValues **local_178;
int local_170;
KeyValues **local_168;
char *local_154 [5];
int local_140 [5];
CFmtStrN<256> local_12c [5];
char local_127 [263];
int local_20;
local_154[0] = "gambler";
local_154[1] = "producer";
local_154[2] = "coach";
local_20 = *(int *)(in_GS_OFFSET + 0x14);
local_154[3] = "mechanic";
local_154[4] = "infected";
local_140[0] = 1;
local_140[1] = 1;
local_140[2] = 1;
local_140[3] = 1;
local_140[4] = 4;
uVar2 = KeyValues::GetInt(param_1,"Members/numSlots",4);
uVar16 = 4;
if (3 < (int)uVar2) {
uVar16 = uVar2;
}
if (5 < uVar16) {
uVar16 = 5;
}
pKVar3 = (KeyValues *)KeyValues::FindKey(param_1,"Members",false);
if (pKVar3 != (KeyValues *)0x0) {
iVar4 = KeyValues::GetInt(pKVar3,"numMachines",0);
iVar5 = KeyValues::GetInt(pKVar3,"numPlayers",0);
if (iVar4 < 1) {
local_168 = param_2;
}
else {
local_170 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_170);
pKVar6 = (KeyValues *)KeyValues::FindKey(pKVar3,local_127,false);
if ((pKVar6 != (KeyValues *)0x0) &&
(iVar7 = KeyValues::GetInt(pKVar6,"numPlayers",0), 0 < iVar7)) {
iVar14 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"player%d/Game/avatar",iVar14);
pcVar8 = (char *)KeyValues::GetString(pKVar6,local_127,"");
if ((pcVar8 != (char *)0x0) && (*pcVar8 != '\0')) {
pcVar9 = "gambler";
iVar15 = 0;
while (iVar10 = _V_stricmp(pcVar9,pcVar8), iVar10 != 0) {
iVar15 = iVar15 + 1;
if ((int)uVar16 <= iVar15) goto LAB_0003c528;
pcVar9 = local_154[iVar15];
}
local_140[iVar15] = local_140[iVar15] + -1;
}
LAB_0003c528:
iVar14 = iVar14 + 1;
} while (iVar14 != iVar7);
}
local_170 = local_170 + 1;
} while (local_170 != iVar4);
local_17c = 0;
local_168 = param_2;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_17c);
pKVar6 = (KeyValues *)KeyValues::FindKey(pKVar3,local_127,false);
if ((pKVar6 != (KeyValues *)0x0) &&
(iVar7 = KeyValues::GetInt(pKVar6,"numPlayers",0), 1 < iVar7)) {
iVar14 = 0;
cVar13 = '\0';
do {
while( true ) {
CFmtStrN<256>::CFmtStrN(local_12c,"player%d/Game/avatar",iVar14);
pcVar8 = (char *)KeyValues::GetString(pKVar6,local_127,"");
if ((pcVar8 == (char *)0x0) || (*pcVar8 == '\0')) break;
iVar15 = _V_stricmp("infected",pcVar8);
iVar14 = iVar14 + 1;
cVar13 = (-(iVar15 == 0) & 3U) + 1;
if (iVar14 == iVar7) goto LAB_0003c66e;
}
iVar14 = iVar14 + 1;
} while (iVar14 != iVar7);
LAB_0003c66e:
iVar14 = 0;
do {
while( true ) {
CFmtStrN<256>::CFmtStrN(local_12c,"player%d",iVar14);
pKVar11 = (KeyValues *)KeyValues::FindKey(pKVar6,local_127,false);
if ((pKVar11 != (KeyValues *)0x0) &&
((pcVar8 = (char *)KeyValues::GetString(pKVar11,"Game/avatar",""),
pcVar8 == (char *)0x0 || (*pcVar8 == '\0')))) break;
joined_r0x0003cbda:
iVar14 = iVar14 + 1;
if (iVar14 == iVar7) goto LAB_0003c81c;
}
cVar1 = cVar13;
if (uVar16 == 5) {
bVar17 = 0 < local_140[4];
iVar10 = local_140[1] + local_140[0] + local_140[2] + local_140[3];
iVar15 = local_140[4];
if (cVar13 != '\x04') goto LAB_0003c720;
if (local_140[4] == 0) goto LAB_0003cb38;
}
else {
bVar17 = false;
iVar10 = local_140[1] + local_140[0] + local_140[2] + local_140[3];
iVar15 = 0;
if (cVar13 == '\x04') {
LAB_0003cb38:
cVar13 = '\x01';
}
else {
LAB_0003c720:
if (cVar13 != '\x01') goto LAB_0003c73d;
}
cVar1 = '\x04';
if (iVar10 != 0) {
cVar1 = cVar13;
}
}
LAB_0003c73d:
if ((!bVar17) || (iVar10 < 1)) {
LAB_0003ca80:
if (cVar1 != '\0') goto LAB_0003c770;
if (0 < iVar15) goto LAB_0003ca96;
LAB_0003cb50:
uVar12 = RandomInt(0,3);
uVar2 = uVar12;
do {
iVar15 = local_140[uVar2];
if (iVar15 != 0) goto LAB_0003cb85;
uVar2 = uVar2 + 1 & 3;
} while (uVar12 != uVar2);
iVar15 = local_140[uVar12];
if (iVar15 == 0) {
cVar1 = '\x01';
goto LAB_0003c78a;
}
LAB_0003cb85:
KeyValues::SetString(pKVar11,"Game/avatar",local_154[uVar2]);
*local_168 = pKVar11;
local_168 = local_168 + 1;
local_140[uVar2] = iVar15 + -1;
cVar13 = '\x01';
goto joined_r0x0003cbda;
}
if (iVar10 == iVar15) {
iVar15 = RandomInt(0,1);
goto LAB_0003ca80;
}
if (iVar10 <= iVar15) goto LAB_0003ca80;
if (cVar1 == '\0') goto LAB_0003cb50;
LAB_0003c770:
if (cVar1 != '\x04') {
if (cVar1 == '\x01') goto LAB_0003cb50;
LAB_0003c78a:
iVar10 = RandomInt(0,uVar16 - 1);
iVar15 = local_140[iVar10];
while (iVar15 < 1) {
iVar10 = (iVar10 + 1) % (int)uVar16;
iVar15 = local_140[iVar10];
}
KeyValues::SetString(pKVar11,"Game/avatar",local_154[iVar10]);
local_140[iVar10] = iVar15 + -1;
*local_168 = pKVar11;
local_168 = local_168 + 1;
cVar13 = cVar1;
goto joined_r0x0003cbda;
}
LAB_0003ca96:
if (local_140[4] < 1) {
cVar1 = '\x04';
goto LAB_0003c78a;
}
iVar14 = iVar14 + 1;
iVar15 = local_140[4] + -1;
KeyValues::SetString(pKVar11,"Game/avatar",local_154[4]);
cVar13 = '\x04';
*local_168 = pKVar11;
local_168 = local_168 + 1;
local_140[4] = iVar15;
} while (iVar14 != iVar7);
}
LAB_0003c81c:
local_17c = local_17c + 1;
} while (local_17c != iVar4);
local_170 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_170);
pKVar6 = (KeyValues *)KeyValues::FindKey(pKVar3,local_127,false);
if ((pKVar6 != (KeyValues *)0x0) &&
(iVar7 = KeyValues::GetInt(pKVar6,"numPlayers",0), 0 < iVar7)) {
iVar14 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"player%d",iVar14);
pKVar11 = (KeyValues *)KeyValues::FindKey(pKVar6,local_127,false);
if ((pKVar11 != (KeyValues *)0x0) &&
((pcVar8 = (char *)KeyValues::GetString(pKVar11,"Game/avatar",""),
pcVar8 == (char *)0x0 || (*pcVar8 == '\0')))) {
if (uVar16 == 5) {
iVar10 = local_140[1] + local_140[0] + local_140[2] + local_140[3];
iVar15 = local_140[4];
if ((local_140[4] < 1) || (iVar10 < 1)) {
LAB_0003cc25:
if (iVar15 < 1) goto LAB_0003c938;
}
else {
if (local_140[4] == iVar10) {
iVar15 = RandomInt(0,1);
goto LAB_0003cc25;
}
if (local_140[4] < iVar10) goto LAB_0003c938;
}
uVar2 = 4;
}
else {
LAB_0003c938:
uVar2 = RandomInt(0,3);
}
for (; iVar15 = local_140[uVar2], iVar15 < 1; uVar2 = uVar2 + 1 & 3) {
}
KeyValues::SetString(pKVar11,"Game/avatar",local_154[uVar2]);
local_140[uVar2] = iVar15 + -1;
*local_168 = pKVar11;
local_168 = local_168 + 1;
}
iVar14 = iVar14 + 1;
} while (iVar14 != iVar7);
}
local_170 = local_170 + 1;
} while (local_170 != iVar4);
}
if ((uVar16 == 5) && (1 < iVar5)) {
if (local_140[4] == 4) {
local_180 = 4;
}
else {
if (local_140[1] + local_140[0] + local_140[2] + local_140[3] != 4) goto LAB_0003c9e6;
local_180 = 1;
}
if (param_2 < local_168) {
local_178 = param_2;
do {
uVar20 = 0;
lVar18 = KeyValues::GetUint64((char *)*local_178,0xb4d28);
if (((param_1 != (KeyValues *)0x0) &&
(pKVar3 = (KeyValues *)KeyValues::FindKey(param_1,"Members",false),
pKVar3 != (KeyValues *)0x0)) &&
(iVar4 = KeyValues::GetInt(pKVar3,"numMachines",0), 0 < iVar4)) {
local_170 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"machine%d",local_170,uVar20);
pKVar6 = (KeyValues *)KeyValues::FindKey(pKVar3,local_127,false);
if ((pKVar6 != (KeyValues *)0x0) &&
(iVar5 = KeyValues::GetInt(pKVar6,"numPlayers",0), 0 < iVar5)) {
iVar7 = 0;
do {
CFmtStrN<256>::CFmtStrN(local_12c,"player%d",iVar7,uVar20);
pcVar8 = (char *)KeyValues::FindKey(pKVar6,local_127,false);
if (pcVar8 != (char *)0x0) {
uVar20 = 0;
lVar19 = KeyValues::GetUint64(pcVar8,0xb4d28);
if (lVar18 == lVar19) goto LAB_0003ce30;
}
iVar7 = iVar7 + 1;
} while (iVar7 != iVar5);
}
local_170 = local_170 + 1;
} while (local_170 != iVar4);
}
pKVar6 = (KeyValues *)0x0;
LAB_0003ce30:
pKVar3 = (KeyValues *)0x0;
iVar4 = KeyValues::GetInt(pKVar6,"numPlayers",0);
bVar17 = true;
if (iVar4 == 1) {
pKVar3 = *local_178;
bVar17 = pKVar3 == (KeyValues *)0x0;
}
local_178 = local_178 + 1;
if (!bVar17) goto LAB_0003ce8c;
} while (local_178 < local_168);
}
else {
pKVar3 = (KeyValues *)0x0;
}
if (param_2 < local_168) {
pKVar3 = local_168[-1];
}
LAB_0003ce8c:
if (pKVar3 != (KeyValues *)0x0) {
if (local_180 == 4) {
KeyValues::SetString(pKVar3,"Game/avatar",local_154[4]);
}
else if (local_180 == 1) {
uVar2 = RandomInt(0,3);
uVar16 = uVar2;
do {
if (local_140[uVar16] != 0) goto LAB_0003cee5;
uVar16 = uVar16 + 1 & 3;
} while (uVar2 != uVar16);
if (local_140[uVar16] != 0) {
LAB_0003cee5:
KeyValues::SetString(pKVar3,"Game/avatar",local_154[uVar16]);
}
}
}
}
}
LAB_0003c9e6:
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.