From 5db1e23a7b0e3ab89dc6c3e62c77db6bb0ccf619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 10 Jan 2014 18:19:11 +0100 Subject: [PATCH] fixed empty message karma voting bug --- application/plugins/Karma.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/application/plugins/Karma.php b/application/plugins/Karma.php index 9de039e0..a488ab00 100644 --- a/application/plugins/Karma.php +++ b/application/plugins/Karma.php @@ -231,8 +231,12 @@ class KarmaPlugin implements CallbackListener, Plugin { if(preg_match('/[^+-]/', $message)) { return; } - $vote = substr_count($message, '+'); - $vote -= substr_count($message, '-'); + $countPositive = substr_count($message, '+'); + $countNegative = substr_count($message, '-'); + if ($countPositive <= 0 && $countNegative <= 0) { + return; + } + $vote = $countPositive - $countNegative; $success = $this->handleVote($player, $vote); if(!$success) { $this->maniaControl->chat->sendError('Error occurred.', $player->login);