From bc578d9a4e22c1b161c95fed1fb80619c43620a3 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 10 May 2014 10:12:48 +0200 Subject: [PATCH] bugfixes --- application/core/Bills/BillData.php | 4 ++-- .../Libs/Maniaplanet/DedicatedServer/Connection.php | 2 +- .../DedicatedServer/Xmlrpc/GbxRemote.php | 2 ++ application/core/ManiaControl.php | 6 ++---- application/core/Players/Player.php | 13 ++++++++++++- application/core/Plugins/PluginMenu.php | 6 +++--- application/plugins/MCTeam/KarmaPlugin.php | 3 ++- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/application/core/Bills/BillData.php b/application/core/Bills/BillData.php index d228b0a8..51bf66ba 100644 --- a/application/core/Bills/BillData.php +++ b/application/core/Bills/BillData.php @@ -26,12 +26,12 @@ class BillData { * Construct new BillData * * @param mixed $function - * @param Player $player + * @param Player/string $player * @param int $amount * @param bool $pay * @param string $receiverLogin */ - public function __construct($function, Player $player, $amount, $pay = false, $receiverLogin = null) { + public function __construct($function, $player, $amount, $pay = false, $receiverLogin = null) { $this->function = $function; $this->player = $player; $this->amount = $amount; diff --git a/application/core/Libs/Maniaplanet/DedicatedServer/Connection.php b/application/core/Libs/Maniaplanet/DedicatedServer/Connection.php index cedb102e..935565ce 100644 --- a/application/core/Libs/Maniaplanet/DedicatedServer/Connection.php +++ b/application/core/Libs/Maniaplanet/DedicatedServer/Connection.php @@ -1235,7 +1235,7 @@ class Connection * @return int BillId * @throws InvalidArgumentException */ - function sendBill($payer, $amount, $message, $payee, $multicall=false) + function sendBill($payer, $amount, $message, $payee = '', $multicall=false) { $payerLogin = $this->getLogin($payer); if($payerLogin === false) diff --git a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php index 9debada7..6b3d3c7a 100644 --- a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php +++ b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php @@ -287,6 +287,8 @@ class GbxRemote if($written === 0 || $written === false) return false; + fflush($this->socket); + $data = substr($data, $written); } diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index ff3305ef..04e14a1d 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -44,7 +44,7 @@ class ManiaControl implements CommandListener, TimerListener { /* * Constants */ - const VERSION = '0.141'; + const VERSION = '0.142'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const OS_UNIX = 'Unix'; @@ -64,9 +64,7 @@ class ManiaControl implements CommandListener, TimerListener { /** @var \SimpleXMLElement $config */ public $config = null; public $configurator = null; - /** - * @var Connection $client - */ + /** @var Connection $client */ public $client = null; public $commandManager = null; public $database = null; diff --git a/application/core/Players/Player.php b/application/core/Players/Player.php index 14c50459..541e9370 100644 --- a/application/core/Players/Player.php +++ b/application/core/Players/Player.php @@ -40,7 +40,7 @@ class Player { public $uploadRate = -1; public $skins = null; public $daysSinceZoneInscription = -1; - public $cache = array(); + private $cache = array(); //Flags details public $forcedSpectatorState = 0; @@ -271,6 +271,17 @@ class Player { $this->cache[$className . $cacheName] = $data; } + /** + * Destroys a Cache + * + * @param $object + * @param $cacheName + */ + public function destroyCache($object, $cacheName) { + $className = $this->getClassName($object); + unset($this->cache[$className . $cacheName]); + } + /** * Clear the Player's Temporary Data */ diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index fa26c9a5..84ff71c1 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -66,7 +66,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns * Returns Back to the Plugins */ public function backToPlugins($callback, Player $player) { - unset($player->cache[self::CACHE_SETTING_CLASS]); + $player->destroyCache($this, self::CACHE_SETTING_CLASS); $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $this->maniaControl->configurator->reopenMenu($player, $menuId); } @@ -118,7 +118,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $paging->setLabel($pageCountLabel); - $settingClass = $player->getCache(self::CACHE_SETTING_CLASS); + $settingClass = $player->getCache($this, self::CACHE_SETTING_CLASS); if ($settingClass) { // Show Settings Menu return $this->getPluginSettingsMenu($frame, $width, $height, $paging, $player, $settingClass); @@ -387,7 +387,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns } else if ($settings) { // Open Settings Menu $pluginClass = substr($actionId, strlen(self::ACTION_PREFIX_SETTINGS)); - $player->cache[self::CACHE_SETTING_CLASS] = $pluginClass; + $player->setCache($this, self::CACHE_SETTING_CLASS, $pluginClass); } else if ($boolSetting) { $actionArray = explode(".", $actionId); $setting = $actionArray[1]; diff --git a/application/plugins/MCTeam/KarmaPlugin.php b/application/plugins/MCTeam/KarmaPlugin.php index 67bf246c..fccd6abe 100644 --- a/application/plugins/MCTeam/KarmaPlugin.php +++ b/application/plugins/MCTeam/KarmaPlugin.php @@ -597,7 +597,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $sum = $this->mxKarma["voteCount"] * $this->mxKarma["voteAverage"] - $oldVote + $vote * 100; $modeSum = $this->mxKarma["modeVoteCount"] * $this->mxKarma["modeVoteAverage"] - $oldVote + $vote * 100; } - + //FIXME, how can here ever be division by zero?, a voting just happened before, and a vote of a player is set + //edit problem is if someone votes on one server (on a map which has no votes yet, joins another server than where same map is running and votes again) $this->mxKarma["voteAverage"] = $sum / $this->mxKarma["voteCount"]; $this->mxKarma["modeVoteAverage"] = $modeSum / $this->mxKarma["modeVoteCount"]; $this->mxKarma["votes"][$player->login] = $vote * 100;