dedi improve
This commit is contained in:
parent
5728381093
commit
bfde33e388
@ -373,7 +373,6 @@ class MapManager implements CallbackListener {
|
|||||||
|
|
||||||
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
||||||
$this->currentMap = $this->maps[$rpcMap->uId];
|
$this->currentMap = $this->maps[$rpcMap->uId];
|
||||||
// TODO: why set numbers? shouldn't they be set already?
|
|
||||||
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
||||||
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
||||||
return $this->currentMap;
|
return $this->currentMap;
|
||||||
@ -443,6 +442,11 @@ class MapManager implements CallbackListener {
|
|||||||
if (array_key_exists($callback[1][0]["UId"], $this->maps)) {
|
if (array_key_exists($callback[1][0]["UId"], $this->maps)) {
|
||||||
// Map already exists, only update index
|
// Map already exists, only update index
|
||||||
$this->currentMap = $this->maps[$callback[1][0]["UId"]];
|
$this->currentMap = $this->maps[$callback[1][0]["UId"]];
|
||||||
|
if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) {
|
||||||
|
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
|
||||||
|
$this->currentMap->nbLaps = $rpcMap->nbLaps;
|
||||||
|
$this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$rpcMap = \Maniaplanet\DedicatedServer\Structures\Map::fromArray($callback[1][0]);
|
$rpcMap = \Maniaplanet\DedicatedServer\Structures\Map::fromArray($callback[1][0]);
|
||||||
$this->currentMap = $this->initializeMap($rpcMap);
|
$this->currentMap = $this->initializeMap($rpcMap);
|
||||||
|
@ -208,6 +208,7 @@ 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!';
|
||||||
|
@ -79,7 +79,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_POSY, 7);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_POSY, 7);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 40);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 40);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 15);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 12);
|
||||||
|
|
||||||
//TODO what was CB_IC_ClientUpdated?
|
//TODO what was CB_IC_ClientUpdated?
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleBeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'handleBeginMap');
|
||||||
@ -167,10 +167,14 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->updateManialink = false;
|
var_dump($this->dedimaniaData->records);
|
||||||
if (!$this->dedimaniaData->records) {
|
if (!$this->dedimaniaData->records) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var_dump("update");
|
||||||
|
|
||||||
|
$this->updateManialink = false;
|
||||||
|
|
||||||
$manialink = $this->buildManialink();
|
$manialink = $this->buildManialink();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialink);
|
$this->maniaControl->manialinkManager->sendManialink($manialink);
|
||||||
}
|
}
|
||||||
@ -181,8 +185,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @param null $callback
|
* @param null $callback
|
||||||
*/
|
*/
|
||||||
public function handleEveryMinute($callback = null) {
|
public function handleEveryMinute($callback = null) {
|
||||||
if (!$this->init)
|
if (!$this->init) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$this->checkDedimaniaSession();
|
$this->checkDedimaniaSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,8 +275,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @param $callback
|
* @param $callback
|
||||||
*/
|
*/
|
||||||
public function handleMapEnd($callback) {
|
public function handleMapEnd($callback) {
|
||||||
if (!$this->dedimaniaData->records)
|
if (!$this->dedimaniaData->records) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Send dedimania records
|
// Send dedimania records
|
||||||
$gameMode = $this->getGameModeString();
|
$gameMode = $this->getGameModeString();
|
||||||
@ -399,6 +405,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @param $callback
|
* @param $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerFinished($callback) {
|
public function handlePlayerFinished($callback) {
|
||||||
|
//var_dump($callback);
|
||||||
$data = $callback[1];
|
$data = $callback[1];
|
||||||
if ($data[0] <= 0 || $data[2] <= 0) {
|
if ($data[0] <= 0 || $data[2] <= 0) {
|
||||||
return;
|
return;
|
||||||
@ -419,12 +426,27 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
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);
|
||||||
$inserted = $this->insertDedimaniaRecord($newRecord, $oldRecord);
|
if ($this->insertDedimaniaRecord($newRecord, $oldRecord)) {
|
||||||
if ($inserted) {
|
$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']) {
|
||||||
@ -444,10 +466,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
$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;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,7 +494,6 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
if (!$serverInfo || !$playerInfo || !$mapInfo || !$gameMode) {
|
if (!$serverInfo || !$playerInfo || !$mapInfo || !$gameMode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array($this->dedimaniaData->sessionId, $mapInfo, $gameMode, $serverInfo, $playerInfo);
|
$data = array($this->dedimaniaData->sessionId, $mapInfo, $gameMode, $serverInfo, $playerInfo);
|
||||||
$content = $this->encode_request(self::DEDIMANIA_GETRECORDS, $data);
|
$content = $this->encode_request(self::DEDIMANIA_GETRECORDS, $data);
|
||||||
|
|
||||||
@ -483,6 +503,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->decode($data);
|
$data = $this->decode($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)) {
|
||||||
@ -543,7 +564,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function insertDedimaniaRecord(&$newRecord, $oldRecord) {
|
private function insertDedimaniaRecord(&$newRecord, $oldRecord) {
|
||||||
if (!$newRecord || !isset($this->dedimaniaData->records) || !isset($this->dedimaniaData->records['Records'])) {
|
if (!$newRecord || !$this->dedimaniaData->records || !isset($this->dedimaniaData->records['Records'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,8 +602,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
if ($oldRecord) {
|
if ($oldRecord) {
|
||||||
// Remove old record
|
// Remove old record
|
||||||
foreach($this->dedimaniaData->records['Records'] as $key2 => $record2) {
|
foreach($this->dedimaniaData->records['Records'] as $key2 => $record2) {
|
||||||
if ($record2['Login'] !== $oldRecord['Login'])
|
if ($record2['Login'] !== $oldRecord['Login']) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
unset($this->dedimaniaData->records['Records'][$key2]);
|
unset($this->dedimaniaData->records['Records'][$key2]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -604,8 +626,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
|
|
||||||
// Save replays
|
// Save replays
|
||||||
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;
|
||||||
|
}
|
||||||
$this->setRecordReplays($record);
|
$this->setRecordReplays($record);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -620,8 +643,9 @@ 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 (!isset($this->dedimaniaData->records) || !isset($this->dedimaniaData->records['Records']))
|
if (!$this->dedimaniaData->records|| !isset($this->dedimaniaData->records['Records'])) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Sort records
|
// Sort records
|
||||||
usort($this->dedimaniaData->records['Records'], array($this, 'compareRecords'));
|
usort($this->dedimaniaData->records['Records'], array($this, 'compareRecords'));
|
||||||
@ -663,8 +687,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
private function setRecordReplays(&$record) {
|
private function setRecordReplays(&$record) {
|
||||||
// Set validation replay
|
// Set validation replay
|
||||||
$validationReplay = $this->maniaControl->server->getValidationReplay($record['Login']);
|
$validationReplay = $this->maniaControl->server->getValidationReplay($record['Login']);
|
||||||
if ($validationReplay)
|
if ($validationReplay) {
|
||||||
$record['VReplay'] = $validationReplay;
|
$record['VReplay'] = $validationReplay;
|
||||||
|
}
|
||||||
|
|
||||||
// Set ghost replay
|
// Set ghost replay
|
||||||
if ($record['Rank'] <= 1) {
|
if ($record['Rank'] <= 1) {
|
||||||
@ -678,24 +703,27 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
}
|
}
|
||||||
if ($this->dedimaniaData->directoryAccessChecked) {
|
if ($this->dedimaniaData->directoryAccessChecked) {
|
||||||
$ghostReplay = $this->maniaControl->server->getGhostReplay($record['Login']);
|
$ghostReplay = $this->maniaControl->server->getGhostReplay($record['Login']);
|
||||||
if ($ghostReplay)
|
if ($ghostReplay) {
|
||||||
$record['Top1GReplay'] = $ghostReplay;
|
$record['Top1GReplay'] = $ghostReplay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get max rank for given login
|
* Get max rank for given login
|
||||||
*/
|
*/
|
||||||
private function getMaxRank($login) {
|
private function getMaxRank($login) {
|
||||||
if (!isset($this->dedimaniaData->records))
|
if (!isset($this->dedimaniaData->records)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
$records = $this->dedimaniaData->records;
|
$records = $this->dedimaniaData->records;
|
||||||
$maxRank = $records['ServerMaxRank'];
|
$maxRank = $records['ServerMaxRank'];
|
||||||
foreach($records['Players'] as $player) {
|
foreach($records['Players'] as $player) {
|
||||||
if ($player['Login'] === $login) {
|
if ($player['Login'] === $login) {
|
||||||
if ($player['MaxRank'] > $maxRank)
|
if ($player['MaxRank'] > $maxRank) {
|
||||||
$maxRank = $player['MaxRank'];
|
$maxRank = $player['MaxRank'];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,13 +809,15 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @return array $record
|
* @return array $record
|
||||||
*/
|
*/
|
||||||
private function getDedimaniaRecord($login) {
|
private function getDedimaniaRecord($login) {
|
||||||
if (!isset($this->dedimaniaData->records))
|
if (!$this->dedimaniaData->records) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
$records = $this->dedimaniaData->records['Records'];
|
$records = $this->dedimaniaData->records['Records'];
|
||||||
foreach($records as $record) {
|
foreach($records as $record) {
|
||||||
if ($record['Login'] === $login)
|
if ($record['Login'] === $login) {
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,15 +855,17 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getCheckpoints($login) {
|
private function getCheckpoints($login) {
|
||||||
if (!$login || !isset($this->checkpoints[$login]))
|
if (!$login || !isset($this->checkpoints[$login])) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
$string = '';
|
$string = '';
|
||||||
$count = count($this->checkpoints[$login]);
|
$count = count($this->checkpoints[$login]);
|
||||||
foreach($this->checkpoints[$login] as $index => $check) {
|
foreach($this->checkpoints[$login] as $index => $check) {
|
||||||
$string .= $check;
|
$string .= $check;
|
||||||
if ($index < $count - 1)
|
if ($index < $count - 1) {
|
||||||
$string .= ',';
|
$string .= ',';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,8 +931,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
$titleLabel->setTranslate(true);
|
$titleLabel->setTranslate(true);
|
||||||
|
|
||||||
foreach($records as $index => $record) {
|
foreach($records as $index => $record) {
|
||||||
if ($index >= $lines)
|
if ($index >= $lines) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$y = -8. - $index * $lineHeight;
|
$y = -8. - $index * $lineHeight;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user