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