L L4D2node

GetPlayerSpawnPosition

0x00900f70 · 2342 bytes · __cdecl

_Z22GetPlayerSpawnPosition21SurvivorCharacterTypeP6VectorP6QAnglePP13TerrorNavArea

Decompiled

undefined (4 params)

/* GetPlayerSpawnPosition(SurvivorCharacterType, Vector*, QAngle*, TerrorNavArea**) */

undefined4 GetPlayerSpawnPosition(int param_1,undefined4 *param_2,QAngle *param_3,int *param_4)

{
  float fVar1;
  undefined4 uVar2;
  byte bVar3;
  byte bVar4;
  char cVar5;
  int iVar6;
  int iVar7;
  char *pcVar8;
  char *pcVar9;
  uint uVar10;
  int iVar11;
  Checkpoint *this;
  CBaseEntity *this_00;
  undefined4 uVar12;
  CSurvivorPosition *this_01;
  TerrorNavArea *pTVar13;
  CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>> *pCVar14;
  TerrorNavArea *pTVar15;
  int local_70 [3];
  CSurvivorPosition *local_64;
  TerrorNavArea *local_60;
  undefined4 local_5c;
  undefined4 local_58;
  float local_54;
  undefined4 local_50;
  undefined4 local_4c;
  float local_48;
  undefined4 local_44;
  undefined4 local_40;
  undefined4 local_3c;
  int local_38;
  undefined4 local_34;
  undefined4 local_30;
  undefined4 local_2c;
  undefined4 local_28;
  int local_24;
  undefined4 local_20;
  
  local_44 = 0;
  local_40 = 0;
  local_3c = 0;
  local_38 = 0;
  local_34 = 0;
  local_30 = 0;
  local_2c = 0;
  local_28 = 0;
  local_24 = 0;
  local_20 = 0;
                    /* try { // try from 00900fce to 009013b7 has its CatchHandler @ 0090190e */
  bVar3 = CTerrorGameRules::IsSurvivalMode();
  iVar6 = CTerrorGameRules::FastGetSurvivorSet();
  iVar7 = CTerrorGameRules::FastGetSurvivorSet();
  local_64 = (CSurvivorPosition *)0x0;
  if ((GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
       survivorPositionStr == '\0') &&
     (iVar11 = __cxa_guard_acquire(&GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)
                                    ::survivorPositionStr), iVar11 != 0)) {
    DAT_0100ecc0 = 0;
    GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
    survivorPositionStr = 0;
    DAT_0100ecbc = "info_survivor_position";
    __cxa_guard_release(&GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)
                         ::survivorPositionStr);
    __cxa_atexit(CGameString::~CGameString,
                 &GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
                  survivorPositionStr,&__dso_handle);
  }
  pcVar8 = (char *)CDirector::GetGameModeBase();
