L L4D2node

Path::GetClosestPosition

0x0075ece0 · 353 bytes · __thiscall

_ZNK4Path18GetClosestPositionERK6VectorPKNS_7SegmentEf

Decompiled

undefined (4 params)

/* Path::GetClosestPosition(Vector const&, Path::Segment const*, float) const */

Path * __thiscall
Path::GetClosestPosition(Path *this,Vector *param_1,Segment *param_2,float param_3)

{
  Path *pPVar1;
  float fVar2;
  float local_38;
  float local_30;
  float local_28;
  float local_24;
  float local_20;
  
  if (param_2 == (Segment *)0x0) {
    param_2 = (Segment *)(this + 4);
    if (param_2 == (Segment *)0x0) {
      return (Path *)param_1;
    }
  }
  *(undefined4 *)(this + 0x4414) = *(undefined4 *)param_1;
  *(undefined4 *)(this + 0x4418) = *(undefined4 *)(param_1 + 4);
  *(undefined4 *)(this + 0x441c) = *(undefined4 *)(param_1 + 8);
  local_30 = 0.0;
  local_38 = 1e+11;
  if (0.0 <= param_3) {
    do {
      pPVar1 = (Path *)(**(code **)(*(int *)this + 0x58))(this,param_2);
      if (pPVar1 == (Path *)0x0) break;
      CalcClosestPointOnLineSegment
                (param_1,(Vector *)(param_2 + 8),(Vector *)(pPVar1 + 8),(Vector *)&local_28,
                 (float *)0x0);
      fVar2 = (local_20 - *(float *)(param_1 + 8)) * (local_20 - *(float *)(param_1 + 8)) +
              (local_28 - *(float *)param_1) * (local_28 - *(float *)param_1) +
              (local_24 - *(float *)(param_1 + 4)) * (local_24 - *(float *)(param_1 + 4));
      if (fVar2 < local_38) {
        *(float *)(this + 0x4414) = local_28;
        *(float *)(this + 0x4418) = local_24;
        *(float *)(this + 0x441c) = local_20;
        local_38 = fVar2;
      }
      local_30 = local_30 + *(float *)(param_2 + 0x28);
      param_2 = (Segment *)pPVar1;
    } while ((param_3 == 0.0) || (local_30 <= param_3));
  }
  return this + 0x4414;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)