@@ -504,83 +504,6 @@ void TournamentRecordTeamWin(Team team) {
504504 game.tournament .seriesComplete = true ;
505505}
506506
507- bool Tournament_ReplayGame (int gameNumber, std::string &message) {
508- if (!Tournament_IsActive ()) {
509- message = " Tournament mode is not active." ;
510- return false ;
511- }
512-
513- if (gameNumber < 1 ) {
514- message = " Replay game number must be at least 1." ;
515- return false ;
516- }
517-
518- if (game.tournament .mapOrder .empty ()) {
519- message = " Tournament map order is not locked yet." ;
520- return false ;
521- }
522-
523- const size_t targetIndex = static_cast <size_t >(gameNumber - 1 );
524- if (targetIndex >= game.tournament .mapOrder .size ()) {
525- message =
526- G_Fmt (" Replay game must be between 1 and {}." ,
527- game.tournament .mapOrder .size ())
528- .data ();
529- return false ;
530- }
531-
532- TournamentEnsureStateForMatch ();
533- if (!game.tournament .active ) {
534- message = " Tournament state is not active." ;
535- return false ;
536- }
537-
538- game.tournament .seriesComplete = false ;
539- game.tournament .gamesPlayed = 0 ;
540- game.tournament .teamWins .fill (0 );
541- game.tournament .playerWins .fill (0 );
542-
543- const size_t available = std::min (targetIndex, game.tournament .matchWinners .size ());
544- for (size_t i = 0 ; i < available; ++i) {
545- const std::string &winner = game.tournament .matchWinners [i];
546- if (game.tournament .teamBased ) {
547- if (winner == " red" ) {
548- game.tournament .teamWins [static_cast <size_t >(Team::Red)] += 1 ;
549- } else if (winner == " blue" ) {
550- game.tournament .teamWins [static_cast <size_t >(Team::Blue)] += 1 ;
551- }
552- } else if (!winner.empty ()) {
553- const size_t slot = TournamentFindOrAssignPlayerSlotById (winner, {});
554- if (slot != kTournamentInvalidSlot ) {
555- game.tournament .playerWins [slot] += 1 ;
556- }
557- }
558- game.tournament .gamesPlayed += 1 ;
559- }
560-
561- if (game.tournament .matchWinners .size () > targetIndex)
562- game.tournament .matchWinners .resize (targetIndex);
563- if (game.tournament .matchIds .size () > targetIndex)
564- game.tournament .matchIds .resize (targetIndex);
565- if (game.tournament .matchMaps .size () > targetIndex)
566- game.tournament .matchMaps .resize (targetIndex);
567-
568- game.tournament .gamesPlayed = static_cast <int >(targetIndex);
569- game.tournament .seriesComplete = false ;
570-
571- const std::string &mapName = game.tournament .mapOrder [targetIndex];
572- if (mapName.empty ()) {
573- message = " Replay map is missing." ;
574- return false ;
575- }
576-
577- gi.LocBroadcast_Print (PRINT_CENTER,
578- " .Tournament replay: game {} will be replayed." ,
579- gameNumber);
580- gi.AddCommandString (G_Fmt (" gamemap {}\n " , mapName).data ());
581- return true ;
582- }
583-
584507int TournamentBestOpponentWins (size_t winnerSlot) {
585508 int best = 0 ;
586509 for (size_t i = 0 ; i < game.maxClients ; ++i) {
@@ -687,6 +610,84 @@ void QueueTournamentIntermission(std::string_view baseMessage,
687610
688611} // namespace
689612
613+ bool Tournament_ReplayGame (int gameNumber, std::string &message) {
614+ if (!Tournament_IsActive ()) {
615+ message = " Tournament mode is not active." ;
616+ return false ;
617+ }
618+
619+ if (gameNumber < 1 ) {
620+ message = " Replay game number must be at least 1." ;
621+ return false ;
622+ }
623+
624+ if (game.tournament .mapOrder .empty ()) {
625+ message = " Tournament map order is not locked yet." ;
626+ return false ;
627+ }
628+
629+ const size_t targetIndex = static_cast <size_t >(gameNumber - 1 );
630+ if (targetIndex >= game.tournament .mapOrder .size ()) {
631+ message =
632+ G_Fmt (" Replay game must be between 1 and {}." ,
633+ game.tournament .mapOrder .size ())
634+ .data ();
635+ return false ;
636+ }
637+
638+ TournamentEnsureStateForMatch ();
639+ if (!game.tournament .active ) {
640+ message = " Tournament state is not active." ;
641+ return false ;
642+ }
643+
644+ game.tournament .seriesComplete = false ;
645+ game.tournament .gamesPlayed = 0 ;
646+ game.tournament .teamWins .fill (0 );
647+ game.tournament .playerWins .fill (0 );
648+
649+ const size_t available =
650+ std::min (targetIndex, game.tournament .matchWinners .size ());
651+ for (size_t i = 0 ; i < available; ++i) {
652+ const std::string &winner = game.tournament .matchWinners [i];
653+ if (game.tournament .teamBased ) {
654+ if (winner == " red" ) {
655+ game.tournament .teamWins [static_cast <size_t >(Team::Red)] += 1 ;
656+ } else if (winner == " blue" ) {
657+ game.tournament .teamWins [static_cast <size_t >(Team::Blue)] += 1 ;
658+ }
659+ } else if (!winner.empty ()) {
660+ const size_t slot = TournamentFindOrAssignPlayerSlotById (winner, {});
661+ if (slot != kTournamentInvalidSlot ) {
662+ game.tournament .playerWins [slot] += 1 ;
663+ }
664+ }
665+ game.tournament .gamesPlayed += 1 ;
666+ }
667+
668+ if (game.tournament .matchWinners .size () > targetIndex)
669+ game.tournament .matchWinners .resize (targetIndex);
670+ if (game.tournament .matchIds .size () > targetIndex)
671+ game.tournament .matchIds .resize (targetIndex);
672+ if (game.tournament .matchMaps .size () > targetIndex)
673+ game.tournament .matchMaps .resize (targetIndex);
674+
675+ game.tournament .gamesPlayed = static_cast <int >(targetIndex);
676+ game.tournament .seriesComplete = false ;
677+
678+ const std::string &mapName = game.tournament .mapOrder [targetIndex];
679+ if (mapName.empty ()) {
680+ message = " Replay map is missing." ;
681+ return false ;
682+ }
683+
684+ gi.LocBroadcast_Print (PRINT_CENTER,
685+ " .Tournament replay: game {} will be replayed." ,
686+ gameNumber);
687+ gi.AddCommandString (G_Fmt (" gamemap {}\n " , mapName).data ());
688+ return true ;
689+ }
690+
690691void Marathon_RegisterClientBaseline (gclient_t *cl) {
691692 if (!cl || !game.marathon .active )
692693 return ;
0 commit comments