updatemanager min dedicated build

This commit is contained in:
kremsy 2014-04-14 14:38:00 +02:00 committed by Steffen Schröder
parent 90b68feff0
commit 7021c63be1
2 changed files with 28 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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);
});
}