2013-11-12 15:48:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Maps;
|
|
|
|
|
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map class
|
|
|
|
*
|
|
|
|
* @author kremsy & steeffeen
|
|
|
|
*/
|
|
|
|
class Map {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public properties
|
|
|
|
*/
|
2013-11-25 02:01:15 +01:00
|
|
|
public $index = -1;
|
2013-11-12 15:48:25 +01:00
|
|
|
public $name = 'undefined';
|
|
|
|
public $uid = '';
|
|
|
|
public $fileName = '';
|
|
|
|
public $environment = '';
|
|
|
|
public $goldTime; // TODO: format?
|
|
|
|
public $copperPrice = 0;
|
|
|
|
public $mapType = '';
|
|
|
|
public $mapStyle = '';
|
2013-11-25 19:46:29 +01:00
|
|
|
public $nbCheckpoints = -1;
|
2013-11-12 15:48:25 +01:00
|
|
|
public $mx = null;
|
|
|
|
public $authorLogin = '';
|
|
|
|
public $authorNick = '';
|
|
|
|
public $authorZone = '';
|
|
|
|
public $authorEInfo = '';
|
|
|
|
public $comment = '';
|
|
|
|
public $titleUid = '';
|
|
|
|
public $startTime = 0;
|
2013-11-25 02:01:15 +01:00
|
|
|
public $mapFetcher = null;
|
2013-11-12 15:48:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Private properties
|
|
|
|
*/
|
|
|
|
private $maniaControl = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new map object from rpc data
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\ManiaControl $maniaControl
|
|
|
|
* @param array $rpc_infos
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl, $rpc_infos = null) {
|
2013-12-28 22:43:57 +01:00
|
|
|
// $this->maniaControl = $maniaControl;
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->startTime = time();
|
|
|
|
|
|
|
|
if (!$rpc_infos) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-09 13:45:58 +01:00
|
|
|
$this->name = $rpc_infos['Name'];
|
2013-11-12 15:48:25 +01:00
|
|
|
$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'];
|
2013-12-16 08:38:35 +01:00
|
|
|
if (isset($rpc_infos['NbCheckpoints'])) {
|
|
|
|
$this->nbCheckpoints = $rpc_infos['NbCheckpoints'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->authorNick = $this->authorLogin;
|
|
|
|
|
2013-12-28 22:43:57 +01:00
|
|
|
/*$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
2013-11-12 15:48:25 +01:00
|
|
|
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
|
|
|
$this->mapFetcher = new \GBXChallMapFetcher(true);
|
|
|
|
try {
|
|
|
|
$this->mapFetcher->processFile($mapsDirectory . $this->fileName);
|
|
|
|
}
|
2013-12-09 13:45:58 +01:00
|
|
|
catch (\Exception $e) {
|
2013-11-12 15:48:25 +01:00
|
|
|
trigger_error($e->getMessage(), E_USER_WARNING);
|
|
|
|
}
|
2013-12-16 08:38:35 +01:00
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->authorNick = $this->mapFetcher->authorNick;
|
|
|
|
$this->authorEInfo = $this->mapFetcher->authorEInfo;
|
|
|
|
$this->authorZone = $this->mapFetcher->authorZone;
|
|
|
|
$this->comment = $this->mapFetcher->comment;
|
|
|
|
}
|
2013-12-16 08:38:35 +01:00
|
|
|
|
2013-12-27 21:10:53 +01:00
|
|
|
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
2013-11-12 15:48:25 +01:00
|
|
|
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
|
|
|
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
2013-12-28 22:43:57 +01:00
|
|
|
$this->mx = new \MXInfoFetcher($title, $this->uid, false);*/
|
2013-11-12 15:48:25 +01:00
|
|
|
}
|
|
|
|
}
|