Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverde8 committed Oct 15, 2017
2 parents 340ae52 + e042d4f commit 1918f01
Show file tree
Hide file tree
Showing 33 changed files with 357 additions and 618 deletions.
80 changes: 47 additions & 33 deletions Dedimania/Classes/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
use ManiaLivePlugins\eXpansion\Helpers\Storage as eXpStorage;
use Maniaplanet\DedicatedServer\Structures\GameInfos;
use Maniaplanet\DedicatedServer\Structures\Map;
use /** @noinspection PhpUndefinedClassInspection */ Maniaplanet\DedicatedServer\Xmlrpc\Request;
use /** @noinspection PhpUndefinedClassInspection */
Maniaplanet\DedicatedServer\Xmlrpc\Request;

/**
* Class Connection
Expand Down Expand Up @@ -113,7 +114,7 @@ public function onTick()
$this->lastUpdate = time();
}
} catch (Exception $e) {
$this->console("OnTick Update failed: " . $e->getMessage());
$this->console("OnTick Update failed: ".$e->getMessage());
}
}

Expand Down Expand Up @@ -203,17 +204,19 @@ public function openSession($packmask = "", $config = null)
break;
}

$args = array(array(
"Game" => "TM2",
"Login" => strtolower($config->login),
"Code" => $config->code,
"Tool" => "eXpansion",
"Version" => Core::EXP_VERSION,
"Packmask" => $packmask,
"ServerVersion" => $version->version,
"ServerBuild" => $version->build,
"Path" => $serverInfo->path,
));
$args = array(
array(
"Game" => "TM2",
"Login" => strtolower($config->login),
"Code" => $config->code,
"Tool" => "eXpansion",
"Version" => Core::EXP_VERSION,
"Packmask" => $packmask,
"ServerVersion" => $version->version,
"ServerBuild" => $version->build,
"Path" => $serverInfo->path,
),
);

$request = new dediRequest("dedimania.OpenSession", $args);
$this->send($request, array($this, "xOpenSession"));
Expand Down Expand Up @@ -258,7 +261,7 @@ public function setChallengeTimes(Map $map, $rankings, $vreplay, $greplay)
if ($this->dediUid != $map->uId) {
$this->console(
"[Warning] Map UId mismatch! Map UId differs from dedimania"
. " recieved uid for the map. Times are not sent."
." recieved uid for the map. Times are not sent."
);

return;
Expand All @@ -273,7 +276,7 @@ public function setChallengeTimes(Map $map, $rankings, $vreplay, $greplay)
array(
"Login" => $rank['Login'],
"Best" => intval($rank['BestTime']),
"Checks" => implode(',', $rank['BestCheckpoints'])
"Checks" => implode(',', $rank['BestCheckpoints']),
);
}
}
Expand Down Expand Up @@ -314,7 +317,8 @@ public function setChallengeTimes(Map $map, $rankings, $vreplay, $greplay)
$this->_getMapInfo($map),
$this->_getGameMode(),
$times,
$replays);
$replays,
);

$request = new dediRequest("dedimania.SetChallengeTimes", $args);
$this->send($request, array($this, "xSetChallengeTimes"));
Expand Down Expand Up @@ -447,6 +451,7 @@ public function playerConnect(Player $player, $isSpec)

if ($player->login == $this->storage->serverLogin) {
$this->debug("Abort. tried to send server login.");

return;
}

Expand Down Expand Up @@ -509,7 +514,7 @@ public function playerMultiConnect($players)
}
}

if ($request instanceof dediRequest) {
if ($request instanceof dediRequest) {
$this->send($request, array($this, "xPlayerMultiConnect"));
}
}
Expand All @@ -529,7 +534,8 @@ public function playerDisconnect($login)
$args = array(
$this->sessionId,
$login,
"");
"",
);
$request = new dediRequest("dedimania.PlayerDisconnect", $args);
$this->send($request, array($this, "xPlayerDisconnect"));
}
Expand All @@ -545,16 +551,20 @@ public function updateServerPlayers($map)
{
if ($this->sessionId === null) {
$this->debug("Session id is null!");

return;
}

if (is_array($map)) {
$uid = $map['UId'];
} else if (is_object($map)) {
$uid = $map->uId;
} else {
$this->console("Error: updateServerPlayers: map is not array or object");
return;
if (is_object($map)) {
$uid = $map->uId;
} else {
$this->console("Error: updateServerPlayers: map is not array or object");

return;
}
}

$players = array();
Expand All @@ -579,6 +589,7 @@ public function updateServerPlayers($map)

$request = new dediRequest("dedimania.UpdateServerPlayers", $args);
$this->send($request, array($this, "xUpdateServerPlayers"));

return;
}

Expand Down Expand Up @@ -654,7 +665,6 @@ public function detectScriptName()
*/
public function _process($dedires, $callback)
{

try {

if (is_array($dedires) && array_key_exists('Message', $dedires)) {
Expand All @@ -666,8 +676,8 @@ public function _process($dedires, $callback)
if (count($errors) > 0 && array_key_exists('methods', $errors[0])) {
foreach ($errors[0]['methods'] as $error) {
if (!empty($error['errors'])) {
$this->console('[Dedimania service return error] Method:' . $error['methodName']);
$this->console('Error string:' . $error['errors']);
$this->console('[Dedimania service return error] Method:'.$error['methodName']);
$this->console('Error string:'.$error['errors']);
}
}
}
Expand All @@ -678,12 +688,14 @@ public function _process($dedires, $callback)


if (array_key_exists("faultString", $array[0])) {
$this->console("Fault from dedimania server: " . $array[0]['faultString']);
$this->console("Fault from dedimania server: ".$array[0]['faultString']);

return;
}

if (!empty($array[0][0]['Error'])) {
$this->console("Error from dedimania server: " . $array[0][0]['Error']);
$this->console("Error from dedimania server: ".$array[0][0]['Error']);

return;
}

Expand All @@ -697,7 +709,7 @@ public function _process($dedires, $callback)
$this->console("[Dedimania Error] Can't find Message from Dedimania reply");
}
} catch (Exception $e) {
$this->console("[Dedimania Error] connection to dedimania server failed." . $e->getMessage());
$this->console("[Dedimania Error] connection to dedimania server failed.".$e->getMessage());
}

}
Expand All @@ -718,6 +730,7 @@ public function dbsort($a, $b)
} elseif ($a['Best'] > $b['Best']) {// best b better than best a
return 1;
}

