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));
// Get MapTypes
$this->maniaControl->client->query('GetModeScriptInfo');
$scriptInfos = $this->maniaControl->client->getResponse();
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$mapTypes = $scriptInfos["CompatibleMapTypes"];
$mapTypes = $scriptInfos->compatibleMapTypes;
// compile search URL
$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);
}
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)) {
$success = true;
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) {
$success = false;
}

View File

@ -105,8 +105,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$map = $nextQueued[1];
$this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$> requested by $<" . $requester->nickname . "$>.", $player->login);
} else {
$this->maniaControl->client->query('GetNextMapIndex');
$mapIndex = $this->maniaControl->client->getResponse();
$mapIndex = $this->maniaControl->client->getNextMapIndex();
$maps = $this->maniaControl->mapManager->getMaps();
$map = $maps[$mapIndex];
$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!';
$this->maniaControl->chat->sendSuccess($message);
$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!';
$this->maniaControl->chat->sendSuccess($message);
$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);
break;
case self::ACTION_SWITCH_MAP:
$this->maniaControl->client->query('JumpToMapIndex', $mapId);
$this->maniaControl->client->jumpToMapIndex($mapId);
$mapList = $this->maniaControl->mapManager->getMaps();
$map = $mapList[$mapId];

View File

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

View File

@ -36,30 +36,32 @@ class Player {
/**
* Construct a player from XmlRpc data
*
* @param array $rpcInfos
* @param \Maniaplanet\DedicatedServer\Structures\Player $mpPlayer
*/
public function __construct(array $rpcInfos) {
if(!$rpcInfos) {
public function __construct($mpPlayer) {
if(!$mpPlayer) {
return;
}
$this->pid = $rpcInfos['PlayerId'];
$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;
$rpcInfos = (array)$mpPlayer; //Temporary
$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();

View File

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

View File

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

View File

@ -323,12 +323,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
}
$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());
$this->maniaControl->chat->sendError("Creating donation failed.", $player->login);
return false;
}
$bill = $this->maniaControl->client->getResponse();
$this->openBills[$bill] = array(true, $player->login, $receiver, $amount, time());
return true;
@ -363,12 +362,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$receiver = $player->login;
}
$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());
$this->maniaControl->chat->sendError("Creating payout failed.", $player->login);
return false;
}
$bill = $this->maniaControl->client->getResponse();
$this->openBills[$bill] = array(false, $player->login, $receiver, $amount, time());
return true;
}
@ -385,11 +383,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
return false;
}
if(!$this->maniaControl->client->query('GetServerPlanets')) {
if(!$planets = $this->maniaControl->client->getServerPlanets()) {
trigger_error("Couldn't retrieve server planets. " . $this->maniaControl->getClientErrorText());
return false;
}
$planets = $this->maniaControl->client->getResponse();
$message = "This Server has {$planets} Planets!";
return $this->maniaControl->chat->sendInformation($message, $player->login);
}