Adaptation to new dedicated-api
This commit is contained in:
		| @@ -306,7 +306,7 @@ class MapManager implements CallbackListener { | ||||
| 		} else { | ||||
| 			// Write map via write file method | ||||
| 			try { | ||||
| 				$this->maniaControl->client->writeFileFromString($relativeMapFileName, $file); | ||||
| 				$this->maniaControl->client->writeFile($relativeMapFileName, $file); | ||||
| 			} catch (InvalidArgumentException $e) { | ||||
| 				if ($e->getMessage() == 'data are too big') { | ||||
| 					$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login); | ||||
| @@ -720,4 +720,4 @@ class MapManager implements CallbackListener { | ||||
| 		return count($this->maps); | ||||
| 	} | ||||
| 	// TODO: add local map by filename | ||||
| }  | ||||
| } | ||||
|   | ||||
| @@ -59,36 +59,29 @@ class Player { | ||||
| 	public $currentTargetId = 0; | ||||
|  | ||||
| 	/** | ||||
| 	 * Construct a player from ManiaPlanet Player structure | ||||
| 	 * | ||||
| 	 * @param \Maniaplanet\DedicatedServer\Structures\Player $mpPlayer | ||||
| 	 * @param bool $connected | ||||
| 	 */ | ||||
| 	public function __construct($mpPlayer) { | ||||
| 		if (!$mpPlayer) { | ||||
| 			$this->isConnected = false; | ||||
| 			return; | ||||
| 		} | ||||
| 	public function __construct($connected) | ||||
| 	{ | ||||
| 		$this->isConnected = $connected; | ||||
|  | ||||
| 		if ($connected) { | ||||
| 			$this->joinTime = time(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Update from ManiaPlanet PlayerInfo structure | ||||
| 	 * @param \Maniaplanet\DedicatedServer\Structures\PlayerInfo $mpPlayer | ||||
| 	 */ | ||||
| 	public function setInfo($mpPlayer) | ||||
| 	{ | ||||
| 		$this->pid                      = $mpPlayer->playerId; | ||||
| 		$this->login                    = $mpPlayer->login; | ||||
| 		$this->nickname                 = Formatter::stripDirtyCodes($mpPlayer->nickName); | ||||
| 		$this->rawNickname              = $mpPlayer->nickName; | ||||
| 		$this->path                     = $mpPlayer->path; | ||||
| 		$this->language                 = $mpPlayer->language; | ||||
| 		$this->avatar                   = $mpPlayer->avatar['FileName']; | ||||
| 		$this->allies                   = $mpPlayer->allies; | ||||
| 		$this->clubLink                 = $mpPlayer->clubLink; | ||||
| 		$this->teamId                   = $mpPlayer->teamId; | ||||
| 		$this->isOfficial               = $mpPlayer->isInOfficialMode; | ||||
| 		$this->ladderScore              = $mpPlayer->ladderStats['PlayerRankings'][0]['Score']; | ||||
| 		$this->ladderRank               = $mpPlayer->ladderStats['PlayerRankings'][0]['Ranking']; | ||||
| 		$this->ladderStats              = $mpPlayer->ladderStats; | ||||
| 		$this->daysSinceZoneInscription = $mpPlayer->hoursSinceZoneInscription / 24; | ||||
| 		$this->ipAddress                = $mpPlayer->iPAddress; | ||||
| 		$this->clientVersion            = $mpPlayer->clientVersion; | ||||
| 		$this->downloadRate             = $mpPlayer->downloadRate; | ||||
| 		$this->uploadRate               = $mpPlayer->uploadRate; | ||||
| 		$this->skins                    = $mpPlayer->skins; | ||||
|  | ||||
| 		//Flag Details | ||||
| 		$this->forcedSpectatorState     = $mpPlayer->forceSpectator; | ||||
| @@ -108,7 +101,37 @@ class Player { | ||||
| 		$this->autoTarget           = $mpPlayer->autoTarget; | ||||
| 		$this->currentTargetId      = $mpPlayer->currentTargetId; | ||||
|  | ||||
| 		$this->joinTime = time(); | ||||
| 		if (!$this->nickname) { | ||||
| 			$this->nickname = $this->login; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Update from ManiaPlanet PlayerDetailedInfo structure | ||||
| 	 * @param \Maniaplanet\DedicatedServer\Structures\PlayerDetailedInfo $mpPlayer | ||||
| 	 */ | ||||
| 	public function setDetailedInfo($mpPlayer) | ||||
| 	{ | ||||
| 		$this->pid                      = $mpPlayer->playerId; | ||||
| 		$this->login                    = $mpPlayer->login; | ||||
| 		$this->nickname                 = Formatter::stripDirtyCodes($mpPlayer->nickName); | ||||
| 		$this->rawNickname              = $mpPlayer->nickName; | ||||
| 		$this->path                     = $mpPlayer->path; | ||||
| 		$this->language                 = $mpPlayer->language; | ||||
| 		$this->avatar                   = $mpPlayer->avatar->fileName; | ||||
| 		$this->allies                   = $mpPlayer->allies; | ||||
| 		$this->clubLink                 = $mpPlayer->clubLink; | ||||
| 		$this->teamId                   = $mpPlayer->teamId; | ||||
| 		$this->isOfficial               = $mpPlayer->isInOfficialMode; | ||||
| 		$this->ladderScore              = $mpPlayer->ladderStats->playerRankings[0]->score; | ||||
| 		$this->ladderRank               = $mpPlayer->ladderStats->playerRankings[0]->ranking; | ||||
| 		$this->ladderStats              = $mpPlayer->ladderStats; | ||||
| 		$this->daysSinceZoneInscription = $mpPlayer->hoursSinceZoneInscription / 24; | ||||
| 		$this->ipAddress                = $mpPlayer->iPAddress; | ||||
| 		$this->clientVersion            = $mpPlayer->clientVersion; | ||||
| 		$this->downloadRate             = $mpPlayer->downloadRate; | ||||
| 		$this->uploadRate               = $mpPlayer->uploadRate; | ||||
| 		$this->skins                    = $mpPlayer->skins; | ||||
|  | ||||
| 		if (!$this->nickname) { | ||||
| 			$this->nickname = $this->login; | ||||
|   | ||||
| @@ -116,26 +116,16 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
| 			if ($playerItem->playerId <= 0) { | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			$detailedPlayerInfo        = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login); | ||||
| 			$playerItem->path          = $detailedPlayerInfo->path; | ||||
| 			$playerItem->language      = $detailedPlayerInfo->language; | ||||
| 			$playerItem->clientVersion = $detailedPlayerInfo->clientVersion; | ||||
| 			$playerItem->iPAddress     = $detailedPlayerInfo->iPAddress; | ||||
| 			$playerItem->isSpectator   = $detailedPlayerInfo->isSpectator; | ||||
| 			$playerItem->avatar        = $detailedPlayerInfo->avatar; | ||||
| 			$playerItem->ladderStats   = $detailedPlayerInfo->ladderStats; | ||||
| 			$playerItem->downloadRate  = $detailedPlayerInfo->downloadRate; | ||||
| 			$playerItem->uploadRate    = $detailedPlayerInfo->uploadRate; | ||||
|  | ||||
| 			$playerItem->hoursSinceZoneInscription = $detailedPlayerInfo->hoursSinceZoneInscription; | ||||
| 			$detailedPlayerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login); | ||||
|  | ||||
| 			//Check if the Player is in a Team, to notify if its a TeamMode or not | ||||
| 			if ($playerItem->teamId != -1) { | ||||
| 				$this->maniaControl->server->setTeamMode(true); | ||||
| 			} | ||||
|  | ||||
| 			$player                = new Player($playerItem); | ||||
| 			$player = new Player(true); | ||||
| 			$player->setInfo($playerItem); | ||||
| 			$player->setDetailedInfo($detailedPlayerInfo); | ||||
| 			$player->hasJoinedGame = true; | ||||
| 			$this->addPlayer($player); | ||||
| 		} | ||||
| @@ -220,7 +210,8 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
| 		$login = $callback[1][0]; | ||||
| 		try { | ||||
| 			$playerInfo = $this->maniaControl->client->getDetailedPlayerInfo($login); | ||||
| 			$player     = new Player($playerInfo); | ||||
| 			$player     = new Player(true); | ||||
| 			$player->setDetailedInfo($playerInfo); | ||||
|  | ||||
| 			$this->addPlayer($player); | ||||
| 		} catch (LoginUnknownException $e) { | ||||
| @@ -381,7 +372,7 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
| 			return null; | ||||
| 		} | ||||
|  | ||||
| 		$player              = new Player(null); | ||||
| 		$player              = new Player(false); | ||||
| 		$player->index       = $row->index; | ||||
| 		$player->login       = $row->login; | ||||
| 		$player->rawNickname = $row->nickname; | ||||
| @@ -482,7 +473,7 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
| 			return null; | ||||
| 		} | ||||
|  | ||||
| 		$player              = new Player(null); | ||||
| 		$player              = new Player(false); | ||||
| 		$player->index       = $playerIndex; | ||||
| 		$player->login       = $row->login; | ||||
| 		$player->rawNickname = $row->nickname; | ||||
|   | ||||
| @@ -275,7 +275,7 @@ class Server implements CallbackListener { | ||||
| 	/** | ||||
| 	 * Get Server Player Info | ||||
| 	 * | ||||
| 	 * @return \Maniaplanet\DedicatedServer\Structures\Player | ||||
| 	 * @return \Maniaplanet\DedicatedServer\Structures\PlayerInfo | ||||
| 	 */ | ||||
| 	public function getInfo() { | ||||
| 		return $this->maniaControl->client->getMainServerPlayerInfo(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user