return 0;
}

Expand All @@ -729,13 +742,13 @@ public function xOpenSession($data)
if (isset($data[0][0]['SessionId'])) {
$this->sessionId = $data[0][0]['SessionId'];
$this->console("Authentication success to dedimania server!");
$this->debug("recieved Session key:" . $this->sessionId);
$this->debug("recieved Session key:".$this->sessionId);
Dispatcher::dispatch(new dediEvent(dediEvent::ON_OPEN_SESSION, $this->sessionId));

return;
}
if (!empty($data[0][0]['Error'])) {
$this->console("Authentication Error occurred: " . $data[0][0]['Error']);
$this->console("Authentication Error occurred: ".$data[0][0]['Error']);

return;
}
Expand All @@ -754,7 +767,8 @@ public function xGetRecords($data)
self::$dediMap = null;

if (!empty($data[0]['Error'])) {
$this->console("Error from dediserver: " . $data[0]['Error']);
$this->console("Error from dediserver: ".$data[0]['Error']);

return;
}

Expand Down Expand Up @@ -820,7 +834,7 @@ public function xPlayerConnect($data)
try {
$player = $this->storage->getPlayerObject($dediplayer->login);
$this->connection->chatSendServerMessage(
"Player" . $player->nickName . '$z$s$fff[' . $player->login . '] is $f00BANNED$fff from dedimania.'
"Player".$player->nickName.'$z$s$fff['.$player->login.'] is $f00BANNED$fff from dedimania.'
);
} catch (Exception $e) {

Expand All @@ -843,7 +857,7 @@ public function xPlayerMultiConnect($data)
try {
$pla = $this->storage->getPlayerObject($dediPlayer->login);
$this->connection->chatSendServerMessage(
"Player" . $pla->nickName . '$z$s$fff[' . $pla->login . '] is $f00BANNED$fff from dedimania.'
"Player".$pla->nickName.'$z$s$fff['.$pla->login.'] is $f00BANNED$fff from dedimania.'
);
} catch (Exception $e) {

Expand Down
4 changes: 2 additions & 2 deletions Dedimania/DedimaniaAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ public function reArrage($login)


// update checkpoints for the record
$playerinfo = \ManiaLivePlugins\eXpansion\Core\Core::$playerInfo;

$record->checkpoints = implode(",", $playerinfo[$login]->checkpoints);
// $playerinfo = \ManiaLivePlugins\eXpansion\Core\Core::$playerInfo;
// $record->checkpoints = implode(",", $playerinfo[$login]->checkpoints);

// add record
$newrecords[$record->login] = $record;
Expand Down
Loading

0 comments on commit 1918f01

Please sign in to comment.