karma fix
This commit is contained in:
parent
60b13c8bbc
commit
53ddea9d45
@ -222,7 +222,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
public function handleBeginMap(Map $map) {
|
||||
//send Map Karma to MX from previous Map
|
||||
if(isset($this->mxKarma['map'])){
|
||||
if (isset($this->mxKarma['map'])) {
|
||||
$votes = array();
|
||||
foreach($this->mxKarma['votes'] as $login => $value) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
@ -578,6 +578,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$query .= '&applicationIdentifier=' . urlencode($applicationIdentifier);
|
||||
$query .= '&testMode=' . $testMode;
|
||||
|
||||
$this->mxKarma['connectionInProgress'] = true;
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($mxKarmaCode) {
|
||||
if (!$error) {
|
||||
@ -589,11 +590,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->log($error);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, "application/json", 1000);
|
||||
}
|
||||
@ -610,20 +613,23 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey);
|
||||
$query .= '&activationHash=' . urlencode($hash);
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use($query) {
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($query) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success && $data->data->activated) {
|
||||
$this->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
} else {
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
} else {
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$this->maniaControl->log($error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, "application/json", 1000);
|
||||
}
|
||||
@ -642,7 +648,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->mxKarma['session'])) {
|
||||
if (!isset($this->mxKarma['session']) && isset($this->mxKarma['connectionInProgress']) && $this->mxKarma['connectionInProgress'] != true) {
|
||||
$this->mxKarmaOpenSession();
|
||||
return;
|
||||
}
|
||||
@ -693,7 +699,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->mxKarma['session'])) {
|
||||
if (!isset($this->mxKarma['session']) && isset($this->mxKarma['connectionInProgress']) && $this->mxKarma['connectionInProgress'] != true) {
|
||||
$this->mxKarmaOpenSession();
|
||||
return;
|
||||
}
|
||||
@ -715,8 +721,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
private function postKarmaVotes(Map $map, array $votes, $import = false) {
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
|
||||
if(count($votes) == 0)
|
||||
if (count($votes) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$properties = array();
|
||||
if ($gameMode == 'Script') {
|
||||
@ -726,9 +733,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$properties['gamemode'] = $gameMode;
|
||||
}
|
||||
|
||||
if($import){
|
||||
if ($import) {
|
||||
$properties['maptime'] = 0;
|
||||
}else{
|
||||
} else {
|
||||
$properties['maptime'] = time() - $this->mxKarma['startTime'];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user