some fixes
This commit is contained in:
@ -16,7 +16,7 @@ class Plugin_Chatlog extends Plugin{
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
private $config = null;
|
||||
|
||||
@ -25,8 +25,8 @@ class Plugin_Chatlog extends Plugin{
|
||||
/**
|
||||
* Constuct chatlog plugin
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
// Load config
|
||||
$this->config = Tools::loadConfig('chatlog.plugin.xml');
|
||||
@ -38,7 +38,7 @@ class Plugin_Chatlog extends Plugin{
|
||||
$this->loadSettings();
|
||||
|
||||
// Register for callbacksc
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCHAT, $this, 'handlePlayerChatCallback');
|
||||
|
||||
error_log('Chatlog Pugin v' . self::VERSION . ' ready!');
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class Plugin_Karma {
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
private $config = null;
|
||||
|
||||
@ -27,10 +27,10 @@ class Plugin_Karma {
|
||||
/**
|
||||
* Construct plugin
|
||||
*
|
||||
* @param object $mControl
|
||||
* @param object $mc
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
// Load config
|
||||
$this->config = Tools::loadConfig('karma.plugin.xml');
|
||||
@ -40,10 +40,10 @@ class Plugin_Karma {
|
||||
$this->initDatabase();
|
||||
|
||||
// Register for callbacks
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMapCallback');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnectCallback');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||
'handleManialinkPageAnswerCallback');
|
||||
|
||||
error_log('Karma Pugin v' . self::VERSION . ' ready!');
|
||||
@ -57,7 +57,7 @@ class Plugin_Karma {
|
||||
$this->sendManialinkRequested = -1;
|
||||
|
||||
// Send manialink to all players
|
||||
$players = $this->iControl->server->getPlayers();
|
||||
$players = $this->mc->server->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
$login = $player['Login'];
|
||||
$manialink = $this->buildManialink($login);
|
||||
@ -66,7 +66,7 @@ class Plugin_Karma {
|
||||
$this->sendManialinkRequested = time() + 5;
|
||||
continue;
|
||||
}
|
||||
Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login);
|
||||
Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ class Plugin_Karma {
|
||||
$login = $callback[1][0];
|
||||
$manialink = $this->buildManialink($login);
|
||||
if (!$manialink) return;
|
||||
Tools::sendManialinkPage($this->iControl->client, $manialink->asXml(), $login);
|
||||
Tools::sendManialinkPage($this->mc->client, $manialink->asXml(), $login);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,9 +116,9 @@ class Plugin_Karma {
|
||||
PRIMARY KEY (`index`),
|
||||
UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;";
|
||||
$result = $this->iControl->database->query($query);
|
||||
if ($this->iControl->database->mysqli->error) {
|
||||
trigger_error('MySQL Error on creating karma table. ' . $this->iControl->database->mysqli->error, E_USER_ERROR);
|
||||
$result = $this->mc->database->query($query);
|
||||
if ($this->mc->database->mysqli->error) {
|
||||
trigger_error('MySQL Error on creating karma table. ' . $this->mc->database->mysqli->error, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,9 +158,9 @@ class Plugin_Karma {
|
||||
|
||||
// Save vote
|
||||
$login = $callback[1][1];
|
||||
$playerIndex = $this->iControl->database->getPlayerIndex($login);
|
||||
$map = $this->iControl->server->getMap();
|
||||
$mapIndex = $this->iControl->database->getMapIndex($map['UId']);
|
||||
$playerIndex = $this->mc->database->getPlayerIndex($login);
|
||||
$map = $this->mc->server->getMap();
|
||||
$mapIndex = $this->mc->database->getMapIndex($map['UId']);
|
||||
$query = "INSERT INTO `" . self::TABLE_KARMA . "` (
|
||||
`mapIndex`,
|
||||
`playerIndex`,
|
||||
@ -171,11 +171,11 @@ class Plugin_Karma {
|
||||
" . $vote . "
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
`vote` = VALUES(`vote`);";
|
||||
$result = $this->iControl->database->query($query);
|
||||
$result = $this->mc->database->query($query);
|
||||
if (!$result) return;
|
||||
|
||||
// Send success message
|
||||
$this->iControl->chat->sendSuccess('Vote successfully updated!', $login);
|
||||
$this->mc->chat->sendSuccess('Vote successfully updated!', $login);
|
||||
|
||||
// Send updated manialink
|
||||
$this->sendManialinkRequested = time() + 1;
|
||||
@ -190,14 +190,14 @@ class Plugin_Karma {
|
||||
$pos_x = (float) $this->config->pos_x;
|
||||
$pos_y = (float) $this->config->pos_y;
|
||||
|
||||
$mysqli = $this->iControl->database->mysqli;
|
||||
$mysqli = $this->mc->database->mysqli;
|
||||
|
||||
// Get indezes
|
||||
$playerIndex = $this->iControl->database->getPlayerIndex($login);
|
||||
$playerIndex = $this->mc->database->getPlayerIndex($login);
|
||||
if ($playerIndex === null) return null;
|
||||
$map = $this->iControl->server->getMap();
|
||||
$map = $this->mc->server->getMap();
|
||||
if (!$map) return null;
|
||||
$mapIndex = $this->iControl->database->getMapIndex($map['UId']);
|
||||
$mapIndex = $this->mc->database->getMapIndex($map['UId']);
|
||||
if ($mapIndex === null) return null;
|
||||
|
||||
// Get votings
|
||||
|
@ -17,15 +17,15 @@ class Plugin_Obstacle extends Plugin {
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
private $config = null;
|
||||
|
||||
/**
|
||||
* Constuct obstacle plugin
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
// Load config
|
||||
$this->config = Tools::loadConfig('obstacle.plugin.xml');
|
||||
@ -34,7 +34,7 @@ class Plugin_Obstacle extends Plugin {
|
||||
if (!Tools::toBool($this->config->enabled)) return;
|
||||
|
||||
// Register for jump command
|
||||
$this->iControl->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
|
||||
$this->mc->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
|
||||
|
||||
error_log('Obstacle Pugin v' . self::VERSION . ' ready!');
|
||||
}
|
||||
@ -45,16 +45,16 @@ class Plugin_Obstacle extends Plugin {
|
||||
public function command_jumpto($chat) {
|
||||
$login = $chat[1][1];
|
||||
$rightLevel = (string) $this->config->jumps_rightlevel;
|
||||
if (!$this->iControl->authentication->checkRight($login, $rightLevel)) {
|
||||
if (!$this->mc->authentication->checkRight($login, $rightLevel)) {
|
||||
// Not allowed
|
||||
$this->iControl->authentication->sendNotAllowed($login);
|
||||
$this->mc->authentication->sendNotAllowed($login);
|
||||
}
|
||||
else {
|
||||
// Send jump callback
|
||||
$params = explode(' ', $chat[1][2], 2);
|
||||
$param = $login . ";" . $params[1] . ";";
|
||||
if (!$this->iControl->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
|
||||
trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->iControl->getClientErrorText());
|
||||
if (!$this->mc->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
|
||||
trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->mc->getClientErrorText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,15 @@ abstract class Plugin_Name {
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
/**
|
||||
* Construct plugin
|
||||
*
|
||||
* @param object $mControl
|
||||
* @param object $mc
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
error_log('Pugin v' . self::VERSION . ' ready!');
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Plugin_Records {
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
private $settings = null;
|
||||
|
||||
@ -58,8 +58,8 @@ class Plugin_Records {
|
||||
/**
|
||||
* Constuct plugin
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
// Load config
|
||||
$this->config = Tools::loadConfig('records.plugin.xml');
|
||||
@ -74,17 +74,17 @@ class Plugin_Records {
|
||||
$this->initTables();
|
||||
|
||||
// Register for callbacks
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInit');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_SECOND, $this, 'handle1Second');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_1_MINUTE, $this, 'handle1Minute');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_3_MINUTE, $this, 'handle3Minute');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleMapBegin');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_CLIENTUPDATED, $this, 'handleClientUpdated');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ENDMAP, $this, 'handleMapEnd');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpoint');
|
||||
|
||||
error_log('Records Pugin v' . self::VERSION . ' ready!');
|
||||
}
|
||||
@ -93,7 +93,7 @@ class Plugin_Records {
|
||||
* Init needed database tables
|
||||
*/
|
||||
private function initTables() {
|
||||
$database = $this->iControl->database;
|
||||
$database = $this->mc->database;
|
||||
|
||||
// Records table
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_RECORDS . "` (
|
||||
@ -227,7 +227,7 @@ class Plugin_Records {
|
||||
if ($init || !array_key_exists('serverData', $this->dedimaniaData) || !is_array($this->dedimaniaData['serverData'])) {
|
||||
$serverData = array();
|
||||
$serverData['Game'] = 'TM2';
|
||||
$serverInfo = $this->iControl->server->getInfo(true);
|
||||
$serverInfo = $this->mc->server->getInfo(true);
|
||||
|
||||
// Get dedimania account data
|
||||
$accounts = $this->config->xpath('dedimania_records/account');
|
||||
@ -250,9 +250,9 @@ class Plugin_Records {
|
||||
|
||||
// Complete seesion data
|
||||
$serverData['Path'] = $serverInfo['Path'];
|
||||
$systemInfo = $this->iControl->server->getSystemInfo();
|
||||
$systemInfo = $this->mc->server->getSystemInfo();
|
||||
$serverData['Packmask'] = substr($systemInfo['TitleId'], 2);
|
||||
$serverVersion = $this->iControl->server->getVersion();
|
||||
$serverVersion = $this->mc->server->getVersion();
|
||||
$serverData['ServerVersion'] = $serverVersion['Version'];
|
||||
$serverData['ServerBuild'] = $serverVersion['Build'];
|
||||
$serverData['Tool'] = 'ManiaControl';
|
||||
@ -352,7 +352,7 @@ class Plugin_Records {
|
||||
if ($this->settings->local_records_enabled) $this->sendManialink($this->manialinks[self::MLID_LOCAL], $login);
|
||||
|
||||
if ($this->settings->dedimania_enabled && $this->dedimaniaData['context']) {
|
||||
$player = $this->iControl->server->getPlayer($login, true);
|
||||
$player = $this->mc->server->getPlayer($login, true);
|
||||
if ($player) {
|
||||
// Send dedimania request
|
||||
$data = array($this->dedimaniaData['sessionId'], $player['Login'], $player['NickName'], $player['Path'],
|
||||
@ -435,7 +435,7 @@ class Plugin_Records {
|
||||
* Build map info struct for dedimania requests
|
||||
*/
|
||||
private function getMapInfo() {
|
||||
$map = $this->iControl->server->getMap();
|
||||
$map = $this->mc->server->getMap();
|
||||
if (!$map) return null;
|
||||
$mapInfo = array();
|
||||
$mapInfo['UId'] = $map['UId'];
|
||||
@ -528,12 +528,12 @@ class Plugin_Records {
|
||||
* Build server info struct for callbacks
|
||||
*/
|
||||
private function getSrvInfo() {
|
||||
$server = $this->iControl->server->getOptions();
|
||||
$server = $this->mc->server->getOptions();
|
||||
if (!$server) return null;
|
||||
$client = null;
|
||||
$players = null;
|
||||
$spectators = null;
|
||||
$this->iControl->server->getPlayers($client, $players, $spectators);
|
||||
$this->mc->server->getPlayers($client, $players, $spectators);
|
||||
if (!is_array($players) || !is_array($spectators)) return null;
|
||||
return array('SrvName' => $server['Name'], 'Comment' => $server['Comment'], 'Private' => (strlen($server['Password']) > 0),
|
||||
'NumPlayers' => count($players), 'MaxPlayers' => $server['CurrentMaxPlayers'], 'NumSpecs' => count($spectators),
|
||||
@ -547,7 +547,7 @@ class Plugin_Records {
|
||||
$client = null;
|
||||
$players;
|
||||
$spectators;
|
||||
$allPlayers = $this->iControl->server->getPlayers($client, $players, $spectators);
|
||||
$allPlayers = $this->mc->server->getPlayers($client, $players, $spectators);
|
||||
if (!is_array($players) || !is_array($spectators)) return null;
|
||||
$playerInfo = array();
|
||||
foreach ($allPlayers as $player) {
|
||||
@ -560,9 +560,9 @@ class Plugin_Records {
|
||||
* Get dedi string representation of the current game mode
|
||||
*/
|
||||
private function getGameModeString() {
|
||||
$gameMode = $this->iControl->server->getGameMode();
|
||||
$gameMode = $this->mc->server->getGameMode();
|
||||
if ($gameMode === null) {
|
||||
trigger_error("Couldn't retrieve game mode. " . $this->iControl->getClientErrorText());
|
||||
trigger_error("Couldn't retrieve game mode. " . $this->mc->getClientErrorText());
|
||||
return null;
|
||||
}
|
||||
switch ($gameMode) {
|
||||
@ -585,7 +585,7 @@ class Plugin_Records {
|
||||
* Build votes info struct for callbacks
|
||||
*/
|
||||
private function getVotesInfo() {
|
||||
$map = $this->iControl->server->getMap();
|
||||
$map = $this->mc->server->getMap();
|
||||
if (!$map) return null;
|
||||
$gameMode = $this->getGameModeString();
|
||||
if (!$gameMode) return null;
|
||||
@ -646,14 +646,14 @@ class Plugin_Records {
|
||||
|
||||
$login = $data[1];
|
||||
$time = $data[2];
|
||||
$newMap = $this->iControl->server->getMap();
|
||||
$newMap = $this->mc->server->getMap();
|
||||
if (!$newMap) return;
|
||||
if (!$this->mapInfo || $this->mapInfo['UId'] !== $newMap['UId']) {
|
||||
$this->mapInfo = $this->getMapInfo();
|
||||
}
|
||||
$map = $newMap;
|
||||
|
||||
$player = $this->iControl->server->getPlayer($login);
|
||||
$player = $this->mc->server->getPlayer($login);
|
||||
|
||||
if ($this->settings->local_records_enabled) {
|
||||
// Get old record of the player
|
||||
@ -668,13 +668,13 @@ class Plugin_Records {
|
||||
// Same time
|
||||
$message = '$<' . $player['NickName'] . '$> equalized her/his $<$o' . $oldRecord['rank'] . '.$> Local Record: ' .
|
||||
Tools::formatTime($oldRecord['time']);
|
||||
$this->iControl->chat->sendInformation($message);
|
||||
$this->mc->chat->sendInformation($message);
|
||||
$save = false;
|
||||
}
|
||||
}
|
||||
if ($save) {
|
||||
// Save time
|
||||
$database = $this->iControl->database;
|
||||
$database = $this->mc->database;
|
||||
$query = "INSERT INTO `" . self::TABLE_RECORDS . "` (
|
||||
`mapUId`,
|
||||
`Login`,
|
||||
@ -701,7 +701,7 @@ class Plugin_Records {
|
||||
}
|
||||
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['rank'] . '.$> Local Record: ' .
|
||||
Tools::formatTime($newRecord['time']);
|
||||
$this->iControl->chat->sendInformation($message);
|
||||
$this->mc->chat->sendInformation($message);
|
||||
$this->updateManialinks[self::MLID_LOCAL] = true;
|
||||
}
|
||||
}
|
||||
@ -745,7 +745,7 @@ class Plugin_Records {
|
||||
}
|
||||
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] .
|
||||
'.$> Dedimania Record: ' . Tools::formatTime($newRecord['Best']);
|
||||
$this->iControl->chat->sendInformation($message);
|
||||
$this->mc->chat->sendInformation($message);
|
||||
$this->updateManialinks[self::MLID_DEDI] = true;
|
||||
}
|
||||
}
|
||||
@ -859,21 +859,21 @@ class Plugin_Records {
|
||||
if (!$record || !$this->settings->dedimania_enabled) return;
|
||||
|
||||
// Set validation replay
|
||||
$validationReplay = $this->iControl->server->getValidationReplay($record['Login']);
|
||||
$validationReplay = $this->mc->server->getValidationReplay($record['Login']);
|
||||
if ($validationReplay) $record['VReplay'] = $validationReplay;
|
||||
|
||||
// Set ghost replay
|
||||
if ($record['Rank'] <= 1) {
|
||||
$dataDirectory = $this->iControl->server->getDataDirectory();
|
||||
$dataDirectory = $this->mc->server->getDataDirectory();
|
||||
if (!isset($this->dedimaniaData['directoryAccessChecked'])) {
|
||||
$access = $this->iControl->server->checkAccess($dataDirectory);
|
||||
$access = $this->mc->server->checkAccess($dataDirectory);
|
||||
if (!$access) {
|
||||
trigger_error("No access to the servers data directory. Can't retrieve ghost replays.");
|
||||
}
|
||||
$this->dedimaniaData['directoryAccessChecked'] = $access;
|
||||
}
|
||||
if ($this->dedimaniaData['directoryAccessChecked']) {
|
||||
$ghostReplay = $this->iControl->server->getGhostReplay($record['Login']);
|
||||
$ghostReplay = $this->mc->server->getGhostReplay($record['Login']);
|
||||
if ($ghostReplay) $record['Top1GReplay'] = $ghostReplay;
|
||||
}
|
||||
}
|
||||
@ -939,15 +939,15 @@ class Plugin_Records {
|
||||
* Send manialink to clients
|
||||
*/
|
||||
private function sendManialink($manialink, $login = null) {
|
||||
if (!$manialink || !$this->iControl->client) return;
|
||||
if (!$manialink || !$this->mc->client) return;
|
||||
if (!$login) {
|
||||
if (!$this->iControl->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) {
|
||||
trigger_error("Couldn't send manialink to players. " . $this->iControl->getClientErrorText());
|
||||
if (!$this->mc->client->query('SendDisplayManialinkPage', $manialink->asXML(), 0, false)) {
|
||||
trigger_error("Couldn't send manialink to players. " . $this->mc->getClientErrorText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) {
|
||||
trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->iControl->getClientErrorText());
|
||||
if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login, $manialink->asXML(), 0, false)) {
|
||||
trigger_error("Couldn't send manialink to player '" . $login . "'. " . $this->mc->getClientErrorText());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -967,7 +967,7 @@ class Plugin_Records {
|
||||
* Update local records manialink
|
||||
*/
|
||||
private function buildLocalManialink() {
|
||||
$map = $this->iControl->server->getMap();
|
||||
$map = $this->mc->server->getMap();
|
||||
if (!$map) {
|
||||
return null;
|
||||
}
|
||||
@ -1146,12 +1146,12 @@ class Plugin_Records {
|
||||
private function getLocalRecords($mapUId, $limit = -1) {
|
||||
$query = "SELECT * FROM (
|
||||
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` recs, (SELECT @rank := 0) ra
|
||||
WHERE recs.`mapUId` = '" . $this->iControl->database->escape($mapUId) . "'
|
||||
WHERE recs.`mapUId` = '" . $this->mc->database->escape($mapUId) . "'
|
||||
ORDER BY recs.`time` ASC
|
||||
" . ($limit > 0 ? "LIMIT " . $limit : "") . ") records
|
||||
LEFT JOIN `" . Database::TABLE_PLAYERS . "` players
|
||||
ON records.`Login` = players.`Login`;";
|
||||
return $this->iControl->database->query($query);
|
||||
return $this->mc->database->query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1163,7 +1163,7 @@ class Plugin_Records {
|
||||
*/
|
||||
private function getLocalRecord($mapUId, $login) {
|
||||
if (!$mapUId || !$login) return null;
|
||||
$database = $this->iControl->database;
|
||||
$database = $this->mc->database;
|
||||
$query = "SELECT records.* FROM (
|
||||
SELECT recs.*, @rank := @rank + 1 as `rank` FROM `" . self::TABLE_RECORDS . "` `recs`, (SELECT @rank := 0) r
|
||||
WHERE recs.`mapUid` = '" . $database->escape($mapUId) . "'
|
||||
|
@ -23,7 +23,7 @@ class Plugin_United {
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $mControl = null;
|
||||
private $mc = null;
|
||||
|
||||
private $config = null;
|
||||
|
||||
@ -46,8 +46,8 @@ class Plugin_United {
|
||||
/**
|
||||
* Constuct plugin
|
||||
*/
|
||||
public function __construct($mControl) {
|
||||
$this->mControl = $mControl;
|
||||
public function __construct($mc) {
|
||||
$this->mc = $mc;
|
||||
|
||||
// Load config
|
||||
$this->config = Tools::loadConfig('united.plugin.xml');
|
||||
@ -60,14 +60,14 @@ class Plugin_United {
|
||||
$this->loadClients();
|
||||
|
||||
// Register for callbacks
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_ONINIT, $this, 'handleOnInitCallback');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Seconds');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->mc->callbacks->registerCallbackHandler(Callbacks::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||
'handleManialinkPageAnswer');
|
||||
|
||||
// Register for commands
|
||||
$this->iControl->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand');
|
||||
$this->mc->commands->registerCommandHandler('nextserver', $this, 'handleNextServerCommand');
|
||||
|
||||
if ($this->settings->widgets_enabled) {
|
||||
// Build addfavorite manialink
|
||||
@ -88,9 +88,9 @@ class Plugin_United {
|
||||
|
||||
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
|
||||
// Send favorite widget
|
||||
if (!$this->iControl->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0,
|
||||
if (!$this->mc->client->query('SendDisplayManialinkPage', $this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0,
|
||||
false)) {
|
||||
trigger_error("Couldn't send favorite widget! " . $this->iControl->getClientErrorText());
|
||||
trigger_error("Couldn't send favorite widget! " . $this->mc->getClientErrorText());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ class Plugin_United {
|
||||
$this->settings->enabled = Tools::toBool($this->config->enabled);
|
||||
|
||||
// Timeout
|
||||
$timeout = $this->iControl->server->config->xpath('timeout');
|
||||
$timeout = $this->mc->server->config->xpath('timeout');
|
||||
if ($timeout) {
|
||||
$this->settings->timeout = (int) $timeout[0];
|
||||
}
|
||||
@ -169,7 +169,7 @@ class Plugin_United {
|
||||
$client->readCB();
|
||||
$callbacks = $client->getCBResponses();
|
||||
if (!is_array($callbacks) || $client->isError()) {
|
||||
trigger_error("Error reading server callbacks! " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Error reading server callbacks! " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
else {
|
||||
if ($client == $currentServer) {
|
||||
@ -189,7 +189,7 @@ class Plugin_United {
|
||||
$this->lastStatusCheck = time();
|
||||
|
||||
if (!$client->query('CheckEndMatchCondition')) {
|
||||
trigger_error("Couldn't get game server status. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't get game server status. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
else {
|
||||
$response = $client->getResponse();
|
||||
@ -241,7 +241,7 @@ class Plugin_United {
|
||||
*/
|
||||
public function handle5Seconds($callback = null) {
|
||||
// Update lobby infos
|
||||
$players = $this->iControl->server->getPlayers();
|
||||
$players = $this->mc->server->getPlayers();
|
||||
if (is_array($players)) {
|
||||
$playerCount = count($players);
|
||||
$playerLevel = 0.;
|
||||
@ -253,7 +253,7 @@ class Plugin_United {
|
||||
}
|
||||
foreach ($this->lobbies as $lobby) {
|
||||
if (!$lobby->query('SetLobbyInfo', true, $playerCount, 255, $playerLevel)) {
|
||||
trigger_error("Couldn't update lobby info. " . $this->iControl->getClientErrorText($lobby));
|
||||
trigger_error("Couldn't update lobby info. " . $this->mc->getClientErrorText($lobby));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,14 +263,14 @@ class Plugin_United {
|
||||
$joinLink = $this->getJoinLink();
|
||||
foreach ($clients as $client) {
|
||||
if ($client == $this->gameServer[$this->currentClientIndex]) continue;
|
||||
$players = $this->iControl->server->getPlayers($client);
|
||||
$players = $this->mc->server->getPlayers($client);
|
||||
if (!is_array($players)) continue;
|
||||
foreach ($players as $player) {
|
||||
$login = $player['Login'];
|
||||
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
|
||||
trigger_error(
|
||||
"Couldn't redirect player '" . $login . "' to active game server. " .
|
||||
$this->iControl->getClientErrorText($client));
|
||||
$this->mc->getClientErrorText($client));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,28 +291,28 @@ class Plugin_United {
|
||||
if ($add_all) {
|
||||
// Add all server
|
||||
foreach ($this->gameServer as $serverClient) {
|
||||
array_push($serverLogins, $this->iControl->server->getLogin($serverClient));
|
||||
array_push($serverLogins, $this->mc->server->getLogin($serverClient));
|
||||
}
|
||||
foreach ($this->lobbies as $serverClient) {
|
||||
array_push($serverLogins, $this->iControl->server->getLogin($serverClient));
|
||||
array_push($serverLogins, $this->mc->server->getLogin($serverClient));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add only current server
|
||||
array_push($serverLogins, $this->iControl->server->getLogin());
|
||||
array_push($serverLogins, $this->mc->server->getLogin());
|
||||
}
|
||||
|
||||
// Build manialink url
|
||||
$manialink = 'iControl?favorite';
|
||||
$manialink = 'mc?favorite';
|
||||
foreach ($serverLogins as $serverLogin) {
|
||||
$manialink .= '&' . $serverLogin;
|
||||
}
|
||||
|
||||
// Send url to player
|
||||
if (!$this->iControl->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) {
|
||||
if (!$this->mc->client->query('SendOpenLinkToLogin', $login, $manialink, 1)) {
|
||||
trigger_error(
|
||||
"Couldn't open manialink to add server to favorite for '" . $login . "'! " .
|
||||
$this->iControl->getClientErrorText());
|
||||
$this->mc->getClientErrorText());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -345,39 +345,39 @@ class Plugin_United {
|
||||
|
||||
// Restart map on next game server
|
||||
if (!$newClient->query('RestartMap')) {
|
||||
trigger_error("Couldn't restart map on next game server. " . $this->iControl->getClientErrorText($newClient));
|
||||
trigger_error("Couldn't restart map on next game server. " . $this->mc->getClientErrorText($newClient));
|
||||
}
|
||||
|
||||
if ($simulateMapEnd) {
|
||||
// Simulate EndMap on old client
|
||||
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP));
|
||||
$this->mc->callbacks->triggerCallback(Callbacks::CB_IC_ENDMAP, array(Callbacks::CB_IC_ENDMAP));
|
||||
}
|
||||
|
||||
// Transfer players to next server
|
||||
$joinLink = $this->getJoinLink($newClient);
|
||||
if (!$oldClient->query('GetPlayerList', 255, 0)) {
|
||||
trigger_error("Couldn't get player list. " . $this->iControl->getClientErrorText($oldClient));
|
||||
trigger_error("Couldn't get player list. " . $this->mc->getClientErrorText($oldClient));
|
||||
}
|
||||
else {
|
||||
$playerList = $oldClient->getResponse();
|
||||
foreach ($playerList as $player) {
|
||||
$login = $player['Login'];
|
||||
if (!$oldClient->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
|
||||
trigger_error("Couldn't redirect player to next game server. " . $this->iControl->getClientErrorText($oldClient));
|
||||
trigger_error("Couldn't redirect player to next game server. " . $this->mc->getClientErrorText($oldClient));
|
||||
}
|
||||
}
|
||||
|
||||
$this->iControl->client = $newClient;
|
||||
$this->mc->client = $newClient;
|
||||
}
|
||||
|
||||
// Trigger client updated callback
|
||||
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer");
|
||||
$this->mc->callbacks->triggerCallback(Callbacks::CB_IC_CLIENTUPDATED, "Plugin_United.SwitchedServer");
|
||||
|
||||
if ($simulateMapEnd) {
|
||||
// Simulate BeginMap on new client
|
||||
$map = $this->iControl->server->getMap();
|
||||
$map = $this->mc->server->getMap();
|
||||
if ($map) {
|
||||
$this->iControl->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map)));
|
||||
$this->mc->callbacks->triggerCallback(Callbacks::CB_IC_BEGINMAP, array(Callbacks::CB_IC_BEGINMAP, array($map)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -391,9 +391,9 @@ class Plugin_United {
|
||||
if (!$command) return;
|
||||
$login = $command[1][1];
|
||||
|
||||
if (!$this->iControl->authentication->checkRight($login, 'operator')) {
|
||||
if (!$this->mc->authentication->checkRight($login, 'operator')) {
|
||||
// Not allowed
|
||||
$this->iControl->authentication->sendNotAllowed($login);
|
||||
$this->mc->authentication->sendNotAllowed($login);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ class Plugin_United {
|
||||
$this->switchServerRequested = time() + 3;
|
||||
|
||||
// Send chat message
|
||||
$this->iControl->chat->sendInformation("Switching to next server in 3 seconds...");
|
||||
$this->mc->chat->sendInformation("Switching to next server in 3 seconds...");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,7 +418,7 @@ class Plugin_United {
|
||||
$joinLink = $this->getJoinLink($gameserver, !$data[1]);
|
||||
if (!$client->query('SendOpenLinkToLogin', $login, $joinLink, 1)) {
|
||||
trigger_error(
|
||||
"United Plugin: Couldn't redirect player to current game server. " . $this->iControl->getClientErrorText($client));
|
||||
"United Plugin: Couldn't redirect player to current game server. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,7 +473,7 @@ class Plugin_United {
|
||||
}
|
||||
|
||||
// Wait for server to be ready
|
||||
if (!$this->iControl->server->waitForStatus($client, 4)) {
|
||||
if (!$this->mc->server->waitForStatus($client, 4)) {
|
||||
trigger_error("Server couldn't get ready!", E_USER_ERROR);
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ class Plugin_United {
|
||||
if (!$client->query('SetApiVersion', ManiaControl::API_VERSION)) {
|
||||
trigger_error(
|
||||
"Couldn't set API version '" . ManiaControl::API_VERSION . "'! This might cause problems. " .
|
||||
$this->iControl->getClientErrorText($client));
|
||||
$this->mc->getClientErrorText($client));
|
||||
}
|
||||
|
||||
// Set server settings
|
||||
@ -489,30 +489,30 @@ class Plugin_United {
|
||||
$hideServer = ($isGameServer && $this->settings->hide_game_server ? 1 : 0);
|
||||
// Passwords
|
||||
if (!$client->query('SetServerPassword', $password)) {
|
||||
trigger_error("Couldn't set server join password. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't set server join password. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
if (!$client->query('SetServerPasswordForSpectator', $password)) {
|
||||
trigger_error("Couldn't set server spec password. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't set server spec password. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
// Show/Hide server
|
||||
if (!$client->query('SetHideServer', $hideServer)) {
|
||||
trigger_error(
|
||||
"Couldn't set server '" . ($hideServer == 0 ? 'shown' : 'hidden') . "'. " .
|
||||
$this->iControl->getClientErrorText($client));
|
||||
$this->mc->getClientErrorText($client));
|
||||
}
|
||||
|
||||
// Enable service announces
|
||||
if (!$client->query("DisableServiceAnnounces", false)) {
|
||||
trigger_error("Couldn't enable service announces. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't enable service announces. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
|
||||
// Set game mode
|
||||
if (!$client->query('SetGameMode', $this->settings->gamemode)) {
|
||||
trigger_error(
|
||||
"Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->iControl->getClientErrorText($client));
|
||||
"Couldn't set game mode (" . $this->settings->gamemode . "). " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
else if (!$client->query('RestartMap')) {
|
||||
trigger_error("Couldn't restart map to change game mode. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't restart map to change game mode. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
|
||||
// Save client
|
||||
@ -520,7 +520,7 @@ class Plugin_United {
|
||||
if ($isGameServer) {
|
||||
array_push($this->gameServer, $client);
|
||||
if (count($this->gameServer) === 1) {
|
||||
$this->iControl->client = $client;
|
||||
$this->mc->client = $client;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -543,9 +543,9 @@ class Plugin_United {
|
||||
|
||||
if (Tools::toBool($this->config->widgets->addfavorite->enabled)) {
|
||||
// Send favorite widget
|
||||
if (!$this->iControl->client->query('SendDisplayManialinkPageToLogin', $login,
|
||||
if (!$this->mc->client->query('SendDisplayManialinkPageToLogin', $login,
|
||||
$this->manialinks[self::ML_ADDFAVORITE]->asXml(), 0, false)) {
|
||||
trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->iControl->getClientErrorText());
|
||||
trigger_error("Couldn't send favorite widget to player '" . $login . "'! " . $this->mc->getClientErrorText());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -559,14 +559,14 @@ class Plugin_United {
|
||||
$client = $this->gameServer[$this->currentClientIndex];
|
||||
}
|
||||
if (!$client->query('GetSystemInfo')) {
|
||||
trigger_error("Couldn't fetch server system info. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't fetch server system info. " . $this->mc->getClientErrorText($client));
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
$systemInfo = $client->getResponse();
|
||||
$password = '';
|
||||
if (!$client->query('GetServerPassword')) {
|
||||
trigger_error("Couldn't get server password. " . $this->iControl->getClientErrorText($client));
|
||||
trigger_error("Couldn't get server password. " . $this->mc->getClientErrorText($client));
|
||||
}
|
||||
else {
|
||||
$password = $client->getResponse();
|
||||
|
Reference in New Issue
Block a user