From e4001e98f897b3e60f121bb739a6a43d663989d4 Mon Sep 17 00:00:00 2001 From: Julien Pardons Date: Thu, 12 Oct 2023 09:50:56 +0200 Subject: [PATCH] Fix backup round --- src/eBot/Application/Application.php | 6 +++++- src/eBot/Match/Match.php | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/eBot/Application/Application.php b/src/eBot/Application/Application.php index 9276e06b..0c8279f5 100644 --- a/src/eBot/Application/Application.php +++ b/src/eBot/Application/Application.php @@ -98,6 +98,7 @@ public function run() ); $time = time(); + $timePub = time(); while (true) { $ip = ""; @@ -304,7 +305,10 @@ public function run() } //if ($nbMessage < 100) { - \eBot\Manager\MatchManager::getInstance()->sendPub(); + if ($timePub + 1 < time()) { + $timePub = time(); + \eBot\Manager\MatchManager::getInstance()->sendPub(); + } \eTools\Task\TaskManager::getInstance()->runTask(); //} } diff --git a/src/eBot/Match/Match.php b/src/eBot/Match/Match.php index 2e9cf14b..e2f71e17 100644 --- a/src/eBot/Match/Match.php +++ b/src/eBot/Match/Match.php @@ -582,6 +582,7 @@ public function taskExecute($name) { if ($name == self::SET_LIVE) { $this->addLog("Setting live."); + $this->pendingContinueMatch = false; $this->enable = true; } else if ($name == self::TASK_ENGAGE_MAP) { $tvTimeRemaining = $this->rcon->send("tv_time_remaining"); @@ -718,7 +719,7 @@ private function isMatchRound() public function sendRotateMessage() { // This is to send to players the status - if ($this->isMatchRound() && !$this->enable) { + if ($this->isMatchRound() && !$this->enable && !$this->pendingContinueMatch) { if (time() - $this->lastMessage >= 8) { $this->say("Match is paused, write !continue to continue the match."); $teamA = strtoupper($this->side['team_a']); @@ -1755,7 +1756,7 @@ private function processRoundScored(\eBot\Message\Type\RoundScored $message) } $data = $this->rcon->send("mp_backup_round_file_last"); - if (preg_match('!"mp_backup_round_file_last" = "(?[a-zA-Z0-9\-_\.]+)"!', $data, $match)) { + if (preg_match('!mp_backup_round_file_last = (?[a-zA-Z0-9\-_\.]+)!', $data, $match)) { $backupFile = "'" . $match["backup"] . "'"; } else { $backupFile = 'NULL'; @@ -2778,7 +2779,7 @@ private function continueMatch() if ($this->continue["ct"] && $this->continue["t"]) { $this->continue["ct"] = false; $this->continue["t"] = false; - + $this->pendingContinueMatch = true; $this->addMatchLog("Getting back to the match."); $this->addLog("Getting back to the match."); @@ -3369,9 +3370,12 @@ public function adminStopBack() } } + private $pendingContinueMatch = false; + public function adminGoBackRounds($round) { $this->enable = false; + $this->pendingContinueMatch = true; $sql = mysqli_query(Application::getInstance()->db, "SELECT * FROM round_summary WHERE match_id = '" . $this->match_id . "' AND map_id = '" . $this->currentMap->getMapId() . "' AND round_id = $round"); $req = mysqli_fetch_array($sql);