From dbdc318bba5bb5596101d934229bc8a18425676a Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 12 Mar 2014 13:07:02 +0100 Subject: [PATCH] titleprefix fix --- application/core/Admin/ActionsMenu.php | 6 +----- .../core/Callbacks/CallbackManager.php | 8 ++------ .../ManiaExchange/ManiaExchangeManager.php | 12 +++++------ application/core/Maps/Map.php | 20 ++++++++++++++++++- application/plugins/CustomVotes.php | 6 +----- application/plugins/Dedimania/Dedimania.php | 4 ++-- application/plugins/Donations.php | 6 +----- application/plugins/ServerRanking.php | 11 ++++------ application/plugins/SlotMachine.php | 6 +----- 9 files changed, 36 insertions(+), 43 deletions(-) diff --git a/application/core/Admin/ActionsMenu.php b/application/core/Admin/ActionsMenu.php index f27a3d15..34be4218 100644 --- a/application/core/Admin/ActionsMenu.php +++ b/application/core/Admin/ActionsMenu.php @@ -170,12 +170,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $itemMarginFactorX = 1.3; $itemMarginFactorY = 1.2; - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtoupper(substr($titleId, 0, 2)); - //If game is shootmania lower the icons position by 20 - if($titlePrefix == 'SM') { + if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $posY -= $shootManiaOffset; } diff --git a/application/core/Callbacks/CallbackManager.php b/application/core/Callbacks/CallbackManager.php index 5caaeb9a..f0723606 100644 --- a/application/core/Callbacks/CallbackManager.php +++ b/application/core/Callbacks/CallbackManager.php @@ -190,9 +190,7 @@ class CallbackManager { $callbackName = $callback[0]; switch($callbackName) { case 'ManiaPlanet.BeginMatch': - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); - if ($titlePrefix == "sm") { + if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $this->triggerCallback($callbackName, $callback); break; } @@ -201,9 +199,7 @@ class CallbackManager { $this->triggerCallback($callbackName, $callback); break; case 'ManiaPlanet.EndMatch': //TODO temporary fix - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); - if ($titlePrefix == "sm") { + if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $this->triggerCallback($callbackName, $callback); break; } diff --git a/application/core/ManiaExchange/ManiaExchangeManager.php b/application/core/ManiaExchange/ManiaExchangeManager.php index b202b2ed..144ad244 100644 --- a/application/core/ManiaExchange/ManiaExchangeManager.php +++ b/application/core/ManiaExchange/ManiaExchangeManager.php @@ -180,9 +180,8 @@ class ManiaExchangeManager { * @return bool */ public function getMapInfo($id, $function) { - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); + // Get Title Prefix + $titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame(); // compile search URL $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $id; @@ -211,9 +210,8 @@ class ManiaExchangeManager { * @return array|null */ public function getMaplistByMixedUidIdString($string) { - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); + // Get Title Prefix + $titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame(); // compile search URL $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $string; @@ -269,7 +267,7 @@ class ManiaExchangeManager { // Get Title Id $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); + $titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame(); // compile search URL $url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on'; diff --git a/application/core/Maps/Map.php b/application/core/Maps/Map.php index 5682996d..c3c2bc6d 100644 --- a/application/core/Maps/Map.php +++ b/application/core/Maps/Map.php @@ -50,7 +50,7 @@ class Map { return; } $this->name = FORMATTER::stripDirtyCodes($mpMap->name); - $this->rawName = $mpMap->name; + $this->rawName = $mpMap->name; $this->uid = $mpMap->uId; $this->fileName = $mpMap->fileName; $this->authorLogin = $mpMap->author; @@ -65,6 +65,24 @@ class Map { $this->authorNick = $this->authorLogin; } + /** + * Get's the gameType of the Current Map + * + * @return string + */ + public function getGame() { + switch($this->environment) { + case 'Storm': + return "sm"; + case 'Canyon': + case 'Stadium': + case 'Valley': + return "tm"; + default: + return ""; + } + } + /** * Checks if a map Update is available * diff --git a/application/plugins/CustomVotes.php b/application/plugins/CustomVotes.php index 5ac60920..40c528cb 100644 --- a/application/plugins/CustomVotes.php +++ b/application/plugins/CustomVotes.php @@ -641,12 +641,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $itemMarginFactorX = 1.3; $itemMarginFactorY = 1.2; - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtoupper(substr($titleId, 0, 2)); - //If game is shootmania lower the icons position by 20 - if ($titlePrefix == 'SM') { + if($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $posY -= $shootManiaOffset; } diff --git a/application/plugins/Dedimania/Dedimania.php b/application/plugins/Dedimania/Dedimania.php index 12e048f5..cf7e1246 100644 --- a/application/plugins/Dedimania/Dedimania.php +++ b/application/plugins/Dedimania/Dedimania.php @@ -98,7 +98,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin { // Open session $serverInfo = $this->maniaControl->server->getInfo(); $serverVersion = $this->maniaControl->client->getVersion(); - $packMask = substr($this->maniaControl->server->titleId, 2); + $packMask = $this->maniaControl->mapManager->getCurrentMap()->getGame(); $dedimaniaCode = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login . '$l'); if ($dedimaniaCode == '') { @@ -955,7 +955,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin { return $manialink; } - + /** * Decodes xml rpc response * diff --git a/application/plugins/Donations.php b/application/plugins/Donations.php index cff6e923..76488a99 100644 --- a/application/plugins/Donations.php +++ b/application/plugins/Donations.php @@ -199,12 +199,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $itemMarginFactorX = 1.3; $itemMarginFactorY = 1.2; - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtoupper(substr($titleId, 0, 2)); - //If game is shootmania lower the icons position by 20 - if ($titlePrefix == 'SM') { + if($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $posY -= $shootManiaOffset; } diff --git a/application/plugins/ServerRanking.php b/application/plugins/ServerRanking.php index caccc5dc..500b5037 100644 --- a/application/plugins/ServerRanking.php +++ b/application/plugins/ServerRanking.php @@ -1,17 +1,16 @@ settingManager->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3); $maniaControl->settingManager->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50); - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtolower(substr($titleId, 0, 2)); - - if ($titlePrefix == 'tm') { //TODO also add obstacle here as default + if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'tm') { + //TODO also add obstacle here as default $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RECORDS); } else if ($this->maniaControl->client->getScriptName()["CurrentValue"] == "InstaDM.Script.txt") { $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS); diff --git a/application/plugins/SlotMachine.php b/application/plugins/SlotMachine.php index 52ebec03..f3e5f2c6 100644 --- a/application/plugins/SlotMachine.php +++ b/application/plugins/SlotMachine.php @@ -381,12 +381,8 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer $itemMarginFactorY = 1.2; $posY += $width * $itemMarginFactorY; - // Get Title Id - $titleId = $this->maniaControl->server->titleId; - $titlePrefix = strtoupper(substr($titleId, 0, 2)); - //If game is shootmania lower the icons position by 20 - if ($titlePrefix == 'SM') { + if($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $posY -= $shootManiaOffset; }