to have this mc version working you need to update the dedicated server scripts
This commit is contained in:
kremsy 2017-04-13 16:12:10 +02:00
parent 09b974e2cc
commit 7a7826b4b6
17 changed files with 273 additions and 64 deletions

View File

@ -73,7 +73,10 @@ interface Callbacks {
const MP_WARMUP_END = 'Maniaplanet.WarmUp.End';
const MP_WARMUP_STATUS = 'Maniaplanet.WarmUp.Status';
const SM_UIPROPERTIES = 'Shootmania.UIProperties';
const MP_USES_TEAMMODE = 'Maniaplanet.Mode.UseTeams';
const MP_PAUSE_STATUS = 'Maniaplanet.Pause.Status';
const SM_UIPROPERTIES = 'Shootmania.UI.Properties';
const SM_SCORES = "Shootmania.Scores";
const SM_ONEVENTDEFAULT = "Shootmania.Event.Default";
@ -95,7 +98,6 @@ interface Callbacks {
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
//SM GameMode Callbacks
const SM_COMBO_PAUSESTATUS = 'Shootmania.Combo.Pause';
const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn';
const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn';
const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload';
@ -122,7 +124,7 @@ interface Callbacks {
const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound";
const TM_WARMUPEND = "Trackmania.WarmUp.End";
const TM_UIPROPERTIES = 'Trackmania.UIProperties';
const TM_UIPROPERTIES = 'Trackmania.UI.Properties';
const TM_POINTSREPARTITION = 'Trackmania.PointsRepartition';
@ -312,7 +314,7 @@ interface Callbacks {
* @deprecated
*/
const ONPLAYERREQUESTRESPAWN = 'Callbacks.OnPlayerRequestRespawn';
/*
* TrackMania Callbacks
*/

View File

@ -4,11 +4,14 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\CaptureStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\Callbacks\Structures\Common\StatusCallbackStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\LoadingUnloadingMapStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\ModeUseTeamsStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartEndStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartServerStructure;
use ManiaControl\Callbacks\Structures\NearMissStructure;
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
use ManiaControl\Callbacks\Structures\ShootMania\StatusCallbackStructure;
use ManiaControl\Callbacks\Structures\XmlRpc\AllApiVersionsStructure;
use ManiaControl\Callbacks\Structures\XmlRpc\ApiVersionStructure;
use ManiaControl\Callbacks\Structures\XmlRpc\CallbackHelpStructure;
@ -100,7 +103,7 @@ class LibXmlRpcCallbacks implements CallbackListener {
break;
case 'Maniaplanet.StartMap_End': //Use the MapManager Callback
$jsonData = json_decode($data[0]);
$this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, 'False');
$this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, $jsonData->restarted);
//TODO Test if json is correctly parsed
break;
case 'Maniaplanet.EndMap_Start':
@ -117,21 +120,25 @@ class LibXmlRpcCallbacks implements CallbackListener {
break;
case Callbacks::MP_LOADINGMAPEND:
case Callbacks::MP_UNLOADINGMAPSTART:
$jsonData = json_decode($data[0]);
$map = $this->maniaControl->getMapManager()->getMapByUid($jsonData->map->uid); //Verify Json
$this->maniaControl->getCallbackManager()->triggerCallback($name, $map);
$this->maniaControl->getCallbackManager()->triggerCallback($name, new LoadingUnloadingMapStructure($this->maniaControl, $data));
break;
case Callbacks::MP_LOADINGMAPSTART:
case Callbacks::MP_UNLOADINGMAPEND:
case Callbacks::MP_PODIUMSTART:
case Callbacks::MP_PODIUMEND:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new BaseTimeStructure($this->maniaControl, $data));
break;
case Callbacks::MP_WARMUP_START:
case Callbacks::MP_WARMUP_END:
$this->maniaControl->getCallbackManager()->triggerCallback($name);
break;
case Callbacks::MP_WARMUP_STATUS:
case Callbacks::MP_PAUSE_STATUS:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new StatusCallbackStructure($this->maniaControl, $data));
break;
case Callbacks::MP_USES_TEAMMODE:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new ModeUseTeamsStructure($this->maniaControl, $data));
break;
//OLD Callbacks
case 'LibXmlRpc_BeginMatch':

View File

@ -81,7 +81,8 @@ class ShootManiaCallbacks implements CallbackListener {
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnScoresStructure($this->maniaControl, $data));
break;
case Callbacks::SM_UIPROPERTIES:
//TODO
//TODO structure, but wait for further update
$this->maniaControl->getCallbackManager()->triggerCallback($name, $data);
break;
case Callbacks::SM_ONEVENTDEFAULT:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnDefaultEventStructure($this->maniaControl, $data));
@ -128,9 +129,6 @@ class ShootManiaCallbacks implements CallbackListener {
case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnPlayerRequestActionChange($this->maniaControl, $data));
break;
case Callbacks::SM_COMBO_PAUSESTATUS:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new StatusCallbackStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ELITE_STARTTURN:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnEliteStartTurnStructure($this->maniaControl, $data));
break;

