internal override void Receive() { if (!Config.IsSinglePlayer) { lock (TcpClient) { base.Receive(); var bytes = ReadStream(DataLength); CommandType = (ServerCommandType)BitConverter.ToUInt16(bytes, 0); Param = BitConverter.ToSingle(bytes, sizeof(ushort)); } } switch (CommandType) { case ServerCommandType.ServerVersion: new ServerMsg(Settings.VersionDisplay, ConnectedPlayer).Send(); break; case ServerCommandType.WorldSize: string message = !File.Exists(Settings.WorldFilePath) ? string.Format("World file not found @ {0}", Settings.WorldFilePath) : string.Format("World size {0}x{1} ({2} KB)", WorldData.SizeInBlocksX, WorldData.SizeInBlocksZ, new FileInfo(Settings.WorldFilePath).Length / 1024); new ServerMsg(message, ConnectedPlayer).Send(); break; case ServerCommandType.MoveSun: if (IsAdmin) { Debug.Assert(Param >= 0 && Param <= 360, "Invalid degrees to move sun: " + Param); SkyHost.SunAngleRadians = OpenTK.MathHelper.DegreesToRadians(Param); //send a sync to each player immediately foreach (var player in Server.Controller.Players.Values) { new ServerSync(SkyHost.SunAngleRadians, player).Send(); } //send confirmation to player that made the change new ServerMsg(string.Format("Moved sun to {0} degrees.", Param), ConnectedPlayer).Send(); } else { ConnectedPlayer.SendAdminRequiredMessage(); } break; case ServerCommandType.Broadcast: if (IsAdmin) { ServerMsg.Broadcast("Player sent broadcast message."); //theres no way to send the actual message from the client to broadcast yet } else { ConnectedPlayer.SendAdminRequiredMessage(); } break; } }
public ServerCommand(ServerCommandType _type, int _timer = 0, string[] _songs = null, string _selectedLevelID = null, int _difficulty = 0, string[] _playerInfos = null, double _selectedSongDuration = 0, double _selectedSongPlayTime = 0) { commandType = _type; lobbyTimer = _timer; songsToDownload = _songs; selectedLevelID = _selectedLevelID; selectedSongDifficlty = _difficulty; playerInfos = _playerInfos; selectedSongDuration = _selectedSongDuration; selectedSongPlayTime = _selectedSongPlayTime; }
public ServerCommand(ServerCommandType _type, int _timer = 0, string[] _songs = null, string _selectedLevelID = null, int _difficulty = 0, string[] _playerInfos = null, double _selectedSongDuration = 0, double _selectedSongPlayTime = 0) { version = Assembly.GetEntryAssembly().GetName().Version.ToString(); commandType = _type; lobbyTimer = _timer; songsToDownload = _songs; serverState = ServerMain.serverState; selectedLevelID = _selectedLevelID; selectedSongDifficlty = _difficulty; playerInfos = _playerInfos; selectedSongDuration = _selectedSongDuration; selectedSongPlayTime = _selectedSongPlayTime; }
public ServerCommand(ServerCommandType _type, int _timer = 0, string[] _songs = null, int _difficulty = 0, string[] _playerInfos = null, double _selectedSongDuration = 0, double _selectedSongPlayTime = 0, string _kickReason = null) { version = Assembly.GetEntryAssembly().GetName().Version.ToString(); commandType = _type; lobbyTimer = _timer; songsToDownload = _songs; serverState = ServerMain.serverState; selectedLevelID = (ServerMain.currentSongIndex >= 0 && ServerMain.availableSongs.Count > ServerMain.currentSongIndex) ? ServerMain.availableSongs[ServerMain.currentSongIndex].levelId : ""; selectedSongDifficlty = _difficulty; playerInfos = _playerInfos; selectedSongDuration = _selectedSongDuration; selectedSongPlayTime = _selectedSongPlayTime; kickReason = _kickReason; noFailMode = Settings.Instance.Server.NoFailMode; scoreboardScoreFormat = Settings.Instance.Server.ScoreboardScoreFormat; }
public static ServerCommand CreateServerCommand(ServerCommandType type, object payload) => new ServerCommand(type, JObject.FromObject(payload));
public ServerCommand(ServerCommandType commandType, float param = 0) : this() { CommandType = commandType; Param = param; }
public Command(Server server, string type) { Server = server; this.commandtype = new ServerCommandType(type); }
protected RconCommand(ServerCommandType commandType) { CommandType = commandType; }
protected RconCommand(ServerCommandType commandType) { CommandType = commandType; }