Checkpoint::GetSpawnPosition
0x0086ba20 · 1747 bytes · __thiscall
_ZNK10Checkpoint16GetSpawnPositionEP6VectorP6QAnglePP13TerrorNavArea
Decompiled
undefined (4 params)
/* Checkpoint::GetSpawnPosition(Vector*, QAngle*, TerrorNavArea**) const */
undefined4 __thiscall
Checkpoint::GetSpawnPosition
(Checkpoint *this,Vector *param_1,QAngle *param_2,TerrorNavArea **param_3)
{
float fVar1;
float fVar2;
uint uVar3;
int *piVar4;
char cVar5;
Vector *pVVar6;
int iVar7;
undefined *puVar8;
int iVar9;
undefined4 uVar10;
CNavArea *this_00;
longdouble lVar11;
float fVar12;
int local_134;
float local_130;
CUtlMemory<TerrorNavArea*,int> *local_12c;
float local_124;
int local_120;
float local_108;
float local_104;
float local_100;
int *local_f8;
undefined4 local_f4;
undefined4 local_f0;
int local_ec;
int *local_e8;
undefined4 local_e4;
undefined4 local_e0;
undefined4 local_d8;
undefined4 local_d4;
float local_cc;
float local_c8;
float local_c4;
undefined4 local_bc;
undefined4 local_b8;
undefined4 local_b4;
float local_ac;
float local_a8;
float local_a4;
float local_9c;
float local_98;
float local_94;
undefined4 local_8c;
undefined1 local_88;
undefined1 local_87;
CNavArea *local_70 [3];
Vector local_64 [32];
float local_44;
char local_39;
if (param_1 == (Vector *)0x0) {
return 0;
}
*(undefined4 *)param_1 = vec3_origin;
*(undefined4 *)(param_1 + 4) = DAT_01053d4c;
*(undefined4 *)(param_1 + 8) = DAT_01053d50;
if (param_2 != (QAngle *)0x0) {
*(undefined4 *)param_2 = vec3_angle;
*(undefined4 *)(param_2 + 4) = DAT_01053d40;
*(undefined4 *)(param_2 + 8) = DAT_01053d44;
}
local_f8 = (int *)0x0;
local_f4 = 0;
local_f0 = 0;
local_ec = 0;
local_e8 = (int *)0x0;
if (*(int *)(this + 0x3c) < 1) {
local_130 = -0.1;
}
else {
local_120 = 0;
local_124 = 0.0;
do {
local_70[0] = *(CNavArea **)(*(int *)(this + 0x30) + local_120 * 4);
if (0 < *(int *)(this + 0x54)) {
iVar9 = 0;
do {
while( true ) {
uVar3 = *(uint *)(*(int *)(this + 0x48) + iVar9 * 4);
if ((((uVar3 == 0xffffffff) ||
(puVar8 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar8 == (undefined *)0xfffffffc
)) || (*(uint *)(puVar8 + 8) != uVar3 >> 0xc)) ||
(piVar4 = *(int **)(puVar8 + 4), piVar4 == (int *)0x0)) break;
/* try { // try from 0086bb76 to 0086c0ac has its CatchHandler @ 0086c103 */
cVar5 = CNavArea::IsBlocked(local_70[0],-1,false);
if (cVar5 != '\0') goto LAB_0086bb83;
pVVar6 = (Vector *)(**(code **)(*piVar4 + 0x288))(piVar4);
cVar5 = CNavArea::IsOverlapping(local_70[0],pVVar6,0.0);
if (cVar5 != '\0') goto LAB_0086bb83;
iVar9 = iVar9 + 1;
if (*(int *)(this + 0x54) <= iVar9) goto LAB_0086bcd0;
}
iVar9 = iVar9 + 1;
} while (iVar9 < *(int *)(this + 0x54));
}
LAB_0086bcd0:
CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>>::InsertBefore
((CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *)&local_f8,local_ec,
(TerrorNavArea **)local_70);
local_124 = (*(float *)(local_70[0] + 0x14) - *(float *)(local_70[0] + 8)) *
(*(float *)(local_70[0] + 0x10) - *(float *)(local_70[0] + 4)) + local_124;
LAB_0086bb83:
local_120 = local_120 + 1;
} while (local_120 < *(int *)(this + 0x3c));
local_130 = local_124 - 0.1;
}
local_12c = (CUtlMemory<TerrorNavArea*,int> *)&local_f8;
local_134 = 100;
do {
lVar11 = (longdouble)RandomFloat(0,local_130);
if (local_ec < 1) {
LAB_0086bc4f:
Warning("Checkpoint::GetSpawnPosition: Selected NULL area\n");
goto LAB_0086bc5b;
}
this_00 = (CNavArea *)*local_f8;
fVar12 = (*(float *)(this_00 + 0x10) - *(float *)(this_00 + 4)) *
(*(float *)(this_00 + 0x14) - *(float *)(this_00 + 8));
if (fVar12 <= (float)lVar11) {
iVar9 = 0;
do {
iVar9 = iVar9 + 1;
if (iVar9 == local_ec) goto LAB_0086bc4f;
this_00 = (CNavArea *)local_f8[iVar9];
fVar12 = fVar12 + (*(float *)(this_00 + 0x14) - *(float *)(this_00 + 8)) *
(*(float *)(this_00 + 0x10) - *(float *)(this_00 + 4));
} while (fVar12 <= (float)lVar11);
}
CNavArea::GetExtent(this_00,(Extent *)&local_e4);
lVar11 = (longdouble)RandomFloat(local_e4,local_d8);
fVar12 = (float)lVar11;
lVar11 = (longdouble)RandomFloat(local_e0,local_d4);
fVar1 = (float)lVar11;
lVar11 = (longdouble)CNavArea::GetZ(this_00,fVar12,fVar1);
fVar2 = (float)lVar11;
iVar9 = (**(code **)(*g_pGameRules + 0x7c))(g_pGameRules);
iVar7 = (**(code **)(*g_pGameRules + 0x7c))(g_pGameRules);
local_bc = 0;
local_b8 = 0;
local_b4 = 0;
local_8c = 0;
local_87 = 0;
local_9c = (*(float *)(iVar9 + 0x18) - *(float *)(iVar7 + 0xc)) * 0.5;
local_98 = (*(float *)(iVar9 + 0x1c) - *(float *)(iVar7 + 0x10)) * 0.5;
local_94 = (*(float *)(iVar9 + 0x20) - *(float *)(iVar7 + 0x14)) * 0.5;
local_88 = local_98 * local_98 + local_9c * local_9c + local_94 * local_94 < 1e-06;
local_ac = (*(float *)(iVar9 + 0x18) + *(float *)(iVar7 + 0xc)) * 0.5;
local_cc = fVar12 + local_ac;
local_ac = -local_ac;
local_a8 = (*(float *)(iVar9 + 0x1c) + *(float *)(iVar7 + 0x10)) * 0.5;
local_a4 = (*(float *)(iVar9 + 0x20) + *(float *)(iVar7 + 0x14)) * 0.5;
local_c8 = fVar1 + local_a8;
local_c4 = fVar2 + local_a4;
local_a8 = -local_a8;
local_a4 = -local_a4;
CTraceFilterSimple::CTraceFilterSimple
((CTraceFilterSimple *)&local_108,(IHandleEntity *)0x0,8,
(_func_bool_IHandleEntity_ptr_int *)0x0);
(**(code **)(*enginetrace + 0x14))
(enginetrace,&local_cc,0x201420b,(CTraceFilterSimple *)&local_108,local_70);
if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
DebugDrawLine((Vector *)local_70,local_64,0xff,0xff,0,true,-1.0);
}
if ((local_39 == '\0') && (1.0 <= local_44)) {
*(float *)param_1 = fVar12;
*(float *)(param_1 + 4) = fVar1;
*(float *)(param_1 + 8) = fVar2;
if (param_2 != (QAngle *)0x0) {
FindInterestingLookAtTarget((Vector *)&local_108);
local_cc = local_108 - fVar12;
local_c8 = local_104 - fVar1;
local_c4 = local_100 - (fVar2 + 35.5);
VectorAngles((Vector *)&local_cc,param_2);
*(undefined4 *)param_2 = 0;
}
if (param_3 == (TerrorNavArea **)0x0) {
uVar10 = 1;
}
else {
*param_3 = (TerrorNavArea *)this_00;
uVar10 = 1;
}
goto LAB_0086bc5d;
}
local_134 = local_134 + -1;
if (local_134 == 0) {
Warning("Checkpoint::GetSpawnPosition: Failed after many tries\n");
LAB_0086bc5b:
uVar10 = 0;
LAB_0086bc5d:
local_ec = 0;
CUtlMemory<TerrorNavArea*,int>::Purge(local_12c);
local_e8 = local_f8;
CUtlMemory<TerrorNavArea*,int>::Purge(local_12c);
return uVar10;
}
} 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.