View File

@ -0,0 +1,39 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\ManiaControl;
/**
* Base Structure Class for all Callbacks using a Timestamp
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class BaseTimeStructure extends BaseStructure {
protected $time;
/**
* BaseResponseStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
}
/**
* Gets the Server Time the Callback was sent
*
* @api
* @return int Time since Serverstart
*/
public function getTime() {
return $this->time;
}
}

View File

@ -24,6 +24,7 @@ class CommonPlayerScore implements UsageInformationAble, JsonSerializable {
protected $rank;
protected $roundPoints;
protected $mapPoints;
protected $matchPoints;
/**
* Returns the Player
@ -105,4 +106,24 @@ class CommonPlayerScore implements UsageInformationAble, JsonSerializable {
$this->mapPoints = $mapPoints;
}
/**
* Gets the Match Points
*
* @api
* @return mixed
*/
public function getMatchPoints() {
return $this->matchPoints;
}
/**
* Sets the Match Points
*
* @api
* @param mixed $matchPoints
*/
public function setMatchPoints($matchPoints) {
$this->matchPoints = $matchPoints;
}
}

View File

@ -3,7 +3,6 @@
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\ManiaControl;
/**
@ -16,6 +15,7 @@ use ManiaControl\ManiaControl;
*/
class StatusCallbackStructure extends BaseResponseStructure {
protected $active;
protected $available;
/**
* Construct a new On Hit Structure
@ -26,7 +26,8 @@ class StatusCallbackStructure extends BaseResponseStructure {
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->active = $this->getPlainJsonObject()->active;
$this->active = $this->getPlainJsonObject()->active;
$this->available = $this->getPlainJsonObject()->available;
}
/**
@ -39,4 +40,14 @@ class StatusCallbackStructure extends BaseResponseStructure {
return $this->active;
}
/**
* Checks if the Mode uses Warmup or not
*
* @api
* @return boolean
*/
public function isAvailable() {
return $this->available;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Loading Map End and UnloadingMap Begin Callbacks
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class LoadingUnloadingMapStructure extends BaseTimeStructure {
private $restarted;
/**
* StartServerStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
}
/**
* Flag if the Server got Restarted
*
* @api
* @return mixed
*/
public function getRestarted() {
return $this->restarted;
}
/**
* Gets the Map
*
* @api
* @return \ManiaControl\Maps\Map
*/
public function getMap() {
return $this->maniaControl->getMapManager()->getMapByUid($this->getPlainJsonObject()->map->uid);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Mode use Teams Callback
*
* @api
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ModeUseTeamsStructure extends BaseResponseStructure {
private $teams;
/**
* StartServerStructure constructor.
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->teams = $this->getPlainJsonObject()->teams;
}
/**
* Returns if the Mode is using Teams
*
* @api
* @return boolean < true if the game mode uses teams, false otherwise
*/
public function modeIsUsingTeams() {
return $this->teams;
}
}

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl;
/**
@ -14,7 +15,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class StartEndStructure extends BaseStructure {
class StartEndStructure extends BaseTimeStructure {
private $count;
/**

View File

@ -2,6 +2,8 @@
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnArmorEmpty Structure Callback
*
@ -11,5 +13,4 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure {
}

View File

@ -26,9 +26,7 @@ class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {
private $shooter;
private $victim;
//private $shooterPoints; (was in mp3)
//private $hitDistance; (was in mp3)
private $distance;
/**
* Construct a new On Hit Structure
@ -39,9 +37,10 @@ class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time;
$this->weapon = $jsonObj->weapon;
$jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time;
$this->weapon = $jsonObj->weapon;
$this->distance = $jsonObj->distance;
$this->shooterPosition = new Position();
$this->shooterPosition->setX($jsonObj->shooterposition->x);
@ -117,4 +116,14 @@ class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {
public function getVictim() {
return $this->victim;
}
/**
* Distance Between Shooter and Victim at the time of the Event
*
* @api
* @return float
*/
public function getDistance() {
return $this->distance;
}
}

View File

@ -15,7 +15,7 @@ use ManiaControl\ManiaControl;
*/
class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {
private $damage;
private $shooterPoints;
/**
* OnHitStructure constructor.
@ -26,7 +26,8 @@ class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {
public function __construct(ManiaControl $maniaControl, array $data) {
parent::__construct($maniaControl, $data);
$this->damage = $this->getPlainJsonObject()->damage;
$this->damage = $this->getPlainJsonObject()->damage;
$this->shooterPoints = $this->getPlainJsonObject()->points;
}
/**
@ -38,4 +39,15 @@ class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {
public function getDamage() {
return $this->damage;
}
/**
* Amount of points scored by the shooter
*
* @api
* @return int
*/
public function getShooterPoints() {
return $this->shooterPoints;
}
}

View File

@ -14,22 +14,4 @@ use ManiaControl\ManiaControl;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure {
private $distance;
public function __construct(ManiaControl $maniaControl, array $data) {
parent::__construct($maniaControl, $data);
$this->distance = $this->getPlainJsonObject()->distance;
}
/**
* Returns the distance
*
*
* @api
* @return float
*/
public function getDistance() {
return $this->distance;
}
}

View File

@ -35,6 +35,7 @@ class OnScoresStructure extends CommonScoresStructure {
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setMatchPoints($jsonPlayer->matchpoints);
$this->playerScores[$jsonPlayer->login] = $playerScore;
}

View File

@ -86,6 +86,10 @@ class TrackManiaCallbacks implements CallbackListener {
break;
case Callbacks::TM_WARMUPEND:
break;
case Callbacks::TM_UIPROPERTIES:
//TODO structure, but wait for further update
$this->maniaControl->getCallbackManager()->triggerCallback($name, $data);
break;
}
}

View File

@ -798,6 +798,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @param string $restart
*/
public function handleScriptBeginMap($mapUid, $restart) {
//TODO remove parseBoolean as soon the mp3 callbacks get removed
$this->beginMap($mapUid, Formatter::parseBoolean($restart));
}
@ -987,8 +988,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @param $searchString
* @return array
*/
public function searchMapsByAuthor($searchString){
return $this->searchMaps($searchString,self::SEARCH_BY_AUTHOR);
public function searchMapsByAuthor($searchString) {
return $this->searchMaps($searchString, self::SEARCH_BY_AUTHOR);
}
@ -998,8 +999,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @param $searchString
* @return array
*/
public function searchMapsByMapName($searchString){
return $this->searchMaps($searchString,self::SEARCH_BY_MAP_NAME);
public function searchMapsByMapName($searchString) {
return $this->searchMaps($searchString, self::SEARCH_BY_MAP_NAME);
}
/**
@ -1010,7 +1011,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @return array
*/
private function searchMaps($searchString, $searchBy = self::SEARCH_BY_MAP_NAME) {
$result = array();
$result = array();
$searchString = strtolower($searchString);
foreach ($this->maps as $map) {
switch ($searchBy) {

View File

@ -3,7 +3,6 @@
namespace ManiaControl\Script;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
@ -228,6 +227,24 @@ class ModeScriptEventManager implements UsageInformationAble {
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.Stop');
}
/**
* Blocks the End of the Warmup,
*
* @param int $time Timer before the end of the warmup when all players are ready. Use a negative value to prevent the warmup from ending even if all players are ready.
*/
public function blockEndWarmUp($time = -1) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.BlockEndWarmUp', array(true, $time));
}
/**
* Blocks the End of the Warmup,
*
* @param int $time Timer before the end of the warmup when all players are ready. Use a negative value to prevent the warmup from ending even if all players are ready.
*/
public function unBlockEndWarmUp($time = -1) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.BlockEndWarmUp', array(false, $time));
}
/**
* Get the status of the warmup.
*
@ -246,34 +263,46 @@ class ModeScriptEventManager implements UsageInformationAble {
* @api
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
*/
public function getComboPauseStatus() {
public function getPauseStatus() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.GetPause', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId);
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.Pause.GetStatus', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
}
/**
* Start a Pause in Combo and triggers a Callback for the Pause Status
* Start a Pause and triggers a Callback for the Pause Status
*
* @api
* @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable()
*/
public function startComboPause() {
public function startPause() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.SetPause', array(true, $responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId);
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.Pause.SetActive', array(true, $responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
}
/**
* End a Pause in Combo and triggers a Callback for the Pause Status
* End a Pause and triggers a Callback for the Pause Status
*
* @api
* @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable()
*/
public function endComboPause() {
public function endPause() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.SetPause', array(false, $responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId);
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.Pause.SetActive', array(false, $responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
}
/**
* Returns if the GameMode is a TeamMode or not
*
* @api
* @return \ManiaControl\Script\InvokeScriptCallback To get The TeamMode Status You can directly set a callable on it via setCallable()
*/
public function isTeamMode() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.Mode.GetUseTeams', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_USES_TEAMMODE, $responseId);
}
/**
@ -321,7 +350,7 @@ class ModeScriptEventManager implements UsageInformationAble {
*/
public function getShootmaniaUIProperties() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($responseId));
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.UI.GetProperties', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_UIPROPERTIES, $responseId);
}
@ -332,7 +361,7 @@ class ModeScriptEventManager implements UsageInformationAble {
* @param string Json-Encoded Xml UI Property String
*/
public function setShootmaniaUIProperties($properties) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($properties));
$this->maniaControl->getClient()->triggerModeScriptEvent(' Shootmania.UI.SetProperties', array($properties));
}
/**
@ -377,7 +406,7 @@ class ModeScriptEventManager implements UsageInformationAble {
*/
public function getTrackmaniaUIProperties() {
$responseId = $this->generateResponseId();
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetUIProperties', array($responseId));
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.SetProperties', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId);
}
@ -388,7 +417,7 @@ class ModeScriptEventManager implements UsageInformationAble {
* @param string Json-Encoded Xml UI Property String
*/
public function setTrackmaniaUIProperties($properties) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($properties));
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.GetProperties', array($properties));
}
/**