infosearcher imrpove
This commit is contained in:
@ -32,7 +32,7 @@ class Map {
|
||||
public $comment = '';
|
||||
public $titleUid = '';
|
||||
public $startTime = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
*/
|
||||
@ -42,46 +42,47 @@ class Map {
|
||||
* Create a new Map Object from Rpc Data
|
||||
*
|
||||
* @param \ManiaControl\ManiaControl $maniaControl
|
||||
* @param array $rpc_infos
|
||||
* @param array $rpc_infos
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl, $rpc_infos = null) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
$this->startTime = time();
|
||||
|
||||
if (!$rpc_infos) return;
|
||||
$this->name = $rpc_infos['Name'];
|
||||
$this->uid = $rpc_infos['UId'];
|
||||
$this->fileName = $rpc_infos['FileName'];
|
||||
$this->startTime = time();
|
||||
|
||||
if(!$rpc_infos) {
|
||||
return;
|
||||
}
|
||||
$this->name = $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->goldTime = $rpc_infos['GoldTime'];
|
||||
$this->copperPrice = $rpc_infos['CopperPrice'];
|
||||
$this->mapType = $rpc_infos['MapType'];
|
||||
$this->mapStyle = $rpc_infos['MapStyle'];
|
||||
if (isset($rpc_infos['NbCheckpoints'])) {
|
||||
$this->mapType = $rpc_infos['MapType'];
|
||||
$this->mapStyle = $rpc_infos['MapStyle'];
|
||||
if(isset($rpc_infos['NbCheckpoints'])) {
|
||||
$this->nbCheckpoints = $rpc_infos['NbCheckpoints'];
|
||||
}
|
||||
|
||||
|
||||
$this->authorNick = $this->authorLogin;
|
||||
|
||||
|
||||
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
||||
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
||||
if($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
||||
$mapFetcher = new \GBXChallMapFetcher(true);
|
||||
try {
|
||||
$mapFetcher->processFile($mapsDirectory . $this->fileName);
|
||||
$this->authorNick = FORMATTER::stripDirtyCodes($mapFetcher->authorNick);
|
||||
$this->authorNick = FORMATTER::stripDirtyCodes($mapFetcher->authorNick);
|
||||
$this->authorEInfo = $mapFetcher->authorEInfo;
|
||||
$this->authorZone = $mapFetcher->authorZone;
|
||||
$this->comment = $mapFetcher->comment;
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->authorZone = $mapFetcher->authorZone;
|
||||
$this->comment = $mapFetcher->comment;
|
||||
} catch(\Exception $e) {
|
||||
trigger_error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
||||
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
||||
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
||||
$this->mx = new \MXInfoFetcher($title, $this->uid, false);
|
||||
$serverInfo = $this->maniaControl->server->titleId;
|
||||
$title = strtoupper(substr($serverInfo, 0, 2));
|
||||
$this->mx = new \MXInfoFetcher($title, $this->uid, false);
|
||||
}
|
||||
}
|
@ -120,13 +120,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$recent = false;
|
||||
}
|
||||
|
||||
$this->maniaControl->mapManager->mxInfoSearcher->getList('');
|
||||
|
||||
// search for matching maps
|
||||
$maps = new MXInfoSearcher($title, $searchString, $author, $environment, $recent);
|
||||
//$maps = new MXInfoSearcher($title, $searchString, $author, $environment, $recent);
|
||||
$maps = $this->maniaControl->mapManager->mxInfoSearcher->getMaps(15);
|
||||
|
||||
// check if there are any results
|
||||
if(!$maps->valid()) {
|
||||
if($maps == null) {
|
||||
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||
if($maps->error != '') {
|
||||
trigger_error($maps->error, E_USER_WARNING);
|
||||
@ -158,6 +157,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$i = 0;
|
||||
$y -= 10;
|
||||
foreach($maps as $map) {
|
||||
var_dump($map);
|
||||
return;
|
||||
$mapFrame = new Frame();
|
||||
$frame->add($mapFrame);
|
||||
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, $map->mood => $x + 100, $map->maptype => $x + 115);
|
||||
|
Reference in New Issue
Block a user