L L4D2node

CFuncTrackTrain::NearestPath

0x00b0a050 · 722 bytes · __thiscall

_ZN15CFuncTrackTrain11NearestPathEv

Decompiled

undefined (1 param)

/* CFuncTrackTrain::NearestPath() */

void __thiscall CFuncTrackTrain::NearestPath(CFuncTrackTrain *this)

{
  char cVar1;
  CBaseEntity *pCVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  CBaseEntity *pCVar5;
  float fVar6;
  float fVar7;
  float fVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  CBaseEntity *local_840;
  float local_83c;
  undefined1 local_834 [16];
  int local_824 [517];
  
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  CEntitySphereQuery::CEntitySphereQuery
            ((CEntitySphereQuery *)local_824,(Vector *)(this + 0x2e0),1024.0,0);
  local_83c = 1024.0;
  local_840 = (CBaseEntity *)0x0;
  while (pCVar2 = (CBaseEntity *)
                  CEntitySphereQuery::GetCurrentEntity((CEntitySphereQuery *)local_824),
        pCVar2 != (CBaseEntity *)0x0) {
    if (((*(uint *)(pCVar2 + 0x150) & 0x2080) == 0) &&
       ((*(char **)(pCVar2 + 0x7c) == "path_track" ||
        (cVar1 = CBaseEntity::ClassMatchesComplex(pCVar2,"path_track"), cVar1 != '\0')))) {
      if (((byte)pCVar2[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition(pCVar2);
      }
      if (((byte)this[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      }
      fVar6 = SQRT((*(float *)(this + 0x2e0) - *(float *)(pCVar2 + 0x2e0)) *
                   (*(float *)(this + 0x2e0) - *(float *)(pCVar2 + 0x2e0)) +
                   (*(float *)(this + 0x2e4) - *(float *)(pCVar2 + 0x2e4)) *
                   (*(float *)(this + 0x2e4) - *(float *)(pCVar2 + 0x2e4)) +
                   (*(float *)(this + 0x2e8) - *(float *)(pCVar2 + 0x2e8)) *
                   (*(float *)(this + 0x2e8) - *(float *)(pCVar2 + 0x2e8)));
      if (fVar6 < local_83c) {
        local_840 = pCVar2;
        local_83c = fVar6;
      }
    }
    local_824[0] = local_824[0] + 1;
  }
  if (local_840 == (CBaseEntity *)0x0) {
    Msg("Can\'t find a nearby track !!!\n");
    CBaseEntity::ThinkSet((_func_void *)local_834,(float)this,(char *)0x0);
    return;
  }
  uVar3 = CBaseEntity::GetDebugName(local_840);
  uVar4 = CBaseEntity::GetDebugName((CBaseEntity *)this);
  DevMsg(2,"TRAIN: %s, Nearest track is %s\n",uVar4,uVar3);
  pCVar5 = (CBaseEntity *)CPathTrack::GetNext((CPathTrack *)local_840);
  pCVar2 = local_840;
  if ((pCVar5 != (CBaseEntity *)0x0) &&
     (fVar7 = *(float *)(this + 0x39c) - *(float *)(pCVar5 + 0x39c),
     fVar11 = *(float *)(this + 0x3a4) - *(float *)(pCVar5 + 0x3a4),
     fVar9 = *(float *)(this + 0x39c) - *(float *)(local_840 + 0x39c),
     fVar6 = *(float *)(this + 0x3a0) - *(float *)(local_840 + 0x3a0),
     fVar10 = *(float *)(this + 0x3a0) - *(float *)(pCVar5 + 0x3a0),
     fVar8 = *(float *)(this + 0x3a4) - *(float *)(local_840 + 0x3a4), pCVar2 = pCVar5,
     SQRT(fVar6 * fVar6 + fVar9 * fVar9 + fVar8 * fVar8) <=
     SQRT(fVar7 * fVar7 + fVar11 * fVar11 + fVar10 * fVar10))) {
    pCVar2 = local_840;
  }
  *(CBaseEntity **)(this + 0x440) = pCVar2;
  if (*(float *)(this + 0x11c) != 0.0) {
    CBaseEntity::SetMoveDoneTime((CBaseEntity *)this,0.1);
    *(code **)(this + 0x14) = Next;
    *(undefined4 *)(this + 0x18) = 0;
  }
  return;
}

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)