dedi continue
This commit is contained in:
parent
bfde33e388
commit
7d2e87f077
@ -208,7 +208,6 @@ class PlayerManager implements CallbackListener {
|
|||||||
|
|
||||||
//Check if Player finished joining the game
|
//Check if Player finished joining the game
|
||||||
if ($player->hasJoinedGame && !$prevJoinState) {
|
if ($player->hasJoinedGame && !$prevJoinState) {
|
||||||
var_dump("test1234");
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
||||||
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
|
||||||
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
||||||
|
@ -242,14 +242,14 @@ class Server implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Retrieve Validation Replay for the given Player
|
* Retrieve Validation Replay for the given Player
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param $login
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getValidationReplay(Player $player) {
|
public function getValidationReplay($login) {
|
||||||
try {
|
try {
|
||||||
$replay = $this->maniaControl->client->getValidationReplay($player->login);
|
$replay = $this->maniaControl->client->getValidationReplay($login);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
trigger_error("Couldn't get validation replay of '{$player->login}'. " . $e->getMessage());
|
trigger_error("Couldn't get validation replay of '{$login}'. " . $e->getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $replay;
|
return $replay;
|
||||||
@ -258,10 +258,10 @@ class Server implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Retrieve Ghost Replay for the given Player
|
* Retrieve Ghost Replay for the given Player
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param $login
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGhostReplay(Player $player) {
|
public function getGhostReplay($login) {
|
||||||
$dataDir = $this->getDataDirectory();
|
$dataDir = $this->getDataDirectory();
|
||||||
if (!$this->checkAccess($dataDir)) {
|
if (!$this->checkAccess($dataDir)) {
|
||||||
return null;
|
return null;
|
||||||
@ -271,11 +271,11 @@ class Server implements CallbackListener {
|
|||||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
$gameMode = $this->getGameMode();
|
$gameMode = $this->getGameMode();
|
||||||
$time = time();
|
$time = time();
|
||||||
$fileName = "GhostReplays/Ghost.{$player->login}.{$gameMode}.{$time}.{$map->uid}.Replay.Gbx";
|
$fileName = "GhostReplays/Ghost.{$login}.{$gameMode}.{$time}.{$map->uid}.Replay.Gbx";
|
||||||
|
|
||||||
// Save ghost replay
|
// Save ghost replay
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->saveBestGhostsReplay($player->login, $fileName);
|
$this->maniaControl->client->saveBestGhostsReplay($login, $fileName);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
trigger_error("Couldn't save ghost replay. " . $e->getMessage());
|
trigger_error("Couldn't save ghost replay. " . $e->getMessage());
|
||||||
return null;
|
return null;
|
||||||
|
@ -167,11 +167,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var_dump($this->dedimaniaData->records);
|
|
||||||
if (!$this->dedimaniaData->records) {
|
if (!$this->dedimaniaData->records) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var_dump("update");
|
|
||||||
|
|
||||||
$this->updateManialink = false;
|
$this->updateManialink = false;
|
||||||
|
|
||||||
@ -305,19 +303,25 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
if (!isset($replays['Top1GReplay'])) {
|
if (!isset($replays['Top1GReplay'])) {
|
||||||
$replays['Top1GReplay'] = '';
|
$replays['Top1GReplay'] = '';
|
||||||
}
|
}
|
||||||
|
//$replays['VReplay'] = '';
|
||||||
|
$replays['Top1GReplay'] = '';
|
||||||
|
$replays['VReplay'] = base64_encode($replays['VReplay']);
|
||||||
|
//$replays['Top1GReplay'] = base64_encode($replays['Top1GReplay']);
|
||||||
|
//xmlrpc_set_type($replays['VReplay'], 'base64');
|
||||||
|
//xmlrpc_set_type($replays['Top1GReplay'], 'base64');
|
||||||
|
|
||||||
xmlrpc_set_type($replays['VReplay'], 'base64');
|
var_dump($replays);
|
||||||
xmlrpc_set_type($replays['Top1GReplay'], 'base64');
|
|
||||||
|
|
||||||
$data = array($this->dedimaniaData->sessionId, $this->getMapInfo(), $gameMode, $times, $replays);
|
$data = array($this->dedimaniaData->sessionId, $this->getMapInfo(), $gameMode, $times, $replays);
|
||||||
|
//var_dump($data);
|
||||||
$content = $this->encode_request(self::DEDIMANIA_SETCHALLENGETIMES, $data);
|
$content = $this->encode_request(self::DEDIMANIA_SETCHALLENGETIMES, $data);
|
||||||
|
|
||||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||||
if ($error != '') {
|
if ($error != '') {
|
||||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||||
}
|
}
|
||||||
|
var_dump($data);
|
||||||
$data = $this->decode($data);
|
$data = $this->decode($data);
|
||||||
|
var_dump($data);
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
foreach($data as $index => $methodResponse) {
|
foreach($data as $index => $methodResponse) {
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
@ -420,35 +424,19 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
|
|
||||||
|
|
||||||
$oldRecord = $this->getDedimaniaRecord($login);
|
$oldRecord = $this->getDedimaniaRecord($login);
|
||||||
|
|
||||||
$save = true;
|
$save = true;
|
||||||
if ($oldRecord) {
|
if ($oldRecord) {
|
||||||
if ($oldRecord['Best'] <= $time) {
|
if ($oldRecord['Best'] <= $time) {
|
||||||
$save = false;
|
$save = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($save) {
|
if ($save) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
// Save time
|
// Save time
|
||||||
$newRecord = array('Login' => $login, 'NickName' => $player->nickname, 'Best' => $data[2], 'Checks' => $this->getCheckpoints($login), 'New' => true);
|
$newRecord = array('Login' => $login, 'NickName' => $player->nickname, 'Best' => $data[2], 'Checks' => $this->getCheckpoints($login), 'New' => true);
|
||||||
if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) {
|
if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) {
|
||||||
$this->displayRecordData($player, $oldRecord, $newRecord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the Record Data
|
|
||||||
*
|
|
||||||
* @param $player
|
|
||||||
* @param $oldRecord
|
|
||||||
* @param $newRecord
|
|
||||||
*/
|
|
||||||
private function displayRecordData($player, $oldRecord, $newRecord) {
|
|
||||||
// Get newly saved record
|
// Get newly saved record
|
||||||
foreach($this->dedimaniaData['records']['Records'] as &$record) {
|
foreach($this->dedimaniaData->records['Records'] as &$record) {
|
||||||
if ($record['Login'] !== $newRecord['Login']) {
|
if ($record['Login'] !== $newRecord['Login']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -464,11 +452,12 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
// Only improved time
|
// Only improved time
|
||||||
$improvement = 'improved her/his';
|
$improvement = 'improved her/his';
|
||||||
}
|
}
|
||||||
$message = '$<' . $player['NickName'] . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] . '.$> Dedimania Record: ' . Formatter::formatTime($newRecord['Best']);
|
$message = '$<' . $player->nickname . '$> ' . $improvement . ' $<$o' . $newRecord['Rank'] . '.$> Dedimania Record: ' . Formatter::formatTime($newRecord['Best']);
|
||||||
$this->maniaControl->chat->sendInformation($message);
|
$this->maniaControl->chat->sendInformation($message);
|
||||||
|
|
||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -643,7 +632,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* Update the sorting and the ranks of all dedimania records
|
* Update the sorting and the ranks of all dedimania records
|
||||||
*/
|
*/
|
||||||
private function updateDedimaniaRecordRanks() {
|
private function updateDedimaniaRecordRanks() {
|
||||||
if (!$this->dedimaniaData->records|| !isset($this->dedimaniaData->records['Records'])) {
|
if (!$this->dedimaniaData->records || !isset($this->dedimaniaData->records['Records'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user