L L4D2node

CDirector::Restart

0x008875e0 · 1811 bytes · __thiscall

_ZN9CDirector7RestartEv

Decompiled

undefined (1 param)

/* CDirector::Restart() */

void __thiscall CDirector::Restart(CDirector *this)

{
  CTerrorPlayer *this_00;
  bool bVar1;
  bool bVar2;
  bool bVar3;
  char cVar4;
  char *pcVar5;
  CBaseEntity *this_01;
  int iVar6;
  KeyValues *this_02;
  Checkpoint *this_03;
  int iVar7;
  byte bVar8;
  int in_GS_OFFSET;
  byte bVar9;
  char local_c1;
  RestartCleanup local_b5;
  undefined4 local_b4;
  undefined4 local_b0;
  undefined1 local_ac;
  int local_a8;
  undefined4 local_a4;
  char *local_a0;
  undefined1 local_9c;
  undefined4 local_98;
  undefined4 local_94;
  char *local_90;
  uint local_8c;
  undefined4 local_88;
  undefined4 local_84;
  undefined4 local_80;
  uint local_7c;
  int local_78;
  int local_74 [5];
  char local_60 [32];
  char local_40 [32];
  int local_20;
  
  bVar9 = 0;
  bVar8 = 1;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  cVar4 = IsFirstMapInScenario();
  if (cVar4 == '\0') {
    bVar8 = (byte)this[0x28e] ^ 1;
  }
  if ((*(int *)(this + 0x284) == 1) && (*(int *)(sv_permawipe._28_4_ + 0x30) == 0)) {
    bVar2 = false;
    local_c1 = '\x01';
  }
  else {
    ForEachTerrorPlayer<DispatchPlayerReportFlush>((DispatchPlayerReportFlush *)&local_84);
    bVar2 = true;
    local_c1 = '\x01';
    if (bVar8 == 0) {
      local_c1 = CTerrorGameRules::IsSurvivalMode();
    }
  }
  HideScoreboard(this);
  local_b0 = 0xffffffff;
  local_ac = 0;
  local_a8 = 0;
  local_b4 = 0xffffffff;
  ForEachPlayer<PlayerCounter>((PlayerCounter *)&local_b4);
  iVar7 = local_a8;
  local_a4 = 0xffffffff;
  local_a0 = "info_window";
  local_9c = 0;
  local_98 = 0;
  ForEachTerrorPlayer<CShowViewportPanel>((CShowViewportPanel *)&local_a4);
  if ((iVar7 == 0) || (cVar4 = CTerrorGameRules::HasPlayerControlledZombies(), cVar4 == '\0')) {
    bVar3 = false;
LAB_008876cf:
    if (*(int *)(sv_permawipe._28_4_ + 0x30) == 0) {
      cVar4 = CTerrorGameRules::IsSurvivalMode();
      if (cVar4 != '\0') {
        local_94 = 0xffffffff;
        local_90 = "fullscreen_survival_scoreboard";
        local_8c = local_8c & 0xffffff00;
        local_88 = 0;
        ForEachTerrorPlayer<CShowViewportPanel>((CShowViewportPanel *)&local_94);
        local_80 = 2;
        local_7c = local_7c & 0xffffff00;
        local_78 = 0;
        local_84 = 0xffffffff;
        ForEachPlayer<PlayerCounter>((PlayerCounter *)&local_84);
        if ((local_78 < 1) && (*(int *)(AllowAllBotGame._28_4_ + 0x30) == 0)) goto LAB_008876db;
      }
      pcVar5 = (char *)GetTransitionedLandmarkName();
      V_strncpy(local_60,pcVar5,0x20);
      local_94 = vec3_origin;
      local_90 = DAT_01053d4c;
      local_8c = DAT_01053d50;
      this_01 = (CBaseEntity *)
                CGlobalEntityList::FindEntityByName
                          ((CGlobalEntityList *)gEntList,(CBaseEntity *)0x0,local_60,
                           (CBaseEntity *)0x0,(CBaseEntity *)0x0,(CBaseEntity *)0x0,
                           (IEntityFindFilter *)0x0);
      if (this_01 != (CBaseEntity *)0x0) {
        if (((byte)this_01[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_01);
        }
        local_94 = *(undefined4 *)(this_01 + 0x2e0);
        local_90 = *(char **)(this_01 + 0x2e4);
        local_8c = *(uint *)(this_01 + 0x2e8);
      }
      ClearTransitionedLandmarkName();
      ForEachTerrorPlayer<RestartCleanup>(&local_b5);
      pcVar5 = local_40;
      for (iVar7 = 8; iVar7 != 0; iVar7 = iVar7 + -1) {
        pcVar5[0] = '\0';
        pcVar5[1] = '\0';
        pcVar5[2] = '\0';
        pcVar5[3] = '\0';
        pcVar5 = pcVar5 + (uint)bVar9 * -8 + 4;
      }
      if (local_c1 == '\0') {
        V_strncpy(local_40,(char *)(this + 0x3b4),0x20);
        UTIL_LogPrintf("Reloading original map %s\n",local_40);
        (**(code **)(*(int *)this + 0x28))(this,0);
        (**(code **)(*(int *)g_pGameRules + 0x9c))(g_pGameRules,local_40);
        DirectorChangelevel((char *)this,local_40);
        goto LAB_008876e3;
      }
      this[0x28f] = (CDirector)0x1;
      if (bVar2) {
        UTIL_LogPrintf("Staying on original map %s\n",this + 0x3b4);
        this[0x28e] = (CDirector)0x0;
      }
      else {
        m_isTransitioning = 1;
        this[0x28e] = (CDirector)0x1;
      }
      this[0x28c] = (CDirector)0x1;
      CDirectorChallengeMode::ShutdownScriptedMode
                (*(CDirectorChallengeMode **)(this + 0x648),2 - (uint)!bVar3,&DAT_00d539c2);
      (**(code **)(*(int *)g_pGameRules + 0x2cc))(g_pGameRules);
      m_isTransitioning = 0;
      cVar4 = CTerrorGameRules::HasPlayerControlledZombies();
      if (cVar4 == '\0') {
        if (*(int *)(this + 0x284) == 1) {
          if (bVar8 == 0) {
            local_74[0] = 0;
            local_74[1] = 0;
            local_74[2] = 0;
            local_74[3] = 0;
            local_74[4] = 0;
            local_84 = 2;
            local_80 = 2;
            local_7c = 3;
            local_78 = 9;
                    /* try { // try from 00887c5f to 00887cdb has its CatchHandler @ 00887d31 */
            ForEachPlayer<PlayerCollector>((PlayerCollector *)&local_84);
            SetTransitionedLandmark(local_60,(Vector *)&local_94);
            if (0 < local_74[3]) {
              iVar7 = 0;
              do {
                this_00 = *(CTerrorPlayer **)(local_74[0] + iVar7 * 4);
                CTerrorPlayer::SetTransitioned(this_00,true);
                CTerrorPlayer::TransitionRestore(this_00);
                iVar7 = iVar7 + 1;
              } while (iVar7 < local_74[3]);
            }
            SetTransitionedLandmark(local_60,(Vector *)&local_94);
            this_03 = (Checkpoint *)TerrorNavMesh::GetInitialCheckpoint(TheNavMesh);
            if (this_03 != (Checkpoint *)0x0) {
              Checkpoint::RespawnSurvivors(this_03);
            }
            local_74[3] = 0;
            CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_74);
            local_74[4] = local_74[0];
            CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_74);
            if (*(int *)(this + 0x284) != 4) goto LAB_00887d09;
          }
LAB_008878df:
          SetNeedToRestoreTransitionedEntities(false);
        }
        else {
          if ((*(int *)(this + 0x284) == 4) || (bVar8 != 0)) goto LAB_008878df;
LAB_00887d09:
          SetNeedToRestoreTransitionedEntities(true);
        }
        RestoreTransitionedEntities();
      }
      (**(code **)(*(int *)this + 0x40))(this);
      CDirectorScriptedEventManager::OnRestartMap(*(CDirectorScriptedEventManager **)(this + 0x638))
      ;
      this[0x28c] = (CDirector)0x0;
      this[0x28f] = (CDirector)0x0;
      goto LAB_008876e3;
    }
  }
  else {
    if ((*(int *)(this + 0x284) == 0x12) && (cVar4 = AreTeamsFlipped(this), cVar4 == '\0')) {
      bVar3 = false;
    }
    else {
      bVar3 = true;
    }
    if (this[0x4e6] == (CDirector)0x0) {
      bVar1 = false;
      local_c1 = '\x01';
    }
    else {
      bVar1 = true;
      if (*(int *)(versus_winning_team_goes_last._28_4_ + 0x30) != 0) {
        bVar1 = true;
        iVar7 = CTerrorGameRules::GetVersusTeamFor(g_pGameRules,2);
        iVar7 = CTerrorGameRules::GetTeamScore(g_pGameRules,iVar7,true);
        iVar6 = CTerrorGameRules::GetVersusTeamFor(g_pGameRules,3);
        iVar6 = CTerrorGameRules::GetTeamScore(g_pGameRules,iVar6,true);
        if (iVar6 < iVar7) {
          bVar3 = false;
        }
      }
    }
    if ((*(int *)(this + 0x284) == 0x12) ||
       (cVar4 = CTerrorGameRules::IsScavengeMode(), cVar4 == '\0')) {
LAB_008879a8:
      if (bVar3) {
        SwapTeams(this);
      }
    }
    else {
      iVar7 = CTerrorGameRules::GetWinningTeamNumber(g_pGameRules,-1);
      iVar6 = CTerrorGameRules::GetVersusTeamFor(g_pGameRules,3);
      if (iVar7 != iVar6) goto LAB_008879a8;
      bVar3 = false;
    }
    if (!bVar1) goto LAB_008876cf;
    this_02 = (KeyValues *)CTerrorGameRules::GetMissionNextMap((KeyValues **)0x0);
    if (this_02 != (KeyValues *)0x0) {
      pcVar5 = (char *)KeyValues::GetString(this_02,"map","");
      (**(code **)(*(int *)this + 0x28))(this,0);
      (**(code **)(*(int *)g_pGameRules + 0x9c))(g_pGameRules,pcVar5);
      DirectorChangelevel((char *)this,pcVar5);
      goto LAB_008876e3;
    }
  }
LAB_008876db:
  FinishScenarioExit(this);
LAB_008876e3:
  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)