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

@ -185,10 +185,8 @@ class CallbackManager {
$this->maniaControl->mapManager->handleBeginMap($callback);
$this->triggerCallback($callbackName, $callback);
break;
case 'ManiaPlanet.EndMatch': // TODO temporary fix
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
$this->triggerCallback($callbackName, $callback);
}
case 'ManiaPlanet.EndMatch':
$this->triggerCallback($callbackName, $callback);
break;
case 'ManiaPlanet.EndMap':
$this->maniaControl->mapManager->handleEndMap($callback);

View File

@ -45,7 +45,7 @@ class LibXmlRpcCallbackManager implements CallbackListener {
break;
case 'BeginMap':
case 'LibXmlRpc_BeginMap':
$this->maniaControl->mapManager->handleScriptBeginMap($data[0]);
$this->maniaControl->mapManager->handleScriptBeginMap($data[1], $data[2]);
break;
case 'LibXmlRpc_BeginSubmatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINSUBMATCH, $data[0]);
@ -64,7 +64,7 @@ class LibXmlRpcCallbackManager implements CallbackListener {
break;
case 'EndMap':
case 'LibXmlRpc_EndMap':
$this->maniaControl->mapManager->handleScriptEndMap($data[0]);
$this->maniaControl->mapManager->handleScriptEndMap($data[1]);
break;
case 'LibXmlRpc_EndMatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMATCH, $data[0]);

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
*