CGameEventManager::SerializeEvent
0x001627d0 · 1500 bytes · __thiscall
_ZN17CGameEventManager14SerializeEventEP10IGameEventP8bf_write
Decompiled
undefined (3 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CGameEventManager::SerializeEvent(IGameEvent*, bf_write*) */
byte __thiscall
CGameEventManager::SerializeEvent(CGameEventManager *this,IGameEvent *param_1,bf_write *param_2)
{
int *piVar1;
byte *pbVar2;
uint uVar3;
bf_write bVar4;
char *pcVar5;
CGameEventManager *pCVar6;
uint uVar7;
uint *puVar8;
KeyValues *this_00;
undefined4 uVar9;
int iVar10;
int *piVar11;
long lVar12;
char *pcVar13;
int iVar14;
uint uVar15;
uint *puVar16;
pCVar6 = this + 0x9c;
if (_SetSeed != 0) {
if (CTelemetryLock::CTelemetryLock(void*,char_const*)::s_bNameSet == '\0') {
(**(code **)(_SetSeed + 0x5c))
(_SetSeed,pCVar6,&CTelemetryLock::CTelemetryLock(void*,char_const*)::tm_fmt);
CTelemetryLock::CTelemetryLock(void*,char_const*)::s_bNameSet = '\x01';
if (_SetSeed == 0) goto LAB_00162887;
}
(**(code **)(_SetSeed + 0x60))
(_SetSeed,0,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3eb,pCVar6,
&CTelemetryLock::CTelemetryLock(void*,char_const*)::tm_fmt,&DAT_002c48a3,
"CGameEventManager");
}
LAB_00162887:
/* try { // try from 00162887 to 0016288b has its CatchHandler @ 00162de4 */
uVar7 = ThreadGetCurrentId();
if (uVar7 != *(uint *)(this + 0x9c)) {
LOCK();
uVar3 = *(uint *)pCVar6;
if (uVar3 == 0) {
*(uint *)pCVar6 = uVar7;
}
UNLOCK();
if (uVar3 != 0) {
/* try { // try from 00162d6b to 00162d6f has its CatchHandler @ 00162de4 */
CThreadFastMutex::Lock((uint)pCVar6,uVar7);
goto LAB_001628bf;
}
}
*(int *)(this + 0xa0) = *(int *)(this + 0xa0) + 1;
LAB_001628bf:
/* try { // try from 00162906 to 00162ae7 has its CatchHandler @ 00162df9 */
if ((_SetSeed != 0) &&
((**(code **)(_SetSeed + 100))
(_SetSeed,0,0,"/data/src/public/tier0/vprof_telemetry.h",0x3f3,
&CTelemetryLock::Locked()::tm_fmt,pCVar6,0), _SetSeed != 0)) {
(**(code **)(_SetSeed + 0x6c))
(_SetSeed,pCVar6,2,"/data/src/public/tier0/vprof_telemetry.h",0x3f4,
&CTelemetryLock::Locked()::tm_fmt,"%s Locked","CGameEventManager");
}
puVar8 = (uint *)GetEventDescriptor(this,param_1);
uVar7 = *puVar8;
uVar3 = *(uint *)(param_2 + 0xc);
if (*(int *)(param_2 + 8) < (int)(uVar3 + 9)) {
*(int *)(param_2 + 0xc) = *(int *)(param_2 + 8);
param_2[0x10] = (bf_write)0x1;
}
else {
iVar10 = ((int)uVar3 >> 5) * 4;
uVar15 = uVar3 & 0x1f;
puVar16 = (uint *)(*(int *)param_2 + iVar10);
iVar14 = 0x20 - uVar15;
*puVar16 = *puVar16 & *(uint *)(&DAT_003f2dc4 + uVar15 * 0x84) | uVar7 << (sbyte)uVar15;
if (iVar14 < 9) {
puVar16 = (uint *)(*(int *)param_2 + 4 + iVar10);
*puVar16 = (&g_BitWriteMasks)[9 - iVar14] & *puVar16 | uVar7 >> ((byte)iVar14 & 0x1f);
}
*(int *)(param_2 + 0xc) = *(int *)(param_2 + 0xc) + 9;
}
this_00 = (KeyValues *)KeyValues::GetFirstSubKey((KeyValues *)puVar8[2]);
if (2 < *(int *)(net_showevents._28_4_ + 0x30)) {
DevMsg("Serializing event \'%s\' (%i):\n",
*(undefined4 *)(puVar8[1] * 0x18 + *(int *)(this + 0x7c) + 0x10),*puVar8);
}
do {
if (this_00 == (KeyValues *)0x0) {
if (*(int *)(net_showevents._28_4_ + 0x30) < 3) {
iVar10 = *(int *)(param_2 + 0xc) - uVar3;
}
else {
iVar10 = *(int *)(param_2 + 0xc) - uVar3;
/* try { // try from 00162daa to 00162dde has its CatchHandler @ 00162df9 */
Msg(" took %d bits, %.1 bytes\n",iVar10,(double)((float)iVar10 * 0.125));
}
puVar8[9] = puVar8[9] + 1;
puVar8[0xb] = puVar8[0xb] + iVar10;
bVar4 = param_2[0x10];
*(int *)(this + 0xa0) = *(int *)(this + 0xa0) + -1;
if (*(int *)(this + 0xa0) == 0) {
LOCK();
*(uint *)pCVar6 = 0;
UNLOCK();
}
if ((pCVar6 != (CGameEventManager *)0x0) && (_SetSeed != 0)) {
(**(code **)(_SetSeed + 0x6c))
(_SetSeed,pCVar6,1,"/data/src/public/tier0/vprof_telemetry.h",0x3fa,
&CTelemetryLock::Unlocked()::tm_fmt,"%s Released","CGameEventManager");
}
return (byte)bVar4 ^ 1;
}
uVar9 = KeyValues::GetName(this_00);
iVar10 = KeyValues::GetInt(this_00,(char *)0x0,0);
if (2 < *(int *)(net_showevents._28_4_ + 0x30)) {
if (iVar10 == 0) {
pcVar13 = "local";
}
else {
piVar11 = (int *)s_GameEventTypesMap;
do {
pcVar5 = (char *)piVar11[2];
pcVar13 = tokenset_t<int>::GetNameByToken(int)::unknown;
if (pcVar5 == (char *)0x0) break;
piVar1 = piVar11 + 3;
piVar11 = piVar11 + 2;
pcVar13 = pcVar5;
} while (iVar10 != *piVar1);
}
DevMsg(" - %s (%s)\n",uVar9,pcVar13);
}
switch(iVar10) {
case 0:
break;
case 1:
pcVar13 = (char *)(**(code **)(*(int *)param_1 + 0x28))(param_1,uVar9,&DAT_002c79d4);
bf_write::WriteString(param_2,pcVar13);
break;
case 2:
(**(code **)(*(int *)param_1 + 0x24))(param_1,uVar9,0);
bf_write::WriteFloat((float)param_2);
break;
case 3:
lVar12 = (**(code **)(*(int *)param_1 + 0x1c))(param_1,uVar9,0);
bf_write::WriteLong(param_2,lVar12);
break;
case 4:
iVar10 = (**(code **)(*(int *)param_1 + 0x1c))(param_1,uVar9,0);
bf_write::WriteShort(param_2,iVar10);
break;
case 5:
uVar7 = (**(code **)(*(int *)param_1 + 0x1c))(param_1,uVar9,0);
bf_write::WriteByte(param_2,uVar7);
break;
case 6:
iVar14 = (**(code **)(*(int *)param_1 + 0x1c))(param_1,uVar9,0);
iVar10 = *(int *)(param_2 + 0xc);
if (iVar10 < *(int *)(param_2 + 8)) {
if (param_2[0x10] == (bf_write)0x0) {
if (iVar14 == 0) {
pbVar2 = (byte *)(*(int *)param_2 + (iVar10 >> 3));
*pbVar2 = *pbVar2 & ~(byte)(1 << ((byte)iVar10 & 7));
}
else {
pbVar2 = (byte *)(*(int *)param_2 + (iVar10 >> 3));
*pbVar2 = *pbVar2 | (byte)(1 << ((byte)iVar10 & 7));
}
*(int *)(param_2 + 0xc) = *(int *)(param_2 + 0xc) + 1;
}
}
else {
param_2[0x10] = (bf_write)0x1;
}
break;
case 7:
/* try { // try from 00162bbf to 00162d03 has its CatchHandler @ 00162df9 */
uVar9 = (**(code **)(*(int *)param_1 + 0x20))(param_1,uVar9,0);
bf_write::WriteLongLong(CONCAT44(uVar9,param_2));
break;
default:
KeyValues::GetName(this_00);
DevMsg(1,"CGameEventManager: unkown type %i for key \'%s\'.\n",iVar10);
}
this_00 = (KeyValues *)KeyValues::GetNextKey(this_00);
} while( true );
}
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.