begin new structure
This commit is contained in:
committed by
Steffen Schröder
parent
5a2d849137
commit
af16f2ac8d
@ -37,27 +37,27 @@ class Map {
|
||||
/**
|
||||
* Create a new Map Object from Rpc Data
|
||||
*
|
||||
* @param array $rpc_infos
|
||||
* @param \Maniaplanet\DedicatedServer\Structures\Map $mpMap
|
||||
* @internal param \ManiaControl\ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct($rpc_infos = null) {
|
||||
public function __construct($mpMap = null) {
|
||||
$this->startTime = time();
|
||||
|
||||
if(!$rpc_infos) {
|
||||
if(!$mpMap) {
|
||||
return;
|
||||
}
|
||||
$this->name = FORMATTER::stripDirtyCodes($rpc_infos['Name']);
|
||||
$this->uid = $rpc_infos['UId'];
|
||||
$this->fileName = $rpc_infos['FileName'];
|
||||
$this->authorLogin = $rpc_infos['Author'];
|
||||
$this->environment = $rpc_infos['Environnement'];
|
||||
$this->goldTime = $rpc_infos['GoldTime'];
|
||||
$this->copperPrice = $rpc_infos['CopperPrice'];
|
||||
$this->mapType = $rpc_infos['MapType'];
|
||||
$this->mapStyle = $rpc_infos['MapStyle'];
|
||||
$this->name = FORMATTER::stripDirtyCodes($mpMap->name);
|
||||
$this->uid = $mpMap->uId;
|
||||
$this->fileName = $mpMap->fileName;
|
||||
$this->authorLogin = $mpMap->author;
|
||||
$this->environment = $mpMap->environnement;
|
||||
$this->goldTime = $mpMap->goldTime;
|
||||
$this->copperPrice = $mpMap->copperPrice;
|
||||
$this->mapType = $mpMap->mapType;
|
||||
$this->mapStyle = $mpMap->mapStyle;
|
||||
|
||||
if(isset($rpc_infos['NbCheckpoints'])) {
|
||||
$this->nbCheckpoints = $rpc_infos['NbCheckpoints'];
|
||||
if(isset($mpMap->nbCheckpoints)) {
|
||||
$this->nbCheckpoints = $mpMap->nbCheckpoints;
|
||||
}
|
||||
|
||||
$this->authorNick = $this->authorLogin;
|
||||
|
@ -320,18 +320,17 @@ class MapManager implements CallbackListener {
|
||||
* Updates the full Map list, needed on Init, addMap and on ShuffleMaps
|
||||
*/
|
||||
private function updateFullMapList() {
|
||||
if(!$this->maniaControl->client->query('GetMapList', 100, 0)) {
|
||||
if(!$maps = $this->maniaControl->client->getMapList(100, 0)) {
|
||||
trigger_error("Couldn't fetch mapList. " . $this->maniaControl->getClientErrorText());
|
||||
return null;
|
||||
}
|
||||
|
||||
$tempList = array();
|
||||
|
||||
$maps = $this->maniaControl->client->getResponse();
|
||||
foreach($maps as $rpcMap) {
|
||||
if(array_key_exists($rpcMap["UId"], $this->maps)) {
|
||||
if(array_key_exists($rpcMap->uId, $this->maps)) {
|
||||
// Map already exists, only update index
|
||||
$tempList[$rpcMap["UId"]] = $this->maps[$rpcMap["UId"]];
|
||||
$tempList[$rpcMap->uId] = $this->maps[$rpcMap->uId];
|
||||
} else { // Insert Map Object
|
||||
$map = $this->initializeMap($rpcMap);
|
||||
$tempList[$map->uid] = $map;
|
||||
@ -351,13 +350,12 @@ class MapManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function fetchCurrentMap() {
|
||||
if(!$this->maniaControl->client->query('GetCurrentMapInfo')) {
|
||||
if(!$rpcMap = $this->maniaControl->client->getCurrentMapInfo()) {
|
||||
trigger_error("Couldn't fetch map info. " . $this->maniaControl->getClientErrorText());
|
||||
return false;
|
||||
}
|
||||
$rpcMap = $this->maniaControl->client->getResponse();
|
||||
if(array_key_exists($rpcMap["UId"], $this->maps)) {
|
||||
$this->currentMap = $this->maps[$rpcMap["UId"]];
|
||||
if(array_key_exists($rpcMap->uId, $this->maps)) {
|
||||
$this->currentMap = $this->maps[$rpcMap->uId];
|
||||
return true;
|
||||
}
|
||||
$map = $this->initializeMap($rpcMap);
|
||||
@ -469,13 +467,12 @@ class MapManager implements CallbackListener {
|
||||
*/
|
||||
public function addMapFromMx($mapId, $login, $update = false) {
|
||||
// Check if ManiaControl can even write to the maps dir
|
||||
if(!$this->maniaControl->client->query('GetMapsDirectory')) {
|
||||
if(!$mapDir = $this->maniaControl->client->getMapsDirectory()) {
|
||||
trigger_error("Couldn't get map directory. " . $this->maniaControl->getClientErrorText());
|
||||
$this->maniaControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
|
||||
return;
|
||||
}
|
||||
|
||||
$mapDir = $this->maniaControl->client->getResponse();
|
||||
if(!is_dir($mapDir)) {
|
||||
trigger_error("ManiaControl doesn't have have access to the maps directory in '{$mapDir}'.");
|
||||
$this->maniaControl->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login);
|
||||
@ -533,12 +530,12 @@ class MapManager implements CallbackListener {
|
||||
// Check for valid map
|
||||
$mapFileName = $downloadDirectory . '/' . $fileName;
|
||||
|
||||
if(!$this->maniaControl->client->query('CheckMapForCurrentServerParams', $mapFileName)) {
|
||||
if(!$response = $this->maniaControl->client->checkMapForCurrentServerParams($mapFileName)) {
|
||||
trigger_error("Couldn't check if map is valid ('{$mapFileName}'). " . $this->maniaControl->getClientErrorText());
|
||||
$this->maniaControl->chat->sendError('Error checking map!', $login);
|
||||
return;
|
||||
}
|
||||
$response = $this->maniaControl->client->getResponse();
|
||||
|
||||
if(!$response) {
|
||||
// Invalid map type
|
||||
$this->maniaControl->chat->sendError("Invalid map type.", $login);
|
||||
@ -546,7 +543,7 @@ class MapManager implements CallbackListener {
|
||||
}
|
||||
|
||||
// Add map to map list
|
||||
if(!$this->maniaControl->client->query('InsertMap', $mapFileName)) {
|
||||
if(!$this->maniaControl->client->insertMap($mapFileName)) {
|
||||
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user