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->maniaControl->mapManager->handleBeginMap($callback);
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
break; break;
case 'ManiaPlanet.EndMatch': // TODO temporary fix case 'ManiaPlanet.EndMatch':
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
}
break; break;
case 'ManiaPlanet.EndMap': case 'ManiaPlanet.EndMap':
$this->maniaControl->mapManager->handleEndMap($callback); $this->maniaControl->mapManager->handleEndMap($callback);

View File

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

View File

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