small callback stability improvement

This commit is contained in:
kremsy 2017-05-09 19:11:19 +02:00
parent 05f688b99f
commit 37e12ebf88
2 changed files with 29 additions and 24 deletions

View File

@ -30,15 +30,18 @@ class OnScoresStructure extends CommonScoresStructure {
$jsonObj = $this->getPlainJsonObject(); $jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) { foreach ($jsonObj->players as $jsonPlayer) {
$playerScore = new PlayerScore(); $player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login)); if($player){
$playerScore->setRank($jsonPlayer->rank); $playerScore = new PlayerScore();
$playerScore->setRoundPoints($jsonPlayer->roundpoints); $playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setMatchPoints($jsonPlayer->matchpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore; $playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setMatchPoints($jsonPlayer->matchpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore;
}
} }
} }
} }

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure; use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore; use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/** /**
@ -29,20 +28,23 @@ class OnScoresStructure extends CommonScoresStructure {
$jsonObj = $this->getPlainJsonObject(); $jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) { foreach ($jsonObj->players as $jsonPlayer) {
$playerScore = new PlayerScore(); $player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login)); if ($player) {
$playerScore->setRank($jsonPlayer->rank); $playerScore = new PlayerScore();
$playerScore->setRoundPoints($jsonPlayer->roundpoints); $playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setMapPoints($jsonPlayer->mappoints); $playerScore->setRank($jsonPlayer->rank);
$playerScore->setBestRaceTime($jsonPlayer->bestracetime); $playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setBestLapTime($jsonPlayer->bestlaptime); $playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setStuntScore($jsonPlayer->stuntsscore); $playerScore->setBestRaceTime($jsonPlayer->bestracetime);
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns); $playerScore->setBestLapTime($jsonPlayer->bestlaptime);
$playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints); $playerScore->setStuntScore($jsonPlayer->stuntsscore);
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns); $playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints); $playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints);
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore; $this->playerScores[$jsonPlayer->login] = $playerScore;
}
} }
} }
} }