fix match score saving after an error when launching

This commit is contained in:
Beu
2025-06-22 17:57:07 +02:00
parent ebecb7da73
commit 0352d96fdf

View File

@ -715,19 +715,20 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
*/ */
public function resetMatchVariables() { public function resetMatchVariables() {
$this->log("Reset match variables"); $this->log("Reset match variables");
$this->matchStarted = false; $this->matchStarted = false;
$this->matchrecover = false; $this->matchrecover = false;
$this->pauseon = false; $this->pauseon = false;
$this->pointstorecover = array(); $this->pointstorecover = array();
$this->currentscore = array(); $this->currentscore = array();
$this->preendroundscore = null; $this->currentteamsscore = array();
$this->settingsloaded = false; $this->preendroundscore = null;
$this->mapsshuffled = false; $this->settingsloaded = false;
$this->mapshidden = false; $this->mapsshuffled = false;
$this->hidenextmaps = false; $this->mapshidden = false;
$this->maps = array(); $this->hidenextmaps = false;
$this->postmatch = true; $this->maps = array();
$this->matchid = ""; $this->postmatch = false;
$this->matchid = "";
$this->settings_nbroundsbymap = -1; $this->settings_nbroundsbymap = -1;
$this->settings_nbwinners = 2; $this->settings_nbwinners = 2;
@ -1138,6 +1139,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
if (!$this->canStartMatch()) return; if (!$this->canStartMatch()) return;
try { try {
$this->resetMatchVariables();
$this->matchid = $this->maniaControl->getServer()->login . "-" . time(); $this->matchid = $this->maniaControl->getServer()->login . "-" . time();
$this->currentgmbase = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE); $this->currentgmbase = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE);
$this->currentcustomgm = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE); $this->currentcustomgm = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE);
@ -1363,11 +1366,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->log("Match finished"); $this->log("Match finished");
$this->resetMatchVariables(); $this->resetMatchVariables();
$this->postmatch = true;
$this->updateAdminUIMenuItems(); $this->updateAdminUIMenuItems();
// Teams Specifics variables
$this->currentteamsscore = [];
} catch (Exception $e) { } catch (Exception $e) {
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "Can't finish the match: " . $e->getMessage()); $this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "Can't finish the match: " . $e->getMessage());
$this->logError("Can't finish the match: ". $e->getMessage()); $this->logError("Can't finish the match: ". $e->getMessage());
@ -1415,6 +1416,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
} }
$this->resetMatchVariables(); $this->resetMatchVariables();
$this->postmatch = true;
$this->updateAdminUIMenuItems(); $this->updateAdminUIMenuItems();
} catch (Exception $e) { } catch (Exception $e) {
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "Can't stop the match: " . $e->getMessage()); $this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "Can't stop the match: " . $e->getMessage());