changes for new structure

This commit is contained in:
kremsy 2014-01-16 19:07:00 +01:00 committed by Steffen Schröder
parent 027af49bc9
commit 0c6d8c010c
9 changed files with 49 additions and 52 deletions

View File

@ -233,10 +233,9 @@ class ManiaExchangeManager {
$titlePrefix = strtolower(substr($titleId, 0, 2)); $titlePrefix = strtolower(substr($titleId, 0, 2));
// Get MapTypes // Get MapTypes
$this->maniaControl->client->query('GetModeScriptInfo'); $scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$scriptInfos = $this->maniaControl->client->getResponse();
$mapTypes = $scriptInfos["CompatibleMapTypes"]; $mapTypes = $scriptInfos->compatibleMapTypes;
// compile search URL // compile search URL
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on'; $url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on';

View File

@ -133,12 +133,12 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
return $this->maniaControl->client->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick); return $this->maniaControl->client->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
} }
if(is_string($logins)) { if(is_string($logins)) {
return $this->maniaControl->client->sendDisplayManialinkPage(null, $logins, $manialinkText, $timeout, $hideOnClick); return $this->maniaControl->client->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
} }
if(is_array($logins)) { if(is_array($logins)) {
$success = true; $success = true;
foreach($logins as $login) { foreach($logins as $login) {
$subSuccess = $this->maniaControl->client->sendDisplayManialinkPage(null, $login, $manialinkText, $timeout, $hideOnClick); $subSuccess = $this->maniaControl->client->sendDisplayManialinkPage($login, $manialinkText, $timeout, $hideOnClick);
if(!$subSuccess) { if(!$subSuccess) {
$success = false; $success = false;
} }

View File

@ -105,8 +105,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$map = $nextQueued[1]; $map = $nextQueued[1];
$this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$> requested by $<" . $requester->nickname . "$>.", $player->login); $this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$> requested by $<" . $requester->nickname . "$>.", $player->login);
} else { } else {
$this->maniaControl->client->query('GetNextMapIndex'); $mapIndex = $this->maniaControl->client->getNextMapIndex();
$mapIndex = $this->maniaControl->client->getResponse();
$maps = $this->maniaControl->mapManager->getMaps(); $maps = $this->maniaControl->mapManager->getMaps();
$map = $maps[$mapIndex]; $map = $maps[$mapIndex];
$this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$>.", $player->login); $this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$>.", $player->login);
@ -186,7 +185,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$message = '$<' . $player->nickname . '$> skipped the current Map!'; $message = '$<' . $player->nickname . '$> skipped the current Map!';
$this->maniaControl->chat->sendSuccess($message); $this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true); $this->maniaControl->log($message, true);
$this->maniaControl->client->query('NextMap'); $this->maniaControl->client->nextMap();
} }
/** /**
@ -203,7 +202,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$message = '$<' . $player->nickname . '$> restarted the current Map!'; $message = '$<' . $player->nickname . '$> restarted the current Map!';
$this->maniaControl->chat->sendSuccess($message); $this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true); $this->maniaControl->log($message, true);
$this->maniaControl->client->query('RestartMap'); $this->maniaControl->client->restartMap();
} }
/** /**

View File

@ -727,7 +727,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->showMapList($player); $this->showMapList($player);
break; break;
case self::ACTION_SWITCH_MAP: case self::ACTION_SWITCH_MAP:
$this->maniaControl->client->query('JumpToMapIndex', $mapId); $this->maniaControl->client->jumpToMapIndex($mapId);
$mapList = $this->maniaControl->mapManager->getMaps(); $mapList = $this->maniaControl->mapManager->getMaps();
$map = $mapList[$mapId]; $map = $mapList[$mapId];

View File

@ -153,9 +153,9 @@ class MapQueue implements CallbackListener, CommandListener {
$map = $this->nextMap[1]; $map = $this->nextMap[1];
$success = $this->maniaControl->client->query('ChooseNextMap', $map->fileName); $success = $this->maniaControl->client->chooseNextMap($map->fileName);
if(!$success) { if(!$success) { //TODO error code?
trigger_error('[' . $this->maniaControl->client->getErrorCode() . '] ChooseNextMap - ' . $this->maniaControl->client->getErrorCode(), E_USER_WARNING); //trigger_error('[' . $this->maniaControl->client->getErrorCode() . '] ChooseNextMap - ' . $this->maniaControl->client->getErrorCode(), E_USER_WARNING);
return; return;
} }
} }

View File

@ -36,30 +36,32 @@ class Player {
/** /**
* Construct a player from XmlRpc data * Construct a player from XmlRpc data
* *
* @param array $rpcInfos * @param \Maniaplanet\DedicatedServer\Structures\Player $mpPlayer
*/ */
public function __construct(array $rpcInfos) { public function __construct($mpPlayer) {
if(!$rpcInfos) { if(!$mpPlayer) {
return; return;
} }
$this->pid = $rpcInfos['PlayerId']; $rpcInfos = (array)$mpPlayer; //Temporary
$this->login = $rpcInfos['Login'];
$this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']);
$this->path = $rpcInfos['Path'];
$this->language = $rpcInfos['Language'];
$this->avatar = $rpcInfos['Avatar']['FileName'];
$this->allies = $rpcInfos['Allies'];
$this->clubLink = $rpcInfos['ClubLink'];
$this->teamId = $rpcInfos['TeamId'];
$this->isSpectator = $rpcInfos['IsSpectator'];
$this->isOfficial = $rpcInfos['IsInOfficialMode'];
$this->isReferee = $rpcInfos['IsReferee'];
$this->ladderScore = $rpcInfos['LadderStats']['PlayerRankings'][0]['Score'];
$this->ladderRank = $rpcInfos['LadderStats']['PlayerRankings'][0]['Ranking'];
$this->maniaPlanetPlayDays = $rpcInfos['HoursSinceZoneInscription'] / 24;
$this->ipAddress = $rpcInfos['IPAddress']; $this->pid = $mpPlayer->playerId;
$this->login = $mpPlayer->login;
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
$this->path = $mpPlayer->path;
$this->language = $mpPlayer->language;
$this->avatar = $mpPlayer->avatar['FileName'];
$this->allies = $mpPlayer->allies;
$this->clubLink = $mpPlayer->clubLink;
$this->teamId = $mpPlayer->teamId;
$this->isSpectator = $mpPlayer->isSpectator;
$this->isOfficial = $mpPlayer->isInOfficialMode;
$this->isReferee = $mpPlayer->isReferee;
$this->ladderScore = $mpPlayer->ladderStats['PlayerRankings'][0]['Score'];
$this->ladderRank = $mpPlayer->ladderStats['PlayerRankings'][0]['Ranking'];
$this->maniaPlanetPlayDays = $mpPlayer->hoursSinceZoneInscription / 24;
$this->ipAddress = $mpPlayer->iPAddress;
$this->joinTime = time(); $this->joinTime = time();

View File

@ -82,14 +82,14 @@ class PlayerActions {
return; return;
} }
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER); $success = $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
if($userIsAbleToSelect) { if($userIsAbleToSelect) {
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_USER_SELECTABLE); $success = $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -125,7 +125,7 @@ class PlayerActions {
$this->forcePlayerToPlay($adminLogin, $targetLogin, true, false); $this->forcePlayerToPlay($adminLogin, $targetLogin, true, false);
} }
$success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId); $success = $this->maniaControl->client->forcePlayerTeam($target->login, $teamId);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -161,7 +161,7 @@ class PlayerActions {
} }
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, $spectatorState); $success = $this->maniaControl->client->forceSpectator($target->login, $spectatorState);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -174,7 +174,7 @@ class PlayerActions {
if($releaseSlot) { if($releaseSlot) {
// Free player slot // Free player slot
$this->maniaControl->client->query('SpectatorReleasePlayerSlot', $target->login); $this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
} }
} }
@ -194,7 +194,7 @@ class PlayerActions {
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$success = $this->maniaControl->client->query('UnIgnore', $target->login); $success = $this->maniaControl->client->unIgnore($target->login);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -222,7 +222,7 @@ class PlayerActions {
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$success = $this->maniaControl->client->query('Ignore', $targetLogin); $success = $this->maniaControl->client->ignore($targetLogin);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -333,9 +333,9 @@ class PlayerActions {
} }
if($target->isFakePlayer()) { if($target->isFakePlayer()) {
$success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login); $success = $this->maniaControl->client->disconnectFakePlayer($target->login);
} else { } else {
$success = $this->maniaControl->client->query('Kick', $target->login, $message); $success = $this->maniaControl->client->kick($target->login, $message);
} }
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
@ -367,7 +367,7 @@ class PlayerActions {
return; return;
} }
$success = $this->maniaControl->client->query('Ban', $target->login, $message); $success = $this->maniaControl->client->ban($target->login, $message);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
@ -462,9 +462,9 @@ class PlayerActions {
* @return bool * @return bool
*/ */
public function isPlayerMuted($login) { public function isPlayerMuted($login) {
$this->maniaControl->client->query('GetIgnoreList', 100, 0); $ignoreList = $this->maniaControl->client->getIgnoreList(100, 0);
foreach($this->maniaControl->client->getResponse() as $ignoredPlayers) { foreach($ignoreList as $ignoredPlayers) {
if($ignoredPlayers["Login"] == $login) { if($ignoredPlayers->login == $login) {
return true; return true;
} }
} }

View File

@ -117,7 +117,7 @@ class PlayerManager implements CallbackListener {
if($playerItem->playerId <= 0) { if($playerItem->playerId <= 0) {
continue; continue;
} }
$playerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem['Login']); $playerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login);
$player = new Player($playerInfo); $player = new Player($playerInfo);
$this->addPlayer($player); $this->addPlayer($player);
} }

