L L4D2node

CTerrorPlayer::ShouldPostThink

0x009ca010 · 589 bytes · __thiscall

_ZN13CTerrorPlayer15ShouldPostThinkEv

Decompiled

undefined (1 param)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CTerrorPlayer::ShouldPostThink() */

CTerrorPlayer __thiscall CTerrorPlayer::ShouldPostThink(CTerrorPlayer *this)

{
  int *piVar1;
  float fVar2;
  CTerrorPlayer CVar3;
  int iVar4;
  CTerrorPlayer *pCVar5;
  int iVar6;
  uint uVar7;
  int iVar8;
  int iVar9;
  ushort uVar10;
  bool bVar11;
  float fVar12;
  float fVar13;
  
  iVar6 = g_TerrorPlayerPostThinkQueue;
  iVar9 = gpGlobals;
  if (*(int *)(tp_schedule_post_think._28_4_ + 0x30) == 0) {
    return (CTerrorPlayer)0x1;
  }
  iVar4 = *(int *)(gpGlobals + 4);
  if (iVar4 != ShouldPostThink()::iFrameLastScheduledPostThink) {
    fVar2 = *(float *)(gpGlobals + 0x1c);
    fVar13 = (float)(int)(0.1 / fVar2 + 0.5);
    fVar12 = (float)g_nTerrorPlayers / fVar13;
    iVar8 = (int)fVar12;
    if ((float)iVar8 < fVar12) {
      iVar8 = iVar8 + 1;
    }
    uVar7 = (uint)DAT_01017334;
    ShouldPostThink()::iFrameLastScheduledPostThink = iVar4;
    if (iVar8 == 0) {
LAB_009ca096:
      iVar6 = g_TerrorPlayerPostThinkQueue;
      if (uVar7 != 0xffff) {
        piVar1 = (int *)(g_TerrorPlayerPostThinkQueue + uVar7 * 8);
        iVar4 = *piVar1;
        fVar12 = *(float *)(iVar9 + 0xc) - *(float *)(iVar4 + 0x3fac);
        while ((fVar2 + fVar2) * fVar13 < fVar12) {
          *(undefined1 *)(iVar4 + 0x3fb0) = 1;
          if (*(ushort *)((int)piVar1 + 6) == 0xffff) break;
          piVar1 = (int *)(iVar6 + (uint)*(ushort *)((int)piVar1 + 6) * 8);
          iVar4 = *piVar1;
          fVar12 = *(float *)(iVar9 + 0xc) - *(float *)(iVar4 + 0x3fac);
        }
      }
    }
    else if (uVar7 != 0xffff) {
      do {
        piVar1 = (int *)(iVar6 + uVar7 * 8);
        iVar8 = iVar8 + -1;
        *(undefined1 *)(*piVar1 + 0x3fb0) = 1;
        uVar7 = (uint)*(ushort *)((int)piVar1 + 6);
        if (iVar8 == 0) goto LAB_009ca096;
      } while (uVar7 != 0xffff);
      CVar3 = this[0x3fb0];
      uVar10 = DAT_01017334;
      goto joined_r0x009ca0fc;
    }
  }
  CVar3 = this[0x3fb0];
  uVar10 = DAT_01017334;
joined_r0x009ca0fc:
  DAT_01017334 = uVar10;
  if (CVar3 != (CTerrorPlayer)0x0) {
    *(undefined4 *)(this + 0x3fac) = *(undefined4 *)(iVar9 + 0xc);
    this[0x3fb0] = (CTerrorPlayer)0x0;
    if (uVar10 == 0xffff) {
      iVar9 = 0x7fff8;
      uVar10 = 0xffff;
    }
    else {
      iVar9 = (uint)uVar10 * 8;
      piVar1 = (int *)(g_TerrorPlayerPostThinkQueue + iVar9);
      pCVar5 = (CTerrorPlayer *)*piVar1;
      while (this != pCVar5) {
        uVar10 = *(ushort *)((int)piVar1 + 6);
        if (uVar10 == 0xffff) {
          iVar9 = 0x7fff8;
          uVar10 = 0xffff;
          break;
        }
        iVar9 = (uint)uVar10 * 8;
        piVar1 = (int *)(g_TerrorPlayerPostThinkQueue + iVar9);
        pCVar5 = (CTerrorPlayer *)*piVar1;
      }
    }
    CUtlLinkedList<CTerrorPlayer*,unsigned_short,false,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CTerrorPlayer*,unsigned_short>,unsigned_short>>
    ::Unlink((CUtlLinkedList<CTerrorPlayer*,unsigned_short,false,unsigned_short,CUtlMemory<UtlLinkedListElem_t<CTerrorPlayer*,unsigned_short>,unsigned_short>>
              *)&g_TerrorPlayerPostThinkQueue,uVar10);
    iVar6 = g_TerrorPlayerPostThinkQueue;
    iVar9 = iVar9 + g_TerrorPlayerPostThinkQueue;
    *(undefined2 *)(iVar9 + 6) = 0xffff;
    uVar7 = (uint)DAT_01017336;
    bVar11 = DAT_01017336 != 0xffff;
    *(ushort *)(iVar9 + 4) = DAT_01017336;
    DAT_01017336 = uVar10;
    if (bVar11) {
      *(ushort *)(iVar6 + 6 + uVar7 * 8) = uVar10;
      uVar10 = DAT_01017334;
    }
    DAT_01017334 = uVar10;
    _DAT_0101733a = _DAT_0101733a + 1;
  }
  return CVar3;
}

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)