improved directory browser and map update check
This commit is contained in:
parent
8d7a147295
commit
5b87873aba
@ -105,10 +105,10 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$index = 0;
|
$index = 0;
|
||||||
foreach ($maps as $map) {
|
foreach ($maps as &$map) {
|
||||||
if (!$map) {
|
if (!$map) {
|
||||||
// TODO: remove after resolving of error report about "non-object"
|
// TODO: remove after resolving of error report about "non-object"
|
||||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Non-Object-Map', $map, $maps);
|
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Non-Object-Map ' . $map->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
|
@ -362,6 +362,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Update MX Data and ID
|
||||||
|
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation($map);
|
||||||
|
|
||||||
|
$map->lastUpdate = time();
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
$message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!';
|
$message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!';
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
|
@ -19,6 +19,9 @@ use ManiaControl\Utils\Formatter;
|
|||||||
class Map implements Dumpable, UsageInformationAble {
|
class Map implements Dumpable, UsageInformationAble {
|
||||||
use DumpTrait, UsageInformationTrait;
|
use DumpTrait, UsageInformationTrait;
|
||||||
|
|
||||||
|
//Minimum Lightmap Version for the Update Check
|
||||||
|
const MIN_LIGHTMAP_VERSION = 7;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public properties
|
* Public properties
|
||||||
*/
|
*/
|
||||||
@ -107,7 +110,27 @@ class Map implements Dumpable, UsageInformationAble {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateAvailable() {
|
public function updateAvailable() {
|
||||||
return ($this->mx && ($this->lastUpdate < strtotime($this->mx->updated) || $this->uid !== $this->mx->uid));
|
//Check if MX Object is existing
|
||||||
|
if (!$this->mx) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if the Lightmap verison on MX surpasses the min Lightmap version
|
||||||
|
if ($this->mx->lightmap < self::MIN_LIGHTMAP_VERSION) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if last Map update is older than the MX Maptime
|
||||||
|
if ($this->lastUpdate < strtotime($this->mx->updated)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if UIDs are different
|
||||||
|
if ($this->uid !== $this->mx->uid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user