error fixes

This commit is contained in:
kremsy 2014-03-13 18:47:40 +01:00 committed by Steffen Schröder
parent d3cc9db29c
commit 79a771583e
7 changed files with 66 additions and 33 deletions

View File

@ -48,9 +48,13 @@ if (LOG_WRITE_CURRENT_FILE) {
function logMessage($message) {
$message .= PHP_EOL;
if (defined('LOG_CURRENT_FILE')) {
file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND);
if(!file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)){
echo "Logfile not Write-able, please check your file Permissions";
}
}
if(!file_put_contents(LOG_FILE, $message, FILE_APPEND)){
echo "Logfile not Write-able, please check your file Permissions";
}
file_put_contents(LOG_FILE, $message, FILE_APPEND);
echo $message;
}

View File

@ -141,9 +141,11 @@ class CommandManager implements CallbackListener {
if ($command == 'admin') {
// Strip 'admin' keyword
if (isset($commandArray[1])) {
$command = $commandArray[1];
unset($commandArray[1]);
}
}
unset($commandArray[0]);
// Compose uniformed message

View File

@ -215,7 +215,7 @@ class Client
while(strlen($contents) < 8){
$newContent = fread($this->socket, 8 - strlen($contents));
//var_dump($contents, $newContent, strlen($contents));
if(strlen($newContent) == 0){
if(strlen($newContent) === false){
var_dump("deb1 transport error" . $contents);
throw new FatalException('deb1 transport error - connection interrupted!' . $contents, FatalException::INTERRUPTED);
}

View File

@ -86,9 +86,14 @@ class PlayerActions {
try {
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER);
} catch(Exception $e) {
if ($e->getMessage() == 'There are too many players') {
$this->maniaControl->chat->sendError("Too many Spectators");
return;
} else {
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 90: " . $e->getMessage());
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
}
return;
}
@ -192,13 +197,14 @@ class PlayerActions {
if ($e->getMessage() == 'The player is not a spectator') {
$this->kickPlayer($adminLogin, $targetLogin, 'Disconnect');
$this->maniaControl->errorHandler->triggerDebugNotice("inaktiv spec player kicked " . $e->getMessage());
}
} else {
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 183: " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
//do nothing
}
}
}
}
/**
* UnMute a Player

View File

@ -723,10 +723,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$this->maniaControl->client->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
$this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
} catch(Exception $e) {
if ($e->getMessage() != 'Login unknown.') {
//do nothing
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 727: " . $e->getMessage());
}
}
});
break;
case self::ACTION_KICK_PLAYER_VOTE:

View File

@ -196,7 +196,9 @@ class StatisticManager {
case self::SPECIAL_STAT_KD_RATIO:
$kills = $this->getStatsRanking(StatisticCollector::STAT_ON_KILL, $serverIndex);
$deaths = $this->getStatsRanking(StatisticCollector::STAT_ON_DEATH, $serverIndex);
if(!$kills || !$deaths){
return array();
}
foreach($deaths as $key => $death) {
if ($death == 0 || !isset($kills[$key])) {
continue;
@ -208,6 +210,9 @@ class StatisticManager {
case self::SPECIAL_STAT_HITS_PH:
$hits = $this->getStatsRanking(StatisticCollector::STAT_ON_HIT, $serverIndex);
$times = $this->getStatsRanking(StatisticCollector::STAT_PLAYTIME, $serverIndex);
if(!$hits || !$times){
return array();
}
foreach($times as $key => $time) {
if ($time == 0 || !isset($hits[$key])) {
continue;
@ -219,6 +224,9 @@ class StatisticManager {
case self::SPECIAL_STAT_ARROW_ACC:
$hits = $this->getStatsRanking(StatisticCollector::STAT_ARROW_HIT, $serverIndex);
$shots = $this->getStatsRanking(StatisticCollector::STAT_ARROW_SHOT, $serverIndex);
if(!$hits || !$shots){
return array();
}
foreach($shots as $key => $shot) {
if ($shot == 0 || !isset($hits[$key])) {
continue;
@ -230,6 +238,9 @@ class StatisticManager {
case self::SPECIAL_STAT_LASER_ACC:
$hits = $this->getStatsRanking(StatisticCollector::STAT_LASER_HIT, $serverIndex);
$shots = $this->getStatsRanking(StatisticCollector::STAT_LASER_SHOT, $serverIndex);
if(!$hits || !$shots){
return array();
}
foreach($shots as $key => $shot) {
if ($shot == 0 || !isset($hits[$key])) {
continue;
@ -241,6 +252,9 @@ class StatisticManager {
case self::SPECIAL_STAT_ROCKET_ACC:
$hits = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_HIT, $serverIndex);
$shots = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_SHOT, $serverIndex);
if(!$hits || !$shots){
return array();
}
foreach($shots as $key => $shot) {
if ($shot == 0 || !isset($hits[$key])) {
continue;
@ -252,6 +266,9 @@ class StatisticManager {
case self::SPECIAL_STAT_NUCLEUS_ACC:
$hits = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_HIT, $serverIndex);
$shots = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_SHOT, $serverIndex);
if(!$hits || !$shots){
return array();
}
foreach($shots as $key => $shot) {
if ($shot == 0 || !isset($hits[$key])) {
continue;

View File

@ -370,12 +370,14 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try {
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
} catch(Exception $e) {
if ($e->getMessage() != 'The player is not a spectator') {
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
//to nothing
}
}
}
}
/**
* Checks if a Player is in the PlayerList and returns the nickname if he is, can be called per login, pid or nickname or lj for