function onPlayerFinish($playerUid, $login, $timeOrScore) { if (!isset($this->players[$login])) { return; } $player = $this->players[$login]; switch ($this->gameInfos->gameMode) { // check stunts case GameInfos::GAMEMODE_STUNTS: if ($timeOrScore > 0 && ($player->score <= 0 || $timeOrScore > $player->score)) { $oldScore = $player->score; $this->updateRanking($this->connection->getCurrentRanking(-1, 0)); if ($player->score == $timeOrScore) { // sanity checks if (count($player->bestCheckpoints) != $this->currentMap->nbCheckpoints) { Console::println('Best score\'s checkpoint count does not match and was ignored!'); Console::printPlayerScore($player); $player->score = $oldScore; return; } Dispatcher::dispatch(new Event(Event::ON_PLAYER_NEW_BEST_SCORE, $player, $oldScore, $timeOrScore)); } } break; // check all other game modes // check all other game modes default: if ($timeOrScore > 0 && ($player->bestTime <= 0 || $timeOrScore < $player->bestTime)) { $oldBest = $player->bestTime; $this->updateRanking($this->connection->getCurrentRanking(-1, 0)); if ($player->bestTime == $timeOrScore) { // sanity checks $totalChecks = 0; switch ($this->gameInfos->gameMode) { case GameInfos::GAMEMODE_LAPS: $totalChecks = $this->currentMap->nbCheckpoints * $this->gameInfos->lapsNbLaps; break; case GameInfos::GAMEMODE_TEAM: case GameInfos::GAMEMODE_ROUNDS: case GameInfos::GAMEMODE_CUP: if ($this->currentMap->nbLaps > 0) { $totalChecks = $this->currentMap->nbCheckpoints * ($this->gameInfos->roundsForcedLaps ?: $this->currentMap->nbLaps); } else { $totalChecks = $this->currentMap->nbCheckpoints; } break; default: $totalChecks = $this->currentMap->nbCheckpoints; break; } if (count($player->bestCheckpoints) != $totalChecks) { Console::println('Best time\'s checkpoint count does not match and was ignored!'); Console::printPlayerBest($player); $player->bestTime = $oldBest; return; } Dispatcher::dispatch(new Event(Event::ON_PLAYER_NEW_BEST_TIME, $player, $oldBest, $timeOrScore)); } } break; } }