fix once again the nbround

This commit is contained in:
Beu 2023-10-16 22:53:47 +02:00
parent c664cc08ce
commit 89ce4f0d61
1 changed files with 15 additions and 19 deletions

View File

@ -442,7 +442,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_SCORES, $this, 'handleTrackmaniaScore');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTROUNDSTART, $this, 'handleBeginRoundCallback');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_ENDROUNDEND, $this, 'handleEndRoundCallback');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_WARMUPSTARTROUND, $this, 'handleStartWarmUpCallback');
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTMATCHSTART, $this, 'handleStartMatchStartCallback');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BEGINMAP, $this, 'handleBeginMapCallback');
@ -456,21 +455,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->maniaControl->getCommunicationManager()->registerCommunicationListener("Match.GetMatchOptions", $this, function () { return new CommunicationAnswer($this->getGMSettings($this->currentgmbase,$this->currentcustomgm)); });
}
public function handleEndRoundCallback(StartEndStructure $structure) {
Logger::log("handleEndRoundCallback");
if (defined("\ManiaControl\ManiaControl::ISTRACKMANIACONTROL") && method_exists($structure, "getValidRoundCount")) {
$this->nbrounds = $structure->getValidRoundCount();
} else if (property_exists($structure->getPlainJsonObject(), "valid")) {
$this->nbrounds = $structure->getPlainJsonObject()->valid;
} else {
$this->nbrounds = $structure->getCount();
}
Logger::log("Rounds finished: " . $this->nbrounds);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
}
/**
* @see \ManiaControl\Plugins\Plugin::unload()
*/
@ -1523,10 +1507,19 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
/**
* Handle callback "BeginRound"
*/
public function handleBeginRoundCallback() {
public function handleBeginRoundCallback(StartEndStructure $structure) {
Logger::log("handleBeginRoundCallback");
if ($this->matchStarted && $this->nbmaps > 0) {
if (defined("\ManiaControl\ManiaControl::ISTRACKMANIACONTROL") && method_exists($structure, "getValidRoundCount")) {
$this->nbrounds = $structure->getValidRoundCount();
} else if (property_exists($structure->getPlainJsonObject(), "valid")) {
$this->nbrounds = $structure->getPlainJsonObject()->valid;
} else {
$this->nbrounds = $structure->getCount();
}
if (in_array($this->currentgmbase, ["Cup", "Teams", "Rounds"])) {
$this->maniaControl->getModeScriptEventManager()->getPauseStatus()->setCallable(function (StatusCallbackStructure $structure) {
if ($structure->getActive()) {
@ -1534,8 +1527,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
Logger::log("Pause");
} else {
if ($this->settings_nbroundsbymap > 1) {
$this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
Logger::log("Round: " . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
$this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
Logger::log("Round: " . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
}
}
});
@ -1704,6 +1697,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
trigger_error($mysqli->error);
}
}
Logger::log("Rounds finished: " . $this->nbrounds);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
}
}
return true;