This commit is contained in:
kremsy 2014-02-19 22:22:28 +01:00 committed by Steffen Schröder
parent 895d500ca6
commit b04eb30284
2 changed files with 21 additions and 8 deletions

View File

@ -14,9 +14,9 @@ class CallbackManager {
* Constants * Constants
*/ */
// ManiaControl callbacks // ManiaControl callbacks
const CB_ONINIT = 'ManiaControl.OnInit'; const CB_ONINIT = 'ManiaControl.OnInit';
const CB_AFTERINIT = 'ManiaControl.AfterInit'; const CB_AFTERINIT = 'ManiaControl.AfterInit';
const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown'; const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown';
// ManiaPlanet callbacks // ManiaPlanet callbacks
const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart'; const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart';
@ -150,7 +150,7 @@ class CallbackManager {
} }
$params = func_get_args(); $params = func_get_args();
$params = array_slice($params, 1, count($params), true); $params = array_slice($params, 1, count($params), true);
foreach ($this->callbackListeners[$callbackName] as $listener) { foreach($this->callbackListeners[$callbackName] as $listener) {
call_user_func_array(array($listener[0], $listener[1]), $params); call_user_func_array(array($listener[0], $listener[1]), $params);
} }
} }
@ -170,7 +170,7 @@ class CallbackManager {
call_user_func_array(array($listener[0], $listener[1]), $params); call_user_func_array(array($listener[0], $listener[1]), $params);
} }
} }
/** /**
* Trigger internal Callbacks and manage Server Callbacks * Trigger internal Callbacks and manage Server Callbacks
*/ */
@ -188,12 +188,25 @@ class CallbackManager {
// Handle callbacks // Handle callbacks
foreach($callbacks as $callback) { foreach($callbacks as $callback) {
$callbackName = $callback[0]; $callbackName = $callback[0];
switch ($callbackName) { switch($callbackName) {
case 'ManiaPlanet.BeginMatch':
$titleId = $this->maniaControl->server->titleId;
$titlePrefix = strtolower(substr($titleId, 0, 2));
if ($titlePrefix != "sm") {
$this->triggerCallback($callbackName, $callback);
break;
}
case 'ManiaPlanet.BeginMap': case 'ManiaPlanet.BeginMap':
$this->maniaControl->mapManager->handleBeginMap($callback); $this->maniaControl->mapManager->handleBeginMap($callback);
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
break; break;
case 'ManiaPlanet.EndMatch': //TODO temporary fix case 'ManiaPlanet.EndMatch': //TODO temporary fix
$titleId = $this->maniaControl->server->titleId;
$titlePrefix = strtolower(substr($titleId, 0, 2));
if ($titlePrefix != "sm") {
$this->triggerCallback($callbackName, $callback);
break;
}
case 'ManiaPlanet.EndMap': case 'ManiaPlanet.EndMap':
$this->maniaControl->mapManager->handleEndMap($callback); $this->maniaControl->mapManager->handleEndMap($callback);
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);

View File

@ -288,9 +288,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
/** /**
* Destroy the Vote on Canceled Callback * Destroy the Vote on Canceled Callback
* *
* @param array $callback * @param Player $player
*/ */
public function handleVoteCanceled(array $callback) { public function handleVoteCanceled(Player $player) {
//reset vote //reset vote
$this->destroyVote(); $this->destroyVote();
} }