revert match settings manager (nevermind)
This commit is contained in:
		| @@ -16,6 +16,7 @@ class CallbackManager { | ||||
| 	 * Constants | ||||
| 	 */ | ||||
| 	// ManiaControl callbacks | ||||
| 	// TODO: move into Callbacks interface | ||||
| 	const CB_ONINIT     = 'ManiaControl.OnInit'; | ||||
| 	const CB_AFTERINIT  = 'ManiaControl.AfterInit'; | ||||
| 	const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown'; | ||||
|   | ||||
| @@ -39,7 +39,7 @@ class Map { | ||||
| 	public $titleUid = ''; | ||||
| 	public $startTime = -1; | ||||
| 	public $lastUpdate = 0; | ||||
|  | ||||
| 	public $karma = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new Map Object from Rpc Data | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use ManiaControl\Callbacks\CallbackListener; | ||||
| use ManiaControl\Commands\CommandListener; | ||||
| use ManiaControl\ManiaControl; | ||||
| use ManiaControl\Manialinks\ManialinkPageAnswerListener; | ||||
| use ManiaControl\Server\MatchSettingsManager; | ||||
| use ManiaControl\Server\Server; | ||||
| use Maniaplanet\DedicatedServer\Xmlrpc\Exception; | ||||
|  | ||||
| /** | ||||
| @@ -62,7 +62,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca | ||||
| 		$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR); | ||||
|  | ||||
| 		//CallbackManager | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(MatchSettingsManager::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged'); | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged'); | ||||
|  | ||||
| 		// Action Open Playerlist | ||||
| 		$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList'); | ||||
|   | ||||
| @@ -326,7 +326,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer | ||||
| 				$playerQuad->addTooltipLabelFeature($descriptionLabel, $description); | ||||
| 			} | ||||
|  | ||||
| 			if ($this->maniaControl->server->matchSettingsManager->isTeamMode()) { | ||||
| 			if ($this->maniaControl->server->isTeamMode()) { | ||||
| 				if ($this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { | ||||
| 					// Force to Red-Team Quad | ||||
| 					$redQuad = new Quad_Emblems(); | ||||
|   | ||||
| @@ -122,7 +122,7 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
|  | ||||
| 			//Check if the Player is in a Team, to notify if its a TeamMode or not | ||||
| 			if ($playerItem->teamId != -1) { | ||||
| 				$this->maniaControl->server->matchSettingsManager->setTeamMode(true); | ||||
| 				$this->maniaControl->server->setTeamMode(true); | ||||
| 			} | ||||
|  | ||||
| 			$player = new Player($this->maniaControl, true); | ||||
| @@ -321,7 +321,7 @@ class PlayerManager implements CallbackListener, TimerListener { | ||||
|  | ||||
| 		//Check if the Player is in a Team, to notify if its a TeamMode or not | ||||
| 		if ($player->teamId != -1) { | ||||
| 			$this->maniaControl->server->matchSettingsManager->setTeamMode(true); | ||||
| 			$this->maniaControl->server->setTeamMode(true); | ||||
| 		} | ||||
|  | ||||
| 		$prevJoinState = $player->hasJoinedGame; | ||||
|   | ||||
| @@ -1,96 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace ManiaControl\Server; | ||||
|  | ||||
| use ManiaControl\Callbacks\CallbackListener; | ||||
| use ManiaControl\ManiaControl; | ||||
|  | ||||
| /** | ||||
|  * Class managing the current Match Settings of the Server | ||||
|  * | ||||
|  * @author    ManiaControl Team <mail@maniacontrol.com> | ||||
|  * @copyright 2014 ManiaControl Team | ||||
|  * @license   http://www.gnu.org/licenses/ GNU General Public License, Version 3 | ||||
|  */ | ||||
| class MatchSettingsManager implements CallbackListener { | ||||
| 	/* | ||||
| 	 * Constants | ||||
| 	 */ | ||||
| 	const CB_TEAM_MODE_CHANGED = 'MatchSettings.TeamModeChanged'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Private Properties | ||||
| 	 */ | ||||
| 	private $maniaControl = null; | ||||
| 	private $teamMode = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Construct a new Match Settings Manager | ||||
| 	 * | ||||
| 	 * @param ManiaControl $maniaControl | ||||
| 	 */ | ||||
| 	public function __construct(ManiaControl $maniaControl) { | ||||
| 		$this->maniaControl = $maniaControl; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set whether the Server Runs a Team-Based Mode or not | ||||
| 	 * | ||||
| 	 * @param bool $teamMode | ||||
| 	 */ | ||||
| 	public function setTeamMode($teamMode = true) { | ||||
| 		$oldStatus      = $this->teamMode; | ||||
| 		$this->teamMode = (bool)$teamMode; | ||||
|  | ||||
| 		// Trigger callback | ||||
| 		if ($oldStatus !== $this->teamMode | $oldStatus === null) { | ||||
| 			$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_MODE_CHANGED, $teamMode); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if the Server Runs a Team-Based Mode | ||||
| 	 * | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function isTeamMode() { | ||||
| 		return $this->teamMode; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Fetch the current Game Mode | ||||
| 	 * | ||||
| 	 * @param bool $stringValue | ||||
| 	 * @param int  $parseValue | ||||
| 	 * @return int | string | ||||
| 	 */ | ||||
| 	public function getGameMode($stringValue = false, $parseValue = null) { | ||||
| 		if (is_int($parseValue)) { | ||||
| 			$gameMode = $parseValue; | ||||
| 		} else { | ||||
| 			$gameMode = $this->maniaControl->client->getGameMode(); | ||||
| 		} | ||||
| 		if ($stringValue) { | ||||
| 			switch ($gameMode) { | ||||
| 				case 0: | ||||
| 					return 'Script'; | ||||
| 				case 1: | ||||
| 					return 'Rounds'; | ||||
| 				case 2: | ||||
| 					return 'TimeAttack'; | ||||
| 				case 3: | ||||
| 					return 'Team'; | ||||
| 				case 4: | ||||
| 					return 'Laps'; | ||||
| 				case 5: | ||||
| 					return 'Cup'; | ||||
| 				case 6: | ||||
| 					return 'Stunts'; | ||||
| 				default: | ||||
| 					return 'Unknown'; | ||||
| 			} | ||||
| 		} | ||||
| 		return $gameMode; | ||||
| 	} | ||||
| } | ||||
| @@ -19,7 +19,8 @@ class Server implements CallbackListener { | ||||
| 	/* | ||||
| 	 * Constants | ||||
| 	 */ | ||||
| 	const TABLE_SERVERS = 'mc_servers'; | ||||
| 	const TABLE_SERVERS        = 'mc_servers'; | ||||
| 	const CB_TEAM_MODE_CHANGED = 'Server.TeamModeChanged'; | ||||
|  | ||||
| 	/* | ||||
| 	 * Public Properties | ||||
| @@ -37,12 +38,12 @@ class Server implements CallbackListener { | ||||
| 	public $usageReporter = null; | ||||
| 	public $rankingManager = null; | ||||
| 	public $scriptManager = null; | ||||
| 	public $matchSettingsManager = null; | ||||
|  | ||||
| 	/* | ||||
| 	 * Private Properties | ||||
| 	 */ | ||||
| 	private $maniaControl = null; | ||||
| 	private $teamMode = null; | ||||
|  | ||||
| 	/** | ||||
| 	 * Construct a new Server | ||||
| @@ -53,11 +54,10 @@ class Server implements CallbackListener { | ||||
| 		$this->maniaControl = $maniaControl; | ||||
| 		$this->initTables(); | ||||
|  | ||||
| 		$this->serverCommands       = new ServerCommands($maniaControl); | ||||
| 		$this->usageReporter        = new UsageReporter($maniaControl); | ||||
| 		$this->rankingManager       = new RankingManager($maniaControl); | ||||
| 		$this->scriptManager        = new ScriptManager($maniaControl); | ||||
| 		$this->matchSettingsManager = new MatchSettingsManager($maniaControl); | ||||
| 		$this->serverCommands = new ServerCommands($maniaControl); | ||||
| 		$this->usageReporter  = new UsageReporter($maniaControl); | ||||
| 		$this->rankingManager = new RankingManager($maniaControl); | ||||
| 		$this->scriptManager  = new ScriptManager($maniaControl); | ||||
|  | ||||
| 		// Register for callbacks | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'onInit'); | ||||
| @@ -290,7 +290,7 @@ class Server implements CallbackListener { | ||||
|  | ||||
| 		// Build file name | ||||
| 		$map      = $this->maniaControl->mapManager->getCurrentMap(); | ||||
| 		$gameMode = $this->matchSettingsManager->getGameMode(); | ||||
| 		$gameMode = $this->getGameMode(); | ||||
| 		$time     = time(); | ||||
| 		$fileName = "GhostReplays/Ghost.{$login}.{$gameMode}.{$time}.{$map->uid}.Replay.Gbx"; | ||||
|  | ||||
| @@ -327,6 +327,42 @@ class Server implements CallbackListener { | ||||
| 		return (is_dir($directory) && is_writable($directory)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Fetch the current Game Mode | ||||
| 	 * | ||||
| 	 * @param bool $stringValue | ||||
| 	 * @param int  $parseValue | ||||
| 	 * @return int | string | ||||
| 	 */ | ||||
| 	public function getGameMode($stringValue = false, $parseValue = null) { | ||||
| 		if (is_int($parseValue)) { | ||||
| 			$gameMode = $parseValue; | ||||
| 		} else { | ||||
| 			$gameMode = $this->maniaControl->client->getGameMode(); | ||||
| 		} | ||||
| 		if ($stringValue) { | ||||
| 			switch ($gameMode) { | ||||
| 				case 0: | ||||
| 					return 'Script'; | ||||
| 				case 1: | ||||
| 					return 'Rounds'; | ||||
| 				case 2: | ||||
| 					return 'TimeAttack'; | ||||
| 				case 3: | ||||
| 					return 'Team'; | ||||
| 				case 4: | ||||
| 					return 'Laps'; | ||||
| 				case 5: | ||||
| 					return 'Cup'; | ||||
| 				case 6: | ||||
| 					return 'Stunts'; | ||||
| 				default: | ||||
| 					return 'Unknown'; | ||||
| 			} | ||||
| 		} | ||||
| 		return $gameMode; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Wait for the Server to have the given Status | ||||
| 	 * | ||||
| @@ -361,37 +397,27 @@ class Server implements CallbackListener { | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Set whether the Server Runs a Team-Based Mode or not | ||||
| 	 * | ||||
| 	 * @deprecated Use MatchSettingsManager instead | ||||
| 	 * @param bool $teamMode | ||||
| 	 */ | ||||
| 	public function setTeamMode($teamMode = true) { | ||||
| 		$this->matchSettingsManager->setTeamMode($teamMode); | ||||
| 		$oldStatus      = $this->teamMode; | ||||
| 		$this->teamMode = (bool)$teamMode; | ||||
|  | ||||
| 		// Trigger callback | ||||
| 		if ($oldStatus !== $this->teamMode | $oldStatus === null) { | ||||
| 			$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_MODE_CHANGED, $teamMode); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if the Server Runs a Team-Based Mode | ||||
| 	 * | ||||
| 	 * @deprecated Use MatchSettingsManager instead | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function isTeamMode() { | ||||
| 		$this->matchSettingsManager->isTeamMode(); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Fetch the current Game Mode | ||||
| 	 * | ||||
| 	 * @deprecated Use MatchSettingsManager instead | ||||
| 	 * @param bool $stringValue | ||||
| 	 * @param int  $parseValue | ||||
| 	 * @return int | string | ||||
| 	 */ | ||||
| 	public function getGameMode($stringValue = false, $parseValue = null) { | ||||
| 		$this->matchSettingsManager->getGameMode($stringValue, $parseValue); | ||||
| 		return $this->teamMode; | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user