PreUpdateProfile
0x002301f0 · 2258 bytes · __cdecl
_Z16PreUpdateProfilef
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* PreUpdateProfile(float) */
void PreUpdateProfile(float param_1)
{
float fVar1;
float fVar2;
uint uVar3;
bool bVar4;
float fVar5;
char cVar6;
int *piVar7;
int iVar8;
int *piVar9;
undefined4 uVar10;
int iVar11;
undefined4 *puVar12;
undefined4 *puVar13;
char *pcVar14;
CUtlVector<int,CUtlMemory<int,int>> *this;
uint uVar15;
char *pcVar16;
uint uVar17;
longdouble lVar18;
int *piVar19;
ulonglong uVar20;
int local_44;
int *local_38;
uint local_20 [4];
if (g_pfnDeferredOp != (code *)0x0) {
(*g_pfnDeferredOp)();
g_pfnDeferredOp = (code *)0x0;
}
if (g_VProfExport[0x20] != '\0') {
_DAT_0040b028 = _DAT_0040b028 + 1;
if (_DAT_0040b028 == 1) {
CVProfNode::EnterScope();
}
g_VProfExport[0x20] = '\0';
}
if (g_VProfExport[0x21] != '\0') {
_DAT_0040b028 = _DAT_0040b028 + -1;
if (_DAT_0040b028 == 0) {
CVProfNode::ExitScope();
}
g_VProfExport[0x21] = '\0';
}
VProfRecord_StartOrStop();
if (_DAT_0040b9d4 != g_VProfTargetThread) {
_DAT_0040b9d4 = g_VProfTargetThread;
}
if (_DAT_0040b028 == 0) goto LAB_002302dc;
if (*(float *)(vprof_dump_oninterval._28_4_ + 0x2c) != 0.0) {
lVar18 = (longdouble)(**(code **)(*(int *)eng + 0x20))(eng);
fVar2 = (float)lVar18;
fVar1 = *(float *)(vprof_dump_oninterval._28_4_ + 0x2c);
if (_DAT_0040b028 != 0) {
_DAT_0040b0b0 = _DAT_0040b0b0 + 1;
CVProfNode::ExitScope();
CVProfNode::MarkFrame();
CVProfNode::EnterScope();
}
fVar5 = s_flIntervalStartTime;
if (fVar1 + s_flIntervalStartTime < fVar2) {
CVProfile::OutputReport(0x40a01c,(char *)0x239,0);
_DAT_0040b028 = _DAT_0040b028 + -1;
if (_DAT_0040b028 == 0) {
CVProfNode::ExitScope();
}
CVProfNode::Reset();
_DAT_0040b0b0 = 0;
_DAT_0040b028 = _DAT_0040b028 + 1;
fVar5 = fVar2;
if (_DAT_0040b028 == 1) {
CVProfNode::EnterScope();
}
}
s_flIntervalStartTime = fVar5;
if (_DAT_0040b028 == 0) goto LAB_002302dc;
}
fVar1 = *(float *)(vprof_dump_spikes._28_4_ + 0x2c);
if (fVar1 == 0.0) goto LAB_002302dc;
_DAT_0040b0b0 = _DAT_0040b0b0 + 1;
CVProfNode::ExitScope();
CVProfNode::MarkFrame();
CVProfNode::EnterScope();
if (g_VProfSignalSpike == '\0') {
bVar4 = false;
lVar18 = (longdouble)(**(code **)(*(int *)eng + 0x1c))(eng);
if (1.0 / ABS(fVar1) < (float)lVar18) {
if (g_VProfSignalSpike != '\0') goto LAB_00230512;
lVar18 = (longdouble)Plat_FloatTime();
if ((double)lVar18 - LastSpikeTime <= 1.0) goto LAB_00230994;
bVar4 = false;
if (LastSpikeFrame + 10 < (int)g_ServerGlobalVariables._4_4_) goto LAB_00230512;
goto LAB_00230662;
}
}
else {
LAB_00230512:
(**(code **)(*g_pFileSystem + 0x48))(g_pFileSystem,"vprof",0);
do {
ConsoleLogger::m_index = ConsoleLogger::m_index + 1;
uVar10 = va("vprof/vprof%d.txt",ConsoleLogger::m_index);
cVar6 = (**(code **)(g_pFileSystem[1] + 0x28))(g_pFileSystem + 1,uVar10,0);
} while (cVar6 != '\0');
lVar18 = (longdouble)Plat_FloatTime();
Msg("******** Spike on frame %d at time %.3f ",g_ServerGlobalVariables._4_4_,(double)lVar18);
if (*(int *)(vprof_dump_spikes_hierarchy._28_4_ + 0x30) == 0) {
iVar11 = *(int *)(vprof_dump_spikes_terse._28_4_ + 0x30);
if (((vprof_dump_spikes_budget_group[0x15] & 0x10) != 0) ||
((*(char **)(vprof_dump_spikes_budget_group._28_4_ + 0x24) != (char *)0x0 &&
(**(char **)(vprof_dump_spikes_budget_group._28_4_ + 0x24) != '\0')))) {
CVProfile::BudgetGroupNameToBudgetGroupID(&g_VProfCurrentProfile);
}
pcVar14 = "FCVAR_NEVER_AS_STRING";
if ((vprof_dump_spikes_node[0x15] & 0x10) == 0) {
pcVar16 = "";
if (*(char **)(vprof_dump_spikes_node._28_4_ + 0x24) != (char *)0x0) {
pcVar16 = *(char **)(vprof_dump_spikes_node._28_4_ + 0x24);
}
pcVar14 = (char *)0x0;
if (*pcVar16 != '\0') {
pcVar14 = pcVar16;
}
}
CVProfile::OutputReport(0x40a01c,(char *)((-(uint)(iVar11 == 0) & 0x31) + 0x208),(int)pcVar14)
;
}
else {
if (((vprof_dump_spikes_budget_group[0x15] & 0x10) != 0) ||
((*(char **)(vprof_dump_spikes_budget_group._28_4_ + 0x24) != (char *)0x0 &&
(**(char **)(vprof_dump_spikes_budget_group._28_4_ + 0x24) != '\0')))) {
CVProfile::BudgetGroupNameToBudgetGroupID(&g_VProfCurrentProfile);
}
pcVar14 = "FCVAR_NEVER_AS_STRING";
if ((vprof_dump_spikes_node[0x15] & 0x10) == 0) {
pcVar16 = "";
if (*(char **)(vprof_dump_spikes_node._28_4_ + 0x24) != (char *)0x0) {
pcVar16 = *(char **)(vprof_dump_spikes_node._28_4_ + 0x24);
}
pcVar14 = (char *)0x0;
if (*pcVar16 != '\0') {
pcVar14 = pcVar16;
}
}
CVProfile::OutputReport(0x40a01c,(char *)0x4,(int)pcVar14);
}
lVar18 = (longdouble)Plat_FloatTime();
LastSpikeTime = (double)lVar18;
LastSpikeFrame = g_ServerGlobalVariables._4_4_;
if (0.0 < *(float *)(vprof_dump_spikes._28_4_ + 0x2c) ||
*(float *)(vprof_dump_spikes._28_4_ + 0x2c) == 0.0) {
LAB_00230994:
bVar4 = false;
}
else {
bVar4 = true;
ConVar::SetValue(5.789e-39);
g_fVprofOnByUI = 0;
}
LAB_00230662:
g_VProfSignalSpike = '\0';
}
iVar11 = 0;
do {
while (_DAT_0040b028 = _DAT_0040b028 + -1, _DAT_0040b028 != 0) {
iVar11 = iVar11 + 1;
}
iVar11 = iVar11 + 1;
CVProfNode::ExitScope();
} while (_DAT_0040b028 != 0);
if (!bVar4) {
CVProfNode::Reset();
_DAT_0040b0b0 = 0;
for (; iVar11 != 0; iVar11 = iVar11 + -1) {
_DAT_0040b028 = _DAT_0040b028 + 1;
if (_DAT_0040b028 == 1) {
CVProfNode::EnterScope();
}
}
}
LAB_002302dc:
iVar11 = *(int *)(vprof_counters._28_4_ + 0x30);
if ((iVar11 != 0) || (g_bDumpCounters != '\0')) {
piVar7 = (int *)CVProfile::GetNumCounters();
local_44 = 0;
local_38 = (int *)0x0;
if (0 < (int)piVar7) {
do {
while (iVar8 = CVProfile::GetCounterGroup(0x40a01c), iVar8 == iVar11 + -1) {
uVar20 = ZEXT48(local_20);
piVar19 = local_38;
piVar9 = (int *)CVProfile::GetCounterNameAndValue(0x40a01c,local_38);
if (g_bDumpCounters != '\0') {
uVar20 = (ulonglong)local_20[0];
piVar19 = piVar9;
Msg("VPROF: %s = %d\n",piVar9,local_20[0]);
}
if (*(int *)(vprof_counters_show_minmax._28_4_ + 0x30) == 0) {
Con_NPrintf(local_44,"%s = %d\n",piVar9);
}
else {
if ((PreUpdateProfile(float)::history == '\0') &&
(iVar8 = __cxa_guard_acquire(&PreUpdateProfile(float)::history,piVar19,uVar20),
iVar8 != 0)) {
puVar12 = &PreUpdateProfile(float)::history;
do {
*puVar12 = 0;
puVar13 = puVar12 + 5;
puVar12[1] = 0;
puVar12[2] = 0;
puVar12[3] = 0;
puVar12[4] = 0;
puVar12 = puVar13;
} while (puVar13 != (undefined4 *)&DAT_003f0018);
__cxa_guard_release(&PreUpdateProfile(float)::history);
__cxa_atexit(__tcf_0,0,&__dso_handle);
}
this = (CUtlVector<int,CUtlMemory<int,int>> *)&PreUpdateProfile(float)::history;
CUtlVector<int,CUtlMemory<int,int>>::EnsureCount
((CUtlVector<int,CUtlMemory<int,int>> *)
(&PreUpdateProfile(float)::history + PreUpdateProfile(float)::nCycle * 5),
(int)piVar7);
*(uint *)((&PreUpdateProfile(float)::history)[PreUpdateProfile(float)::nCycle * 5] +
(int)local_38 * 4) = local_20[0];
uVar15 = local_20[0];
uVar17 = local_20[0];
do {
CUtlVector<int,CUtlMemory<int,int>>::EnsureCount(this,(int)piVar7);
uVar3 = *(uint *)(*(int *)this + (int)local_38 * 4);
if ((int)uVar3 < (int)uVar15) {
uVar15 = uVar3;
}
if ((int)uVar17 < (int)uVar3) {
uVar17 = uVar3;
}
this = this + 0x14;
} while (this != (CUtlVector<int,CUtlMemory<int,int>> *)&DAT_003f0018);
Con_NPrintf(local_44,"%s = %6d (%6d:%6d)\n",piVar9,local_20[0],uVar15,uVar17);
}
local_38 = (int *)((int)local_38 + 1);
local_44 = local_44 + 1;
if (local_38 == piVar7) goto LAB_00230450;
}
local_38 = (int *)((int)local_38 + 1);
} while (local_38 != piVar7);
}
LAB_00230450:
PreUpdateProfile(float)::nCycle = (PreUpdateProfile(float)::nCycle + 1) % 0x1e;
}
CVProfile::ResetCounters(&g_VProfCurrentProfile,0);
CVProfile::ResetCounters(&g_VProfCurrentProfile,3);
uVar10 = g_VProfExport._16_4_;
if (*(int *)(g_pVProfileForDisplay + 0x100c) != 0) {
iVar11 = CVProfile::GetNumBudgetGroups();
if ((int)uVar10 < iVar11) {
iVar11 = CVProfile::GetNumBudgetGroups();
g_VProfExport._16_4_ = 0;
if (iVar11 != 0) {
CUtlVector<float,CUtlMemory<float,int>>::GrowVector
((CUtlVector<float,CUtlMemory<float,int>> *)(g_VProfExport + 4),iVar11);
if ((0 < g_VProfExport._16_4_ - iVar11) && (0 < iVar11)) {
_V_memmove((void *)(g_VProfExport._4_4_ + iVar11 * 4),(void *)g_VProfExport._4_4_,
(g_VProfExport._16_4_ - iVar11) * 4);
}
}
}
iVar11 = CVProfile::GetNumBudgetGroups();
memset((void *)g_VProfExport._4_4_,0,iVar11 << 2);
if ((g_pVProfileForDisplay != (undefined *)0xffffefe8) &&
(*(CVProfNode **)(g_pVProfileForDisplay + 0x1080) != (CVProfNode *)0x0)) {
CVProfExport::CalculateBudgetGroupTimes_Recursive
((CVProfExport *)g_VProfExport,*(CVProfNode **)(g_pVProfileForDisplay + 0x1080));
}
}
VProfRecord_Snapshot();
g_bDumpCounters = 0;
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.