View File

@ -323,12 +323,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
} }
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?'; $message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
if(!$this->maniaControl->client->query('SendBill', $player->login, $amount, $message, $receiver)) { if(!$bill = $this->maniaControl->client->sendBill($player->login, $amount, $message, $receiver)) {
trigger_error("Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText()); trigger_error("Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText());
$this->maniaControl->chat->sendError("Creating donation failed.", $player->login); $this->maniaControl->chat->sendError("Creating donation failed.", $player->login);
return false; return false;
} }
$bill = $this->maniaControl->client->getResponse();
$this->openBills[$bill] = array(true, $player->login, $receiver, $amount, time()); $this->openBills[$bill] = array(true, $player->login, $receiver, $amount, time());
return true; return true;
@ -363,12 +362,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$receiver = $player->login; $receiver = $player->login;
} }
$message = 'Payout from $<' . $this->maniaControl->server->getName() . '$>.'; $message = 'Payout from $<' . $this->maniaControl->server->getName() . '$>.';
if(!$this->maniaControl->client->query('Pay', $receiver, $amount, $message)) { if(!$bill = $this->maniaControl->client->pay($receiver, $amount, $message)) {
trigger_error("Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText()); trigger_error("Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText());
$this->maniaControl->chat->sendError("Creating payout failed.", $player->login); $this->maniaControl->chat->sendError("Creating payout failed.", $player->login);
return false; return false;
} }
$bill = $this->maniaControl->client->getResponse();
$this->openBills[$bill] = array(false, $player->login, $receiver, $amount, time()); $this->openBills[$bill] = array(false, $player->login, $receiver, $amount, time());
return true; return true;
} }
@ -385,11 +383,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return false; return false;
} }
if(!$this->maniaControl->client->query('GetServerPlanets')) { if(!$planets = $this->maniaControl->client->getServerPlanets()) {
trigger_error("Couldn't retrieve server planets. " . $this->maniaControl->getClientErrorText()); trigger_error("Couldn't retrieve server planets. " . $this->maniaControl->getClientErrorText());
return false; return false;
} }
$planets = $this->maniaControl->client->getResponse();
$message = "This Server has {$planets} Planets!"; $message = "This Server has {$planets} Planets!";
return $this->maniaControl->chat->sendInformation($message, $player->login); return $this->maniaControl->chat->sendInformation($message, $player->login);
} }