improved phpdoc
This commit is contained in:
		| @@ -19,6 +19,8 @@ use Maniaplanet\DedicatedServer\Xmlrpc\MapNotCompatibleOrCompleteException; | |||||||
| use Maniaplanet\DedicatedServer\Xmlrpc\MapNotInCurrentSelectionException; | use Maniaplanet\DedicatedServer\Xmlrpc\MapNotInCurrentSelectionException; | ||||||
| use Maniaplanet\DedicatedServer\Xmlrpc\StartIndexOutOfBoundException; | use Maniaplanet\DedicatedServer\Xmlrpc\StartIndexOutOfBoundException; | ||||||
|  |  | ||||||
|  | // TODO: adding of local maps | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Manager for Maps |  * Manager for Maps | ||||||
|  * |  * | ||||||
| @@ -61,9 +63,7 @@ class MapManager implements CallbackListener { | |||||||
| 	 */ | 	 */ | ||||||
| 	private $maniaControl = null; | 	private $maniaControl = null; | ||||||
| 	private $maps = array(); | 	private $maps = array(); | ||||||
| 	/** | 	/** @var Map $currentMap */ | ||||||
| 	 * @var Map $currentMap |  | ||||||
| 	 */ |  | ||||||
| 	private $currentMap = null; | 	private $currentMap = null; | ||||||
| 	private $mapEnded = false; | 	private $mapEnded = false; | ||||||
| 	private $mapBegan = false; | 	private $mapBegan = false; | ||||||
| @@ -71,7 +71,7 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Construct a new Map Manager | 	 * Construct a new Map Manager | ||||||
| 	 * | 	 * | ||||||
| 	 * @param \ManiaControl\ManiaControl $maniaControl | 	 * @param ManiaControl $maniaControl | ||||||
| 	 */ | 	 */ | ||||||
| 	public function __construct(ManiaControl $maniaControl) { | 	public function __construct(ManiaControl $maniaControl) { | ||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
| @@ -133,8 +133,8 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Update a Map from Mania Exchange | 	 * Update a Map from Mania Exchange | ||||||
| 	 * | 	 * | ||||||
| 	 * @param Player  $admin | 	 * @param Player $admin | ||||||
| 	 * @param  string $uid | 	 * @param string $uid | ||||||
| 	 */ | 	 */ | ||||||
| 	public function updateMap(Player $admin, $uid) { | 	public function updateMap(Player $admin, $uid) { | ||||||
| 		$this->updateMapTimestamp($uid); | 		$this->updateMapTimestamp($uid); | ||||||
| @@ -185,10 +185,10 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Remove a Map | 	 * Remove a Map | ||||||
| 	 * | 	 * | ||||||
| 	 * @param \ManiaControl\Players\Player $admin | 	 * @param Player $admin | ||||||
| 	 * @param string                       $uid | 	 * @param string $uid | ||||||
| 	 * @param bool                         $eraseFile | 	 * @param bool   $eraseFile | ||||||
| 	 * @param bool                         $message | 	 * @param bool   $message | ||||||
| 	 */ | 	 */ | ||||||
| 	public function removeMap(Player $admin, $uid, $eraseFile = false, $message = true) { | 	public function removeMap(Player $admin, $uid, $eraseFile = false, $message = true) { | ||||||
| 		if (!isset($this->maps[$uid])) { | 		if (!isset($this->maps[$uid])) { | ||||||
| @@ -237,9 +237,9 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Adds a Map from Mania Exchange | 	 * Adds a Map from Mania Exchange | ||||||
| 	 * | 	 * | ||||||
| 	 * @param      $mapId | 	 * @param int    $mapId | ||||||
| 	 * @param      $login | 	 * @param string $login | ||||||
| 	 * @param bool $update | 	 * @param bool   $update | ||||||
| 	 */ | 	 */ | ||||||
| 	public function addMapFromMx($mapId, $login, $update = false) { | 	public function addMapFromMx($mapId, $login, $update = false) { | ||||||
| 		if (is_numeric($mapId)) { | 		if (is_numeric($mapId)) { | ||||||
| @@ -268,10 +268,10 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Process the MapFile | 	 * Process the MapFile | ||||||
| 	 * | 	 * | ||||||
| 	 * @param           $file | 	 * @param string    $file | ||||||
| 	 * @param MXMapInfo $mapInfo | 	 * @param MXMapInfo $mapInfo | ||||||
| 	 * @param           $login | 	 * @param string    $login | ||||||
| 	 * @param           $update | 	 * @param bool      $update | ||||||
| 	 */ | 	 */ | ||||||
| 	private function processMapFile($file, MXMapInfo $mapInfo, $login, $update) { | 	private function processMapFile($file, MXMapInfo $mapInfo, $login, $update) { | ||||||
| 		// Check if map is already on the server | 		// Check if map is already on the server | ||||||
| @@ -437,7 +437,7 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Save a Map in the Database | 	 * Save a Map in the Database | ||||||
| 	 * | 	 * | ||||||
| 	 * @param \ManiaControl\Maps\Map $map | 	 * @param Map $map | ||||||
| 	 * @return bool | 	 * @return bool | ||||||
| 	 */ | 	 */ | ||||||
| 	private function saveMap(Map &$map) { | 	private function saveMap(Map &$map) { | ||||||
| @@ -623,7 +623,7 @@ class MapManager implements CallbackListener { | |||||||
| 	/** | 	/** | ||||||
| 	 * Get Current Map | 	 * Get Current Map | ||||||
| 	 * | 	 * | ||||||
| 	 * @return Map currentMap | 	 * @return Map | ||||||
| 	 */ | 	 */ | ||||||
| 	public function getCurrentMap() { | 	public function getCurrentMap() { | ||||||
| 		if (!$this->currentMap) { | 		if (!$this->currentMap) { | ||||||
| @@ -642,6 +642,62 @@ class MapManager implements CallbackListener { | |||||||
| 		$this->beginMap($mapUid, strtolower($restart) === 'true' ? true : false); | 		$this->beginMap($mapUid, strtolower($restart) === 'true' ? true : false); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Manage the Begin of a Map | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $uid | ||||||
|  | 	 * @param bool   $restart | ||||||
|  | 	 */ | ||||||
|  | 	private function beginMap($uid, $restart = false) { | ||||||
|  | 		//If a restart occured, first call the endMap to set variables back | ||||||
|  | 		if ($restart) { | ||||||
|  | 			$this->endMap(); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ($this->mapBegan) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		$this->mapBegan = true; | ||||||
|  | 		$this->mapEnded = false; | ||||||
|  |  | ||||||
|  | 		if (array_key_exists($uid, $this->maps)) { | ||||||
|  | 			// Map already exists, only update index | ||||||
|  | 			$this->currentMap = $this->maps[$uid]; | ||||||
|  | 			if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) { | ||||||
|  | 				$rpcMap                          = $this->maniaControl->client->getCurrentMapInfo(); | ||||||
|  | 				$this->currentMap->nbLaps        = $rpcMap->nbLaps; | ||||||
|  | 				$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// Restructure MapList if id is over 15 | ||||||
|  | 		$this->restructureMapList(); | ||||||
|  |  | ||||||
|  | 		// Update the mx of the map (for update checks, etc.) | ||||||
|  | 		$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap); | ||||||
|  |  | ||||||
|  | 		// Trigger own BeginMap callback ( | ||||||
|  | 		//TODO remove deprecated callback later | ||||||
|  | 		$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap); | ||||||
|  | 		$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Manage the End of a Map | ||||||
|  | 	 */ | ||||||
|  | 	private function endMap() { | ||||||
|  | 		if ($this->mapEnded) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		$this->mapEnded = true; | ||||||
|  | 		$this->mapBegan = false; | ||||||
|  |  | ||||||
|  | 		// Trigger own EndMap callback | ||||||
|  | 		$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap); | ||||||
|  | 		//TODO remove deprecated callback later | ||||||
|  | 		$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Handle BeginMap callback | 	 * Handle BeginMap callback | ||||||
| 	 * | 	 * | ||||||
| @@ -686,61 +742,4 @@ class MapManager implements CallbackListener { | |||||||
| 	public function getMapsCount() { | 	public function getMapsCount() { | ||||||
| 		return count($this->maps); | 		return count($this->maps); | ||||||
| 	} | 	} | ||||||
| 	// TODO: add local map by filename |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Manage the End of a Map |  | ||||||
| 	 */ |  | ||||||
| 	private function endMap() { |  | ||||||
| 		if ($this->mapEnded) { |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		$this->mapEnded = true; |  | ||||||
| 		$this->mapBegan = false; |  | ||||||
|  |  | ||||||
| 		// Trigger own EndMap callback |  | ||||||
| 		$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap); |  | ||||||
| 		//TODO remove deprecated callback later |  | ||||||
| 		$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Manage the Begin of a Map |  | ||||||
| 	 * |  | ||||||
| 	 * @param      $uid |  | ||||||
| 	 * @param bool $restart |  | ||||||
| 	 */ |  | ||||||
| 	private function beginMap($uid, $restart = false) { |  | ||||||
| 		//If a restart occured, first call the endMap to set variables back |  | ||||||
| 		if ($restart) { |  | ||||||
| 			$this->endMap(); |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		if ($this->mapBegan) { |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		$this->mapBegan = true; |  | ||||||
| 		$this->mapEnded = false; |  | ||||||
|  |  | ||||||
| 		if (array_key_exists($uid, $this->maps)) { |  | ||||||
| 			// Map already exists, only update index |  | ||||||
| 			$this->currentMap = $this->maps[$uid]; |  | ||||||
| 			if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) { |  | ||||||
| 				$rpcMap                          = $this->maniaControl->client->getCurrentMapInfo(); |  | ||||||
| 				$this->currentMap->nbLaps        = $rpcMap->nbLaps; |  | ||||||
| 				$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		// Restructure MapList if id is over 15 |  | ||||||
| 		$this->restructureMapList(); |  | ||||||
|  |  | ||||||
| 		// Update the mx of the map (for update checks, etc.) |  | ||||||
| 		$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap); |  | ||||||
|  |  | ||||||
| 		// Trigger own BeginMap callback ( |  | ||||||
| 		//TODO remove deprecated callback later |  | ||||||
| 		$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap); |  | ||||||
| 		$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap); |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user