fixed empty message karma voting bug

This commit is contained in:
Steffen Schröder 2014-01-10 18:19:11 +01:00
parent 0cadc02560
commit 5db1e23a7b

View File

@ -231,8 +231,12 @@ class KarmaPlugin implements CallbackListener, Plugin {
if(preg_match('/[^+-]/', $message)) { if(preg_match('/[^+-]/', $message)) {
return; return;
} }
$vote = substr_count($message, '+'); $countPositive = substr_count($message, '+');
$vote -= substr_count($message, '-'); $countNegative = substr_count($message, '-');
if ($countPositive <= 0 && $countNegative <= 0) {
return;
}
$vote = $countPositive - $countNegative;
$success = $this->handleVote($player, $vote); $success = $this->handleVote($player, $vote);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);