LAB_00901048:
  if ((GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
       survivorPositionStr == 0) ||
     (iVar11 = GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
               survivorPositionStr, DAT_0100ecc0 != CGameString::gm_iSerialNumber)) {
    if (DAT_0100ecbc == (char *)0x0) {
      iVar11 = 0;
    }
    else {
      AllocPooledString((char *)local_70);
      GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::
      survivorPositionStr = local_70[0];
      DAT_0100ecc0 = CGameString::gm_iSerialNumber;
      iVar11 = local_70[0];
    }
  }
  local_64 = (CSurvivorPosition *)
             CGlobalEntityList::FindEntityByClassnameFast
                       ((CGlobalEntityList *)gEntList,local_64,iVar11);
  if (local_64 != (CSurvivorPosition *)0x0) {
    pcVar9 = (char *)CSurvivorPosition::GetSurvivorName(local_64);
    if (pcVar9 != (char *)0x0) goto code_r0x009010c3;
    uVar10 = 8;
    goto LAB_009010dd;
  }
  local_64 = (CSurvivorPosition *)0x0;
  pCVar14 = (CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>> *)&local_44;
  if ((0 < local_38) ||
     (iVar6 = local_24,
     pCVar14 = (CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>> *)&local_30,
     0 < local_24)) {
    iVar7 = 0;
    do {
      this_01 = *(CSurvivorPosition **)(*(int *)pCVar14 + iVar7 * 4);
      iVar6 = CSurvivorPosition::GetSurvivorName(this_01);
      if (iVar6 != 0) {
        pcVar8 = (char *)CSurvivorPosition::GetSurvivorName(this_01);
        iVar6 = GetCharacterFromName(pcVar8);
        if ((iVar6 == param_1) && (iVar6 != 8)) {
          if (this_01 != (CSurvivorPosition *)0x0) goto LAB_00901219;
          iVar6 = *(int *)(pCVar14 + 0xc);
          break;
        }
      }
      iVar7 = iVar7 + 1;
      iVar6 = *(int *)(pCVar14 + 0xc);
    } while (iVar7 < *(int *)(pCVar14 + 0xc));
  }
  if (iVar6 == 0) {
LAB_009013b3:
    uVar12 = CTerrorGameRules::IsSurvivalMode();
    if ((char)uVar12 == '\0') {
      if (DAT_00fe6000 < 1) {
LAB_00901614:
                    /* try { // try from 0090162b to 009018b8 has its CatchHandler @ 0090190e */
        this_00 = (CBaseEntity *)
                  CGlobalEntityList::FindEntityByClassname
                            ((CGlobalEntityList *)gEntList,(CBaseEntity *)0x0,"info_player_start");
        if (this_00 == (CBaseEntity *)0x0) {
          if (DAT_00fe6000 == 0) {
            Warning("GetPlayerSpawnPosition: No spawn zones\n");
            uVar12 = 0;
            goto LAB_009012c5;
          }
          iVar6 = *TheNavAreas;
          if (param_2 != (undefined4 *)0x0) {
            fVar1 = *(float *)(iVar6 + 0x34);
            uVar12 = *(undefined4 *)(iVar6 + 0x30);
            *param_2 = *(undefined4 *)(iVar6 + 0x2c);
            param_2[1] = uVar12;
            param_2[2] = fVar1 + 35.5;
          }
          if (param_3 != (QAngle *)0x0) {
            *(undefined4 *)param_3 = vec3_angle;
            *(undefined4 *)(param_3 + 4) = DAT_01053d40;
            *(undefined4 *)(param_3 + 8) = DAT_01053d44;
            local_50 = *(undefined4 *)(iVar6 + 0x2c);
            local_4c = *(undefined4 *)(iVar6 + 0x30);
            local_48 = *(float *)(iVar6 + 0x34) + 35.5;
            FindWeaponSpawnLookAtAngles((Vector *)&local_50,param_3);
          }
          if (param_4 != (int *)0x0) {
            *param_4 = iVar6;
            uVar12 = 1;
            goto LAB_009012c5;
          }
        }
        else {
          if (param_2 != (undefined4 *)0x0) {
            if (((byte)this_00[0x14d] & 8) != 0) {
              CBaseEntity::CalcAbsolutePosition(this_00);
            }
            *param_2 = *(undefined4 *)(this_00 + 0x2e0);
            param_2[1] = *(undefined4 *)(this_00 + 0x2e4);
            param_2[2] = *(undefined4 *)(this_00 + 0x2e8);
          }
          if (param_3 != (QAngle *)0x0) {
            *(undefined4 *)param_3 = vec3_angle;
            *(undefined4 *)(param_3 + 4) = DAT_01053d40;
            *(undefined4 *)(param_3 + 8) = DAT_01053d44;
            if (((byte)this_00[0x14d] & 8) != 0) {
              CBaseEntity::CalcAbsolutePosition(this_00);
            }
            FindWeaponSpawnLookAtAngles((Vector *)(this_00 + 0x2e0),param_3);
          }
          if (param_4 != (int *)0x0) {
            if (((byte)this_00[0x14d] & 8) != 0) {
              CBaseEntity::CalcAbsolutePosition(this_00);
            }
            iVar6 = CNavMesh::GetNearestNavArea
                              (TheNavMesh,(Vector *)(this_00 + 0x2e0),false,10000.0,false,true,false
                              );
            goto LAB_009012bb;
          }
        }
      }
      else {
        pTVar15 = (TerrorNavArea *)*TheNavAreas;
        uVar10 = *(uint *)(pTVar15 + 300);
LAB_009013dd:
        if ((uVar10 & 0x80) == 0) {
          iVar6 = 0;
          do {
            local_60 = pTVar15;
            if (((uVar10 & 0x800) != 0) &&
               (cVar5 = IsAreaConnectedToNonCheckpointArea(pTVar15), cVar5 == '\0')) {
              local_5c = *(undefined4 *)(pTVar15 + 0x2c);
              local_58 = *(undefined4 *)(pTVar15 + 0x30);
              local_54 = *(float *)(pTVar15 + 0x34) + 35.5;
                    /* try { // try from 0090145b to 00901483 has its CatchHandler @ 009018c0 */
              this = (Checkpoint *)
                     TerrorNavMesh::GetCheckpoint((TerrorNavMesh *)TheNavMesh,(Vector *)&local_5c);
              if ((this != (Checkpoint *)0x0) &&
                 ((this[0x5f] == (Checkpoint)0x0 &&
                  (cVar5 = Checkpoint::GetSpawnPosition
                                     (this,(Vector *)&local_5c,(QAngle *)&local_50,&local_60),
                  cVar5 != '\0')))) {
                if (param_2 != (undefined4 *)0x0) {
                  *param_2 = local_5c;
                  param_2[1] = local_58;
                  param_2[2] = local_54;
                }
                if (param_3 != (QAngle *)0x0) {
                  *(undefined4 *)param_3 = local_50;
                  *(undefined4 *)(param_3 + 4) = local_4c;
                  *(float *)(param_3 + 8) = local_48;
                }
                goto LAB_009014da;
              }
            }
            iVar6 = iVar6 + 1;
            if (DAT_00fe6000 <= iVar6) goto LAB_00901614;
            pTVar15 = (TerrorNavArea *)TheNavAreas[iVar6];
            uVar10 = *(uint *)(pTVar15 + 300);
          } while ((uVar10 & 0x80) == 0);
        }
        if (param_2 != (undefined4 *)0x0) {
          fVar1 = *(float *)(pTVar15 + 0x34);
          uVar12 = *(undefined4 *)(pTVar15 + 0x30);
          *param_2 = *(undefined4 *)(pTVar15 + 0x2c);
          param_2[1] = uVar12;
          param_2[2] = fVar1 + 18.0;
        }
        local_60 = pTVar15;
        if (param_3 != (QAngle *)0x0) {
          *(undefined4 *)param_3 = vec3_angle;
          *(undefined4 *)(param_3 + 4) = DAT_01053d40;
          *(undefined4 *)(param_3 + 8) = DAT_01053d44;
          local_50 = *(undefined4 *)(pTVar15 + 0x2c);
          local_4c = *(undefined4 *)(pTVar15 + 0x30);
          local_48 = *(float *)(pTVar15 + 0x34) + 18.0;
                    /* try { // try from 0090160a to 0090160e has its CatchHandler @ 00901918 */
          FindWeaponSpawnLookAtAngles((Vector *)&local_50,param_3);
        }
LAB_009014da:
        if (param_4 != (int *)0x0) {
          *param_4 = (int)local_60;
        }
      }
    }
    else {
      if (DAT_00fe6000 < 1) goto LAB_00901614;
      pTVar15 = (TerrorNavArea *)*TheNavAreas;
      uVar10 = *(uint *)(pTVar15 + 300);
      pTVar13 = pTVar15;
      if ((uVar10 & 0x20) == 0) {
        iVar6 = 0;
        do {
          iVar6 = iVar6 + 1;
          if (iVar6 == DAT_00fe6000) goto LAB_009013dd;
          pTVar13 = (TerrorNavArea *)TheNavAreas[iVar6];
        } while (((byte)((TerrorNavArea *)TheNavAreas[iVar6])[300] & 0x20) == 0);
      }
      if (param_2 != (undefined4 *)0x0) {
        fVar1 = *(float *)(pTVar13 + 0x34);
        uVar2 = *(undefined4 *)(pTVar13 + 0x30);
        *param_2 = *(undefined4 *)(pTVar13 + 0x2c);
        param_2[1] = uVar2;
        param_2[2] = fVar1 + 18.0;
      }
      if (param_3 != (QAngle *)0x0) {
        *(undefined4 *)param_3 = vec3_angle;
        *(undefined4 *)(param_3 + 4) = DAT_01053d40;
        *(undefined4 *)(param_3 + 8) = DAT_01053d44;
        local_50 = *(undefined4 *)(pTVar13 + 0x2c);
        local_4c = *(undefined4 *)(pTVar13 + 0x30);
        local_48 = *(float *)(pTVar13 + 0x34) + 18.0;
        FindWeaponSpawnLookAtAngles((Vector *)&local_50,param_3);
      }
      if (param_4 != (int *)0x0) {
        *param_4 = (int)pTVar13;
        goto LAB_009012c5;
      }
    }
  }
  else {
    GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::idx =
         GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::idx + 1;
    if (GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::idx < iVar6)
    {
      iVar6 = GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::idx * 4
      ;
    }
    else {
      GetPlayerSpawnPosition(SurvivorCharacterType,Vector*,QAngle*,TerrorNavArea**)::idx = 0;
      iVar6 = 0;
    }
    this_01 = *(CSurvivorPosition **)(*(int *)pCVar14 + iVar6);
    if (this_01 == (CSurvivorPosition *)0x0) goto LAB_009013b3;
LAB_00901219:
    if (param_2 != (undefined4 *)0x0) {
      if (((byte)*(CBaseEntity *)(this_01 + 0x14d) & 8) != 0) {
                    /* try { // try from 009014fb to 0090150c has its CatchHandler @ 0090190e */
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this_01);
      }
      *param_2 = *(undefined4 *)(this_01 + 0x2e0);
      param_2[1] = *(undefined4 *)(this_01 + 0x2e4);
      param_2[2] = *(undefined4 *)(this_01 + 0x2e8);
    }
    if (param_3 != (QAngle *)0x0) {
      if (((byte)*(CBaseEntity *)(this_01 + 0x14d) & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this_01);
      }
      *(undefined4 *)param_3 = *(undefined4 *)(this_01 + 0x37c);
      *(undefined4 *)(param_3 + 4) = *(undefined4 *)(this_01 + 0x380);
      *(undefined4 *)(param_3 + 8) = *(undefined4 *)(this_01 + 900);
    }
    if (param_4 == (int *)0x0) goto LAB_009012c0;
    iVar6 = CNavMesh::GetNearestNavArea(TheNavMesh,(CBaseEntity *)this_01,4,10000.0);
