diff --git a/application/core/Maps/MapActions.php b/application/core/Maps/MapActions.php new file mode 100644 index 00000000..89a1eef9 --- /dev/null +++ b/application/core/Maps/MapActions.php @@ -0,0 +1,46 @@ + + * @copyright 2014 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +namespace ManiaControl\Maps; + + +use ManiaControl\ManiaControl; +use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; + +class MapActions { + /* + * Private Properties + */ + private $maniaControl = null; + + /** + * Create a MapActions Instance + * + * @param ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + } + + /** + * Skips the current Map + */ + public function skipMap() { + //Force a EndMap on the MapQueue to set the next Map + $this->maniaControl->mapManager->mapQueue->endMap(null); + + //ignore EndMap on MapQueue + $this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange(); + + //Switch The Map + try { + $this->maniaControl->client->nextMap(); + } catch (ChangeInProgressException $e) { + } + } +} \ No newline at end of file diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index ab7ccc77..86adde2a 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -192,10 +192,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->authenticationManager->sendNotAllowed($player); return; } - try { - $this->maniaControl->client->nextMap(); - } catch (ChangeInProgressException $e) { - } + + $this->maniaControl->mapManager->mapActions->skipMap(); + $message = '$<' . $player->nickname . '$> skipped the current Map!'; $this->maniaControl->chat->sendSuccess($message); $this->maniaControl->log($message, true); diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 32afa57d..3f1eb770 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -327,7 +327,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { if (isset($queuedMaps[$map->uid])) { $label = new Label_Text(); $mapFrame->add($label); - $label->setX($width / 2 - 15); + $label->setX($width / 2 - 13); $label->setAlign(Control::CENTER, Control::CENTER); $label->setZ(0.2); $label->setTextSize(1.5); @@ -595,6 +595,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $this->maniaControl->mapManager->removeMap($player, $mapUid); break; case self::ACTION_SWITCH_MAP: + //Don't queue on Map-Change + $this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange(); try { $this->maniaControl->client->jumpToMapIdent($mapUid); } catch (MapNotFoundException $e) { @@ -624,6 +626,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $self->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!'); $votesPlugin->undefineVote('switchmap'); + //Don't queue on Map-Change + $this->maniaControl->mapManager->mapQueue->dontQueueNextMapChange(); + try { $self->maniaControl->client->JumpToMapIdent($map->uid); } catch (MapNotFoundException $e) { diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index f2195a61..6f9615b6 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -54,6 +54,7 @@ class MapManager implements CallbackListener { public $mapList = null; public $mxList = null; public $mxManager = null; + public $mapActions = null; /* * Private Properties @@ -82,6 +83,7 @@ class MapManager implements CallbackListener { $this->mxList = new ManiaExchangeList($this->maniaControl); $this->mapCommands = new MapCommands($maniaControl); $this->mapQueue = new MapQueue($this->maniaControl); + $this->mapActions = new MapActions($maniaControl); // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit'); diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index 8e1a80ef..837eb073 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -10,6 +10,7 @@ use ManiaControl\Commands\CommandListener; use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException; /** * MapQueue Class @@ -42,6 +43,14 @@ class MapQueue implements CallbackListener, CommandListener { private $queuedMaps = array(); private $nextMap = null; private $buffer = array(); + private $nextNoQueue = false; + + /** + * Don't queue on the next MapChange + */ + public function dontQueueNextMapChange() { + $this->nextNoQueue = true; + } /** * Create a new server MapQueue @@ -291,7 +300,13 @@ class MapQueue implements CallbackListener, CommandListener { * * @param Map $map */ - public function endMap(Map $map) { + public function endMap(Map $map = null) { + //Don't queue next map (for example on skip to map) + if($this->nextNoQueue){ + $this->nextNoQueue = false; + return; + } + $this->nextMap = null; if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) { @@ -333,9 +348,13 @@ class MapQueue implements CallbackListener, CommandListener { return; } $map = $this->nextMap[1]; + /** @var Map $map */ $this->maniaControl->chat->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.'); - $this->maniaControl->client->chooseNextMap($map->fileName); + try{ + $this->maniaControl->client->setNextMapIdent($map->uid); + }catch (NextMapException $e){ + } } /** diff --git a/application/plugins/MCTeam/CustomVotesPlugin.php b/application/plugins/MCTeam/CustomVotesPlugin.php index 649c5efd..9c687e5d 100644 --- a/application/plugins/MCTeam/CustomVotesPlugin.php +++ b/application/plugins/MCTeam/CustomVotesPlugin.php @@ -503,7 +503,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP case 'skipmap': case 'skip': case 'nextmap': - $this->maniaControl->client->nextMap(); + $this->maniaControl->mapManager->mapActions->skipMap(); $this->maniaControl->chat->sendInformation('$f8fVote to $fffskip the map$f8f has been successfull!'); break; case 'restartmap':