From 51e2fde2b070e6b103f07f3cb96eed659208a854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 20 Jun 2014 16:34:19 +0200 Subject: [PATCH] improved mc quit handling --- application/core/ManiaControl.php | 19 ++++++++++++++----- application/core/Server/ServerCommands.php | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index a786d4e7..7025bf9f 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -89,7 +89,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { /* * Private Properties */ - private $shutdownRequested = false; + private $requestQuitMessage = null; /** * Construct ManiaControl @@ -280,7 +280,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->authenticationManager->sendNotAllowed($player); return; } - $this->quit("ManiaControl Shutdown requested by '{$player->login}'!"); + $this->requestQuit("ManiaControl Shutdown requested by '{$player->login}'!"); } /** @@ -317,12 +317,12 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!'); // Main loop - while (!$this->shutdownRequested) { + while (!$this->requestQuitMessage) { $this->loop(); } // Shutdown - $this->quit(); + $this->quit($this->requestQuitMessage); } /** @@ -399,6 +399,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { * Handle Server Stop Callback */ public function handleServerStopCallback() { - $this->quit('The Server has been shut down!'); + $this->requestQuit('The Server has been shut down!'); + } + + /** + * Request ManiaControl to quit + * + * @param mixed $message + */ + public function requestQuit($message = true) { + $this->requestQuitMessage = $message; } } diff --git a/application/core/Server/ServerCommands.php b/application/core/Server/ServerCommands.php index 801b5209..6f0c5c91 100644 --- a/application/core/Server/ServerCommands.php +++ b/application/core/Server/ServerCommands.php @@ -233,9 +233,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage * * @param string $login */ - private function shutdownServer($login = '#') { + private function shutdownServer($login = '-') { + $this->maniaControl->log("Server shutdown requested by '{$login}'!"); $this->maniaControl->client->stopServer(); - $this->maniaControl->quit("Server shutdown requested by '{$login}'"); } /**