L L4D2node

CDirector::UpdateTestLoop

0x00875fe0 · 2175 bytes · __thiscall

_ZN9CDirector14UpdateTestLoopEv

Decompiled

undefined (1 param)

/* CDirector::UpdateTestLoop() */

void __thiscall CDirector::UpdateTestLoop(CDirector *this)

{
  code *pcVar1;
  float fVar2;
  char cVar3;
  char *pcVar4;
  int iVar5;
  int iVar6;
  CBaseEntity *pCVar7;
  char *pcVar8;
  int *piVar9;
  undefined **ppuVar10;
  undefined4 *puVar11;
  int in_GS_OFFSET;
  longdouble lVar12;
  undefined4 auStack_218 [57];
  char local_131 [3];
  char local_12e;
  CFmtStrN<256> local_12c [5];
  undefined1 local_127 [263];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (*(int *)(director_test_loop._28_4_ + 0x30) == 3) {
    ppuVar10 = &PTR_DAT_00ce0b00;
    puVar11 = auStack_218 + 1;
    for (iVar5 = 0x38; iVar5 != 0; iVar5 = iVar5 + -1) {
      *puVar11 = *ppuVar10;
      ppuVar10 = ppuVar10 + 1;
      puVar11 = puVar11 + 1;
    }
    if (*(int *)(gpGlobals + 0x54) != UpdateTestLoop()::lastServerCount) {
      UpdateTestLoop()::lastServerCount = *(int *)(gpGlobals + 0x54);
      lVar12 = (longdouble)Plat_FloatTime();
      UpdateTestLoop()::timeToChange = (float)((double)lVar12 + 15.0);
    }
    fVar2 = UpdateTestLoop()::timeToChange;
    lVar12 = (longdouble)Plat_FloatTime();
    if (fVar2 < (float)lVar12) {
      iVar5 = 1;
      UpdateTestLoop()::timeToChange = 3.4028235e+38;
      (**(code **)(*engine + 0x94))(engine,"mem_dump\n");
      do {
        pcVar4 = "";
        if (*(char **)(gpGlobals + 0x3c) != (char *)0x0) {
          pcVar4 = *(char **)(gpGlobals + 0x3c);
        }
        iVar6 = V_strncmp(pcVar4,(char *)auStack_218[iVar5],4);
        if (iVar6 == 0) {
          pcVar1 = *(code **)(*engine + 0x94);
          CFmtStrN<256>::CFmtStrN(local_12c,"changelevel %s\n",(auStack_218 + 1)[iVar5]);
          (*pcVar1)(engine,local_127);
        }
        iVar5 = iVar5 + 1;
      } while (iVar5 != 0x38);
    }
  }
  else if (*(int *)(director_test_loop._28_4_ + 0x30) == 0) {
    if (UpdateTestLoop()::bInLoop != '\0') {
      UpdateTestLoop()::bInLoop = '\0';
      UpdateTestLoop()::timeLastTransition = -999.0;
      iVar5 = UTIL_GetListenServerHost();
      if (iVar5 != 0) {
        (**(code **)(*engine + 0x9c))(engine,*(undefined4 *)(iVar5 + 0x30),"jointeam survivor\n");
      }
      (**(code **)(*engine + 0x94))(engine,"host_timescale 1\n");
      (**(code **)(*engine + 0x94))(engine,"mem_test_every_n_seconds 0\n");
      (**(code **)(*engine + 0x94))(engine,"sb_all_bot_game 0\n");
      (**(code **)(*engine + 0x94))(engine,"allow_all_bot_survivor_team 0\n");
      (**(code **)(*engine + 0x94))(engine,"sb_all_bot_game 0\n");
    }
  }
  else {
    if ((UpdateTestLoop()::bInLoop == '\0') &&
       (lVar12 = (longdouble)Plat_FloatTime(),
       20.0 < (float)lVar12 - UpdateTestLoop()::timeLastTransition)) {
      (**(code **)(*engine + 0x94))(engine,"sb_all_bot_game 1\n");
      (**(code **)(*engine + 0x94))(engine,"allow_all_bot_survivor_team 1\n");
      (**(code **)(*engine + 0x94))(engine,"host_timescale 2.5\n");
      (**(code **)(*engine + 0x94))(engine,"mem_test_every_n_seconds 30\n");
      (**(code **)(*engine + 0x94))(engine,"think_limit 999\n");
      (**(code **)(*engine + 0x94))(engine,"memorylog_tick 20\n");
      (**(code **)(*engine + 0x94))(engine,"memorylog_mem_dump 1\n");
      if (*(int *)(director_test_loop._28_4_ + 0x30) < 2) {
        (**(code **)(*engine + 0x94))(engine,"developer 1\n");
      }
      else {
        (**(code **)(*engine + 0x94))(engine,"sv_logfile 0\n");
        (**(code **)(*engine + 0x94))(engine,"log on\n");
        (**(code **)(*engine + 0x94))(engine,"developer 2\n");
      }
      UpdateTestLoop()::timeLastForcedSpectator = -99.0;
      if (0 < *(int *)(gpGlobals + 0x14)) {
        iVar5 = 1;
        do {
          pCVar7 = (CBaseEntity *)UTIL_PlayerByIndex(iVar5);
          if (((((pCVar7 != (CBaseEntity *)0x0) && (*(int *)(pCVar7 + 0x30) != 0)) &&
               (*(int *)(pCVar7 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4 != 0)) &&
              ((cVar3 = (**(code **)(*(int *)pCVar7 + 0x16c))(pCVar7), cVar3 != '\0' &&
               (*(int *)(pCVar7 + 0x1f6c) != 2)))) &&
             ((iVar6 = CBaseEntity::GetTeamNumber(pCVar7), iVar6 == 2 &&
              (cVar3 = (**(code **)(*(int *)pCVar7 + 0x778))(pCVar7), cVar3 != '\0')))) {
            piVar9 = (int *)(**(code **)(*(int *)pCVar7 + 0x9a8))(pCVar7);
            (**(code **)(*piVar9 + 0xa4))(piVar9);
          }
          iVar5 = iVar5 + 1;
        } while (iVar5 <= *(int *)(gpGlobals + 0x14));
      }
      UpdateTestLoop()::bInLoop = '\x01';
    }
    pcVar4 = *(char **)(gpGlobals + 0x3c);
    if (pcVar4 == (char *)0x0) {
      pcVar4 = "";
    }
    iVar5 = _V_strcmp(UpdateTestLoop()::szLastMap,pcVar4);
    if (iVar5 != 0) {
      lVar12 = (longdouble)Plat_FloatTime();
      UpdateTestLoop()::iSaferoomAttempts = 0;
      pcVar4 = *(char **)(gpGlobals + 0x3c);
      UpdateTestLoop()::timeLastTransition = (float)lVar12;
      UpdateTestLoop()::timeLastForcedSpectator = UpdateTestLoop()::timeLastTransition - 5.0;
      if (pcVar4 == (char *)0x0) {
        pcVar4 = "";
      }
      V_strncpy(UpdateTestLoop()::szLastMap,pcVar4,0x100);
    }
    lVar12 = (longdouble)Plat_FloatTime();
    if (5.0 < (float)lVar12 - UpdateTestLoop()::timeLastForcedSpectator) {
      lVar12 = (longdouble)Plat_FloatTime();
      UpdateTestLoop()::timeLastForcedSpectator = (float)lVar12;
      if (0 < *(int *)(gpGlobals + 0x14)) {
        iVar5 = 1;
        do {
          pCVar7 = (CBaseEntity *)UTIL_PlayerByIndex(iVar5);
          if ((((pCVar7 != (CBaseEntity *)0x0) && (*(int *)(pCVar7 + 0x30) != 0)) &&
              ((*(int *)(pCVar7 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4 != 0 &&
               (((cVar3 = (**(code **)(*(int *)pCVar7 + 0x16c))(pCVar7), cVar3 != '\0' &&
                 (*(int *)(pCVar7 + 0x1f6c) != 2)) &&
                (iVar6 = CBaseEntity::GetTeamNumber(pCVar7), iVar6 == 2)))))) &&
             (cVar3 = (**(code **)(*(int *)pCVar7 + 0x778))(pCVar7), cVar3 == '\0')) {
            (**(code **)(*engine + 0x9c))
                      (engine,*(undefined4 *)(pCVar7 + 0x30),"jointeam spectator\n");
          }
          iVar5 = iVar5 + 1;
        } while (iVar5 <= *(int *)(gpGlobals + 0x14));
      }
    }
    lVar12 = (longdouble)Plat_FloatTime();
    if ((*(float *)(director_test_loop_time._28_4_ + 0x2c) * 60.0 <
         (float)lVar12 - UpdateTestLoop()::timeLastTransition) || (0.0 < *(float *)(this + 0x27c)))
    {
      lVar12 = (longdouble)Plat_FloatTime();
      iVar5 = 0;
      UpdateTestLoop()::timeLastForcedSpectator = 3.4028235e+38;
      UpdateTestLoop()::timeLastTransition = (float)lVar12;
      (**(code **)(*engine + 0x94))(engine,"mem_dump\n");
      do {
        pcVar4 = *(char **)(gpGlobals + 0x3c);
        if (pcVar4 == (char *)0x0) {
          pcVar4 = "";
        }
        iVar6 = _V_strcmp((&UpdateTestLoop()::loopOrder)[iVar5 * 2],pcVar4);
        if (iVar6 == 0) {
          UpdateTestLoop()::bInLoop = '\0';
          if ((*(int *)(director_test_loop_rotate_maps._28_4_ + 0x30) == 0) ||
             (UpdateTestLoop()::iNumRestarts <
              *(int *)(director_test_loop_restarts_before_rotate._28_4_ + 0x30))) {
            UpdateTestLoop()::iNumRestarts = UpdateTestLoop()::iNumRestarts + 1;
            (**(code **)(*engine + 0x94))(engine,"mp_restartgame 1\n");
          }
          else {
            pcVar4 = "c2m1_highway";
            iVar5 = 0;
            UpdateTestLoop()::iNumRestarts = 0;
            do {
              pcVar8 = *(char **)(gpGlobals + 0x3c);
              if (pcVar8 == (char *)0x0) {
                pcVar8 = "";
              }
              iVar6 = _V_strcmp((&UpdateTestLoop()::loopOrder)[iVar5 * 2],pcVar8);
              if (iVar6 == 0) {
                pcVar4 = (&PTR_s_c2m1_highway_00ce0f44)[iVar5 * 2];
              }
              iVar5 = iVar5 + 1;
            } while (iVar5 != 0xd);
            pcVar1 = *(code **)(*engine + 0x94);
            CFmtStrN<256>::CFmtStrN(local_12c,"map %s\n",pcVar4);
            (*pcVar1)(engine,local_127);
          }
          goto LAB_0087620d;
        }
        iVar5 = iVar5 + 1;
      } while (iVar5 != 0xd);
      UpdateTestLoop()::iSaferoomAttempts = UpdateTestLoop()::iSaferoomAttempts + 1;
      if (UpdateTestLoop()::iSaferoomAttempts < 2) {
        (**(code **)(*engine + 0x94))(engine,"warp_all_survivors_to_checkpoint\n");
      }
      else {
        Msg("Survivors haven\'t closed the saferoom door?\n");
        pcVar4 = "";
        if (*(char **)(gpGlobals + 0x3c) != (char *)0x0) {
          pcVar4 = *(char **)(gpGlobals + 0x3c);
        }
        V_strncpy(local_131,pcVar4,5);
        local_12e = local_12e + '\x01';
        pcVar1 = *(code **)(*engine + 0x94);
        CFmtStrN<256>::CFmtStrN(local_12c,"map %s\n",local_131);
        (*pcVar1)(engine,local_127);
      }
      pcVar4 = "";
      if (*(char **)(gpGlobals + 0x3c) != (char *)0x0) {
        pcVar4 = *(char **)(gpGlobals + 0x3c);
      }
      V_strncpy(UpdateTestLoop()::szLastMap,pcVar4,0x100);
    }
  }
LAB_0087620d:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)