diff --git a/application/core/Update/UpdateData.php b/application/core/Update/UpdateData.php index c587b9e4..b7a33ca8 100644 --- a/application/core/Update/UpdateData.php +++ b/application/core/Update/UpdateData.php @@ -17,16 +17,17 @@ class UpdateData { public $channel = ""; public $url = ""; public $releaseDate = ""; - + public $minDedicatedBuild = ""; /** * Construct new Update Data * - * @param unknown $updateData + * @param Object $updateData */ public function __construct($updateData) { $this->version = $updateData->version; $this->channel = $updateData->channel; $this->url = $updateData->url; $this->releaseDate = $updateData->release_date; + $this->minDedicatedBuild = $updateData->min_dedicated_build; } } diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index 46a80012..54fd9eb3 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -152,6 +152,11 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener return; } + $version = $this->maniaControl->client->getVersion(); + if($this->coreUpdateData->minDedicatedBuild > $version->build){ + return; + } + $buildDate = strtotime($this->currentBuildDate); $releaseTime = strtotime($this->coreUpdateData->releaseDate); if ($buildDate && $buildDate >= $releaseTime) { @@ -186,6 +191,13 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $this->maniaControl->chat->sendInformation('No Update available!', $player->login); return; } + + $version = $this->maniaControl->client->getVersion(); + if($updateData->minDedicatedBuild > $version->build){ + $this->maniaControl->chat->sendError("No new Build for this Server-version available!", $player->login); + return; + } + $this->maniaControl->chat->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login); }); } else { @@ -196,6 +208,12 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener return; } + $version = $this->maniaControl->client->getVersion(); + if($updateData->minDedicatedBuild > $version->build){ + $this->maniaControl->chat->sendError("No new Build for this Server-version available!", $player->login); + return; + } + $buildTime = strtotime($this->currentBuildDate); $releaseTime = strtotime($updateData->releaseDate); if ($buildTime != '') { @@ -259,11 +277,16 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener return; } - $this->checkCoreUpdateAsync(function ($updateData) use (&$player) { + $this->checkCoreUpdateAsync(function (UpdateData $updateData) use (&$player) { if (!$updateData) { $this->maniaControl->chat->sendError('Update is currently not possible!', $player->login); return; } + $version = $this->maniaControl->client->getVersion(); + if($updateData->minDedicatedBuild > $version->build){ + $this->maniaControl->chat->sendError("ManiaControl update version requires a newer Dedicated Server version!", $player->login); + return; + } $this->maniaControl->chat->sendInformation("Starting Update to Version v{$updateData->version}...", $player->login); $this->maniaControl->log("Starting Update to Version v{$updateData->version}..."); @@ -323,7 +346,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener if (!$ignoreVersion && $updateData->version <= ManiaControl::VERSION) { return; } - + call_user_func($function, $updateData); }); }