libxmlrpc callbacks

This commit is contained in:
kremsy 2014-04-24 21:55:47 +02:00 committed by Steffen Schröder
parent 8f1b5ae791
commit 335901edd8
5 changed files with 136 additions and 130 deletions

View File

@ -7,42 +7,42 @@ use ManiaControl\ManiaControl;
/** /**
* Class for managing Server and ManiaControl Callbacks * Class for managing Server and ManiaControl Callbacks
* *
* @author steeffeen & kremsy * @author steeffeen & kremsy
* @copyright ManiaControl Copyright © 2014 ManiaControl Team * @copyright ManiaControl Copyright © 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CallbackManager { 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';
const CB_MP_SERVERSTOP = 'ManiaPlanet.ServerStop'; const CB_MP_SERVERSTOP = 'ManiaPlanet.ServerStop';
const CB_MP_BEGINMATCH = 'ManiaPlanet.BeginMatch'; const CB_MP_BEGINMATCH = 'ManiaPlanet.BeginMatch';
const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch'; const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch';
const CB_MP_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified'; const CB_MP_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified';
const CB_MP_ECHO = 'ManiaPlanet.Echo'; const CB_MP_ECHO = 'ManiaPlanet.Echo';
const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated'; const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated';
const CB_MP_PLAYERCHAT = 'ManiaPlanet.PlayerChat'; const CB_MP_PLAYERCHAT = 'ManiaPlanet.PlayerChat';
const CB_MP_PLAYERCONNECT = 'ManiaPlanet.PlayerConnect'; const CB_MP_PLAYERCONNECT = 'ManiaPlanet.PlayerConnect';
const CB_MP_PLAYERDISCONNECT = 'ManiaPlanet.PlayerDisconnect'; const CB_MP_PLAYERDISCONNECT = 'ManiaPlanet.PlayerDisconnect';
const CB_MP_PLAYERMANIALINKPAGEANSWER = 'ManiaPlanet.PlayerManialinkPageAnswer'; const CB_MP_PLAYERMANIALINKPAGEANSWER = 'ManiaPlanet.PlayerManialinkPageAnswer';
const CB_MP_PLAYERINFOCHANGED = 'ManiaPlanet.PlayerInfoChanged'; const CB_MP_PLAYERINFOCHANGED = 'ManiaPlanet.PlayerInfoChanged';
const CB_MP_PLAYERALLIESCHANGED = 'ManiaPlanet.PlayerAlliesChanged'; const CB_MP_PLAYERALLIESCHANGED = 'ManiaPlanet.PlayerAlliesChanged';
const CB_MP_VOTEUPDATED = 'ManiaPlanet.VoteUpdated'; const CB_MP_VOTEUPDATED = 'ManiaPlanet.VoteUpdated';
const CB_MP_STATUSCHANGED = 'ManiaPlanet.StatusChanged'; const CB_MP_STATUSCHANGED = 'ManiaPlanet.StatusChanged';
const CB_MP_MODESCRIPTCALLBACK = 'ManiaPlanet.ModeScriptCallback'; const CB_MP_MODESCRIPTCALLBACK = 'ManiaPlanet.ModeScriptCallback';
const CB_MP_MODESCRIPTCALLBACKARRAY = 'ManiaPlanet.ModeScriptCallbackArray'; const CB_MP_MODESCRIPTCALLBACKARRAY = 'ManiaPlanet.ModeScriptCallbackArray';
const CB_MP_TUNNELDATARECEIVED = 'ManiaPlanet.TunnelDataReceived'; const CB_MP_TUNNELDATARECEIVED = 'ManiaPlanet.TunnelDataReceived';
// TrackMania callbacks // TrackMania callbacks
const CB_TM_PLAYERCHECKPOINT = 'TrackMania.PlayerCheckpoint'; const CB_TM_PLAYERCHECKPOINT = 'TrackMania.PlayerCheckpoint';
const CB_TM_PLAYERFINISH = 'TrackMania.PlayerFinish'; const CB_TM_PLAYERFINISH = 'TrackMania.PlayerFinish';
const CB_TM_PLAYERINCOHERENCE = 'TrackMania.PlayerIncoherence'; const CB_TM_PLAYERINCOHERENCE = 'TrackMania.PlayerIncoherence';
/* /*
@ -67,15 +67,15 @@ class CallbackManager {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->shootManiaCallbacks = new ShootManiaCallbacks($maniaControl, $this); $this->shootManiaCallbacks = new ShootManiaCallbacks($maniaControl, $this);
$this->libXmlRpcCallbacks = new LibXmlRpcCallbackManager($maniaControl, $this); $this->libXmlRpcCallbacks = new LibXmlRpcCallbackManager($maniaControl, $this);
} }
/** /**
* Register a new Callback Listener * Register a new Callback Listener
* *
* @param string $callbackName * @param string $callbackName
* @param \ManiaControl\Callbacks\CallbackListener $listener * @param \ManiaControl\Callbacks\CallbackListener $listener
* @param string $method * @param string $method
* @return bool * @return bool
*/ */
public function registerCallbackListener($callbackName, CallbackListener $listener, $method) { public function registerCallbackListener($callbackName, CallbackListener $listener, $method) {
@ -93,9 +93,9 @@ class CallbackManager {
/** /**
* Register a new Script Callback Listener * Register a new Script Callback Listener
* *
* @param string $callbackName * @param string $callbackName
* @param CallbackListener $listener * @param CallbackListener $listener
* @param string $method * @param string $method
* @return bool * @return bool
*/ */
public function registerScriptCallbackListener($callbackName, CallbackListener $listener, $method) { public function registerScriptCallbackListener($callbackName, CallbackListener $listener, $method) {
@ -118,8 +118,8 @@ class CallbackManager {
*/ */
public function unregisterCallbackListener(CallbackListener $listener) { public function unregisterCallbackListener(CallbackListener $listener) {
$removed = false; $removed = false;
foreach ($this->callbackListeners as &$listeners) { foreach($this->callbackListeners as &$listeners) {
foreach ($listeners as $key => &$listenerCallback) { foreach($listeners as $key => &$listenerCallback) {
if ($listenerCallback[0] != $listener) { if ($listenerCallback[0] != $listener) {
continue; continue;
} }
@ -138,8 +138,8 @@ class CallbackManager {
*/ */
public function unregisterScriptCallbackListener(CallbackListener $listener) { public function unregisterScriptCallbackListener(CallbackListener $listener) {
$removed = false; $removed = false;
foreach ($this->scriptCallbackListener as &$listeners) { foreach($this->scriptCallbackListener as &$listeners) {
foreach ($listeners as $key => &$listenerCallback) { foreach($listeners as $key => &$listenerCallback) {
if ($listenerCallback[0] != $listener) { if ($listenerCallback[0] != $listener) {
continue; continue;
} }
@ -161,7 +161,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);
} }
} }
@ -177,7 +177,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->scriptCallbackListener[$callbackName] as $listener) { foreach($this->scriptCallbackListener[$callbackName] as $listener) {
call_user_func_array(array($listener[0], $listener[1]), $params); call_user_func_array(array($listener[0], $listener[1]), $params);
} }
} }
@ -197,7 +197,7 @@ class CallbackManager {
$callbacks = $this->maniaControl->client->executeCallbacks(); $callbacks = $this->maniaControl->client->executeCallbacks();
// Handle callbacks // Handle callbacks
foreach ($callbacks as $callback) { foreach($callbacks as $callback) {
$this->handleCallback($callback); $this->handleCallback($callback);
} }
} }
@ -209,7 +209,7 @@ class CallbackManager {
*/ */
private function handleCallback(array $callback) { private function handleCallback(array $callback) {
$callbackName = $callback[0]; $callbackName = $callback[0];
switch ($callbackName) { switch($callbackName) {
case 'ManiaPlanet.BeginMatch': case 'ManiaPlanet.BeginMatch':
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
@ -251,6 +251,6 @@ class CallbackManager {
$scriptCallbackData = $callback[1]; $scriptCallbackData = $callback[1];
$scriptCallbackName = $scriptCallbackData[0]; $scriptCallbackName = $scriptCallbackData[0];
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData); $this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
$this->triggerCallback(Callbacks::ScriptCallback, $scriptCallbackName, $scriptCallbackData[1]); $this->triggerCallback(Callbacks::SCRIPTCALLBACK, $scriptCallbackName, $scriptCallbackData[1]);
} }
} }

View File

@ -9,11 +9,31 @@ namespace ManiaControl\Callbacks;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface Callbacks { interface Callbacks {
const ScriptCallback = 'Callbacks.ScriptCallback'; const SCRIPTCALLBACK = 'Callbacks.ScriptCallback';
/** BeginMatch Callback, param1 MapNumber */ /** BeginMatch Callback, param1 MatchNumber */
const BeginMatch = "Callbacks.BeginMatch"; const BEGINMATCH = "Callbacks.BeginMatch";
/** LoadingMap Callback, param1 MapNumber */ /** LoadingMap Callback, Number of Map */
const LoadingMap = "Callbacks.LoadingMap"; const LOADINGMAP = "Callbacks.LoadingMap";
/** BeginMap Callback, param1 MapNumber */ /** BeginMap Callback, triggered by MapManager, param1 Map Object */
const BeginMap = "Callbacks.BeginMap"; const BEGINMAP = "Callbacks.BeginMap";
/** BeginSubMatch Callback, param1 Number of Submatch */
const BEGINSUBMATCH = "Callbacks.BeginSubmatch";
/** BeginRound Callback, param1 Number of Round */
const BEGINROUND = "Callbacks.BeginRound";
/** BeginTurn Callback, param1 Number of Turn */
const BEGINTURN = "Callbacks.BeginTurn";
/** EndTurn Callback, param1 Number of Turn */
const ENDTURN = "Callbacks.EndTurn";
/** EndRound Callback, param1 Number of Round */
const ENDROUND = "Callbacks.EndRound";
/** EndSubMatch Callback, param1 Number of Submatch */
const ENDSUBMATCH = "Callbacks.EndSubmatch";
/** BeginMap Callback, triggered by MapManager, param1 Map Object */
const ENDMAP = "Callbacks.EndMap";
/** EndMatch Callback, param1 MatchNumber */
const ENDMATCH = "Callbacks.EndMatch";
/** BeginWarmup Callback, no parameters */
const BEGINWARMUP = "Callbacks.BeginWarmUp";
/** EndWarmup Callback, no parameters */
const ENDWARMUP = "Callbacks.EndWarmUp";
} }

View File

@ -1,51 +1,66 @@
<?php <?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 24.04.14
* Time: 16:57
*/
namespace ManiaControl\Callbacks; namespace ManiaControl\Callbacks;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
class LibXmlRpcCallbackManager implements CallbackListener{ class LibXmlRpcCallbackManager implements CallbackListener {
/* /*
* Private Properties * Private Properties
*/ */
private $maniaControl = null; private $maniaControl = null;
/** /**
* Create a new ShootMania Callbacks Instance * Create a new LibXmlRpc Callbacks Instance
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
*/ */
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) { public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$callbackManager->registerCallbackListener(Callbacks::ScriptCallback, $this, 'handleScriptCallbacks'); $callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks');
} }
public function handleScriptCallbacks($name, $data){ public function handleScriptCallbacks($name, $data) {
switch($name){ switch($name) {
case 'LibXmlRpc_BeginMatch': case 'LibXmlRpc_BeginMatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BeginMatch, $data[0]); $this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
break; break;
case 'LibXmlRpc_LoadingMap': case 'LibXmlRpc_LoadingMap':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LoadingMap, $data[0]); $this->maniaControl->callbackManager->triggerCallback(Callbacks::LOADINGMAP, $data[0]);
break; break;
case 'BeginMap':
case 'LibXmlRpc_BeginMap': case 'LibXmlRpc_BeginMap':
//$this->maniaControl->callbackManager->triggerCallback(Callbacks::BeginMap, $data[0]);
$this->maniaControl->mapManager->handleScriptBeginMap($data[0]); $this->maniaControl->mapManager->handleScriptBeginMap($data[0]);
break; break;
case 'LibXmlRpc_BeginSubmatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINSUBMATCH, $data[0]);
break;
case 'LibXmlRpc_BeginTurn':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINTURN, $data[0]);
break;
case 'LibXmlRpc_EndTurn':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDTURN, $data[0]);
break;
case 'LibXmlRpc_EndRound':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDROUND, $data[0]);
break;
case 'LibXmlRpc_EndSubmatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]);
break;
case 'EndMap':
case 'LibXmlRpc_EndMap':
$this->maniaControl->mapManager->handleScriptEndMap($data[0]);
break;
case 'LibXmlRpc_EndMatch':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMATCH, $data[0]);
break;
case 'LibXmlRpc_BeginWarmUp':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINWARMUP);
break;
case 'LibXmlRpc_EndWarmUp':
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDWARMUP);
break;
} }
var_dump($name);
var_dump($data);
} }
} }

View File

@ -7,22 +7,18 @@ use ManiaControl\ManiaControl;
/** /**
* Class handling and parsing ShootMania Callbacks * Class handling and parsing ShootMania Callbacks
* *
* @author steeffeen * @author steeffeen
* @copyright ManiaControl Copyright © 2014 ManiaControl Team * @copyright ManiaControl Copyright © 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class ShootManiaCallbacks implements CallbackListener { class ShootManiaCallbacks implements CallbackListener {
/* /*
* Constants * Constants
*/ */
const SCB_LIBXMLRPC_BEGINMAP = 'LibXmlRpc_BeginMap'; const SCB_TIMEATTACK_ONSTART = 'TimeAttack_OnStart';
const SCB_LIBXMLRPC_ENDMAP = 'LibXmlRpc_EndMap'; const SCB_TIMEATTACK_ONRESTART = 'TimeAttack_OnRestart';
const SCB_OLD_BEGINMAP = 'BeginMap';
const SCB_OLD_ENDMAP = 'EndMap';
const SCB_TIMEATTACK_ONSTART = 'TimeAttack_OnStart';
const SCB_TIMEATTACK_ONRESTART = 'TimeAttack_OnRestart';
const SCB_TIMEATTACK_ONCHECKPOINT = 'TimeAttack_OnCheckpoint'; const SCB_TIMEATTACK_ONCHECKPOINT = 'TimeAttack_OnCheckpoint';
const SCB_TIMEATTACK_ONFINISH = 'TimeAttack_OnFinish'; const SCB_TIMEATTACK_ONFINISH = 'TimeAttack_OnFinish';
/* /*
* Private Properties * Private Properties
@ -38,49 +34,25 @@ class ShootManiaCallbacks implements CallbackListener {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
// Register for script callbacks // Register for script callbacks
$callbackManager->registerScriptCallbackListener(self::SCB_LIBXMLRPC_BEGINMAP, $this, 'callback_LibXmlRpc_BeginMap');
$callbackManager->registerScriptCallbackListener(self::SCB_OLD_BEGINMAP, $this, 'callback_LibXmlRpc_BeginMap');
$callbackManager->registerScriptCallbackListener(self::SCB_LIBXMLRPC_ENDMAP, $this, 'callback_LibXmlRpc_EndMap');
$callbackManager->registerScriptCallbackListener(self::SCB_OLD_ENDMAP, $this, 'callback_LibXmlRpc_EndMap');
$callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONCHECKPOINT, $this, 'callback_TimeAttack_OnCheckpoint'); $callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONCHECKPOINT, $this, 'callback_TimeAttack_OnCheckpoint');
$callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONFINISH, $this, 'callback_TimeAttack_OnFinish'); $callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONFINISH, $this, 'callback_TimeAttack_OnFinish');
} }
/**
* Handle LibXmlRpc BeginMap Script Callback
*
* @param array $callback
*/
public function callback_LibXmlRpc_BeginMap(array $callback) {
$this->maniaControl->mapManager->handleScriptBeginMap($callback);
}
/**
* Handle LibXmlRpc EndMap Script Callback
*
* @param array $callback
*/
public function callback_LibXmlRpc_EndMap(array $callback) {
$this->maniaControl->mapManager->handleScriptEndMap($callback);
}
/** /**
* Handle TimeAttack OnCheckpoint Script Callback * Handle TimeAttack OnCheckpoint Script Callback
* *
* @param array $callback * @param array $callback
*/ */
public function callback_TimeAttack_OnCheckpoint(array $callback) { public function callback_TimeAttack_OnCheckpoint(array $callback) {
$login = $callback[1][0]; $login = $callback[1][0];
$time = (int) $callback[1][1]; $time = (int)$callback[1][1];
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
if (!$player || $time <= 0) { if (!$player || $time <= 0) {
return; return;
} }
// Trigger trackmania player checkpoint callback // Trigger trackmania player checkpoint callback
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0); $checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, $this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
} }
/** /**
@ -89,15 +61,14 @@ class ShootManiaCallbacks implements CallbackListener {
* @param array $callback * @param array $callback
*/ */
public function callback_TimeAttack_OnFinish(array $callback) { public function callback_TimeAttack_OnFinish(array $callback) {
$login = $callback[1][0]; $login = $callback[1][0];
$time = (int) $callback[1][1]; $time = (int)$callback[1][1];
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
if (!$player || $time <= 0) { if (!$player || $time <= 0) {
return; return;
} }
// Trigger trackmania player finish callback // Trigger trackmania player finish callback
$finishCallback = array($player->pid, $player->login, $time); $finishCallback = array($player->pid, $player->login, $time);
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, $this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
} }
} }

