From 72dbbbb746ec658a6de0dce1e5f361e88436403f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 14 Jun 2014 17:10:06 +0200 Subject: [PATCH] check for invalid callback format --- .../core/Statistics/StatisticCollector.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/application/core/Statistics/StatisticCollector.php b/application/core/Statistics/StatisticCollector.php index c3a25a1b..7c2d0b54 100644 --- a/application/core/Statistics/StatisticCollector.php +++ b/application/core/Statistics/StatisticCollector.php @@ -224,15 +224,19 @@ class StatisticCollector implements CallbackListener { break; case 'OnHit': $paramsObject = json_decode($callback[1][1]); - $shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login); - $victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login); - $weapon = $paramsObject->Event->WeaponNum; - if ($shooter) { - $this->maniaControl->statisticManager->incrementStat($this->getWeaponStat(intval($weapon), false), $shooter); - $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_HIT, $shooter); + $weapon = (int)$paramsObject->Event->WeaponNum; + if (isset($paramsObject->Event->Shooter)) { + $shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login); + if ($shooter) { + $this->maniaControl->statisticManager->incrementStat($this->getWeaponStat($weapon, false), $shooter); + $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_HIT, $shooter); + } } - if ($victim) { - $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim); + if (isset($paramsObject->Event->Victim)) { + $victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login); + if ($victim) { + $this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim); + } } break; case 'OnArmorEmpty':