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;
/** /**
@ -27,22 +26,25 @@ class OnScoresStructure extends CommonScoresStructure {
parent::__construct($maniaControl, $data); parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject(); $jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) {
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
$playerScore->setStuntScore($jsonPlayer->stuntsscore);
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
$playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints);
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore; foreach ($jsonObj->players as $jsonPlayer) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
if ($player) {
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
$playerScore->setStuntScore($jsonPlayer->stuntsscore);
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
$playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints);
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore;
}
} }
} }
} }