cleanedup endMap / beginMap bugs

This commit is contained in:
kremsy
2014-05-09 12:14:25 +02:00
parent a51d5423a3
commit d208be32c8
3 changed files with 27 additions and 16 deletions

View File

@ -635,29 +635,33 @@ class MapManager implements CallbackListener {
/**
* Handle Script BeginMap callback
*
* @param int $mapNumber
* @param $mapUid
* @param $restart
*/
public function handleScriptBeginMap($mapNumber) {
$this->handleBeginMap(array());
public function handleScriptBeginMap($mapUid, $restart) {
$this->beginMap($mapUid, $restart);
}
/**
* Handle BeginMap callback
* Manage the begin Of a Map
*
* @param array $callback
* @param $uid
* @param bool $restart
*/
public function handleBeginMap(array $callback) {
private function beginMap($uid, $restart = false) {
if ($restart) {
$this->handleEndMap(array());
}
if ($this->mapBegan) {
return;
}
$this->mapBegan = true;
$this->mapEnded = false;
if (!isset($callback[1][0]["UId"])) {
$this->currentMap = $this->fetchCurrentMap();
} else if (array_key_exists($callback[1][0]["UId"], $this->maps)) {
if (array_key_exists($uid, $this->maps)) {
// Map already exists, only update index
$this->currentMap = $this->maps[$callback[1][0]["UId"]];
$this->currentMap = $this->maps[$uid];
if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) {
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
$this->currentMap->nbLaps = $rpcMap->nbLaps;
@ -677,6 +681,15 @@ class MapManager implements CallbackListener {
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
}
/**
* Handle BeginMap callback
*
* @param array $callback
*/
public function handleBeginMap(array $callback) {
$this->beginMap($callback[1][0]["UId"]);
}
/**
* Handle Script EndMap Callback
*