Compare commits

..

No commits in common. "8736c183d1c665df32789d77f6bd6d5b19c0dea0" and "95613535c5471d644c8efe2a471d5e1df893963d" have entirely different histories.

View File

@ -37,7 +37,7 @@ use ManiaControl\Callbacks\TimerListener; // for pause
class MatchManagerCore implements CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin { class MatchManagerCore implements CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
const PLUGIN_ID = 152; const PLUGIN_ID = 152;
const PLUGIN_VERSION = 4.2; const PLUGIN_VERSION = 4.0;
const PLUGIN_NAME = 'MatchManager Core'; const PLUGIN_NAME = 'MatchManager Core';
const PLUGIN_AUTHOR = 'Beu'; const PLUGIN_AUTHOR = 'Beu';
@ -321,8 +321,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
private $settings_pointlimit = 100; private $settings_pointlimit = 100;
private $currentscore = array(); private $currentscore = array();
/** @var OnScoresStructure|null $preendroundscore */ private $preendroundscore = array();
private $preendroundscore = null;
private $currentteamsscore = array(); private $currentteamsscore = array();
private $pausetimer = 0; private $pausetimer = 0;
private $pauseon = false; private $pauseon = false;
@ -477,7 +476,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
`matchid` VARCHAR(100) NOT NULL, `matchid` VARCHAR(100) NOT NULL,
`timestamp` INT(10) NOT NULL, `timestamp` INT(10) NOT NULL,
`rank` INT(4) NOT NULL, `rank` INT(4) NOT NULL,
`login` VARCHAR(36) NOT NULL, `login` VARCHAR(30) NOT NULL,
`matchpoints` INT(10) NOT NULL, `matchpoints` INT(10) NOT NULL,
`mappoints` INT(10) NOT NULL, `mappoints` INT(10) NOT NULL,
`roundpoints` INT(10) NOT NULL, `roundpoints` INT(10) NOT NULL,
@ -536,20 +535,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
if ($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error, E_USER_ERROR); trigger_error($mysqli->error, E_USER_ERROR);
} }
$query = 'IF NOT EXISTS( SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE `table_name` = "' . self::DB_ROUNDSDATA . '"
AND `table_schema` = "' . $mysqliconfig->name . '"
AND `column_name` = "login"
AND `CHARACTER_MAXIMUM_LENGTH` = 36) THEN
ALTER TABLE `' . self::DB_ROUNDSDATA . '`
MODIFY `login` VARCHAR(36) NOT NULL;
END IF;';
$mysqli->query($query);
if ($mysqli->error) {
trigger_error($mysqli->error, E_USER_ERROR);
}
} }
public function getMatchStatus() { public function getMatchStatus() {
@ -729,7 +714,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->postmatch = true; $this->postmatch = true;
$this->matchid = ""; $this->matchid = "";
$this->settings_nbroundsbymap = -1; $this->settings_nbroundsbymap = 5;
$this->settings_nbwinners = 2; $this->settings_nbwinners = 2;
$this->settings_nbmapsbymatch = 0; $this->settings_nbmapsbymatch = 0;
$this->settings_pointlimit = 100; $this->settings_pointlimit = 100;
@ -854,7 +839,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
if (isset($this->currentgmsettings[self::SETTING_MATCH_S_ROUNDSPERMAP])) { if (isset($this->currentgmsettings[self::SETTING_MATCH_S_ROUNDSPERMAP])) {
$this->settings_nbroundsbymap = (int) $this->currentgmsettings[self::SETTING_MATCH_S_ROUNDSPERMAP]; $this->settings_nbroundsbymap = (int) $this->currentgmsettings[self::SETTING_MATCH_S_ROUNDSPERMAP];
} else { } else {
$this->settings_nbroundsbymap = -1; $this->settings_nbroundsbymap = 1;
} }
if (isset($this->currentgmsettings[self::SETTING_MATCH_S_MAPSPERMATCH])) { if (isset($this->currentgmsettings[self::SETTING_MATCH_S_MAPSPERMATCH])) {
$this->settings_nbmapsbymatch = (int) $this->currentgmsettings[self::SETTING_MATCH_S_MAPSPERMATCH]; $this->settings_nbmapsbymatch = (int) $this->currentgmsettings[self::SETTING_MATCH_S_MAPSPERMATCH];
@ -1497,7 +1482,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'The match is currently on $<$F00pause$>!'); $this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'The match is currently on $<$F00pause$>!');
Logger::log("Pause"); Logger::log("Pause");
} else { } else {
if ($this->settings_nbroundsbymap > 1) { if ($this->settings_nbroundsbymap != 1) {
$this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap); $this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
Logger::log("Round: " . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap); Logger::log("Round: " . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
} }
@ -1528,7 +1513,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
} elseif ($structure->getSection() == "EndMap" && $this->hidenextmaps && isset($this->maps[$this->nbmaps])) { } elseif ($structure->getSection() == "EndMap" && $this->hidenextmaps && isset($this->maps[$this->nbmaps])) {
$this->maniaControl->getClient()->addMap($this->maps[$this->nbmaps]); $this->maniaControl->getClient()->addMap($this->maps[$this->nbmaps]);
} elseif ($structure->getSection() == "PreEndRound") { } elseif ($structure->getSection() == "PreEndRound") {
$this->preendroundscore = $structure; $this->preendroundscore = $structure->getPlayerScores();
} elseif ($structure->getSection() == "EndRound") { } elseif ($structure->getSection() == "EndRound") {
$timestamp = time(); $timestamp = time();
@ -1544,14 +1529,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO"); Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
} }
$preendroundplayersscore = [];
$preendroundteamsscore = [];
if ($this->preendroundscore !== null) {
$preendroundplayersscore = $this->preendroundscore->getPlayerScores();
$preendroundteamsscore = $this->preendroundscore->getTeamScores();;
}
$this->preendroundscore = null;
//$rank = 1; //$rank = 1;
foreach ($results as $result) { foreach ($results as $result) {
/** @var \ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore $result */ /** @var \ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore $result */
@ -1567,20 +1544,21 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$prevracetime = $result->getPrevRaceTime(); $prevracetime = $result->getPrevRaceTime();
$prevracecheckpoints = implode(",", $result->getPrevRaceCheckpoints()); $prevracecheckpoints = implode(",", $result->getPrevRaceCheckpoints());
if (count($preendroundplayersscore) > 0) { if (count($this->preendroundscore) > 0) {
$preendroundarray = array_filter($preendroundplayersscore, function ($e) use ($player) { return $e->getPlayer() === $player ; }); foreach ($this->preendroundscore as $k => $preendroundresult) {
if ($preendroundresult->getPlayer() === $player) {
if ($roundpoints == 0 && $preendroundresult->getRoundPoints() != 0) {
$roundpoints = $preendroundresult->getRoundPoints();
}
if ($mappoints == 0 && $preendroundresult->getMapPoints() != 0) {
$mappoints = $preendroundresult->getMapPoints();
}
foreach ($preendroundarray as $key => $preendround) { unset($this->preendroundscore[$k]);
if ($roundpoints == 0 && $preendround->getRoundPoints() != 0) {
$roundpoints = $preendround->getRoundPoints();
}
if ($mappoints == 0 && $preendround->getMapPoints() != 0) {
$mappoints = $preendround->getMapPoints();
}
unset($preendroundplayersscore[$key]);
break; break;
} }
} }
}
$this->currentscore = array_merge($this->currentscore, array( $this->currentscore = array_merge($this->currentscore, array(
array($rank, $player->login, $matchpoints, $mappoints, $roundpoints, $bestracetime, $bestracecheckpoints, $bestlaptime, $bestlapcheckpoints, $prevracetime, $prevracecheckpoints, $player->teamId) array($rank, $player->login, $matchpoints, $mappoints, $roundpoints, $bestracetime, $bestracecheckpoints, $bestlaptime, $bestlapcheckpoints, $prevracetime, $prevracecheckpoints, $player->teamId)
@ -1605,21 +1583,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$mappoints = $teamresult->getMapPoints(); $mappoints = $teamresult->getMapPoints();
$roundpoints = $teamresult->getRoundPoints(); $roundpoints = $teamresult->getRoundPoints();
if (count($preendroundteamsscore) > 0) {
$preendroundarray = array_filter($preendroundteamsscore, function ($e) use ($teamid) { return $e->getTeamId() === $teamid ; });
foreach ($preendroundarray as $key => $preendround) {
if ($roundpoints == 0 && $preendround->getRoundPoints() != 0) {
$roundpoints = $preendround->getRoundPoints();
}
if ($mappoints == 0 && $preendround->getMapPoints() != 0) {
$mappoints = $preendround->getMapPoints();
}
unset($preendroundteamsscore[$key]);
break;
}
}
$this->currentteamsscore = array_merge($this->currentteamsscore, array( $this->currentteamsscore = array_merge($this->currentteamsscore, array(
array($rank, $teamid, $teamname, $matchpoints, $mappoints, $roundpoints) array($rank, $teamid, $teamname, $matchpoints, $mappoints, $roundpoints)
)); ));
@ -1630,6 +1593,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
// //
// End Round Routines // End Round Routines
// //
$this->preendroundscore = array();
if (!$this->pauseon && !$this->skipround) { if (!$this->pauseon && !$this->skipround) {
if ($this->currentgmbase != "Cup") { if ($this->currentgmbase != "Cup") {
$this->nbrounds++; $this->nbrounds++;