LAB_009012bb:
    *param_4 = iVar6;
  }
LAB_009012c0:
  uVar12 = 1;
LAB_009012c5:
  local_24 = 0;
  CUtlMemory<CSurvivorPosition*,int>::Purge((CUtlMemory<CSurvivorPosition*,int> *)&local_30);
  local_20 = local_30;
  CUtlMemory<CSurvivorPosition*,int>::Purge((CUtlMemory<CSurvivorPosition*,int> *)&local_30);
  local_38 = 0;
  CUtlMemory<CSurvivorPosition*,int>::Purge((CUtlMemory<CSurvivorPosition*,int> *)&local_44);
  local_34 = local_44;
  CUtlMemory<CSurvivorPosition*,int>::Purge((CUtlMemory<CSurvivorPosition*,int> *)&local_44);
  return uVar12;
code_r0x009010c3:
  uVar10 = GetCharacterFromName(pcVar9);
  if ((3 < uVar10 - 4) || (iVar7 != 2)) {
LAB_009010dd:
    if ((iVar6 != 1) || (3 < uVar10)) {
      iVar11 = CSurvivorPosition::GetGameMode(local_64);
      if (iVar11 == 0) {
        iVar11 = CNavMesh::GetNearestNavArea(TheNavMesh,(CBaseEntity *)local_64,0,10000.0);
        if (iVar11 == 0) {
          bVar4 = 0;
        }
        else {
          bVar4 = (byte)(*(uint *)(iVar11 + 300) >> 0xb) & 1;
        }
        if (bVar4 == (bVar3 ^ 1)) {
          CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>>::InsertBefore
                    ((CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>> *)&local_30,
                     local_24,&local_64);
        }
      }
      else {
        pcVar9 = (char *)CSurvivorPosition::GetGameMode(local_64);
        if ((pcVar8 == pcVar9) || (iVar11 = _V_stricmp(pcVar8,pcVar9), iVar11 == 0)) {
          CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>>::InsertBefore
                    ((CUtlVector<CSurvivorPosition*,CUtlMemory<CSurvivorPosition*,int>> *)&local_44,
                     local_38,&local_64);
        }
      }
    }
  }
  goto LAB_00901048;
}

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)