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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$pageFrame->add($playerFrame);
|
||||
$playerFrame->setY($y);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -247,7 +247,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget != 'AdminList') {
|
||||
if ($openedWidget !== 'AdminList') {
|
||||
unset($this->adminListShown[$player->login]);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class TimerManager {
|
||||
public function unregisterTimerListening(TimerListener $listener, $method) {
|
||||
$removed = false;
|
||||
foreach ($this->timerListenings as $key => &$listening) {
|
||||
if ($listening->listener === $listener && $listening->method == $method) {
|
||||
if ($listening->listener === $listener && $listening->method === $method) {
|
||||
unset($this->timerListenings[$key]);
|
||||
$removed = true;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class CommandManager implements CallbackListener {
|
||||
$removed = false;
|
||||
foreach ($listenerArray as &$listeners) {
|
||||
foreach ($listeners as $key => &$listenerCallback) {
|
||||
if ($listenerCallback[0] == $listener) {
|
||||
if ($listenerCallback[0] === $listener) {
|
||||
unset($listeners[$key]);
|
||||
$removed = true;
|
||||
}
|
||||
@ -162,11 +162,11 @@ class CommandManager implements CallbackListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr($message, 0, 2) == '//' || $command == 'admin') {
|
||||
if (substr($message, 0, 2) === '//' || $command === 'admin') {
|
||||
// Admin command
|
||||
$commandListeners = $this->adminCommandListeners;
|
||||
|
||||
if ($command == 'admin') {
|
||||
if ($command === 'admin') {
|
||||
// Strip 'admin' keyword
|
||||
if (isset($commandArray[1])) {
|
||||
$command = $commandArray[1];
|
||||
|
@ -60,7 +60,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$showCommands = array();
|
||||
$registeredMethods = array();
|
||||
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']];
|
||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||
} else {
|
||||
@ -91,7 +91,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$showCommands = array();
|
||||
$registeredMethods = array();
|
||||
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']];
|
||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||
} else {
|
||||
@ -133,7 +133,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$registeredMethods = array();
|
||||
foreach (array_reverse($commands) as $command) {
|
||||
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']];
|
||||
$showCommands[$name]['Name'] .= '|' . $command['Name'];
|
||||
} else {
|
||||
@ -204,7 +204,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
||||
$pageFrame->add($playerFrame);
|
||||
$playerFrame->setY($y);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
|
@ -207,7 +207,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
$menuItemLabel->setAction(self::ACTION_SELECTMENU . '.' . $menuId);
|
||||
|
||||
//Show a Menu
|
||||
if ($menuId == $menuIdShown) {
|
||||
if ($menuId === $menuIdShown) {
|
||||
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $script, $player);
|
||||
$menusFrame->add($menuControl);
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$index = 0;
|
||||
$y = 0;
|
||||
foreach ($settings as $setting) {
|
||||
if (!$pageFrame) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
$y = $height * 0.41;
|
||||
$paging->addPage($pageFrame);
|
||||
$y = $height * 0.41;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
@ -195,10 +195,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
$y -= $settingHeight;
|
||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
$pageFrame = null;
|
||||
}
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
@ -255,7 +251,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pageFrame = null;
|
||||
$index = 0;
|
||||
foreach ($settingClasses as $settingClass) {
|
||||
if (!$pageFrame) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
$y = $height * 0.41;
|
||||
@ -265,9 +261,9 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$classLabel = new Label_Text();
|
||||
|
||||
$settingClassArray = explode('\\', $settingClass);
|
||||
$className = "";
|
||||
$className = '';
|
||||
for ($i = 1; $i < count($settingClassArray); $i++) {
|
||||
$className .= $settingClassArray[$i] . " - ";
|
||||
$className .= $settingClassArray[$i] . ' - ';
|
||||
}
|
||||
$className = substr($className, 0, -3);
|
||||
|
||||
@ -282,11 +278,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
||||
|
||||
$y -= $settingHeight;
|
||||
|
||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
$pageFrame = null;
|
||||
}
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||
}
|
||||
|
||||
if ($substyle != '') {
|
||||
if ($substyle) {
|
||||
$quad = new Quad_Icons64x64_1();
|
||||
$settingFrame->add($quad);
|
||||
$quad->setX($width / 2 * 0.545);
|
||||
|
@ -211,7 +211,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.23, 0, -0.01);
|
||||
$quad->setSize(4, 4);
|
||||
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $name, $value, $quad);
|
||||
$settingFrame->add($checkBox);
|
||||
} else {
|
||||
@ -225,11 +224,12 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$entry->setName(self::ACTION_PREFIX_SETTING . $name);
|
||||
$entry->setDefault($value);
|
||||
|
||||
if ($name == "Comment") { //
|
||||
if ($name === 'Comment') {
|
||||
$entry->setAutoNewLine(true);
|
||||
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
|
||||
$settingFrame->setY($y - $settingHeight * 1.5);
|
||||
// dummy:
|
||||
// TODO: "dummy:" what? remove?
|
||||
$y -= $settingHeight * 3;
|
||||
$id += 3;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class AsynchronousFileReader {
|
||||
$request->socketSelect();
|
||||
}
|
||||
} 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]);
|
||||
} else {
|
||||
throw $e;
|
||||
@ -82,7 +82,7 @@ class AsynchronousFileReader {
|
||||
$request->getOptions()->set(CURLOPT_TIMEOUT, 10) //
|
||||
->set(CURLOPT_HEADER, false) //don't display response header
|
||||
->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_HTTPHEADER, $header) //
|
||||
->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) //
|
||||
@ -148,7 +148,7 @@ class AsynchronousFileReader {
|
||||
$request = new Request($url);
|
||||
$request->getOptions()->set(CURLOPT_HEADER, false) //don't display response header
|
||||
->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_POST, true) //post field
|
||||
->set(CURLOPT_POSTFIELDS, $content) //post content field
|
||||
@ -160,8 +160,8 @@ class AsynchronousFileReader {
|
||||
$request->addListener('complete', function (Event $event) use (&$function) {
|
||||
/** @var Response $response */
|
||||
$response = $event->response;
|
||||
$error = "";
|
||||
$content = "";
|
||||
$error = null;
|
||||
$content = null;
|
||||
if ($response->hasError()) {
|
||||
$error = $response->getError()->getMessage();
|
||||
} else {
|
||||
|
@ -55,7 +55,7 @@ abstract class FileUtil {
|
||||
if ($info['timed_out'] || !$buffer) {
|
||||
return null;
|
||||
}
|
||||
if (substr($buffer, 9, 3) != '200') {
|
||||
if (substr($buffer, 9, 3) !== '200') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ class ManiaControl implements CommandListener, TimerListener {
|
||||
|
||||
// Execute start script in background
|
||||
// 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 &';
|
||||
exec($command);
|
||||
} else {
|
||||
@ -263,20 +263,10 @@ class ManiaControl implements CommandListener, TimerListener {
|
||||
/**
|
||||
* Get the Operating System on which ManiaControl is running
|
||||
*
|
||||
* @param string $compareOS
|
||||
* @return string|bool
|
||||
* @return string
|
||||
*/
|
||||
public function getOS($compareOS = null) {
|
||||
$windows = 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) {
|
||||
public function getOS() {
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
return self::OS_WIN;
|
||||
}
|
||||
return self::OS_UNIX;
|
||||
|
@ -34,7 +34,7 @@ class MXMapInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->prefix == 'tm') {
|
||||
if ($this->prefix === 'tm') {
|
||||
$this->dir = 'tracks';
|
||||
$this->id = $mx->TrackID;
|
||||
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
|
||||
@ -44,7 +44,7 @@ class MXMapInfo {
|
||||
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
||||
}
|
||||
|
||||
if (!isset($mx->GbxMapName) || $mx->GbxMapName == '?') {
|
||||
if (!isset($mx->GbxMapName) || $mx->GbxMapName === '?') {
|
||||
$this->name = $mx->Name;
|
||||
} else {
|
||||
$this->name = Formatter::stripDirtyCodes($mx->GbxMapName);
|
||||
@ -84,9 +84,9 @@ class MXMapInfo {
|
||||
$this->ratingVoteCount = isset($mx->RatingVoteCount) ? $mx->RatingVoteCount : 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;
|
||||
} elseif ($this->lbrating == 0 && $this->trkvalue > 0) {
|
||||
} elseif (!$this->lbrating && $this->trkvalue > 0) {
|
||||
$this->lbrating = $this->trkvalue;
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ class MXMapInfo {
|
||||
$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;
|
||||
} else {
|
||||
$this->replayurl = '';
|
||||
|
@ -108,21 +108,22 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$environment = '';
|
||||
if (count($params) >= 1) {
|
||||
foreach ($params as $param) {
|
||||
if ($param == '/xlist' || $param == MapCommands::ACTION_OPEN_XLIST) {
|
||||
if ($param === '/xlist' || $param === MapCommands::ACTION_OPEN_XLIST) {
|
||||
continue;
|
||||
}
|
||||
if ($param == self::ACTION_SEARCH_MAPNAME) {
|
||||
if ($param === self::ACTION_SEARCH_MAPNAME) {
|
||||
$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'];
|
||||
} else if (strtolower(substr($param, 0, 5)) == 'auth:') {
|
||||
} else if (strtolower(substr($param, 0, 5)) === 'auth:') {
|
||||
$author = substr($param, 5);
|
||||
} else if (strtolower(substr($param, 0, 4)) == 'env:') {
|
||||
} else if (strtolower(substr($param, 0, 4)) === 'env:') {
|
||||
$environment = substr($param, 4);
|
||||
} else {
|
||||
if ($searchString == '') {
|
||||
if (!$searchString) {
|
||||
$searchString = $param;
|
||||
} else { // concatenate words in name
|
||||
} else {
|
||||
// concatenate words in name
|
||||
$searchString .= '%20' . $param;
|
||||
}
|
||||
}
|
||||
@ -192,7 +193,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$mapFrame = new Frame();
|
||||
$pageFrame->add($mapFrame);
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
if ($i % 2 === 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$mapFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -201,7 +202,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
}
|
||||
|
||||
$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);
|
||||
$authorLabel = $labels[2];
|
||||
$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) {
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget != 'ManiaExchangeList') {
|
||||
if ($openedWidget !== 'ManiaExchangeList') {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class ManiaExchangeManager {
|
||||
//Set changed time into the map object
|
||||
$map->lastUpdate = strtotime($changed);
|
||||
|
||||
if ($mxId != 0) {
|
||||
if ($mxId) {
|
||||
$appendString = $mxId . ',';
|
||||
//Set the mx id to the mxidmapvektor
|
||||
$this->mxIdUidVector[$mxId] = $map->uid;
|
||||
@ -122,7 +122,7 @@ class ManiaExchangeManager {
|
||||
$id++;
|
||||
|
||||
//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);
|
||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
||||
$mapIdString = '';
|
||||
@ -131,7 +131,7 @@ class ManiaExchangeManager {
|
||||
$mapIdString .= $appendString;
|
||||
}
|
||||
|
||||
if ($mapIdString != '') {
|
||||
if ($mapIdString) {
|
||||
$mapIdString = substr($mapIdString, 0, -1);
|
||||
$this->getMaplistByMixedUidIdString($mapIdString);
|
||||
}
|
||||
@ -273,6 +273,8 @@ class ManiaExchangeManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: remove $env because it's not really used?
|
||||
|
||||
// Get Title Id
|
||||
$titleId = $this->maniaControl->server->titleId;
|
||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||
@ -282,20 +284,20 @@ class ManiaExchangeManager {
|
||||
|
||||
$game = explode('@', $titleId);
|
||||
$envNumber = $this->getEnvironment($game[0]);
|
||||
if ($env != '' || $envNumber != -1) {
|
||||
if ($env || $envNumber > -1) {
|
||||
$url .= '&environments=' . $envNumber;
|
||||
}
|
||||
if ($name != '') {
|
||||
if ($name) {
|
||||
$url .= '&trackname=' . str_replace(" ", "%20", $name);
|
||||
}
|
||||
if ($author != '') {
|
||||
if ($author) {
|
||||
$url .= '&author=' . $author;
|
||||
}
|
||||
|
||||
$url .= '&priord=' . $searchOrder;
|
||||
$url .= '&limit=' . $maxMapsReturned;
|
||||
|
||||
if ($titlePrefix != "tm") {
|
||||
if ($titlePrefix !== "tm") {
|
||||
$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
|
||||
*/
|
||||
public function getGame() {
|
||||
switch ($this->environment) {
|
||||
case 'Storm':
|
||||
return "sm";
|
||||
return 'sm';
|
||||
case 'Canyon':
|
||||
case 'Stadium':
|
||||
case 'Valley':
|
||||
return "tm";
|
||||
default:
|
||||
return "";
|
||||
return 'tm';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +103,7 @@ class Map {
|
||||
*/
|
||||
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;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -342,11 +342,11 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
/** @var Map $map */
|
||||
foreach ($maps as $map) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -363,23 +363,32 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
public function command_List(array $chatCallback, Player $player) {
|
||||
$chatCommands = explode(' ', $chatCallback[1][2]);
|
||||
$this->maniaControl->mapManager->mapList->playerCloseWidget($player);
|
||||
|
||||
if (isset($chatCommands[1])) {
|
||||
if ($chatCommands[1] == ' ' || $chatCommands[1] == 'all') {
|
||||
$this->maniaControl->mapManager->mapList->showMapList($player);
|
||||
} elseif ($chatCommands[1] == 'best') {
|
||||
$this->showMapListKarma(true, $player);
|
||||
} elseif ($chatCommands[1] == 'worst') {
|
||||
$this->showMapListKarma(false, $player);
|
||||
} elseif ($chatCommands[1] == 'newest') {
|
||||
$this->showMapListDate(true, $player);
|
||||
} elseif ($chatCommands[1] == 'oldest') {
|
||||
$this->showMapListDate(false, $player);
|
||||
} elseif ($chatCommands[1] == 'author') {
|
||||
if (isset($chatCommands[2])) {
|
||||
$this->showMaplistAuthor($chatCommands[2], $player);
|
||||
} else {
|
||||
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
|
||||
}
|
||||
$listParam = strtolower($chatCommands[1]);
|
||||
switch ($listParam) {
|
||||
case 'best':
|
||||
$this->showMapListKarma(true, $player);
|
||||
break;
|
||||
case 'worst':
|
||||
$this->showMapListKarma(false, $player);
|
||||
break;
|
||||
case 'newest':
|
||||
$this->showMapListDate(true, $player);
|
||||
break;
|
||||
case 'oldest':
|
||||
$this->showMapListDate(false, $player);
|
||||
break;
|
||||
case 'author':
|
||||
if (isset($chatCommands[2])) {
|
||||
$this->showMaplistAuthor($chatCommands[2], $player);
|
||||
} else {
|
||||
$this->maniaControl->chat->sendError('Missing Author Login!', $player->login);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->maniaControl->mapManager->mapList->showMapList($player);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->mapManager->mapList->showMapList($player);
|
||||
@ -409,7 +418,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$plus = 0;
|
||||
foreach ($votes as $vote) {
|
||||
if (isset($vote->vote)) {
|
||||
if ($vote->vote != 0.5) {
|
||||
if ($vote->vote !== 0.5) {
|
||||
if ($vote->vote < 0.5) {
|
||||
$min = $min + $vote->count;
|
||||
} else {
|
||||
|
@ -240,7 +240,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mapFrame->setZ(0.1);
|
||||
$mapFrame->setY($y);
|
||||
|
||||
if ($id % 2 != 0) {
|
||||
if ($id % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$mapFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -422,7 +422,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$plus = 0;
|
||||
foreach ($votes as $vote) {
|
||||
if (isset($vote->vote)) {
|
||||
if ($vote->vote != 0.5) {
|
||||
if ($vote->vote !== 0.5) {
|
||||
if ($vote->vote < 0.5) {
|
||||
$min = $min + $vote->count;
|
||||
} else {
|
||||
|
@ -310,7 +310,7 @@ class MapManager implements CallbackListener {
|
||||
try {
|
||||
$this->maniaControl->client->writeFile($relativeMapFileName, $file);
|
||||
} 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);
|
||||
return;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($this->queuedMaps) == 0) {
|
||||
if (empty($this->queuedMaps)) {
|
||||
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -135,12 +135,20 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
$chatCommands = explode(' ', $chatCallback[1][2]);
|
||||
|
||||
if (isset($chatCommands[1])) {
|
||||
if ($chatCommands[1] == ' ' || $chatCommands[1] == 'list') {
|
||||
$this->showMapQueue($player);
|
||||
} elseif ($chatCommands[1] == 'display') {
|
||||
$this->showMapQueueManialink($player);
|
||||
} elseif ($chatCommands[1] == 'clear') {
|
||||
$this->clearMapQueue($player);
|
||||
$listParam = strtolower($chatCommands[1]);
|
||||
switch ($listParam) {
|
||||
case 'list':
|
||||
$this->showMapQueue($player);
|
||||
break;
|
||||
case 'display':
|
||||
$this->showMapQueueManialink($player);
|
||||
break;
|
||||
case 'clear':
|
||||
$this->clearMapQueue($player);
|
||||
break;
|
||||
default:
|
||||
$this->showMapQueue($player);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->showMapQueue($player);
|
||||
@ -153,7 +161,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* @param 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);
|
||||
return;
|
||||
}
|
||||
@ -174,14 +182,14 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showMapQueueManialink(Player $player) {
|
||||
if (count($this->queuedMaps) == 0) {
|
||||
$this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
||||
if (empty($this->queuedMaps)) {
|
||||
$this->maniaControl->chat->sendError('There are no Maps in the Jukebox!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$maps = array();
|
||||
foreach ($this->queuedMaps as $queuedMap) {
|
||||
$maps[] = $queuedMap[1];
|
||||
array_push($maps, $queuedMap[1]);
|
||||
}
|
||||
|
||||
$this->maniaControl->mapManager->mapList->showMapList($player, $maps);
|
||||
@ -220,12 +228,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
*/
|
||||
public function addMapToMapQueue($login, $uid) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if player is allowed to add (another) map
|
||||
$admin = false;
|
||||
if ($this->maniaControl->authenticationManager->checkRight($player, 2) || $this->maniaControl->authenticationManager->checkRight($player, 3) || $this->maniaControl->authenticationManager->checkRight($player, 4)) {
|
||||
$admin = true;
|
||||
}
|
||||
$isModerator = $this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
$mapsForPlayer = 0;
|
||||
foreach ($this->queuedMaps as $queuedMap) {
|
||||
@ -234,16 +242,15 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
}
|
||||
|
||||
$maxPlayer = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
||||
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||
|
||||
if ($admin && $maxAdmin != -1) {
|
||||
if ($mapsForPlayer == $maxAdmin) {
|
||||
if ($isModerator) {
|
||||
$maxAdmin = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
|
||||
$this->maniaControl->chat->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
|
||||
return;
|
||||
}
|
||||
} elseif (!$admin && $maxPlayer != -1) {
|
||||
if ($mapsForPlayer == $maxPlayer) {
|
||||
} else {
|
||||
$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);
|
||||
return;
|
||||
}
|
||||
@ -308,9 +315,8 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
}
|
||||
|
||||
$this->nextMap = null;
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE) == true) {
|
||||
|
||||
//Skip Map if requester has left
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
|
||||
// Skip Map if requester has left
|
||||
foreach ($this->queuedMaps as $queuedMap) {
|
||||
$player = $queuedMap[0];
|
||||
|
||||
@ -324,7 +330,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
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
|
||||
if ($player->authLevel > 0) {
|
||||
break;
|
||||
|
@ -180,7 +180,7 @@ class Player {
|
||||
* @return bool
|
||||
*/
|
||||
public function isFakePlayer() {
|
||||
return ($this->pid <= 0 || $this->path == "");
|
||||
return ($this->pid <= 0 || !$this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,9 +102,9 @@ class PlayerActions {
|
||||
|
||||
$chatMessage = false;
|
||||
$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!';
|
||||
} else if ($teamId == self::TEAM_RED) {
|
||||
} else if ($teamId === self::TEAM_RED) {
|
||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
|
||||
}
|
||||
if (!$chatMessage) {
|
||||
@ -497,7 +497,7 @@ class PlayerActions {
|
||||
public function isPlayerMuted($login) {
|
||||
$ignoreList = $this->maniaControl->client->getIgnoreList(100, 0);
|
||||
foreach ($ignoreList as $ignoredPlayers) {
|
||||
if ($ignoredPlayers->login == $login) {
|
||||
if ($ignoredPlayers->login === $login) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -223,12 +223,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
$type = 2;
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = intval($params[2]);
|
||||
}
|
||||
$selectable = false;
|
||||
if ($type == 2) {
|
||||
$selectable = true;
|
||||
$type = (int)$params[2];
|
||||
}
|
||||
$selectable = ($type === 2);
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
}
|
||||
|
@ -225,52 +225,51 @@ class PlayerDetailed {
|
||||
$frame = new Frame();
|
||||
|
||||
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);
|
||||
$y = $this->height / 2 - 15;
|
||||
$x = -$this->width / 2 + 52;
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX = -$this->width / 2 + 52;
|
||||
$id = 1;
|
||||
|
||||
foreach ($playerStats as $stat) {
|
||||
$statProperties = $stat[0];
|
||||
$value = $stat[1];
|
||||
|
||||
if (floatval($value) == 0) {
|
||||
$value = (float)$stat[1];
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($statProperties->type == StatisticManager::STAT_TYPE_TIME) {
|
||||
$statProperties = $stat[0];
|
||||
if ($statProperties->type === StatisticManager::STAT_TYPE_TIME) {
|
||||
$value = Formatter::formatTimeHMS($value);
|
||||
} else if ($statProperties->type == StatisticManager::STAT_TYPE_FLOAT) {
|
||||
$value = round(floatval($value), 2);
|
||||
} else if ($statProperties->type === StatisticManager::STAT_TYPE_FLOAT) {
|
||||
$value = round($value, 2);
|
||||
}
|
||||
|
||||
if ($id % 2 != 0) {
|
||||
if ($id % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$frame->add($lineQuad);
|
||||
$lineQuad->setSize(49, 4);
|
||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
$lineQuad->setPosition($x, $y, 0.001);
|
||||
$lineQuad->setPosition($posX, $posY, 0.001);
|
||||
$lineQuad->setHAlign(Control::LEFT);
|
||||
}
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition($x + 4, $y);
|
||||
$label->setPosition($posX + 4, $posY);
|
||||
$label->setText($statProperties->name);
|
||||
$label->setHAlign(Control::LEFT);
|
||||
$label->setTextSize(1.5);
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition($x + 40, $y);
|
||||
$label->setPosition($posX + 40, $posY);
|
||||
$label->setText($value);
|
||||
$label->setTextSize(1.5);
|
||||
|
||||
$y -= 4;
|
||||
$posY -= 4;
|
||||
$id++;
|
||||
|
||||
if ($id > self::STATS_PER_COLUMN) {
|
||||
$y = $this->height / 2 - 15;
|
||||
$x += 47;
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX += 47;
|
||||
$id = 0;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget != 'PlayerList') {
|
||||
if ($openedWidget !== 'PlayerList') {
|
||||
unset($this->playersListShown[$player->login]);
|
||||
}
|
||||
}
|
||||
@ -187,7 +187,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame = new Frame();
|
||||
$pageFrame->add($playerFrame);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -200,8 +200,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
|
||||
$playerFrame->setY($y);
|
||||
|
||||
//Show current Player Arrow
|
||||
if ($listPlayer->index == $player->index) {
|
||||
// Show current Player Arrow
|
||||
if ($listPlayer->index === $player->index) {
|
||||
$currentQuad = new Quad_Icons64x64_1();
|
||||
$playerFrame->add($currentQuad);
|
||||
$currentQuad->setX($x + 3.5);
|
||||
@ -238,14 +238,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
|
||||
if ($countryCode != 'OTH') {
|
||||
if ($countryCode !== 'OTH') {
|
||||
// Nation Quad
|
||||
$countryQuad = new Quad();
|
||||
$playerFrame->add($countryQuad);
|
||||
$countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country");
|
||||
$countryQuad->setX($x + 98);
|
||||
$countryQuad->setSize(4, 4);
|
||||
$countryQuad->setZ(1);
|
||||
$countryQuad->setSize(4, 4);
|
||||
|
||||
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
|
||||
}
|
||||
@ -255,15 +255,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($rightQuad);
|
||||
$rightQuad->setX($x + 13);
|
||||
$rightQuad->setZ(3);
|
||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||
$rightQuad->setSize(7, 3.5);
|
||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||
|
||||
$rightLabel = new Label_Text();
|
||||
$playerFrame->add($rightLabel);
|
||||
$rightLabel->setX($x + 13.9);
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setZ(3.1);
|
||||
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setTextColor("fff");
|
||||
|
||||
$description = $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer) . " " . $listPlayer->nickname;
|
||||
@ -274,8 +274,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 61);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
||||
$playerQuad->setSize(2.7, 2.7);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
||||
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
||||
$description = 'View Statistics of $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@ -285,8 +285,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 64.5);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
||||
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER . "." . $listPlayer->login);
|
||||
@ -296,8 +296,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 68);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||
$playerQuad->addPlayerProfileFeature($listPlayer->login);
|
||||
|
||||
// Description Label
|
||||
@ -310,8 +310,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 132);
|
||||
$playerQuad->setZ(0.1);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
||||
|
||||
// Description Label
|
||||
@ -326,9 +326,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($redQuad);
|
||||
$redQuad->setX($x + 145);
|
||||
$redQuad->setZ(0.1);
|
||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||
$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
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Red Team!';
|
||||
@ -339,9 +339,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($blueQuad);
|
||||
$blueQuad->setX($x + 141);
|
||||
$blueQuad->setZ(0.1);
|
||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||
$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
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
||||
@ -353,9 +353,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($kickQuad);
|
||||
$kickQuad->setX($x + 141);
|
||||
$kickQuad->setZ(0.1);
|
||||
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
|
||||
$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 . '$>!';
|
||||
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@ -367,9 +367,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playQuad);
|
||||
$playQuad->setX($x + 143);
|
||||
$playQuad->setZ(0.1);
|
||||
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
|
||||
$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!';
|
||||
$playQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@ -382,9 +382,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($spectatorQuad);
|
||||
$spectatorQuad->setX($x + 137);
|
||||
$spectatorQuad->setZ(0.1);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$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
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
@ -395,9 +395,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($spectatorQuad);
|
||||
$spectatorQuad->setX($x + 137);
|
||||
$spectatorQuad->setZ(0.1);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$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
|
||||
$description = 'Start a Vote to force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
@ -409,8 +409,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Show advanced window
|
||||
if ($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
||||
$frame = $this->showAdvancedPlayerWidget($player, $this->playersListShown[$player->login]);
|
||||
$listShownValue = $this->playersListShown[$player->login];
|
||||
if ($listShownValue && $listShownValue !== self::SHOWN_MAIN_WINDOW) {
|
||||
$frame = $this->showAdvancedPlayerWidget($player, $listShownValue);
|
||||
$maniaLink->add($frame);
|
||||
}
|
||||
|
||||
@ -773,7 +774,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Reopen widget
|
||||
if ($shown != self::SHOWN_MAIN_WINDOW) {
|
||||
if ($shown !== self::SHOWN_MAIN_WINDOW) {
|
||||
$this->playersListShown[$login] = false;
|
||||
}
|
||||
$this->showPlayerList($player);
|
||||
|
@ -123,7 +123,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$detailedPlayerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login);
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$player->teamId = $callback[1][0]["TeamId"];
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
@ -446,7 +446,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
*/
|
||||
public function getPlayerByIndex($index, $connectedPlayersOnly = false) {
|
||||
foreach ($this->players as $player) {
|
||||
if ($player->index == $index) {
|
||||
if ($player->index === $index) {
|
||||
return $player;
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
// Display normal Plugin List
|
||||
// Plugin pages
|
||||
$y = 0.;
|
||||
$posY = 0.;
|
||||
$pluginUpdates = $this->maniaControl->updateManager->pluginUpdateManager->getPluginsUpdates();
|
||||
|
||||
usort($pluginClasses, function ($a, $b) {
|
||||
@ -142,14 +142,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
$paging->addPage($pageFrame);
|
||||
$y = $height * 0.41;
|
||||
$posY = $height * 0.41;
|
||||
}
|
||||
|
||||
$active = $this->maniaControl->pluginManager->isPluginActive($pluginClass);
|
||||
|
||||
$pluginFrame = new Frame();
|
||||
$pageFrame->add($pluginFrame);
|
||||
$pluginFrame->setY($y);
|
||||
$pluginFrame->setY($posY);
|
||||
|
||||
$activeQuad = new Quad_Icons64x64_1();
|
||||
$pluginFrame->add($activeQuad);
|
||||
@ -207,7 +207,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$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();
|
||||
$pluginFrame->add($quadUpdate);
|
||||
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
|
||||
@ -217,16 +217,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
|
||||
}
|
||||
|
||||
$y -= $entryHeight;
|
||||
$posY -= $entryHeight;
|
||||
}
|
||||
|
||||
if ($pluginUpdates != false) {
|
||||
if ($pluginUpdates) {
|
||||
$updatePluginsButton = new Label_Button();
|
||||
$frame->add($updatePluginsButton);
|
||||
$updatePluginsButton->setHAlign(Control::RIGHT);
|
||||
$updatePluginsButton->setX($width * 0.5);
|
||||
$updatePluginsButton->setY(-29);
|
||||
$updatePluginsButton->setZ(2);
|
||||
$updatePluginsButton->setPosition($width * 0.5, -29, 2);
|
||||
$updatePluginsButton->setWidth(10);
|
||||
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
|
||||
$updatePluginsButton->setText(count($pluginUpdates) . ' update(s)');
|
||||
|
@ -111,7 +111,7 @@ class RankingManager implements CallbackListener {
|
||||
$leaders = array();
|
||||
$prev = -1;
|
||||
foreach ($this->rankings as $score) {
|
||||
if ($prev != -1 && $prev < $score) {
|
||||
if ($prev !== -1 && $prev < $score) {
|
||||
return $leaders;
|
||||
}
|
||||
array_push($leaders, $leader);
|
||||
|
@ -111,7 +111,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
}
|
||||
$pauseExists = false;
|
||||
foreach ($scriptInfos->commandDescs as $param) {
|
||||
if ($param->name == "Command_ForceWarmUp") {
|
||||
if ($param->name === 'Command_ForceWarmUp') {
|
||||
$pauseExists = true;
|
||||
break;
|
||||
}
|
||||
@ -269,7 +269,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if (count($params) >= 2) {
|
||||
$param = $params[1];
|
||||
if ($param == 'empty') {
|
||||
if (strtolower($param) === 'empty') {
|
||||
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
||||
if ($this->serverShutdownEmpty) {
|
||||
$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
|
||||
$xStart = -$width / 2;
|
||||
$y = $height / 2;
|
||||
$posY = $height / 2;
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = new Label();
|
||||
@ -164,22 +164,22 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
// Headline
|
||||
$headFrame = new Frame();
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($y - 5);
|
||||
$headFrame->setY($posY - 5);
|
||||
|
||||
$x = $xStart;
|
||||
$array['$oId'] = $x + 5;
|
||||
$array['$oNickname'] = $x + 14;
|
||||
$posX = $xStart;
|
||||
$array['$oId'] = $posX + 5;
|
||||
$array['$oNickname'] = $posX + 14;
|
||||
|
||||
|
||||
//Compute Headline
|
||||
$x = $xStart + 55;
|
||||
$posX = $xStart + 55;
|
||||
$statRankings = array();
|
||||
foreach ($this->statArray as $key => $stat) {
|
||||
$ranking = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
||||
if (!empty($ranking)) {
|
||||
$statRankings[$stat["Name"]] = $ranking;
|
||||
$array[$stat['HeadShortCut']] = $x;
|
||||
$x += $stat["Width"];
|
||||
$array[$stat['HeadShortCut']] = $posX;
|
||||
$posX += $stat["Width"];
|
||||
} else {
|
||||
unset($this->statArray[$key]);
|
||||
}
|
||||
@ -188,18 +188,18 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||
|
||||
//Description Label
|
||||
$i = 2;
|
||||
$index = 2;
|
||||
foreach ($this->statArray as $statArray) {
|
||||
if (!isset($labels[$i])) {
|
||||
if (!isset($labels[$index])) {
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var Label_Text $label [] */
|
||||
$label = $labels[$i];
|
||||
$label = $labels[$index];
|
||||
|
||||
$label->setAction(self::ACTION_SORT_STATS . '.' . $statArray["Name"]);
|
||||
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $statArray["Name"]);
|
||||
$i++;
|
||||
$index++;
|
||||
}
|
||||
|
||||
// define standard properties
|
||||
@ -207,8 +207,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$style = Label_Text::STYLE_TextCardSmall;
|
||||
$textSize = 1.5;
|
||||
$textColor = 'FFF';
|
||||
$i = 1;
|
||||
$y -= 10;
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
|
||||
if (!isset($statRankings[$order])) {
|
||||
return;
|
||||
@ -219,7 +219,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
if (!$listPlayer) {
|
||||
continue;
|
||||
}
|
||||
if ($i == 15) {
|
||||
if ($index === 15) {
|
||||
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);
|
||||
|
||||
|
||||
$x = $xStart + 55;
|
||||
$posX = $xStart + 55;
|
||||
foreach ($displayArray as $key => $array) {
|
||||
$label = new Label_Text();
|
||||
$playerFrame->add($label);
|
||||
$label->setHAlign($hAlign);
|
||||
$label->setX($x);
|
||||
$label->setX($posX);
|
||||
$label->setStyle($style);
|
||||
$label->setTextSize($textSize);
|
||||
$label->setText($array['Value']);
|
||||
$label->setTextColor($textColor);
|
||||
$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();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -282,8 +282,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$y -= 4;
|
||||
$index++;
|
||||
$posY -= 4;
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
|
@ -182,11 +182,11 @@ class StatisticManager {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
if ($minValue == -1) {
|
||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = " . $statId . " ORDER BY value DESC;";
|
||||
} else {
|
||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = " . $statId . " AND value >= " . $minValue . " ORDER BY value DESC;";
|
||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = {$statId}";
|
||||
if ($minValue >= 0) {
|
||||
$query .= " AND value >= {$minValue}";
|
||||
}
|
||||
$query .= " ORDER BY value DESC;";
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
@ -196,7 +196,7 @@ class StatisticManager {
|
||||
|
||||
$stats = array();
|
||||
while ($row = $result->fetch_object()) {
|
||||
if ($serverIndex == -1) {
|
||||
if ($serverIndex < 0) {
|
||||
if (!isset($stats[$row->playerId])) {
|
||||
$stats[$row->playerId] = $row->value;
|
||||
} else {
|
||||
@ -206,9 +206,9 @@ class StatisticManager {
|
||||
$stats[$row->playerId] = $row->value;
|
||||
}
|
||||
}
|
||||
$result->free();
|
||||
|
||||
arsort($stats);
|
||||
$result->free();
|
||||
return $stats;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($deaths as $key => $death) {
|
||||
if ($death == 0 || !isset($kills[$key])) {
|
||||
if (!$death || !isset($kills[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($kills[$key]) / intval($death);
|
||||
@ -243,7 +243,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($times as $key => $time) {
|
||||
if ($time == 0 || !isset($hits[$key])) {
|
||||
if (!$time || !isset($hits[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($hits[$key]) / (intval($time) / 3600);
|
||||
@ -257,7 +257,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($shots as $key => $shot) {
|
||||
if ($shot == 0 || !isset($hits[$key])) {
|
||||
if (!$shot || !isset($hits[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||
@ -271,7 +271,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($shots as $key => $shot) {
|
||||
if ($shot == 0 || !isset($hits[$key])) {
|
||||
if (!$shot || !isset($hits[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||
@ -285,7 +285,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($shots as $key => $shot) {
|
||||
if ($shot == 0 || !isset($hits[$key])) {
|
||||
if (!$shot || !isset($hits[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||
@ -299,7 +299,7 @@ class StatisticManager {
|
||||
return array();
|
||||
}
|
||||
foreach ($shots as $key => $shot) {
|
||||
if ($shot == 0 || !isset($hits[$key])) {
|
||||
if (!$shot || !isset($hits[$key])) {
|
||||
continue;
|
||||
}
|
||||
$statsArray[$key] = intval($hits[$key]) / (intval($shot));
|
||||
@ -347,7 +347,7 @@ class StatisticManager {
|
||||
}
|
||||
$kills = intval($playerStats[StatisticCollector::STAT_ON_KILL][1]);
|
||||
$deaths = intval($playerStats[StatisticCollector::STAT_ON_DEATH][1]);
|
||||
if ($deaths == 0) {
|
||||
if (!$deaths) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, $kills / $deaths);
|
||||
@ -358,7 +358,7 @@ class StatisticManager {
|
||||
}
|
||||
$hits = intval($playerStats[StatisticCollector::STAT_ON_HIT][1]);
|
||||
$time = intval($playerStats[StatisticCollector::STAT_PLAYTIME][1]);
|
||||
if ($time == 0) {
|
||||
if (!$time) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, $hits / ($time / 3600));
|
||||
@ -369,7 +369,7 @@ class StatisticManager {
|
||||
}
|
||||
$hits = intval($playerStats[StatisticCollector::STAT_ARROW_HIT][1]);
|
||||
$shots = intval($playerStats[StatisticCollector::STAT_ARROW_SHOT][1]);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||
@ -380,7 +380,7 @@ class StatisticManager {
|
||||
}
|
||||
$hits = intval($playerStats[StatisticCollector::STAT_LASER_HIT][1]);
|
||||
$shots = intval($playerStats[StatisticCollector::STAT_LASER_SHOT][1]);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||
@ -391,7 +391,7 @@ class StatisticManager {
|
||||
}
|
||||
$hits = intval($playerStats[StatisticCollector::STAT_ROCKET_HIT][1]);
|
||||
$shots = intval($playerStats[StatisticCollector::STAT_ROCKET_SHOT][1]);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, $hits / $shots);
|
||||
@ -402,7 +402,7 @@ class StatisticManager {
|
||||
}
|
||||
$hits = intval($playerStats[StatisticCollector::STAT_NUCLEUS_HIT][1]);
|
||||
$shots = intval($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT][1]);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
continue;
|
||||
}
|
||||
$playerStats[$stat->name] = array($stat, (float)($hits / $shots));
|
||||
@ -426,42 +426,42 @@ class StatisticManager {
|
||||
case self::SPECIAL_STAT_KD_RATIO:
|
||||
$kills = $this->getStatisticData(StatisticCollector::STAT_ON_KILL, $playerId, $serverIndex);
|
||||
$deaths = $this->getStatisticData(StatisticCollector::STAT_ON_DEATH, $playerId, $serverIndex);
|
||||
if ($deaths == 0) {
|
||||
if (!$deaths) {
|
||||
return -1;
|
||||
}
|
||||
return intval($kills) / intval($deaths);
|
||||
case self::SPECIAL_STAT_HITS_PH:
|
||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ON_HIT, $playerId, $serverIndex);
|
||||
$time = $this->getStatisticData(StatisticCollector::STAT_PLAYTIME, $playerId, $serverIndex);
|
||||
if ($time == 0) {
|
||||
if (!$time) {
|
||||
return -1;
|
||||
}
|
||||
return intval($hits) / (intval($time) / 3600);
|
||||
case self::SPECIAL_STAT_ARROW_ACC:
|
||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ARROW_HIT, $playerId, $serverIndex);
|
||||
$shots = $this->getStatisticData(StatisticCollector::STAT_ARROW_SHOT, $playerId, $serverIndex);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
return -1;
|
||||
}
|
||||
return intval($hits) / intval($shots);
|
||||
case self::SPECIAL_STAT_LASER_ACC:
|
||||
$hits = $this->getStatisticData(StatisticCollector::STAT_LASER_HIT, $playerId, $serverIndex);
|
||||
$shots = $this->getStatisticData(StatisticCollector::STAT_LASER_SHOT, $playerId, $serverIndex);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
return -1;
|
||||
}
|
||||
return intval($hits) / intval($shots);
|
||||
case self::SPECIAL_STAT_NUCLEUS_ACC:
|
||||
$hits = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_HIT, $playerId, $serverIndex);
|
||||
$shots = $this->getStatisticData(StatisticCollector::STAT_NUCLEUS_SHOT, $playerId, $serverIndex);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
return -1;
|
||||
}
|
||||
return intval($hits) / intval($shots);
|
||||
case self::SPECIAL_STAT_ROCKET_ACC:
|
||||
$hits = $this->getStatisticData(StatisticCollector::STAT_ROCKET_HIT, $playerId, $serverIndex);
|
||||
$shots = $this->getStatisticData(StatisticCollector::STAT_ROCKET_SHOT, $playerId, $serverIndex);
|
||||
if ($shots == 0) {
|
||||
if (!$shots) {
|
||||
return -1;
|
||||
}
|
||||
return intval($hits) / intval($shots);
|
||||
@ -474,7 +474,7 @@ class StatisticManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($serverIndex == -1) {
|
||||
if ($serverIndex < 0) {
|
||||
$query = "SELECT SUM(value) as value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . ";";
|
||||
} else {
|
||||
$query = "SELECT value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . " AND `serverIndex` = '" . $serverIndex . "';";
|
||||
@ -529,7 +529,7 @@ class StatisticManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($serverIndex == -1) {
|
||||
if ($serverIndex) {
|
||||
$serverIndex = $this->maniaControl->server->index;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
|
||||
if ($update) {
|
||||
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
|
||||
if ($pluginClass == 'All') {
|
||||
if ($pluginClass === 'All') {
|
||||
$this->performPluginsUpdate($player);
|
||||
} else {
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
try {
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
|
||||
} 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());
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
//to nothing
|
||||
|
@ -195,7 +195,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
* @param float $neededRatio
|
||||
*/
|
||||
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);
|
||||
}
|
||||
$voteCommand = new VoteCommand($voteIndex, $voteName, $idBased, $neededRatio);
|
||||
@ -221,7 +221,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
|
||||
$pauseExists = false;
|
||||
foreach ($scriptInfos->commandDescs as $param) {
|
||||
if ($param->name == "Command_ForceWarmUp") {
|
||||
if ($param->name === "Command_ForceWarmUp") {
|
||||
$pauseExists = true;
|
||||
break;
|
||||
}
|
||||
@ -286,7 +286,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
@ -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->function = $function;
|
||||
|
||||
if ($this->currentVote->voteCommand->startText != '') {
|
||||
if ($this->currentVote->voteCommand->startText) {
|
||||
$message = $this->currentVote->voteCommand->startText;
|
||||
} else {
|
||||
$message = '$fff$<' . $player->nickname . '$>$s$f8f started a $fff$<' . $this->currentVote->voteCommand->name . '$>$f8f!';
|
||||
|
@ -61,7 +61,7 @@ class DedimaniaData {
|
||||
public function toArray() {
|
||||
$array = array();
|
||||
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;
|
||||
}
|
||||
$array[ucfirst($key)] = $value;
|
||||
|
@ -153,7 +153,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$serverInfo = $this->maniaControl->server->getInfo();
|
||||
$serverVersion = $this->maniaControl->client->getVersion();
|
||||
$packMask = $this->maniaControl->server->titleId;
|
||||
if ($packMask != 'Trackmania_2@nadeolabs') {
|
||||
if ($packMask !== 'Trackmania_2@nadeolabs') {
|
||||
$packMask = substr($this->maniaControl->server->titleId, 2);
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @return bool
|
||||
*/
|
||||
private function fetchDedimaniaRecords($reset = true) {
|
||||
if (!$this->dedimaniaData || $this->dedimaniaData->sessionId == '') {
|
||||
if (!$this->dedimaniaData || !$this->dedimaniaData->sessionId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
if ($error != '') {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
private function getPlayerList() {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
|
||||
if (count($players) == 0) {
|
||||
if (empty($players)) {
|
||||
return null;
|
||||
}
|
||||
$playerInfo = array();
|
||||
@ -352,25 +352,31 @@ 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
|
||||
*/
|
||||
private function getGameModeString() {
|
||||
$gameMode = $this->maniaControl->server->getGameMode();
|
||||
$scriptNameResponse = $this->maniaControl->client->getScriptName();
|
||||
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse["CurrentValue"]);
|
||||
$gameMode = $this->maniaControl->server->getGameMode();
|
||||
if ($gameMode === null) {
|
||||
trigger_error("Couldn't retrieve game mode. ");
|
||||
trigger_error("Couldn't retrieve game mode.");
|
||||
return null;
|
||||
}
|
||||
switch ($gameMode) {
|
||||
case 0:
|
||||
{
|
||||
if ($scriptName == 'Rounds' || $scriptName == 'Cup' || $scriptName == 'Team') {
|
||||
return 'Rounds';
|
||||
} else if ($scriptName == 'TimeAttack' || $scriptName == 'Laps' || $scriptName == 'TeamAttack' || $scriptName == 'TimeAttackPlus') {
|
||||
return 'TA';
|
||||
$scriptNameResponse = $this->maniaControl->client->getScriptName();
|
||||
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse['CurrentValue']);
|
||||
switch ($scriptName) {
|
||||
case 'Rounds':
|
||||
case 'Cup':
|
||||
case 'Team':
|
||||
return 'Rounds';
|
||||
case 'TimeAttack':
|
||||
case 'Laps':
|
||||
case 'TeamAttack':
|
||||
case 'TimeAttackPlus':
|
||||
return 'TA';
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -390,16 +396,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle 1Second callback
|
||||
* Handle 1 Second Callback
|
||||
*/
|
||||
public function updateEverySecond($time) {
|
||||
if (!$this->updateManialink) {
|
||||
public function updateEverySecond() {
|
||||
if (!$this->updateManialink || !$this->dedimaniaData->records) {
|
||||
return;
|
||||
}
|
||||
if (!$this->dedimaniaData->records) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateManialink = false;
|
||||
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
@ -526,7 +528,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
if ($error != '') {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
@ -609,7 +611,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
if ($error != '') {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
@ -656,7 +658,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
break;
|
||||
}
|
||||
|
||||
if ($record->newRecord == false) {
|
||||
if (!$record->newRecord) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
$maniaControl = $this->maniaControl;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self, &$maniaControl) {
|
||||
if ($error != '') {
|
||||
if ($error) {
|
||||
$maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
@ -714,7 +716,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$serverInfo = $this->getServerInfo();
|
||||
$playerList = $this->getPlayerList();
|
||||
$votesInfo = $this->getVotesInfo();
|
||||
if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || $this->dedimaniaData->sessionId == '') {
|
||||
if (!$serverInfo || !$votesInfo || !$playerList || !isset($this->dedimaniaData) || !$this->dedimaniaData->sessionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -724,7 +726,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
if ($error != '') {
|
||||
if ($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
|
||||
*/
|
||||
private function updateDedimaniaRecordRanks() {
|
||||
if ($this->dedimaniaData->getRecordCount() == 0) {
|
||||
if ($this->dedimaniaData->getRecordCount() === 0) {
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
return;
|
||||
}
|
||||
@ -1031,7 +1033,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
|
||||
if ($actionId == self::ACTION_SHOW_DEDIRECORDSLIST) {
|
||||
if ($actionId === self::ACTION_SHOW_DEDIRECORDSLIST) {
|
||||
$this->showDediRecordsList(array(), $player);
|
||||
}
|
||||
}
|
||||
@ -1093,7 +1095,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$recordFrame = new Frame();
|
||||
$pageFrame->add($recordFrame);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$recordFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
|
@ -160,7 +160,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$pageFrame->add($playerFrame);
|
||||
$playerFrame->setY($y);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
|
@ -99,7 +99,7 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
$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)!';
|
||||
throw new \Exception($error);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
||||
$mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
|
||||
|
||||
if ($mxKarmaCode == '') {
|
||||
if (!$mxKarmaCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
// Fetch the Mx Karma Votes
|
||||
$self->getMxKarmaVotes();
|
||||
} 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);
|
||||
$self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
||||
} else {
|
||||
@ -348,7 +348,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$properties = array();
|
||||
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
if ($gameMode == 'Script') {
|
||||
if ($gameMode === 'Script') {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$properties['gamemode'] = $scriptName["CurrentValue"];
|
||||
} else {
|
||||
@ -393,7 +393,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$self->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||
} else {
|
||||
$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']);
|
||||
return;
|
||||
}
|
||||
@ -455,12 +455,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
|
||||
if (count($votes) == 0) {
|
||||
if (empty($votes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$properties = array();
|
||||
if ($gameMode == 'Script') {
|
||||
if ($gameMode === 'Script') {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$properties['gamemode'] = $scriptName["CurrentValue"];
|
||||
} else {
|
||||
@ -490,7 +490,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$self->maniaControl->log("Votes successfully submitted");
|
||||
} else {
|
||||
$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']);
|
||||
return;
|
||||
}
|
||||
@ -967,7 +967,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
$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}";
|
||||
$result2 = $mysqli->query($query);
|
||||
if ($mysqli->error) {
|
||||
@ -1011,7 +1011,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->mxKarma['votes']) || count($this->mxKarma['votes']) == 0) {
|
||||
if (!isset($this->mxKarma['votes']) || empty($this->mxKarma['votes'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
||||
*/
|
||||
public function getLocalRecords(Map $map, $limit = -1) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$limit = ($limit > 0 ? "LIMIT " . $limit : "");
|
||||
$limit = ($limit > 0 ? 'LIMIT ' . $limit : '');
|
||||
$query = "SELECT * FROM (
|
||||
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
|
||||
WHERE recs.`mapIndex` = {$map->index}
|
||||
@ -435,30 +435,34 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
||||
$this->updateManialink = true;
|
||||
|
||||
// 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);
|
||||
$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 = 'You ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Local Record: $<$fff' . Formatter::formatTime($newRecord->time) . '$>';
|
||||
if ($oldRecord) {
|
||||
$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);
|
||||
|
||||
$message = '$3c0';
|
||||
if ($notifyOnlyDriver) {
|
||||
$message .= 'You';
|
||||
} else {
|
||||
$improvement = ((!$oldRecord || $newRecord->rank < $oldRecord->rank) ? 'gained the' : 'improved the');
|
||||
$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 .= '$<$fff' . $callback->player->nickname . '$>';
|
||||
}
|
||||
$message .= ' ' . ($improvedRank ? 'gained' : 'improved') . ' the';
|
||||
$message .= ' $<$ff0' . $newRecord->rank . '.$> Local Record:';
|
||||
$message .= ' $<$fff' . Formatter::formatTime($newRecord->time) . '$>!';
|
||||
if ($oldRecord) {
|
||||
$message .= ' (';
|
||||
if ($improvedRank) {
|
||||
$message .= '$<$ff0' . $oldRecord->rank . '.$> ';
|
||||
}
|
||||
if ($oldRecord) {
|
||||
$message .= ' ($<$ff0' . $oldRank . '$>$<$fff-' . Formatter::formatTime(($oldRecord->time - $newRecord->time)) . '$>)';
|
||||
}
|
||||
$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);
|
||||
@ -596,7 +600,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
||||
$recordFrame = new Frame();
|
||||
$pageFrame->add($recordFrame);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$recordFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -647,7 +651,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
||||
}
|
||||
|
||||
$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);
|
||||
if ($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
|
||||
*/
|
||||
class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
/**
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 6;
|
||||
@ -109,10 +109,10 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
|
||||
$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
|
||||
$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);
|
||||
} else {
|
||||
$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
|
||||
$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 . ')';
|
||||
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(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);
|
||||
$playerFrame->setY($y);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@ -521,6 +522,25 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
// Render and display xml
|
||||
$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