View File

@ -5,6 +5,7 @@ namespace ManiaControl\Maps;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Files\FileUtil; use ManiaControl\Files\FileUtil;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\ManiaExchange\ManiaExchangeList; use ManiaControl\ManiaExchange\ManiaExchangeList;
@ -29,8 +30,10 @@ class MapManager implements CallbackListener {
/* /*
* Constants * Constants
*/ */
const TABLE_MAPS = 'mc_maps'; const TABLE_MAPS = 'mc_maps';
const CB_BEGINMAP = 'MapManager.BeginMap'; /** @deprecated CB_BEGINMAP */
const CB_BEGINMAP = 'MapManager.BeginMap';
/** @deprecated CB_ENDMAP */
const CB_ENDMAP = 'MapManager.EndMap'; const CB_ENDMAP = 'MapManager.EndMap';
const CB_MAPS_UPDATED = 'MapManager.MapsUpdated'; const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated'; const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
@ -503,16 +506,18 @@ class MapManager implements CallbackListener {
// Update the mx of the map (for update checks, etc.) // Update the mx of the map (for update checks, etc.)
$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap); $this->mxManager->fetchManiaExchangeMapInformations($this->currentMap);
// Trigger own BeginMap callback // Trigger own BeginMap callback (
//TODO remove deprecated callback later
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap); $this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap);
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
} }
/** /**
* Handle Script BeginMap callback * Handle Script BeginMap callback
* *
* @param array $callback * @param int $mapNumber
*/ */
public function handleScriptBeginMap(array $callback) { public function handleScriptBeginMap($mapNumber) {
$this->handleBeginMap(array()); $this->handleBeginMap(array());
} }
@ -530,22 +535,17 @@ class MapManager implements CallbackListener {
// Trigger own EndMap callback // Trigger own EndMap callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap); $this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
//TODO remove deprecated callback later
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
} }
/** /**
* Handle Script EndMap Callback * Handle Script EndMap Callback
* *
* @param array $callback * @param int $mapNumber
*/ */
public function handleScriptEndMap(array $callback) { public function handleScriptEndMap($mapNumber) {
if ($this->mapEnded) { $this->handleEndMap(array());
return;
}
$this->mapEnded = true;
$this->mapBegan = false;
// Trigger own EndMap callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
} }
/** /**