From ac1479c2dfc61853e36e3a39f415ecb377e576df Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 11 Nov 2013 18:37:53 +0100 Subject: [PATCH] improved map object --- application/core/maniaControl.php | 4 +- application/core/map.php | 96 +++++++++++++++--------------- application/core/mapHandler.php | 1 + application/core/playerHandler.php | 2 +- application/core/server.php | 2 +- 5 files changed, 54 insertions(+), 51 deletions(-) diff --git a/application/core/maniaControl.php b/application/core/maniaControl.php index 5d333edd..d537bfb4 100644 --- a/application/core/maniaControl.php +++ b/application/core/maniaControl.php @@ -21,6 +21,7 @@ require_once __DIR__ . '/pluginHandler.php'; require_once __DIR__ . '/server.php'; require_once __DIR__ . '/settingManager.php'; require_once __DIR__ . '/settingConfigurator.php'; +require_once __DIR__ . '/map.php'; require_once __DIR__ . '/mapHandler.php'; require_once __DIR__ . '/GbxDataFetcher/gbxdatafetcher.inc.php'; require_once __DIR__ . '/ManiaExchange/mxinfofetcher.inc.php'; @@ -76,8 +77,9 @@ class ManiaControl { $this->chat = new Chat($this); $this->callbacks = new Callbacks($this); $this->server = new Server($this); - $this->playerHandler = new PlayerHandler($this); $this->authentication = new Authentication($this); + $this->playerHandler = new PlayerHandler($this); + $this->mapHandler = new MapHandler($this); $this->manialinkIdHandler = new ManialinkIdHandler(); $this->commands = new Commands($this); $this->pluginHandler = new PluginHandler($this); diff --git a/application/core/map.php b/application/core/map.php index 559bea6a..5c2813c9 100644 --- a/application/core/map.php +++ b/application/core/map.php @@ -8,72 +8,72 @@ namespace ManiaControl; * @author kremsy & steeffeen */ -class map { +class Map { + /** + * Private properties + */ + private $maniaControl = 0; + + /** + * Public properties + */ + public $mapFetcher = null; + public $id = 0; public $name = ''; public $uid = 0; - public $filename = ''; + public $fileName = ''; public $environment = ''; - public $mood = ''; - public $bronzetime; //format? - public $silvertime; //format? - public $goldtime; //format? - public $authortime; //format? - public $copperprice = 0; - public $laprace = 0; - public $forcedlaps = 0; - public $nblaps = 0; - public $nbchecks = 0; - public $score = 0; - public $starttime = 0; - public $maptype = ''; - public $mapstyle = ''; - public $titleuid = 0; - // public $gbx; //needed? would be the whole gbx object + public $goldTime; //format? + public $copperPrice = 0; + public $mapType = ''; + public $mapStyle = ''; + public $mx = null; public $authorLogin = ''; public $authorNick = ''; public $authorZone = ''; - public $authorEInfo; //format? + public $authorEInfo = ''; + public $comment = ''; + public $titleUid = ''; + + public $starttime = 0; - //Todo: check RPC infos // instantiates the map with an RPC response - public function __construct($rpc_infos = null) { - $this->id = 0; + public function __construct(ManiaControl $maniaControl, $rpc_infos = null) { + $this->maniaControl = $maniaControl; + if ($rpc_infos) { - $this->name = stripNewlines($rpc_infos['Name']); + $this->name = $rpc_infos['Name']; //in aseco stripped new lines on name $this->uid = $rpc_infos['UId']; - $this->filename = $rpc_infos['FileName']; + $this->fileName = $rpc_infos['FileName']; $this->authorLogin = $rpc_infos['Author']; $this->environment = $rpc_infos['Environnement']; - $this->mood = $rpc_infos['Mood']; - $this->bronzetime = $rpc_infos['BronzeTime']; - $this->silvertime = $rpc_infos['SilverTime']; - $this->goldtime = $rpc_infos['GoldTime']; - $this->authortime = $rpc_infos['AuthorTime']; - $this->copperprice = $rpc_infos['CopperPrice']; - $this->laprace = $rpc_infos['LapRace']; - $this->forcedlaps = 0; - $this->nblaps = $rpc_infos['NbLaps']; - $this->nbchecks = $rpc_infos['NbCheckpoints']; - $this->maptype = $rpc_infos['MapType']; - $this->mapstyle = $rpc_infos['MapStyle']; + $this->goldTime = $rpc_infos['GoldTime']; + $this->copperPrice = $rpc_infos['CopperPrice']; + $this->mapType = $rpc_infos['MapType']; + $this->mapStyle = $rpc_infos['MapStyle']; - $this->starttime = time(); + $this->mapFetcher = new \GBXChallMapFetcher(true); + + try{ + $this->mapFetcher->processFile($this->maniaControl->server->getMapsDirectory() . $this->fileName); + } catch (Exception $e){ + trigger_error($e->getMessage(), E_USER_WARNING); + } + $this->authorNick = $this->mapFetcher->authorNick; + $this->authorEInfo = $this->mapFetcher->authorEInfo; + $this->authorZone = $this->mapFetcher->authorZone; + $this->comment = $this->mapFetcher->comment; + //additional properties anyway in the mapfetcher object + + //TODO: change to SM to gameerkennung + //TODO: define timeout if mx is down + $this->mx = new \MXInfoFetcher('SM', $this->uid, false); //SM -> change to gameerkennung } else { $this->name = 'undefined'; } - /* $mapFetcher = new \GBXChallMapFetcher(true); - try{ - $mapFetcher->processFile($this->mc->server->mapdir . $this->filename); - } catch (Exception $e){ - trigger_error($e->getMessage(), E_USER_WARNING); - } - $this->authorNick = $mapFetcher->authorNick; - $this->authorEInfo = $mapFetcher->authorEInfo; - $this->authorZone = $mapFetcher->authorZone; - */ - $this->mx = new \MXInfoFetcher('SM', $this->uid, false); //SM -> change to gameerkennung + $this->starttime = time(); } } \ No newline at end of file diff --git a/application/core/mapHandler.php b/application/core/mapHandler.php index 33ca4824..b7b01749 100644 --- a/application/core/mapHandler.php +++ b/application/core/mapHandler.php @@ -57,6 +57,7 @@ class mapHandler { $this->maniaControl->client->query('GetMapList', 300, 0); $mapList = $this->maniaControl->client->getResponse(); foreach ($mapList as $map) { + $map = new Map($this->maniaControl, $map); $this->addMap($map); } } diff --git a/application/core/playerHandler.php b/application/core/playerHandler.php index 3ea50457..635c1860 100644 --- a/application/core/playerHandler.php +++ b/application/core/playerHandler.php @@ -118,7 +118,7 @@ class PlayerHandler { $player = $this->removePlayer($login); if($this->maniaControl->settingManager->getSetting($this,"Leave Join Messages")){ - $played = timeFormatter::formatTime(time() - $player->joinTime); + $played = TimeFormatter::formatTime(time() - $player->joinTime); $this->maniaControl->chat->sendChat($player->nickname . '$z $ff0has left the game. Played:$fff ' . $played); } } diff --git a/application/core/server.php b/application/core/server.php index 4f5c3f52..b620cf37 100644 --- a/application/core/server.php +++ b/application/core/server.php @@ -59,7 +59,7 @@ class Server { if (!$dataDirectory) { return null; } - return $dataDirectory . 'UserData/Maps/'; + return $dataDirectory . 'Maps/'; } /**