diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index e60b2e5c5..e74a68dad 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -31,7 +31,9 @@ class ConsoleAPI{ public function init(){ $this->server->schedule(2, array($this, "handle"), array(), true); - $this->loop = new ConsoleLoop(); + if(!defined("NO_THREADS")){ + $this->loop = new ConsoleLoop(); + } $this->register("help", "[page|command name]", array($this, "defaultCommands")); $this->register("status", "", array($this, "defaultCommands")); $this->register("difficulty", "<0|1|2|3>", array($this, "defaultCommands")); @@ -42,9 +44,11 @@ class ConsoleAPI{ function __destruct(){ $this->server->deleteEvent($this->event); - $this->loop->stop(); - $this->loop->notify(); - //$this->loop->join(); + if(!defined("NO_THREADS")){ + $this->loop->stop(); + $this->loop->notify(); + //$this->loop->join(); + } } public function defaultCommands($cmd, $params, $issuer, $alias){ @@ -248,6 +252,9 @@ class ConsoleAPI{ } public function handle($time){ + if(defined("NO_THREADS")){ + return; + } if($this->loop->line !== false){ $line = trim($this->loop->line); $this->loop->line = false; diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 157994dbe..54f8cd3ba 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -281,7 +281,7 @@ class ServerAPI{ if($this->getProperty("auto-save") === true){ $this->server->schedule(18000, array($this, "autoSave"), array(), true); } - if($this->getProperty("enable-rcon") === true){ + if(!defined("NO_THREADS") and $this->getProperty("enable-rcon") === true){ $this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("rcon.port", $this->getProperty("server-port")), ($ip = $this->getProperty("server-ip")) != "" ? $ip:"0.0.0.0", $this->getProperty("rcon.threads", 1), $this->getProperty("rcon.clients-per-thread", 50)); } diff --git a/src/tests/ServerSuiteTest.php b/src/tests/ServerSuiteTest.php index 7338a2212..069576c4b 100644 --- a/src/tests/ServerSuiteTest.php +++ b/src/tests/ServerSuiteTest.php @@ -12,6 +12,7 @@ class ServerSuiteTest extends PHPUnit_Framework_TestCase{ } public function testRead(){ + define("NO_THREADS", true); require_once(dirname(__FILE__)."/../dependencies.php"); require_once(FILE_PATH."/src/functions.php"); require_once(FILE_PATH."/src/dependencies.php");