code refactoring
- improved comparing & checking - improved string composition
This commit is contained in:
parent
bd6e0b5151
commit
9985b814d2
@ -123,7 +123,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
// If game is shootmania lower the icons position by 20
|
// If game is shootmania lower the icons position by 20
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'sm') {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -247,7 +247,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||||
//unset when another main widget got opened
|
//unset when another main widget got opened
|
||||||
if ($openedWidget != 'AdminList') {
|
if ($openedWidget !== 'AdminList') {
|
||||||
unset($this->adminListShown[$player->login]);
|
unset($this->adminListShown[$player->login]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class TimerManager {
|
|||||||
public function unregisterTimerListening(TimerListener $listener, $method) {
|
public function unregisterTimerListening(TimerListener $listener, $method) {
|
||||||
$removed = false;
|
$removed = false;
|
||||||
foreach ($this->timerListenings as $key => &$listening) {
|
foreach ($this->timerListenings as $key => &$listening) {
|
||||||
if ($listening->listener === $listener && $listening->method == $method) {
|
if ($listening->listener === $listener && $listening->method === $method) {
|
||||||
unset($this->timerListenings[$key]);
|
unset($this->timerListenings[$key]);
|
||||||
$removed = true;
|
$removed = true;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ class CommandManager implements CallbackListener {
|
|||||||
$removed = false;
|
$removed = false;
|
||||||
foreach ($listenerArray as &$listeners) {
|
foreach ($listenerArray as &$listeners) {
|
||||||
foreach ($listeners as $key => &$listenerCallback) {
|
foreach ($listeners as $key => &$listenerCallback) {
|
||||||
if ($listenerCallback[0] == $listener) {
|
if ($listenerCallback[0] === $listener) {
|
||||||
unset($listeners[$key]);
|
unset($listeners[$key]);
|
||||||
$removed = true;
|
$removed = true;
|
||||||
}
|
}
|
||||||
@ -162,11 +162,11 @@ class CommandManager implements CallbackListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($message, 0, 2) == '//' || $command == 'admin') {
|
if (substr($message, 0, 2) === '//' || $command === 'admin') {
|
||||||
// Admin command
|
// Admin command
|
||||||
$commandListeners = $this->adminCommandListeners;
|
$commandListeners = $this->adminCommandListeners;
|
||||||
|
|
||||||
if ($command == 'admin') {
|
if ($command === 'admin') {
|
||||||
// Strip 'admin' keyword
|
// Strip 'admin' keyword
|
||||||
if (isset($commandArray[1])) {
|
if (isset($commandArray[1])) {
|
||||||
$command = $commandArray[1];
|
$command = $commandArray[1];
|
||||||
|
@ -60,7 +60,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$showCommands = array();
|
$showCommands = array();
|
||||||
$registeredMethods = array();
|
$registeredMethods = array();
|
||||||
foreach (array_reverse($this->adminCommands) as $command) {
|
foreach (array_reverse($this->adminCommands) as $command) {
|
||||||
if (array_key_exists($command['Method'], $registeredMethods) && $showCommands[$registeredMethods[$command['Method']]]['Description'] == $command['Description']) {
|
if (array_key_exists($command['Method'], $registeredMethods) && $showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) {
|
||||||
$name = $registeredMethods[$command['Method']];
|
$name = $registeredMethods[$command['Method']];
|
||||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||||
} else {
|
} else {
|
||||||
@ -91,7 +91,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$showCommands = array();
|
$showCommands = array();
|
||||||
$registeredMethods = array();
|
$registeredMethods = array();
|
||||||
foreach (array_reverse($this->playerCommands) as $command) {
|
foreach (array_reverse($this->playerCommands) as $command) {
|
||||||
if (array_key_exists($command['Method'], $registeredMethods) && $showCommands[$registeredMethods[$command['Method']]]['Description'] == $command['Description']) {
|
if (array_key_exists($command['Method'], $registeredMethods) && $showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) {
|
||||||
$name = $registeredMethods[$command['Method']];
|
$name = $registeredMethods[$command['Method']];
|
||||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||||
} else {
|
} else {
|
||||||
@ -133,7 +133,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$registeredMethods = array();
|
$registeredMethods = array();
|
||||||
foreach (array_reverse($commands) as $command) {
|
foreach (array_reverse($commands) as $command) {
|
||||||
if (array_key_exists($command['Method'], $registeredMethods)) {
|
if (array_key_exists($command['Method'], $registeredMethods)) {
|
||||||
if ($showCommands[$registeredMethods[$command['Method']]]['Description'] == $command['Description']) {
|
if ($showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) {
|
||||||
$name = $registeredMethods[$command['Method']];
|
$name = $registeredMethods[$command['Method']];
|
||||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||||
} else {
|
} else {
|
||||||
@ -204,7 +204,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
|
@ -207,7 +207,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
|||||||
$menuItemLabel->setAction(self::ACTION_SELECTMENU . '.' . $menuId);
|
$menuItemLabel->setAction(self::ACTION_SELECTMENU . '.' . $menuId);
|
||||||
|
|
||||||
//Show a Menu
|
//Show a Menu
|
||||||
if ($menuId == $menuIdShown) {
|
if ($menuId === $menuIdShown) {
|
||||||
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $script, $player);
|
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $script, $player);
|
||||||
$menusFrame->add($menuControl);
|
$menusFrame->add($menuControl);
|
||||||
}
|
}
|
||||||
|
@ -128,11 +128,11 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$index = 0;
|
$index = 0;
|
||||||
$y = 0;
|
$y = 0;
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
if (!$pageFrame) {
|
if ($index % $pageMaxCount === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
$y = $height * 0.41;
|
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
|
$y = $height * 0.41;
|
||||||
}
|
}
|
||||||
|
|
||||||
$settingFrame = new Frame();
|
$settingFrame = new Frame();
|
||||||
@ -195,10 +195,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
||||||
$pageFrame = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +251,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$pageFrame = null;
|
$pageFrame = null;
|
||||||
$index = 0;
|
$index = 0;
|
||||||
foreach ($settingClasses as $settingClass) {
|
foreach ($settingClasses as $settingClass) {
|
||||||
if (!$pageFrame) {
|
if ($index % $pageMaxCount === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
$y = $height * 0.41;
|
$y = $height * 0.41;
|
||||||
@ -265,9 +261,9 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$classLabel = new Label_Text();
|
$classLabel = new Label_Text();
|
||||||
|
|
||||||
$settingClassArray = explode('\\', $settingClass);
|
$settingClassArray = explode('\\', $settingClass);
|
||||||
$className = "";
|
$className = '';
|
||||||
for ($i = 1; $i < count($settingClassArray); $i++) {
|
for ($i = 1; $i < count($settingClassArray); $i++) {
|
||||||
$className .= $settingClassArray[$i] . " - ";
|
$className .= $settingClassArray[$i] . ' - ';
|
||||||
}
|
}
|
||||||
$className = substr($className, 0, -3);
|
$className = substr($className, 0, -3);
|
||||||
|
|
||||||
@ -282,11 +278,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
|
|
||||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
||||||
$pageFrame = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($substyle != '') {
|
if ($substyle) {
|
||||||
$quad = new Quad_Icons64x64_1();
|
$quad = new Quad_Icons64x64_1();
|
||||||
$settingFrame->add($quad);
|
$settingFrame->add($quad);
|
||||||
$quad->setX($width / 2 * 0.545);
|
$quad->setX($width / 2 * 0.545);
|
||||||
|
@ -211,7 +211,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$quad = new Quad();
|
$quad = new Quad();
|
||||||
$quad->setPosition($width * 0.23, 0, -0.01);
|
$quad->setPosition($width * 0.23, 0, -0.01);
|
||||||
$quad->setSize(4, 4);
|
$quad->setSize(4, 4);
|
||||||
|
|
||||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $name, $value, $quad);
|
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $name, $value, $quad);
|
||||||
$settingFrame->add($checkBox);
|
$settingFrame->add($checkBox);
|
||||||
} else {
|
} else {
|
||||||
@ -225,11 +224,12 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$entry->setName(self::ACTION_PREFIX_SETTING . $name);
|
$entry->setName(self::ACTION_PREFIX_SETTING . $name);
|
||||||
$entry->setDefault($value);
|
$entry->setDefault($value);
|
||||||
|
|
||||||
if ($name == "Comment") { //
|
if ($name === 'Comment') {
|
||||||
$entry->setAutoNewLine(true);
|
$entry->setAutoNewLine(true);
|
||||||
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
|
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
|
||||||
$settingFrame->setY($y - $settingHeight * 1.5);
|
$settingFrame->setY($y - $settingHeight * 1.5);
|
||||||
// dummy:
|
// dummy:
|
||||||
|
// TODO: "dummy:" what? remove?
|
||||||
$y -= $settingHeight * 3;
|
$y -= $settingHeight * 3;
|
||||||
$id += 3;
|
$id += 3;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class AsynchronousFileReader {
|
|||||||
$request->socketSelect();
|
$request->socketSelect();
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($e->getMessage() == "Cannot perform if there are no requests in queue.") {
|
if ($e->getMessage() === 'Cannot perform if there are no requests in queue.') {
|
||||||
unset($this->requests[$key]);
|
unset($this->requests[$key]);
|
||||||
} else {
|
} else {
|
||||||
throw $e;
|
throw $e;
|
||||||
@ -82,7 +82,7 @@ class AsynchronousFileReader {
|
|||||||
$request->getOptions()->set(CURLOPT_TIMEOUT, 10) //
|
$request->getOptions()->set(CURLOPT_TIMEOUT, 10) //
|
||||||
->set(CURLOPT_HEADER, false) //don't display response header
|
->set(CURLOPT_HEADER, false) //don't display response header
|
||||||
->set(CURLOPT_CRLF, true) //linux linefeed
|
->set(CURLOPT_CRLF, true) //linux linefeed
|
||||||
->set(CURLOPT_ENCODING, "")//accept encoding
|
->set(CURLOPT_ENCODING, '')//accept encoding
|
||||||
->set(CURLOPT_AUTOREFERER, true)//accept link reference
|
->set(CURLOPT_AUTOREFERER, true)//accept link reference
|
||||||
->set(CURLOPT_HTTPHEADER, $header) //
|
->set(CURLOPT_HTTPHEADER, $header) //
|
||||||
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) //
|
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) //
|
||||||
@ -148,7 +148,7 @@ class AsynchronousFileReader {
|
|||||||
$request = new Request($url);
|
$request = new Request($url);
|
||||||
$request->getOptions()->set(CURLOPT_HEADER, false) //don't display response header
|
$request->getOptions()->set(CURLOPT_HEADER, false) //don't display response header
|
||||||
->set(CURLOPT_CRLF, true) //linux linefeed
|
->set(CURLOPT_CRLF, true) //linux linefeed
|
||||||
->set(CURLOPT_ENCODING, "")//accept encoding
|
->set(CURLOPT_ENCODING, '')//accept encoding
|
||||||
//->set(CURLOPT_AUTOREFERER, true)//accept link reference
|
//->set(CURLOPT_AUTOREFERER, true)//accept link reference
|
||||||
->set(CURLOPT_POST, true) //post field
|
->set(CURLOPT_POST, true) //post field
|
||||||
->set(CURLOPT_POSTFIELDS, $content) //post content field
|
->set(CURLOPT_POSTFIELDS, $content) //post content field
|
||||||
@ -160,8 +160,8 @@ class AsynchronousFileReader {
|
|||||||
$request->addListener('complete', function (Event $event) use (&$function) {
|
$request->addListener('complete', function (Event $event) use (&$function) {
|
||||||
/** @var Response $response */
|
/** @var Response $response */
|
||||||
$response = $event->response;
|
$response = $event->response;
|
||||||
$error = "";
|
$error = null;
|
||||||
$content = "";
|
$content = null;
|
||||||
if ($response->hasError()) {
|
if ($response->hasError()) {
|
||||||
$error = $response->getError()->getMessage();
|
$error = $response->getError()->getMessage();
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,7 +55,7 @@ abstract class FileUtil {
|
|||||||
if ($info['timed_out'] || !$buffer) {
|
if ($info['timed_out'] || !$buffer) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (substr($buffer, 9, 3) != '200') {
|
if (substr($buffer, 9, 3) !== '200') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
|
|
||||||
// Execute start script in background
|
// Execute start script in background
|
||||||
// TODO: restart the .php script itself ($_SERVER['scriptname'] or something + $argv)
|
// TODO: restart the .php script itself ($_SERVER['scriptname'] or something + $argv)
|
||||||
if ($this->getOS(self::OS_UNIX)) {
|
if ($this->getOS() === self::OS_UNIX) {
|
||||||
$command = 'sh ' . escapeshellarg(ManiaControlDir . 'ManiaControl.sh') . ' > /dev/null &';
|
$command = 'sh ' . escapeshellarg(ManiaControlDir . 'ManiaControl.sh') . ' > /dev/null &';
|
||||||
exec($command);
|
exec($command);
|
||||||
} else {
|
} else {
|
||||||
@ -263,20 +263,10 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
/**
|
/**
|
||||||
* Get the Operating System on which ManiaControl is running
|
* Get the Operating System on which ManiaControl is running
|
||||||
*
|
*
|
||||||
* @param string $compareOS
|
* @return string
|
||||||
* @return string|bool
|
|
||||||
*/
|
*/
|
||||||
public function getOS($compareOS = null) {
|
public function getOS() {
|
||||||
$windows = defined('PHP_WINDOWS_VERSION_MAJOR');
|
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||||
if ($compareOS) {
|
|
||||||
// Return bool whether OS equals $compareOS
|
|
||||||
if ($compareOS == self::OS_WIN) {
|
|
||||||
return $windows;
|
|
||||||
}
|
|
||||||
return !$windows;
|
|
||||||
}
|
|
||||||
// Return OS
|
|
||||||
if ($windows) {
|
|
||||||
return self::OS_WIN;
|
return self::OS_WIN;
|
||||||
}
|
}
|
||||||
return self::OS_UNIX;
|
return self::OS_UNIX;
|
||||||
|
@ -34,7 +34,7 @@ class MXMapInfo {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->prefix == 'tm') {
|
if ($this->prefix === 'tm') {
|
||||||
$this->dir = 'tracks';
|
$this->dir = 'tracks';
|
||||||
$this->id = $mx->TrackID;
|
$this->id = $mx->TrackID;
|
||||||
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
|
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
|
||||||
@ -44,7 +44,7 @@ class MXMapInfo {
|
|||||||
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($mx->GbxMapName) || $mx->GbxMapName == '?') {
|
if (!isset($mx->GbxMapName) || $mx->GbxMapName === '?') {
|
||||||
$this->name = $mx->Name;
|
$this->name = $mx->Name;
|
||||||
} else {
|
} else {
|
||||||
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
|
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
|
||||||
@ -84,9 +84,9 @@ class MXMapInfo {
|
|||||||
$this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 0;
|
$this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 0;
|
||||||
$this->ratingVoteAverage = isset($mx->RatingVoteAverage) ? $mx->RatingVoteAverage : 0;
|
$this->ratingVoteAverage = isset($mx->RatingVoteAverage) ? $mx->RatingVoteAverage : 0;
|
||||||
|
|
||||||
if ($this->trkvalue == 0 && $this->lbrating > 0) {
|
if (!$this->trkvalue && $this->lbrating > 0) {
|
||||||
$this->trkvalue = $this->lbrating;
|
$this->trkvalue = $this->lbrating;
|
||||||
} elseif ($this->lbrating == 0 && $this->trkvalue > 0) {
|
} elseif (!$this->lbrating && $this->trkvalue > 0) {
|
||||||
$this->lbrating = $this->trkvalue;
|
$this->lbrating = $this->trkvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class MXMapInfo {
|
|||||||
$this->thumburl = '';
|
$this->thumburl = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->prefix == 'tm' && $this->replayid > 0) {
|
if ($this->prefix === 'tm' && $this->replayid > 0) {
|
||||||
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
|
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
|
||||||
} else {
|
} else {
|
||||||
$this->replayurl = '';
|
$this->replayurl = '';
|
||||||
|
@ -108,21 +108,22 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
$environment = '';
|
$environment = '';
|
||||||
if (count($params) >= 1) {
|
if (count($params) >= 1) {
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
if ($param == '/xlist' || $param == MapCommands::ACTION_OPEN_XLIST) {
|
if ($param === '/xlist' || $param === MapCommands::ACTION_OPEN_XLIST) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($param == self::ACTION_SEARCH_MAPNAME) {
|
if ($param === self::ACTION_SEARCH_MAPNAME) {
|
||||||
$searchString = $chatCallback[1][3][0]['Value'];
|
$searchString = $chatCallback[1][3][0]['Value'];
|
||||||
} else if ($param == self::ACTION_SEARCH_AUTHOR) {
|
} else if ($param === self::ACTION_SEARCH_AUTHOR) {
|
||||||
$author = $chatCallback[1][3][0]['Value'];
|
$author = $chatCallback[1][3][0]['Value'];
|
||||||
} else if (strtolower(substr($param, 0, 5)) == 'auth:') {
|
} else if (strtolower(substr($param, 0, 5)) === 'auth:') {
|
||||||
$author = substr($param, 5);
|
$author = substr($param, 5);
|
||||||
} else if (strtolower(substr($param, 0, 4)) == 'env:') {
|
} else if (strtolower(substr($param, 0, 4)) === 'env:') {
|
||||||
$environment = substr($param, 4);
|
$environment = substr($param, 4);
|
||||||
} else {
|
} else {
|
||||||
if ($searchString == '') {
|
if (!$searchString) {
|
||||||
$searchString = $param;
|
$searchString = $param;
|
||||||
} else { // concatenate words in name
|
} else {
|
||||||
|
// concatenate words in name
|
||||||
$searchString .= '%20' . $param;
|
$searchString .= '%20' . $param;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
$mapFrame = new Frame();
|
$mapFrame = new Frame();
|
||||||
$pageFrame->add($mapFrame);
|
$pageFrame->add($mapFrame);
|
||||||
|
|
||||||
if ($i % 2 == 0) {
|
if ($i % 2 === 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$mapFrame->add($lineQuad);
|
$mapFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -201,7 +202,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
||||||
$array = array('$s' . $map->id => $x + 3.5, '$s' . $map->name => $x + 12.5, '$s' . $map->author => $x + 59, '$s' . str_replace("Arena", "", $map->maptype) => $x + 103, '$s' . $map->mood => $x + 118, '$s' . $time => $x + 130);
|
$array = array('$s' . $map->id => $x + 3.5, '$s' . $map->name => $x + 12.5, '$s' . $map->author => $x + 59, '$s' . str_replace('Arena', '', $map->maptype) => $x + 103, '$s' . $map->mood => $x + 118, '$s' . $time => $x + 130);
|
||||||
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
||||||
$authorLabel = $labels[2];
|
$authorLabel = $labels[2];
|
||||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||||
@ -337,7 +338,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
*/
|
*/
|
||||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||||
//unset when another main widget got opened
|
//unset when another main widget got opened
|
||||||
if ($openedWidget != 'ManiaExchangeList') {
|
if ($openedWidget !== 'ManiaExchangeList') {
|
||||||
unset($this->mapListShown[$player->login]);
|
unset($this->mapListShown[$player->login]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ class ManiaExchangeManager {
|
|||||||
//Set changed time into the map object
|
//Set changed time into the map object
|
||||||
$map->lastUpdate = strtotime($changed);
|
$map->lastUpdate = strtotime($changed);
|
||||||
|
|
||||||
if ($mxId != 0) {
|
if ($mxId) {
|
||||||
$appendString = $mxId . ',';
|
$appendString = $mxId . ',';
|
||||||
//Set the mx id to the mxidmapvektor
|
//Set the mx id to the mxidmapvektor
|
||||||
$this->mxIdUidVector[$mxId] = $map->uid;
|
$this->mxIdUidVector[$mxId] = $map->uid;
|
||||||
@ -122,7 +122,7 @@ class ManiaExchangeManager {
|
|||||||
$id++;
|
$id++;
|
||||||
|
|
||||||
//If Max Maplimit is reached, or string gets too long send the request
|
//If Max Maplimit is reached, or string gets too long send the request
|
||||||
if ($id % self::MAPS_PER_MX_FETCH == 0) {
|
if ($id % self::MAPS_PER_MX_FETCH === 0) {
|
||||||
$mapIdString = substr($mapIdString, 0, -1);
|
$mapIdString = substr($mapIdString, 0, -1);
|
||||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
$this->getMaplistByMixedUidIdString($mapIdString);
|
||||||
$mapIdString = '';
|
$mapIdString = '';
|
||||||
@ -131,7 +131,7 @@ class ManiaExchangeManager {
|
|||||||
$mapIdString .= $appendString;
|
$mapIdString .= $appendString;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mapIdString != '') {
|
if ($mapIdString) {
|
||||||
$mapIdString = substr($mapIdString, 0, -1);
|
$mapIdString = substr($mapIdString, 0, -1);
|
||||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
$this->getMaplistByMixedUidIdString($mapIdString);
|
||||||
}
|
}
|
||||||
@ -273,6 +273,8 @@ class ManiaExchangeManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove $env because it's not really used?
|
||||||
|
|
||||||
// Get Title Id
|
// Get Title Id
|
||||||
$titleId = $this->maniaControl->server->titleId;
|
$titleId = $this->maniaControl->server->titleId;
|
||||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||||
@ -282,20 +284,20 @@ class ManiaExchangeManager {
|
|||||||
|
|
||||||
$game = explode('@', $titleId);
|
$game = explode('@', $titleId);
|
||||||
$envNumber = $this->getEnvironment($game[0]);
|
$envNumber = $this->getEnvironment($game[0]);
|
||||||
if ($env != '' || $envNumber != -1) {
|
if ($env || $envNumber > -1) {
|
||||||
$url .= '&environments=' . $envNumber;
|
$url .= '&environments=' . $envNumber;
|
||||||
}
|
}
|
||||||
if ($name != '') {
|
if ($name) {
|
||||||
$url .= '&trackname=' . str_replace(" ", "%20", $name);
|
$url .= '&trackname=' . str_replace(" ", "%20", $name);
|
||||||
}
|
}
|
||||||
if ($author != '') {
|
if ($author) {
|
||||||
$url .= '&author=' . $author;
|
$url .= '&author=' . $author;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url .= '&priord=' . $searchOrder;
|
$url .= '&priord=' . $searchOrder;
|
||||||
$url .= '&limit=' . $maxMapsReturned;
|
$url .= '&limit=' . $maxMapsReturned;
|
||||||
|
|
||||||
if ($titlePrefix != "tm") {
|
if ($titlePrefix !== "tm") {
|
||||||
$url .= '&minexebuild=' . self::MIN_EXE_BUILD;
|
$url .= '&minexebuild=' . self::MIN_EXE_BUILD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,21 +80,20 @@ class Map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's the gameType of the Current Map
|
* Get the Game Type of the Map
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGame() {
|
public function getGame() {
|
||||||
switch ($this->environment) {
|
switch ($this->environment) {
|
||||||
case 'Storm':
|
case 'Storm':
|
||||||
return "sm";
|
return 'sm';
|
||||||
case 'Canyon':
|
case 'Canyon':
|
||||||
case 'Stadium':
|
case 'Stadium':
|
||||||
case 'Valley':
|
case 'Valley':
|
||||||
return "tm";
|
return 'tm';
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +103,7 @@ class Map {
|
|||||||
*/
|
*/
|
||||||
public function updateAvailable() {
|
public function updateAvailable() {
|
||||||
|
|
||||||
if ($this->mx && ($this->lastUpdate < strtotime($this->mx->updated) || $this->uid != $this->mx->uid)) {
|
if ($this->mx && ($this->lastUpdate < strtotime($this->mx->updated) || $this->uid !== $this->mx->uid)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -342,11 +342,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
foreach ($maps as $map) {
|
foreach ($maps as $map) {
|
||||||
if ($map->authorLogin == $author) {
|
if ($map->authorLogin == $author) {
|
||||||
$mapList[] = $map;
|
array_push($mapList, $map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($mapList) == 0) {
|
if (empty($mapList)) {
|
||||||
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
|
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -363,23 +363,32 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
public function command_List(array $chatCallback, Player $player) {
|
public function command_List(array $chatCallback, Player $player) {
|
||||||
$chatCommands = explode(' ', $chatCallback[1][2]);
|
$chatCommands = explode(' ', $chatCallback[1][2]);
|
||||||
$this->maniaControl->mapManager->mapList->playerCloseWidget($player);
|
$this->maniaControl->mapManager->mapList->playerCloseWidget($player);
|
||||||
|
|
||||||
if (isset($chatCommands[1])) {
|
if (isset($chatCommands[1])) {
|
||||||
if ($chatCommands[1] == ' ' || $chatCommands[1] == 'all') {
|
$listParam = strtolower($chatCommands[1]);
|
||||||
$this->maniaControl->mapManager->mapList->showMapList($player);
|
switch ($listParam) {
|
||||||
} elseif ($chatCommands[1] == 'best') {
|
case 'best':
|
||||||
$this->showMapListKarma(true, $player);
|
$this->showMapListKarma(true, $player);
|
||||||
} elseif ($chatCommands[1] == 'worst') {
|
break;
|
||||||
|
case 'worst':
|
||||||
$this->showMapListKarma(false, $player);
|
$this->showMapListKarma(false, $player);
|
||||||
} elseif ($chatCommands[1] == 'newest') {
|
break;
|
||||||
|
case 'newest':
|
||||||
$this->showMapListDate(true, $player);
|
$this->showMapListDate(true, $player);
|
||||||
} elseif ($chatCommands[1] == 'oldest') {
|
break;
|
||||||
|
case 'oldest':
|
||||||
$this->showMapListDate(false, $player);
|
$this->showMapListDate(false, $player);
|
||||||
} elseif ($chatCommands[1] == 'author') {
|
break;
|
||||||
|
case 'author':
|
||||||
if (isset($chatCommands[2])) {
|
if (isset($chatCommands[2])) {
|
||||||
$this->showMaplistAuthor($chatCommands[2], $player);
|
$this->showMaplistAuthor($chatCommands[2], $player);
|
||||||
} else {
|
} else {
|
||||||
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
|
$this->maniaControl->chat->sendError('Missing Author Login!', $player->login);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->maniaControl->mapManager->mapList->showMapList($player);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->maniaControl->mapManager->mapList->showMapList($player);
|
$this->maniaControl->mapManager->mapList->showMapList($player);
|
||||||
@ -409,7 +418,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$plus = 0;
|
$plus = 0;
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote) {
|
||||||
if (isset($vote->vote)) {
|
if (isset($vote->vote)) {
|
||||||
if ($vote->vote != 0.5) {
|
if ($vote->vote !== 0.5) {
|
||||||
if ($vote->vote < 0.5) {
|
if ($vote->vote < 0.5) {
|
||||||
$min = $min + $vote->count;
|
$min = $min + $vote->count;
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$mapFrame->setZ(0.1);
|
$mapFrame->setZ(0.1);
|
||||||
$mapFrame->setY($y);
|
$mapFrame->setY($y);
|
||||||
|
|
||||||
if ($id % 2 != 0) {
|
if ($id % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$mapFrame->add($lineQuad);
|
$mapFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -422,7 +422,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$plus = 0;
|
$plus = 0;
|
||||||
foreach ($votes as $vote) {
|
foreach ($votes as $vote) {
|
||||||
if (isset($vote->vote)) {
|
if (isset($vote->vote)) {
|
||||||
if ($vote->vote != 0.5) {
|
if ($vote->vote !== 0.5) {
|
||||||
if ($vote->vote < 0.5) {
|
if ($vote->vote < 0.5) {
|
||||||
$min = $min + $vote->count;
|
$min = $min + $vote->count;
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,7 +310,7 @@ class MapManager implements CallbackListener {
|
|||||||
try {
|
try {
|
||||||
$this->maniaControl->client->writeFile($relativeMapFileName, $file);
|
$this->maniaControl->client->writeFile($relativeMapFileName, $file);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
if ($e->getMessage() == 'data are too big') {
|
if ($e->getMessage() === 'data are too big') {
|
||||||
$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login);
|
$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->queuedMaps) == 0) {
|
if (empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $admin->login);
|
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $admin->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -135,12 +135,20 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
$chatCommands = explode(' ', $chatCallback[1][2]);
|
$chatCommands = explode(' ', $chatCallback[1][2]);
|
||||||
|
|
||||||
if (isset($chatCommands[1])) {
|
if (isset($chatCommands[1])) {
|
||||||
if ($chatCommands[1] == ' ' || $chatCommands[1] == 'list') {
|
$listParam = strtolower($chatCommands[1]);
|
||||||
|
switch ($listParam) {
|
||||||
|
case 'list':
|
||||||
$this->showMapQueue($player);
|
$this->showMapQueue($player);
|
||||||
} elseif ($chatCommands[1] == 'display') {
|
break;
|
||||||
|
case 'display':
|
||||||
$this->showMapQueueManialink($player);
|
$this->showMapQueueManialink($player);
|
||||||
} elseif ($chatCommands[1] == 'clear') {
|
break;
|
||||||
|
case 'clear':
|
||||||
$this->clearMapQueue($player);
|
$this->clearMapQueue($player);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->showMapQueue($player);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->showMapQueue($player);
|
$this->showMapQueue($player);
|
||||||
@ -153,7 +161,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapQueue(Player $player) {
|
public function showMapQueue(Player $player) {
|
||||||
if (count($this->queuedMaps) == 0) {
|
if (empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -174,14 +182,14 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapQueueManialink(Player $player) {
|
public function showMapQueueManialink(Player $player) {
|
||||||
if (count($this->queuedMaps) == 0) {
|
if (empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
$this->maniaControl->chat->sendError('There are no Maps in the Jukebox!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$maps = array();
|
$maps = array();
|
||||||
foreach ($this->queuedMaps as $queuedMap) {
|
foreach ($this->queuedMaps as $queuedMap) {
|
||||||
$maps[] = $queuedMap[1];
|
array_push($maps, $queuedMap[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->mapManager->mapList->showMapList($player, $maps);
|
$this->maniaControl->mapManager->mapList->showMapList($player, $maps);
|
||||||
@ -220,12 +228,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
*/
|
*/
|
||||||
public function addMapToMapQueue($login, $uid) {
|
public function addMapToMapQueue($login, $uid) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
if (!$player) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Check if player is allowed to add (another) map
|
//Check if player is allowed to add (another) map
|
||||||
$admin = false;
|
$isModerator = $this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, 2) || $this->maniaControl->authenticationManager->checkRight($player, 3) || $this->maniaControl->authenticationManager->checkRight($player, 4)) {
|
|
||||||
$admin = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mapsForPlayer = 0;
|
$mapsForPlayer = 0;
|
||||||
foreach ($this->queuedMaps as $queuedMap) {
|
foreach ($this->queuedMaps as $queuedMap) {
|
||||||
@ -234,16 +242,15 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$maxPlayer = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
if ($isModerator) {
|
||||||
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||||
|
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
|
||||||
if ($admin && $maxAdmin != -1) {
|
|
||||||
if ($mapsForPlayer == $maxAdmin) {
|
|
||||||
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
|
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} elseif (!$admin && $maxPlayer != -1) {
|
} else {
|
||||||
if ($mapsForPlayer == $maxPlayer) {
|
$maxPlayer = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
||||||
|
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
|
||||||
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login);
|
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -308,8 +315,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->nextMap = null;
|
$this->nextMap = null;
|
||||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
|
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
|
||||||
|
|
||||||
// Skip Map if requester has left
|
// Skip Map if requester has left
|
||||||
foreach ($this->queuedMaps as $queuedMap) {
|
foreach ($this->queuedMaps as $queuedMap) {
|
||||||
$player = $queuedMap[0];
|
$player = $queuedMap[0];
|
||||||
@ -324,7 +330,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN) == false) {
|
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN)) {
|
||||||
//Check if the queuer is a admin
|
//Check if the queuer is a admin
|
||||||
if ($player->authLevel > 0) {
|
if ($player->authLevel > 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -180,7 +180,7 @@ class Player {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isFakePlayer() {
|
public function isFakePlayer() {
|
||||||
return ($this->pid <= 0 || $this->path == "");
|
return ($this->pid <= 0 || !$this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,9 +102,9 @@ class PlayerActions {
|
|||||||
|
|
||||||
$chatMessage = false;
|
$chatMessage = false;
|
||||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||||
if ($teamId == self::TEAM_BLUE) {
|
if ($teamId === self::TEAM_BLUE) {
|
||||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
|
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
|
||||||
} else if ($teamId == self::TEAM_RED) {
|
} else if ($teamId === self::TEAM_RED) {
|
||||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
|
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
|
||||||
}
|
}
|
||||||
if (!$chatMessage) {
|
if (!$chatMessage) {
|
||||||
@ -497,7 +497,7 @@ class PlayerActions {
|
|||||||
public function isPlayerMuted($login) {
|
public function isPlayerMuted($login) {
|
||||||
$ignoreList = $this->maniaControl->client->getIgnoreList(100, 0);
|
$ignoreList = $this->maniaControl->client->getIgnoreList(100, 0);
|
||||||
foreach ($ignoreList as $ignoredPlayers) {
|
foreach ($ignoreList as $ignoredPlayers) {
|
||||||
if ($ignoredPlayers->login == $login) {
|
if ($ignoredPlayers->login === $login) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,12 +223,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
|||||||
|
|
||||||
$type = 2;
|
$type = 2;
|
||||||
if (isset($params[2]) && is_numeric($params[2])) {
|
if (isset($params[2]) && is_numeric($params[2])) {
|
||||||
$type = intval($params[2]);
|
$type = (int)$params[2];
|
||||||
}
|
|
||||||
$selectable = false;
|
|
||||||
if ($type == 2) {
|
|
||||||
$selectable = true;
|
|
||||||
}
|
}
|
||||||
|
$selectable = ($type === 2);
|
||||||
|
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||||
}
|
}
|
||||||
|
@ -225,52 +225,51 @@ class PlayerDetailed {
|
|||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
|
|
||||||
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);
|
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);
|
||||||
$y = $this->height / 2 - 15;
|
$posY = $this->height / 2 - 15;
|
||||||
$x = -$this->width / 2 + 52;
|
$posX = -$this->width / 2 + 52;
|
||||||
$id = 1;
|
$id = 1;
|
||||||
|
|
||||||
foreach ($playerStats as $stat) {
|
foreach ($playerStats as $stat) {
|
||||||
$statProperties = $stat[0];
|
$value = (float)$stat[1];
|
||||||
$value = $stat[1];
|
if (!$value) {
|
||||||
|
|
||||||
if (floatval($value) == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($statProperties->type == StatisticManager::STAT_TYPE_TIME) {
|
$statProperties = $stat[0];
|
||||||
|
if ($statProperties->type === StatisticManager::STAT_TYPE_TIME) {
|
||||||
$value = Formatter::formatTimeHMS($value);
|
$value = Formatter::formatTimeHMS($value);
|
||||||
} else if ($statProperties->type == StatisticManager::STAT_TYPE_FLOAT) {
|
} else if ($statProperties->type === StatisticManager::STAT_TYPE_FLOAT) {
|
||||||
$value = round(floatval($value), 2);
|
$value = round($value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id % 2 != 0) {
|
if ($id % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$frame->add($lineQuad);
|
$frame->add($lineQuad);
|
||||||
$lineQuad->setSize(49, 4);
|
$lineQuad->setSize(49, 4);
|
||||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$lineQuad->setPosition($x, $y, 0.001);
|
$lineQuad->setPosition($posX, $posY, 0.001);
|
||||||
$lineQuad->setHAlign(Control::LEFT);
|
$lineQuad->setHAlign(Control::LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setPosition($x + 4, $y);
|
$label->setPosition($posX + 4, $posY);
|
||||||
$label->setText($statProperties->name);
|
$label->setText($statProperties->name);
|
||||||
$label->setHAlign(Control::LEFT);
|
$label->setHAlign(Control::LEFT);
|
||||||
$label->setTextSize(1.5);
|
$label->setTextSize(1.5);
|
||||||
|
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setPosition($x + 40, $y);
|
$label->setPosition($posX + 40, $posY);
|
||||||
$label->setText($value);
|
$label->setText($value);
|
||||||
$label->setTextSize(1.5);
|
$label->setTextSize(1.5);
|
||||||
|
|
||||||
$y -= 4;
|
$posY -= 4;
|
||||||
$id++;
|
$id++;
|
||||||
|
|
||||||
if ($id > self::STATS_PER_COLUMN) {
|
if ($id > self::STATS_PER_COLUMN) {
|
||||||
$y = $this->height / 2 - 15;
|
$posY = $this->height / 2 - 15;
|
||||||
$x += 47;
|
$posX += 47;
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
*/
|
*/
|
||||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||||
//unset when another main widget got opened
|
//unset when another main widget got opened
|
||||||
if ($openedWidget != 'PlayerList') {
|
if ($openedWidget !== 'PlayerList') {
|
||||||
unset($this->playersListShown[$player->login]);
|
unset($this->playersListShown[$player->login]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -201,7 +201,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
// Show current Player Arrow
|
// Show current Player Arrow
|
||||||
if ($listPlayer->index == $player->index) {
|
if ($listPlayer->index === $player->index) {
|
||||||
$currentQuad = new Quad_Icons64x64_1();
|
$currentQuad = new Quad_Icons64x64_1();
|
||||||
$playerFrame->add($currentQuad);
|
$playerFrame->add($currentQuad);
|
||||||
$currentQuad->setX($x + 3.5);
|
$currentQuad->setX($x + 3.5);
|
||||||
@ -238,14 +238,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
}
|
}
|
||||||
|
|
||||||
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
|
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
|
||||||
if ($countryCode != 'OTH') {
|
if ($countryCode !== 'OTH') {
|
||||||
// Nation Quad
|
// Nation Quad
|
||||||
$countryQuad = new Quad();
|
$countryQuad = new Quad();
|
||||||
$playerFrame->add($countryQuad);
|
$playerFrame->add($countryQuad);
|
||||||
$countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country");
|
$countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country");
|
||||||
$countryQuad->setX($x + 98);
|
$countryQuad->setX($x + 98);
|
||||||
$countryQuad->setSize(4, 4);
|
|
||||||
$countryQuad->setZ(1);
|
$countryQuad->setZ(1);
|
||||||
|
$countryQuad->setSize(4, 4);
|
||||||
|
|
||||||
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
|
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
|
||||||
}
|
}
|
||||||
@ -255,15 +255,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($rightQuad);
|
$playerFrame->add($rightQuad);
|
||||||
$rightQuad->setX($x + 13);
|
$rightQuad->setX($x + 13);
|
||||||
$rightQuad->setZ(3);
|
$rightQuad->setZ(3);
|
||||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
|
||||||
$rightQuad->setSize(7, 3.5);
|
$rightQuad->setSize(7, 3.5);
|
||||||
|
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||||
|
|
||||||
$rightLabel = new Label_Text();
|
$rightLabel = new Label_Text();
|
||||||
$playerFrame->add($rightLabel);
|
$playerFrame->add($rightLabel);
|
||||||
$rightLabel->setX($x + 13.9);
|
$rightLabel->setX($x + 13.9);
|
||||||
$rightLabel->setTextSize(0.8);
|
|
||||||
$rightLabel->setZ(3.1);
|
$rightLabel->setZ(3.1);
|
||||||
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($listPlayer->authLevel));
|
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||||
|
$rightLabel->setTextSize(0.8);
|
||||||
$rightLabel->setTextColor("fff");
|
$rightLabel->setTextColor("fff");
|
||||||
|
|
||||||
$description = $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer) . " " . $listPlayer->nickname;
|
$description = $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer) . " " . $listPlayer->nickname;
|
||||||
@ -274,8 +274,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
$playerQuad->setX($x + 61);
|
$playerQuad->setX($x + 61);
|
||||||
$playerQuad->setZ(3);
|
$playerQuad->setZ(3);
|
||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
|
||||||
$playerQuad->setSize(2.7, 2.7);
|
$playerQuad->setSize(2.7, 2.7);
|
||||||
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
||||||
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
||||||
$description = 'View Statistics of $<' . $listPlayer->nickname . '$>';
|
$description = 'View Statistics of $<' . $listPlayer->nickname . '$>';
|
||||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
@ -285,8 +285,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
$playerQuad->setX($x + 64.5);
|
$playerQuad->setX($x + 64.5);
|
||||||
$playerQuad->setZ(3);
|
$playerQuad->setZ(3);
|
||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
||||||
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
|
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
|
||||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER . "." . $listPlayer->login);
|
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER . "." . $listPlayer->login);
|
||||||
@ -296,8 +296,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
$playerQuad->setX($x + 68);
|
$playerQuad->setX($x + 68);
|
||||||
$playerQuad->setZ(3);
|
$playerQuad->setZ(3);
|
||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||||
$playerQuad->addPlayerProfileFeature($listPlayer->login);
|
$playerQuad->addPlayerProfileFeature($listPlayer->login);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
@ -310,8 +310,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
$playerQuad->setX($x + 132);
|
$playerQuad->setX($x + 132);
|
||||||
$playerQuad->setZ(0.1);
|
$playerQuad->setZ(0.1);
|
||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||||
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
@ -326,9 +326,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($redQuad);
|
$playerFrame->add($redQuad);
|
||||||
$redQuad->setX($x + 145);
|
$redQuad->setX($x + 145);
|
||||||
$redQuad->setZ(0.1);
|
$redQuad->setZ(0.1);
|
||||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
|
||||||
$redQuad->setSize(3.8, 3.8);
|
$redQuad->setSize(3.8, 3.8);
|
||||||
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||||
|
$redQuad->setAction(self::ACTION_FORCE_RED . '.' . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Red-Team Description Label
|
// Force to Red-Team Description Label
|
||||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Red Team!';
|
$description = 'Force $<' . $listPlayer->nickname . '$> to Red Team!';
|
||||||
@ -339,9 +339,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($blueQuad);
|
$playerFrame->add($blueQuad);
|
||||||
$blueQuad->setX($x + 141);
|
$blueQuad->setX($x + 141);
|
||||||
$blueQuad->setZ(0.1);
|
$blueQuad->setZ(0.1);
|
||||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
|
||||||
$blueQuad->setSize(3.8, 3.8);
|
$blueQuad->setSize(3.8, 3.8);
|
||||||
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||||
|
$blueQuad->setAction(self::ACTION_FORCE_BLUE . '.' . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Blue-Team Description Label
|
// Force to Blue-Team Description Label
|
||||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
||||||
@ -353,9 +353,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($kickQuad);
|
$playerFrame->add($kickQuad);
|
||||||
$kickQuad->setX($x + 141);
|
$kickQuad->setX($x + 141);
|
||||||
$kickQuad->setZ(0.1);
|
$kickQuad->setZ(0.1);
|
||||||
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
|
|
||||||
$kickQuad->setSize(3.8, 3.8);
|
$kickQuad->setSize(3.8, 3.8);
|
||||||
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . "." . $listPlayer->login);
|
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
|
||||||
|
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . '.' . $listPlayer->login);
|
||||||
|
|
||||||
$description = 'Start a Kick Vote on $<' . $listPlayer->nickname . '$>!';
|
$description = 'Start a Kick Vote on $<' . $listPlayer->nickname . '$>!';
|
||||||
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
@ -367,9 +367,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($playQuad);
|
$playerFrame->add($playQuad);
|
||||||
$playQuad->setX($x + 143);
|
$playQuad->setX($x + 143);
|
||||||
$playQuad->setZ(0.1);
|
$playQuad->setZ(0.1);
|
||||||
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
|
|
||||||
$playQuad->setSize(3.8, 3.8);
|
$playQuad->setSize(3.8, 3.8);
|
||||||
$playQuad->setAction(self::ACTION_FORCE_PLAY . "." . $listPlayer->login);
|
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
|
||||||
|
$playQuad->setAction(self::ACTION_FORCE_PLAY . '.' . $listPlayer->login);
|
||||||
|
|
||||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Play!';
|
$description = 'Force $<' . $listPlayer->nickname . '$> to Play!';
|
||||||
$playQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
$playQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
@ -382,9 +382,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($spectatorQuad);
|
$playerFrame->add($spectatorQuad);
|
||||||
$spectatorQuad->setX($x + 137);
|
$spectatorQuad->setX($x + 137);
|
||||||
$spectatorQuad->setZ(0.1);
|
$spectatorQuad->setZ(0.1);
|
||||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
|
||||||
$spectatorQuad->setSize(3.8, 3.8);
|
$spectatorQuad->setSize(3.8, 3.8);
|
||||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||||
|
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . '.' . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Spectator Description Label
|
// Force to Spectator Description Label
|
||||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||||
@ -395,9 +395,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$playerFrame->add($spectatorQuad);
|
$playerFrame->add($spectatorQuad);
|
||||||
$spectatorQuad->setX($x + 137);
|
$spectatorQuad->setX($x + 137);
|
||||||
$spectatorQuad->setZ(0.1);
|
$spectatorQuad->setZ(0.1);
|
||||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
|
||||||
$spectatorQuad->setSize(3.8, 3.8);
|
$spectatorQuad->setSize(3.8, 3.8);
|
||||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . "." . $listPlayer->login);
|
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||||
|
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . '.' . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Spectator Description Label
|
// Force to Spectator Description Label
|
||||||
$description = 'Start a Vote to force $<' . $listPlayer->nickname . '$> to Spectator!';
|
$description = 'Start a Vote to force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||||
@ -409,8 +409,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show advanced window
|
// Show advanced window
|
||||||
if ($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
$listShownValue = $this->playersListShown[$player->login];
|
||||||
$frame = $this->showAdvancedPlayerWidget($player, $this->playersListShown[$player->login]);
|
if ($listShownValue && $listShownValue !== self::SHOWN_MAIN_WINDOW) {
|
||||||
|
$frame = $this->showAdvancedPlayerWidget($player, $listShownValue);
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +774,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reopen widget
|
// Reopen widget
|
||||||
if ($shown != self::SHOWN_MAIN_WINDOW) {
|
if ($shown !== self::SHOWN_MAIN_WINDOW) {
|
||||||
$this->playersListShown[$login] = false;
|
$this->playersListShown[$login] = false;
|
||||||
}
|
}
|
||||||
$this->showPlayerList($player);
|
$this->showPlayerList($player);
|
||||||
|
@ -123,7 +123,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
$detailedPlayerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login);
|
$detailedPlayerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login);
|
||||||
|
|
||||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||||
if ($playerItem->teamId != -1) {
|
if ($playerItem->teamId >= 0) {
|
||||||
$this->maniaControl->server->setTeamMode(true);
|
$this->maniaControl->server->setTeamMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
$player->teamId = $callback[1][0]["TeamId"];
|
$player->teamId = $callback[1][0]["TeamId"];
|
||||||
|
|
||||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||||
if ($player->teamId != -1) {
|
if ($player->teamId >= 0) {
|
||||||
$this->maniaControl->server->setTeamMode(true);
|
$this->maniaControl->server->setTeamMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
*/
|
*/
|
||||||
public function getPlayerByIndex($index, $connectedPlayersOnly = false) {
|
public function getPlayerByIndex($index, $connectedPlayersOnly = false) {
|
||||||
foreach ($this->players as $player) {
|
foreach ($this->players as $player) {
|
||||||
if ($player->index == $index) {
|
if ($player->index === $index) {
|
||||||
return $player;
|
return $player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
|
|
||||||
// Display normal Plugin List
|
// Display normal Plugin List
|
||||||
// Plugin pages
|
// Plugin pages
|
||||||
$y = 0.;
|
$posY = 0.;
|
||||||
$pluginUpdates = $this->maniaControl->updateManager->pluginUpdateManager->getPluginsUpdates();
|
$pluginUpdates = $this->maniaControl->updateManager->pluginUpdateManager->getPluginsUpdates();
|
||||||
|
|
||||||
usort($pluginClasses, function ($a, $b) {
|
usort($pluginClasses, function ($a, $b) {
|
||||||
@ -142,14 +142,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
$y = $height * 0.41;
|
$posY = $height * 0.41;
|
||||||
}
|
}
|
||||||
|
|
||||||
$active = $this->maniaControl->pluginManager->isPluginActive($pluginClass);
|
$active = $this->maniaControl->pluginManager->isPluginActive($pluginClass);
|
||||||
|
|
||||||
$pluginFrame = new Frame();
|
$pluginFrame = new Frame();
|
||||||
$pageFrame->add($pluginFrame);
|
$pageFrame->add($pluginFrame);
|
||||||
$pluginFrame->setY($y);
|
$pluginFrame->setY($posY);
|
||||||
|
|
||||||
$activeQuad = new Quad_Icons64x64_1();
|
$activeQuad = new Quad_Icons64x64_1();
|
||||||
$pluginFrame->add($activeQuad);
|
$pluginFrame->add($activeQuad);
|
||||||
@ -207,7 +207,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
$statusChangeButton->setAction(self::ACTION_PREFIX_ENABLEPLUGIN . $pluginClass);
|
$statusChangeButton->setAction(self::ACTION_PREFIX_ENABLEPLUGIN . $pluginClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pluginUpdates != false && array_key_exists($pluginClass::getId(), $pluginUpdates)) {
|
if ($pluginUpdates && array_key_exists($pluginClass::getId(), $pluginUpdates)) {
|
||||||
$quadUpdate = new Quad_Icons128x128_1();
|
$quadUpdate = new Quad_Icons128x128_1();
|
||||||
$pluginFrame->add($quadUpdate);
|
$pluginFrame->add($quadUpdate);
|
||||||
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
|
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
|
||||||
@ -217,16 +217,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
|
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
$y -= $entryHeight;
|
$posY -= $entryHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pluginUpdates != false) {
|
if ($pluginUpdates) {
|
||||||
$updatePluginsButton = new Label_Button();
|
$updatePluginsButton = new Label_Button();
|
||||||
$frame->add($updatePluginsButton);
|
$frame->add($updatePluginsButton);
|
||||||
$updatePluginsButton->setHAlign(Control::RIGHT);
|
$updatePluginsButton->setHAlign(Control::RIGHT);
|
||||||
$updatePluginsButton->setX($width * 0.5);
|
$updatePluginsButton->setPosition($width * 0.5, -29, 2);
|
||||||
$updatePluginsButton->setY(-29);
|
|
||||||
$updatePluginsButton->setZ(2);
|
|
||||||
$updatePluginsButton->setWidth(10);
|
$updatePluginsButton->setWidth(10);
|
||||||
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
|
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
|
||||||
$updatePluginsButton->setText(count($pluginUpdates) . ' update(s)');
|
$updatePluginsButton->setText(count($pluginUpdates) . ' update(s)');
|
||||||
|
@ -111,7 +111,7 @@ class RankingManager implements CallbackListener {
|
|||||||
$leaders = array();
|
$leaders = array();
|
||||||
$prev = -1;
|
$prev = -1;
|
||||||
foreach ($this->rankings as $score) {
|
foreach ($this->rankings as $score) {
|
||||||
if ($prev != -1 && $prev < $score) {
|
if ($prev !== -1 && $prev < $score) {
|
||||||
return $leaders;
|
return $leaders;
|
||||||
}
|
}
|
||||||
array_push($leaders, $leader);
|
array_push($leaders, $leader);
|
||||||
|
@ -111,7 +111,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
}
|
}
|
||||||
$pauseExists = false;
|
$pauseExists = false;
|
||||||
foreach ($scriptInfos->commandDescs as $param) {
|
foreach ($scriptInfos->commandDescs as $param) {
|
||||||
if ($param->name == "Command_ForceWarmUp") {
|
if ($param->name === 'Command_ForceWarmUp') {
|
||||||
$pauseExists = true;
|
$pauseExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if (count($params) >= 2) {
|
if (count($params) >= 2) {
|
||||||
$param = $params[1];
|
$param = $params[1];
|
||||||
if ($param == 'empty') {
|
if (strtolower($param) === 'empty') {
|
||||||
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
||||||
if ($this->serverShutdownEmpty) {
|
if ($this->serverShutdownEmpty) {
|
||||||
$this->maniaControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $player->login);
|
$this->maniaControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $player->login);
|
||||||
|
@ -150,7 +150,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
|
|
||||||
// Start offsets
|
// Start offsets
|
||||||
$xStart = -$width / 2;
|
$xStart = -$width / 2;
|
||||||
$y = $height / 2;
|
$posY = $height / 2;
|
||||||
|
|
||||||
// Predefine Description Label
|
// Predefine Description Label
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
@ -164,22 +164,22 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
// Headline
|
// Headline
|
||||||
$headFrame = new Frame();
|
$headFrame = new Frame();
|
||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($y - 5);
|
$headFrame->setY($posY - 5);
|
||||||
|
|
||||||
$x = $xStart;
|
$posX = $xStart;
|
||||||
$array['$oId'] = $x + 5;
|
$array['$oId'] = $posX + 5;
|
||||||
$array['$oNickname'] = $x + 14;
|
$array['$oNickname'] = $posX + 14;
|
||||||
|
|
||||||
|
|
||||||
//Compute Headline
|
//Compute Headline
|
||||||
$x = $xStart + 55;
|
$posX = $xStart + 55;
|
||||||
$statRankings = array();
|
$statRankings = array();
|
||||||
foreach ($this->statArray as $key => $stat) {
|
foreach ($this->statArray as $key => $stat) {
|
||||||
$ranking = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
$ranking = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
||||||
if (!empty($ranking)) {
|
if (!empty($ranking)) {
|
||||||
$statRankings[$stat["Name"]] = $ranking;
|
$statRankings[$stat["Name"]] = $ranking;
|
||||||
$array[$stat['HeadShortCut']] = $x;
|
$array[$stat['HeadShortCut']] = $posX;
|
||||||
$x += $stat["Width"];
|
$posX += $stat["Width"];
|
||||||
} else {
|
} else {
|
||||||
unset($this->statArray[$key]);
|
unset($this->statArray[$key]);
|
||||||
}
|
}
|
||||||
@ -188,18 +188,18 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
//Description Label
|
//Description Label
|
||||||
$i = 2;
|
$index = 2;
|
||||||
foreach ($this->statArray as $statArray) {
|
foreach ($this->statArray as $statArray) {
|
||||||
if (!isset($labels[$i])) {
|
if (!isset($labels[$index])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Label_Text $label [] */
|
/** @var Label_Text $label [] */
|
||||||
$label = $labels[$i];
|
$label = $labels[$index];
|
||||||
|
|
||||||
$label->setAction(self::ACTION_SORT_STATS . '.' . $statArray["Name"]);
|
$label->setAction(self::ACTION_SORT_STATS . '.' . $statArray["Name"]);
|
||||||
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $statArray["Name"]);
|
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $statArray["Name"]);
|
||||||
$i++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// define standard properties
|
// define standard properties
|
||||||
@ -207,8 +207,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$style = Label_Text::STYLE_TextCardSmall;
|
$style = Label_Text::STYLE_TextCardSmall;
|
||||||
$textSize = 1.5;
|
$textSize = 1.5;
|
||||||
$textColor = 'FFF';
|
$textColor = 'FFF';
|
||||||
$i = 1;
|
$index = 1;
|
||||||
$y -= 10;
|
$posY -= 10;
|
||||||
|
|
||||||
if (!isset($statRankings[$order])) {
|
if (!isset($statRankings[$order])) {
|
||||||
return;
|
return;
|
||||||
@ -219,7 +219,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
if (!$listPlayer) {
|
if (!$listPlayer) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($i == 15) {
|
if ($index === 15) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,28 +252,28 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$array = array($i => $xStart + 5, $listPlayer->nickname => $xStart + 14);
|
$array = array($index => $xStart + 5, $listPlayer->nickname => $xStart + 14);
|
||||||
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
||||||
|
|
||||||
|
|
||||||
$x = $xStart + 55;
|
$posX = $xStart + 55;
|
||||||
foreach ($displayArray as $key => $array) {
|
foreach ($displayArray as $key => $array) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$playerFrame->add($label);
|
$playerFrame->add($label);
|
||||||
$label->setHAlign($hAlign);
|
$label->setHAlign($hAlign);
|
||||||
$label->setX($x);
|
$label->setX($posX);
|
||||||
$label->setStyle($style);
|
$label->setStyle($style);
|
||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText($array['Value']);
|
$label->setText($array['Value']);
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $key);
|
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $key);
|
||||||
$x += $array['Width'];
|
$posX += $array['Width'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($posY);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($index % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -282,8 +282,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$i++;
|
$index++;
|
||||||
$y -= 4;
|
$posY -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
|
@ -182,11 +182,11 @@ class StatisticManager {
|
|||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$statId = $this->getStatId($statName);
|
$statId = $this->getStatId($statName);
|
||||||
|
|
||||||
if ($minValue == -1) {
|
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = {$statId}";
|
||||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = " . $statId . " ORDER BY value DESC;";
|
if ($minValue >= 0) {
|
||||||
} else {
|
$query .= " AND value >= {$minValue}";
|
||||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = " . $statId . " AND value >= " . $minValue . " ORDER BY value DESC;";
|
|
||||||
}
|
}
|
||||||
|
$query .= " ORDER BY value DESC;";
|
||||||
|
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -196,7 +196,7 @@ class StatisticManager {
|
|||||||
|
|
||||||
$stats = array();
|
$stats = array();
|
||||||
while ($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
if ($serverIndex == -1) {
|
if ($serverIndex < 0) {
|
||||||
if (!isset($stats[$row->playerId])) {
|
if (!isset($stats[$row->playerId])) {
|
||||||
$stats[$row->playerId] = $row->value;
|
$stats[$row->playerId] = $row->value;
|
||||||
} else {
|
} else {
|
||||||
@ -206,9 +206,9 @@ class StatisticManager {
|
|||||||
$stats[$row->playerId] = $row->value;
|
$stats[$row->playerId] = $row->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$result->free();
|
||||||
|
|
||||||
arsort($stats);
|
arsort($stats);
|
||||||
$result->free();
|
|
||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($deaths as $key => $death) {
|
foreach ($deaths as $key => $death) {
|
||||||
if ($death == 0 || !isset($kills[$key])) {
|
if (!$death || !isset($kills[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($kills[$key]) / intval($death);
|
$statsArray[$key] = intval($kills[$key]) / intval($death);
|
||||||
@ -243,7 +243,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($times as $key => $time) {
|
foreach ($times as $key => $time) {
|
||||||
if ($time == 0 || !isset($hits[$key])) {
|
if (!$time || !isset($hits[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($hits[$key]) / (intval($time) / 3600);
|
$statsArray[$key] = intval($hits[$key]) / (intval($time) / 3600);
|
||||||
@ -257,7 +257,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($shots as $key => $shot) {
|
foreach ($shots as $key => $shot) {
|
||||||
if ($shot == 0 || !isset($hits[$key])) {
|
if (!$shot || !isset($hits[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||||
@ -271,7 +271,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($shots as $key => $shot) {
|
foreach ($shots as $key => $shot) {
|
||||||
if ($shot == 0 || !isset($hits[$key])) {
|
if (!$shot || !isset($hits[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||||
@ -285,7 +285,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($shots as $key => $shot) {
|
foreach ($shots as $key => $shot) {
|
||||||
if ($shot == 0 || !isset($hits[$key])) {
|
if (!$shot || !isset($hits[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||||
@ -299,7 +299,7 @@ class StatisticManager {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
foreach ($shots as $key => $shot) {
|
foreach ($shots as $key => $shot) {
|
||||||
if ($shot == 0 || !isset($hits[$key])) {
|
if (!$shot || !isset($hits[$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||||
@ -347,7 +347,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$kills = intval($playerStats[StatisticCollector::STAT_ON_KILL][1]);
|
$kills = intval($playerStats[StatisticCollector::STAT_ON_KILL][1]);
|
||||||
$deaths = intval($playerStats[StatisticCollector::STAT_ON_DEATH][1]);
|
$deaths = intval($playerStats[StatisticCollector::STAT_ON_DEATH][1]);
|
||||||
if ($deaths == 0) {
|
if (!$deaths) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, $kills / $deaths);
|
$playerStats[$stat->name] = array($stat, $kills / $deaths);
|
||||||
@ -358,7 +358,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$hits = intval($playerStats[StatisticCollector::STAT_ON_HIT][1]);
|
$hits = intval($playerStats[StatisticCollector::STAT_ON_HIT][1]);
|
||||||
$time = intval($playerStats[StatisticCollector::STAT_PLAYTIME][1]);
|
$time = intval($playerStats[StatisticCollector::STAT_PLAYTIME][1]);
|
||||||
if ($time == 0) {
|
if (!$time) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, $hits / ($time / 3600));
|
$playerStats[$stat->name] = array($stat, $hits / ($time / 3600));
|
||||||
@ -369,7 +369,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$hits = intval($playerStats[StatisticCollector::STAT_ARROW_HIT][1]);
|
$hits = intval($playerStats[StatisticCollector::STAT_ARROW_HIT][1]);
|
||||||
$shots = intval($playerStats[StatisticCollector::STAT_ARROW_SHOT][1]);
|
$shots = intval($playerStats[StatisticCollector::STAT_ARROW_SHOT][1]);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||||
@ -380,7 +380,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$hits = intval($playerStats[StatisticCollector::STAT_LASER_HIT][1]);
|
$hits = intval($playerStats[StatisticCollector::STAT_LASER_HIT][1]);
|
||||||
$shots = intval($playerStats[StatisticCollector::STAT_LASER_SHOT][1]);
|
$shots = intval($playerStats[StatisticCollector::STAT_LASER_SHOT][1]);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||||
@ -391,7 +391,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$hits = intval($playerStats[StatisticCollector::STAT_ROCKET_HIT][1]);
|
$hits = intval($playerStats[StatisticCollector::STAT_ROCKET_HIT][1]);
|
||||||
$shots = intval($playerStats[StatisticCollector::STAT_ROCKET_SHOT][1]);
|
$shots = intval($playerStats[StatisticCollector::STAT_ROCKET_SHOT][1]);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||||
@ -402,7 +402,7 @@ class StatisticManager {
|
|||||||
}
|
}
|
||||||
$hits = intval($playerStats[StatisticCollector::STAT_NUCLEUS_HIT][1]);
|
$hits = intval($playerStats[StatisticCollector::STAT_NUCLEUS_HIT][1]);
|
||||||
$shots = intval($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT][1]);
|
$shots = intval($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT][1]);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$playerStats[$stat->name] = array($stat, (float)($hits / $shots));
|
$playerStats[$stat->name] = array($stat, (float)($hits / $shots));
|
||||||
@ -426,42 +426,42 @@ class StatisticManager {
|
|||||||
case self::SPECIAL_STAT_KD_RATIO:
|
case self::SPECIAL_STAT_KD_RATIO:
|
||||||
$kills = $this->getStatisticData(StatisticCollector::STAT_ON_KILL, $playerId, $serverIndex);
|
$kills = $this->getStatisticData(StatisticCollector::STAT_ON_KILL, $playerId, $serverIndex);
|
||||||
$deaths = $this->getStatisticData(StatisticCollector::STAT_ON_DEATH, $playerId, $serverIndex);
|
$deaths = $this->getStatisticData(StatisticCollector::STAT_ON_DEATH, $playerId, $serverIndex);
|
||||||
if ($deaths == 0) {
|
if (!$deaths) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($kills) / intval($deaths);
|
return intval($kills) / intval($deaths);
|
||||||
case self::SPECIAL_STAT_HITS_PH:
|
case self::SPECIAL_STAT_HITS_PH:
|
||||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ON_HIT, $playerId, $serverIndex);
|
$hits = $this->getStatisticData(StatisticCollector::STAT_ON_HIT, $playerId, $serverIndex);
|
||||||
$time = $this->getStatisticData(StatisticCollector::STAT_PLAYTIME, $playerId, $serverIndex);
|
$time = $this->getStatisticData(StatisticCollector::STAT_PLAYTIME, $playerId, $serverIndex);
|
||||||
if ($time == 0) {
|
if (!$time) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($hits) / (intval($time) / 3600);
|
return intval($hits) / (intval($time) / 3600);
|
||||||
case self::SPECIAL_STAT_ARROW_ACC:
|
case self::SPECIAL_STAT_ARROW_ACC:
|
||||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ARROW_HIT, $playerId, $serverIndex);
|
$hits = $this->getStatisticData(StatisticCollector::STAT_ARROW_HIT, $playerId, $serverIndex);
|
||||||
$shots = $this->getStatisticData(StatisticCollector::STAT_ARROW_SHOT, $playerId, $serverIndex);
|
$shots = $this->getStatisticData(StatisticCollector::STAT_ARROW_SHOT, $playerId, $serverIndex);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($hits) / intval($shots);
|
return intval($hits) / intval($shots);
|
||||||
case self::SPECIAL_STAT_LASER_ACC:
|
case self::SPECIAL_STAT_LASER_ACC:
|
||||||
$hits = $this->getStatisticData(StatisticCollector::STAT_LASER_HIT, $playerId, $serverIndex);
|
$hits = $this->getStatisticData(StatisticCollector::STAT_LASER_HIT, $playerId, $serverIndex);
|
||||||
$shots = $this->getStatisticData(StatisticCollector::STAT_LASER_SHOT, $playerId, $serverIndex);
|
$shots = $this->getStatisticData(StatisticCollector::STAT_LASER_SHOT, $playerId, $serverIndex);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($hits) / intval($shots);
|
return intval($hits) / intval($shots);
|
||||||
case self::SPECIAL_STAT_NUCLEUS_ACC:
|
case self::SPECIAL_STAT_NUCLEUS_ACC:
|
||||||
$hits = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_HIT, $playerId, $serverIndex);
|
$hits = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_HIT, $playerId, $serverIndex);
|
||||||
$shots = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_SHOT, $playerId, $serverIndex);
|
$shots = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_SHOT, $playerId, $serverIndex);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($hits) / intval($shots);
|
return intval($hits) / intval($shots);
|
||||||
case self::SPECIAL_STAT_ROCKET_ACC:
|
case self::SPECIAL_STAT_ROCKET_ACC:
|
||||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ROCKET_HIT, $playerId, $serverIndex);
|
$hits = $this->getStatisticData(StatisticCollector::STAT_ROCKET_HIT, $playerId, $serverIndex);
|
||||||
$shots = $this->getStatisticData(StatisticCollector::STAT_ROCKET_SHOT, $playerId, $serverIndex);
|
$shots = $this->getStatisticData(StatisticCollector::STAT_ROCKET_SHOT, $playerId, $serverIndex);
|
||||||
if ($shots == 0) {
|
if (!$shots) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return intval($hits) / intval($shots);
|
return intval($hits) / intval($shots);
|
||||||
@ -474,7 +474,7 @@ class StatisticManager {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($serverIndex == -1) {
|
if ($serverIndex < 0) {
|
||||||
$query = "SELECT SUM(value) as value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . ";";
|
$query = "SELECT SUM(value) as value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . ";";
|
||||||
} else {
|
} else {
|
||||||
$query = "SELECT value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . " AND `serverIndex` = '" . $serverIndex . "';";
|
$query = "SELECT value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . " AND `serverIndex` = '" . $serverIndex . "';";
|
||||||
@ -529,7 +529,7 @@ class StatisticManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($serverIndex == -1) {
|
if ($serverIndex) {
|
||||||
$serverIndex = $this->maniaControl->server->index;
|
$serverIndex = $this->maniaControl->server->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
|||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
|
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
|
||||||
if ($pluginClass == 'All') {
|
if ($pluginClass === 'All') {
|
||||||
$this->performPluginsUpdate($player);
|
$this->performPluginsUpdate($player);
|
||||||
} else {
|
} else {
|
||||||
$pluginUpdateData = $this->getPluginUpdate($pluginClass);
|
$pluginUpdateData = $this->getPluginUpdate($pluginClass);
|
||||||
|
@ -153,7 +153,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($player && $login == 'lj') {
|
if ($player && strtolower($login) === 'lj') {
|
||||||
return $player->nickname;
|
return $player->nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
|||||||
try {
|
try {
|
||||||
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
|
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($e->getMessage() != 'The player is not a spectator') {
|
if ($e->getMessage() !== 'The player is not a spectator') {
|
||||||
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
|
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
|
||||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||||
//to nothing
|
//to nothing
|
||||||
|
@ -195,7 +195,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param float $neededRatio
|
* @param float $neededRatio
|
||||||
*/
|
*/
|
||||||
public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) {
|
public function defineVote($voteIndex, $voteName, $idBased = false, $startText = '', $neededRatio = -1) {
|
||||||
if ($neededRatio == -1) {
|
if ($neededRatio < 0) {
|
||||||
$neededRatio = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_RATIO);
|
$neededRatio = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_RATIO);
|
||||||
}
|
}
|
||||||
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
|
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
|
||||||
@ -221,7 +221,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
|
|
||||||
$pauseExists = false;
|
$pauseExists = false;
|
||||||
foreach ($scriptInfos->commandDescs as $param) {
|
foreach ($scriptInfos->commandDescs as $param) {
|
||||||
if ($param->name == "Command_ForceWarmUp") {
|
if ($param->name === "Command_ForceWarmUp") {
|
||||||
$pauseExists = true;
|
$pauseExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
//If game is shootmania lower the icons position by 20
|
//If game is shootmania lower the icons position by 20
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'sm') {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->currentVote->neededPlayerRatio = floatval($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_PLAYER_RATIO));
|
$this->currentVote->neededPlayerRatio = floatval($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_DEFAULT_PLAYER_RATIO));
|
||||||
$this->currentVote->function = $function;
|
$this->currentVote->function = $function;
|
||||||
|
|
||||||
if ($this->currentVote->voteCommand->startText != '') {
|
if ($this->currentVote->voteCommand->startText) {
|
||||||
$message = $this->currentVote->voteCommand->startText;
|
$message = $this->currentVote->voteCommand->startText;
|
||||||
} else {
|
} else {
|
||||||
$message = '$fff$<' . $player->nickname . '$>$s$f8f started a $fff$<' . $this->currentVote->voteCommand->name . '$>$f8f!';
|
$message = '$fff$<' . $player->nickname . '$>$s$f8f started a $fff$<' . $this->currentVote->voteCommand->name . '$>$f8f!';
|
||||||
|
@ -61,7 +61,7 @@ class DedimaniaData {
|
|||||||
public function toArray() {
|
public function toArray() {
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach (get_object_vars($this) as $key => $value) {
|
foreach (get_object_vars($this) as $key => $value) {
|
||||||
if ($key == 'records' || $key == 'sessionId' || $key == 'directoryAccessChecked' || $key == 'serverMaxRank' || $key == 'players') {
|
if ($key === 'records' || $key === 'sessionId' || $key === 'directoryAccessChecked' || $key === 'serverMaxRank' || $key === 'players') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$array[ucfirst($key)] = $value;
|
$array[ucfirst($key)] = $value;
|
||||||
|
@ -153,7 +153,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$serverInfo = $this->maniaControl->server->getInfo();
|
$serverInfo = $this->maniaControl->server->getInfo();
|
||||||
$serverVersion = $this->maniaControl->client->getVersion();
|
$serverVersion = $this->maniaControl->client->getVersion();
|
||||||
$packMask = $this->maniaControl->server->titleId;
|
$packMask = $this->maniaControl->server->titleId;
|
||||||
if ($packMask != 'Trackmania_2@nadeolabs') {
|
if ($packMask !== 'Trackmania_2@nadeolabs') {
|
||||||
$packMask = substr($this->maniaControl->server->titleId, 2);
|
$packMask = substr($this->maniaControl->server->titleId, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function fetchDedimaniaRecords($reset = true) {
|
private function fetchDedimaniaRecords($reset = true) {
|
||||||
if (!$this->dedimaniaData || $this->dedimaniaData->sessionId == '') {
|
if (!$this->dedimaniaData || !$this->dedimaniaData->sessionId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||||
if ($error != '') {
|
if ($error) {
|
||||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
private function getPlayerList() {
|
private function getPlayerList() {
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
|
|
||||||
if (count($players) == 0) {
|
if (empty($players)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$playerInfo = array();
|
$playerInfo = array();
|
||||||
@ -352,14 +352,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Dedimania string representation of the current game mode
|
* Get Dedimania String Representation of the current Game Mode
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
private function getGameModeString() {
|
private function getGameModeString() {
|
||||||
$gameMode = $this->maniaControl->server->getGameMode();
|
$gameMode = $this->maniaControl->server->getGameMode();
|
||||||
$scriptNameResponse = $this->maniaControl->client->getScriptName();
|
|
||||||
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse["CurrentValue"]);
|
|
||||||
if ($gameMode === null) {
|
if ($gameMode === null) {
|
||||||
trigger_error("Couldn't retrieve game mode.");
|
trigger_error("Couldn't retrieve game mode.");
|
||||||
return null;
|
return null;
|
||||||
@ -367,9 +365,17 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
switch ($gameMode) {
|
switch ($gameMode) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
if ($scriptName == 'Rounds' || $scriptName == 'Cup' || $scriptName == 'Team') {
|
$scriptNameResponse = $this->maniaControl->client->getScriptName();
|
||||||
|
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']);
|
||||||
|
switch ($scriptName) {
|
||||||
|
case 'Rounds':
|
||||||
|
case 'Cup':
|
||||||
|
case 'Team':
|
||||||
return 'Rounds';
|
return 'Rounds';
|
||||||
} else if ($scriptName == 'TimeAttack' || $scriptName == 'Laps' || $scriptName == 'TeamAttack' || $scriptName == 'TimeAttackPlus') {
|
case 'TimeAttack':
|
||||||
|
case 'Laps':
|
||||||
|
case 'TeamAttack':
|
||||||
|
case 'TimeAttackPlus':
|
||||||
return 'TA';
|
return 'TA';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -390,16 +396,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 1Second callback
|
* Handle 1 Second Callback
|
||||||
*/
|
*/
|
||||||
public function updateEverySecond($time) {
|
public function updateEverySecond() {
|
||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink || !$this->dedimaniaData->records) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->dedimaniaData->records) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->updateManialink = false;
|
$this->updateManialink = false;
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||||
@ -526,7 +528,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||||
if ($error != '') {
|
if ($error) {
|
||||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,7 +611,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||||
if ($error != '') {
|
if ($error) {
|
||||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,7 +658,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($record->newRecord == false) {
|
if (!$record->newRecord) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
array_push($times, array('Login' => $record->login, 'Best' => $record->best, 'Checks' => $record->checkpoints));
|
array_push($times, array('Login' => $record->login, 'Best' => $record->best, 'Checks' => $record->checkpoints));
|
||||||
@ -683,7 +685,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$self = $this;
|
$self = $this;
|
||||||
$maniaControl = $this->maniaControl;
|
$maniaControl = $this->maniaControl;
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self, &$maniaControl) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self, &$maniaControl) {
|
||||||
if ($error != '') {
|
if ($error) {
|
||||||
$maniaControl->log("Dedimania Error: " . $error);
|
$maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +716,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$serverInfo = $this->getServerInfo();
|
$serverInfo = $this->getServerInfo();
|
||||||
$playerList = $this->getPlayerList();
|
$playerList = $this->getPlayerList();
|
||||||
$votesInfo = $this->getVotesInfo();
|
$votesInfo = $this->getVotesInfo();
|
||||||
if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || $this->dedimaniaData->sessionId == '') {
|
if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +726,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||||
if ($error != '') {
|
if ($error) {
|
||||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,7 +973,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
* Update the sorting and the ranks of all dedimania records
|
* Update the sorting and the ranks of all dedimania records
|
||||||
*/
|
*/
|
||||||
private function updateDedimaniaRecordRanks() {
|
private function updateDedimaniaRecordRanks() {
|
||||||
if ($this->dedimaniaData->getRecordCount() == 0) {
|
if ($this->dedimaniaData->getRecordCount() === 0) {
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1031,7 +1033,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$login = $callback[1][1];
|
$login = $callback[1][1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
|
||||||
if ($actionId == self::ACTION_SHOW_DEDIRECORDSLIST) {
|
if ($actionId === self::ACTION_SHOW_DEDIRECORDSLIST) {
|
||||||
$this->showDediRecordsList(array(), $player);
|
$this->showDediRecordsList(array(), $player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1093,7 +1095,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
$recordFrame = new Frame();
|
$recordFrame = new Frame();
|
||||||
$pageFrame->add($recordFrame);
|
$pageFrame->add($recordFrame);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$recordFrame->add($lineQuad);
|
$recordFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
|
@ -160,7 +160,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
//If game is shootmania lower the icons position by 20
|
//If game is shootmania lower the icons position by 20
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'sm') {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
|
@ -99,7 +99,7 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug
|
|||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$allowOthers = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES);
|
$allowOthers = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES);
|
||||||
if (!$allowOthers && $this->maniaControl->server->titleId != 'SMStormRoyal@nadeolabs') {
|
if (!$allowOthers && $this->maniaControl->server->titleId !== 'SMStormRoyal@nadeolabs') {
|
||||||
$error = 'This plugin only supports Royal (check Settings)!';
|
$error = 'This plugin only supports Royal (check Settings)!';
|
||||||
throw new \Exception($error);
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
||||||
$mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
|
$mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
|
||||||
|
|
||||||
if ($mxKarmaCode == '') {
|
if (!$mxKarmaCode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
// Fetch the Mx Karma Votes
|
// Fetch the Mx Karma Votes
|
||||||
$self->getMxKarmaVotes();
|
$self->getMxKarmaVotes();
|
||||||
} else {
|
} else {
|
||||||
if ($data->data->message == "invalid hash") {
|
if ($data->data->message === "invalid hash") {
|
||||||
$permission = $self->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
$permission = $self->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||||
$self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
$self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
||||||
} else {
|
} else {
|
||||||
@ -348,7 +348,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$properties = array();
|
$properties = array();
|
||||||
|
|
||||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||||
if ($gameMode == 'Script') {
|
if ($gameMode === 'Script') {
|
||||||
$scriptName = $this->maniaControl->client->getScriptName();
|
$scriptName = $this->maniaControl->client->getScriptName();
|
||||||
$properties['gamemode'] = $scriptName["CurrentValue"];
|
$properties['gamemode'] = $scriptName["CurrentValue"];
|
||||||
} else {
|
} else {
|
||||||
@ -393,7 +393,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$self->maniaControl->log("MX-Karma Votes successfully fetched");
|
$self->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||||
} else {
|
} else {
|
||||||
$self->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
$self->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
||||||
if ($data->data->message == "invalid session") {
|
if ($data->data->message === 'invalid session') {
|
||||||
unset($this->mxKarma['session']);
|
unset($this->mxKarma['session']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -455,12 +455,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
|
|
||||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||||
|
|
||||||
if (count($votes) == 0) {
|
if (empty($votes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$properties = array();
|
$properties = array();
|
||||||
if ($gameMode == 'Script') {
|
if ($gameMode === 'Script') {
|
||||||
$scriptName = $this->maniaControl->client->getScriptName();
|
$scriptName = $this->maniaControl->client->getScriptName();
|
||||||
$properties['gamemode'] = $scriptName["CurrentValue"];
|
$properties['gamemode'] = $scriptName["CurrentValue"];
|
||||||
} else {
|
} else {
|
||||||
@ -490,7 +490,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
$self->maniaControl->log("Votes successfully submitted");
|
$self->maniaControl->log("Votes successfully submitted");
|
||||||
} else {
|
} else {
|
||||||
$self->maniaControl->log("Error while updating votes: " . $data->data->message);
|
$self->maniaControl->log("Error while updating votes: " . $data->data->message);
|
||||||
if ($data->data->message == "invalid session") {
|
if ($data->data->message === "invalid session") {
|
||||||
unset($this->mxKarma['session']);
|
unset($this->mxKarma['session']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -967,7 +967,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
$vote = $result->fetch_object();
|
$vote = $result->fetch_object();
|
||||||
|
|
||||||
if ($result->field_count == 0 || !$vote) {
|
if (!$result->field_count || !$vote) {
|
||||||
$query = "SELECT vote, login, nickname FROM `" . self::TABLE_KARMA . "` k LEFT JOIN `" . PlayerManager::TABLE_PLAYERS . "` p ON (k.playerIndex=p.index) WHERE mapIndex = {$map->index}";
|
$query = "SELECT vote, login, nickname FROM `" . self::TABLE_KARMA . "` k LEFT JOIN `" . PlayerManager::TABLE_PLAYERS . "` p ON (k.playerIndex=p.index) WHERE mapIndex = {$map->index}";
|
||||||
$result2 = $mysqli->query($query);
|
$result2 = $mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
@ -1011,7 +1011,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->mxKarma['votes']) || count($this->mxKarma['votes']) == 0) {
|
if (!isset($this->mxKarma['votes']) || empty($this->mxKarma['votes'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
*/
|
*/
|
||||||
public function getLocalRecords(Map $map, $limit = -1) {
|
public function getLocalRecords(Map $map, $limit = -1) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$limit = ($limit > 0 ? "LIMIT " . $limit : "");
|
$limit = ($limit > 0 ? 'LIMIT ' . $limit : '');
|
||||||
$query = "SELECT * FROM (
|
$query = "SELECT * FROM (
|
||||||
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
|
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
|
||||||
WHERE recs.`mapIndex` = {$map->index}
|
WHERE recs.`mapIndex` = {$map->index}
|
||||||
@ -436,29 +436,33 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
|
|
||||||
// Announce record
|
// Announce record
|
||||||
$newRecord = $this->getLocalRecord($map, $callback->player);
|
$newRecord = $this->getLocalRecord($map, $callback->player);
|
||||||
|
$improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank);
|
||||||
|
|
||||||
$notifyOnlyDriver = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER);
|
$notifyOnlyDriver = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER);
|
||||||
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
$notifyOnlyBestRecords = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS);
|
||||||
if ($notifyOnlyDriver || $notifyOnlyBestRecords > 0 && $newRecord->rank > $notifyOnlyBestRecords) {
|
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved your');
|
$message = '$3c0';
|
||||||
$message = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
if ($notifyOnlyDriver) {
|
||||||
if ($oldRecord) {
|
$message .= 'You';
|
||||||
$oldRank = ($improvement == 'improved your') ? '' : $oldRecord->rank . '. ';
|
|
||||||
}
|
|
||||||
if ($oldRecord) {
|
|
||||||
$message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>!';
|
|
||||||
}
|
|
||||||
$this->maniaControl->chat->sendInformation('$3c0' . $message . '!', $callback->player->login);
|
|
||||||
} else {
|
} else {
|
||||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
$message .= '$<$fff' . $callback->player->nickname . '$>';
|
||||||
$message = '$<$fff' . $callback->player->nickname . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
|
||||||
if ($oldRecord) {
|
|
||||||
$oldRank = ($improvement == 'improved the') ? '' : $oldRecord->rank . '. ';
|
|
||||||
}
|
}
|
||||||
|
$message .= ' ' . ($improvedRank ? 'gained' : 'improved') . ' the';
|
||||||
|
$message .= ' $<$ff0' . $newRecord->rank . '.$> Local Record:';
|
||||||
|
$message .= ' $<$fff' . Formatter::formatTime($newRecord->time) . '$>!';
|
||||||
if ($oldRecord) {
|
if ($oldRecord) {
|
||||||
$message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>)';
|
$message .= ' (';
|
||||||
|
if ($improvedRank) {
|
||||||
|
$message .= '$<$ff0' . $oldRecord->rank . '.$> ';
|
||||||
}
|
}
|
||||||
$this->maniaControl->chat->sendInformation('$3c0' . $message . '!');
|
$timeDiff = $oldRecord->time - $newRecord->time;
|
||||||
|
$message .= '$<$fff-' . Formatter::formatTime($timeDiff) . '$>)';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($notifyOnlyDriver) {
|
||||||
|
$this->maniaControl->chat->sendInformation($message, $callback->player);
|
||||||
|
} else if (!$notifyOnlyBestRecords || $newRecord->rank <= $notifyOnlyBestRecords) {
|
||||||
|
$this->maniaControl->chat->sendInformation($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord);
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord);
|
||||||
@ -596,7 +600,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
$recordFrame = new Frame();
|
$recordFrame = new Frame();
|
||||||
$pageFrame->add($recordFrame);
|
$pageFrame->add($recordFrame);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$recordFrame->add($lineQuad);
|
$recordFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -647,7 +651,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = " . $currentMap->index . " AND `playerIndex` = " . $player->index . "";
|
$query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = {$currentMap->index} AND `playerIndex` = {$player->index};";
|
||||||
$mysqli->query($query);
|
$mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
|
@ -27,7 +27,7 @@ use Maniaplanet\DedicatedServer\Structures\AbstractStructure;
|
|||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 6;
|
const PLUGIN_ID = 6;
|
||||||
@ -109,10 +109,10 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
$script = $this->maniaControl->client->getScriptName();
|
$script = $this->maniaControl->client->getScriptName();
|
||||||
|
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'tm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'tm') {
|
||||||
//TODO also add obstacle here as default
|
//TODO also add obstacle here as default
|
||||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RECORDS);
|
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RECORDS);
|
||||||
} else if ($script["CurrentValue"] == "InstaDM.Script.txt") {
|
} else if ($script["CurrentValue"] === 'InstaDM.Script.txt') {
|
||||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS);
|
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS);
|
||||||
} else {
|
} else {
|
||||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_POINTS);
|
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_POINTS);
|
||||||
@ -120,7 +120,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
//Check if the type is Correct
|
//Check if the type is Correct
|
||||||
$type = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_RANKING_TYPE);
|
$type = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_RANKING_TYPE);
|
||||||
if ($type != self::RANKING_TYPE_RECORDS && $type != self::RANKING_TYPE_POINTS && $type != self::RANKING_TYPE_RATIOS) {
|
if (!$this->isValidRankingType($type)) {
|
||||||
$error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_POINTS . ', ' . self::RANKING_TYPE_POINTS . ')';
|
$error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_POINTS . ', ' . self::RANKING_TYPE_POINTS . ')';
|
||||||
throw new \Exception($error);
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$this->maniaControl->commandManager->registerCommandListener('nextrank', $this, 'command_nextRank', false, 'Shows the person in front of you in the ServerRanking.');
|
$this->maniaControl->commandManager->registerCommandListener('nextrank', $this, 'command_nextRank', false, 'Shows the person in front of you in the ServerRanking.');
|
||||||
$this->maniaControl->commandManager->registerCommandListener(array('topranks', 'top100'), $this, 'command_topRanks', false, 'Shows an overview of the best-ranked 100 players.');
|
$this->maniaControl->commandManager->registerCommandListener(array('topranks', 'top100'), $this, 'command_topRanks', false, 'Shows an overview of the best-ranked 100 players.');
|
||||||
|
|
||||||
$this->resetRanks(); //TODO only update records count
|
// TODO: only update records count
|
||||||
|
$this->resetRanks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -502,7 +503,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if ($i % 2 !== 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
@ -521,6 +522,25 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
// Render and display xml
|
// Render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TopRanks');
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TopRanks');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the possible Ranking Types
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
private function getRankingTypes() {
|
||||||
|
return array(self::RANKING_TYPE_POINTS, self::RANKING_TYPE_RATIOS, self::RANKING_TYPE_RECORDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given Ranking Type is valid
|
||||||
|
*
|
||||||
|
* @param string $rankingType
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isValidRankingType($rankingType) {
|
||||||
|
return in_array($rankingType, $this->getRankingTypes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user