Skip to content

Commit

Permalink
Fix backup round
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Pardons committed Oct 12, 2023
1 parent 8ba7ce6 commit e4001e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/eBot/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function run()
);

$time = time();
$timePub = time();
while (true) {
$ip = "";

Expand Down Expand Up @@ -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();
//}
}
Expand Down
10 changes: 7 additions & 3 deletions src/eBot/Match/Match.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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" = "(?<backup>[a-zA-Z0-9\-_\.]+)"!', $data, $match)) {
if (preg_match('!mp_backup_round_file_last = (?<backup>[a-zA-Z0-9\-_\.]+)!', $data, $match)) {
$backupFile = "'" . $match["backup"] . "'";
} else {
$backupFile = 'NULL';
Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e4001e9

Please sign in to comment.