From 02454b9c9058e1e831ec6bfa67550a5d573249cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Wa=C3=9Fill?= Date: Mon, 6 Nov 2023 11:57:40 +0100 Subject: [PATCH] Fix detecting tv_autorecord at game start This will prevent a crash on startup. Also added more logging and simplified the check, no need for a regex here. --- src/eBot/Match/Match.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/eBot/Match/Match.php b/src/eBot/Match/Match.php index 7625fb38..f545294c 100644 --- a/src/eBot/Match/Match.php +++ b/src/eBot/Match/Match.php @@ -2485,12 +2485,18 @@ private function processRoundStart(\eBot\Message\Type\RoundStart $message) if ($this->waitRoundStartRecord) { $record_name = $this->match_id . "_" . \eTools\Utils\Slugify::cleanTeamName($this->teamAName) . "-" . \eTools\Utils\Slugify::cleanTeamName($this->teamBName) . "_" . $this->currentMap->getMapName(); + + // Disable running autorecord to use eBots version. $text = $this->rcon->send("tv_autorecord"); - if (preg_match('!"tv_autorecord" = "(?.*)"!', $text, $match)) { - if ($match["value"] == 1) { - Logger::log("Stopping running records (tv_autorecord)."); - $this->rcon->send("tv_autorecord 0; tv_stoprecord"); - } + Logger::log("Checking for tv_autorecord: " . $text); + // Check if $text contains the desired format + if (strpos($text, "true") !== false) { + // Log a message and stop running records + Logger::log("Stopping running records (tv_autorecord)."); + $this->rcon->send("tv_autorecord 0; tv_stoprecord"); + } + else { + Logger::log("Could not detect a running tv_autorecord."); } Logger::log("Launching record $record_name");