/// <summary> /// Removes the <see cref="LogicServerCommand"/> instance. /// </summary> public LogicServerCommand RemoveServerCommand() { LogicServerCommand tmp = this._serverCommand; this._serverCommand = null; return(tmp); }
public void AddServerCommand(LogicServerCommand serverCommand) { int id = -1; for (int i = 0; i < this.ServerCommands.Size(); i++) { if (this.ServerCommands[i].GetId() > id) { id = this.ServerCommands[i].GetId(); } } serverCommand.SetId(id + 1); this.ServerCommands.Add(serverCommand); if (this.CurrentSession != null && this.CurrentSession.GameState != null) { this.CurrentSession.SendMessage(new HomeServerCommandAllowedMessage { ServerCommand = serverCommand }, 10); } else { GameAvatarManager.ExecuteServerCommandsInOfflineMode(this); GameAvatarManager.Save(this); } }
/// <summary> /// Destructs this instance. /// </summary> public override void Destruct() { base.Destruct(); if (this._serverCommand != null) { this._serverCommand.Destruct(); this._serverCommand = null; } }
public void AllowServerCommand(LogicServerCommand serverCommand) { foreach (long id in this.Members.Keys) { ServerMessageManager.SendMessage(new GameAllowServerCommandMessage { AccountId = id, ServerCommand = serverCommand }, 9); } }
public void AddServerCommand(LogicServerCommand serverCommand) { if (this.m_logicGameMode.GetState() != 1) { throw new Exception("GameMode.addServerCommand: Method called in invalid game state."); } this.m_serverCommandStorage.AddServerCommand(serverCommand); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(serverCommand); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); }
public void CheckExecutableServerCommands(int endSubTick, LogicArrayList <LogicCommand> commands) { for (int i = 0; i < commands.Size(); i++) { LogicCommand command = commands[i]; if (command.IsServerCommand()) { if (this.m_logicGameMode.GetState() != 1) { commands.Remove(i--); continue; } LogicServerCommand serverCommand = (LogicServerCommand)command; LogicServerCommand bufferedServerCommand = null; for (int j = 0; j < this.m_bufferedServerCommands.Size(); j++) { LogicServerCommand tmp = this.m_bufferedServerCommands[j]; if (tmp.GetId() == serverCommand.GetId()) { bufferedServerCommand = tmp; } } if (bufferedServerCommand == null || bufferedServerCommand.GetCommandType() != serverCommand.GetCommandType() || bufferedServerCommand.GetExecuteSubTick() != -1 && bufferedServerCommand.GetExecuteSubTick() >= this.m_logicGameMode.GetLevel().GetLogicTime().GetTick()) { commands.Remove(i--); continue; } bufferedServerCommand.SetExecuteSubTick(serverCommand.GetExecuteSubTick()); commands[i] = bufferedServerCommand; } } }
/// <summary> /// Initializes a new instance of the <see cref="AvailableServerCommandMessage"/> class. /// </summary> public AvailableServerCommandMessage(Connection connection, LogicServerCommand command) : base(connection) { this.Type = Message.AvailableServerCommand; this.Command = command; }
/// <summary> /// Sets the <see cref="LogicServerCommand"/> instance. /// </summary> public void SetServerCommand(LogicServerCommand command) { this._serverCommand = command; }
/// <summary> /// Decodes this instance. /// </summary> public override void Decode() { base.Decode(); this._serverCommand = LogicCommandManager.DecodeCommand(this.Stream) as LogicServerCommand; }
public override void Decode(ByteStream stream) { this.ServerCommand = (LogicServerCommand)LogicCommandManager.DecodeCommand(stream); }
private static void OnHomeStateCallbackMessageReceived(GameStateCallbackMessage message) { if (GameAvatarManager.TryGet(message.AccountId, out GameAvatar gameDocument)) { gameDocument.LogicClientAvatar = message.LogicClientAvatar; if (message.HomeJSON != null) { for (int i = 0; i < message.ExecutedServerCommands.Size(); i++) { LogicServerCommand serverCommand = message.ExecutedServerCommands[i]; for (int j = 0; j < gameDocument.ServerCommands.Size(); j++) { if (gameDocument.ServerCommands[j].GetId() == serverCommand.GetId()) { gameDocument.ServerCommands.Remove(j); break; } } } gameDocument.LogicClientHome.GetCompressibleHomeJSON().Set(message.HomeJSON); gameDocument.LogicClientHome.SetShieldDurationSeconds(message.RemainingShieldTime); gameDocument.LogicClientHome.SetGuardDurationSeconds(message.RemainingGuardTime); gameDocument.LogicClientHome.SetPersonalBreakSeconds(message.NextPersonalBreakTime); gameDocument.SaveTime = message.SaveTime; } if (gameDocument.LogicClientAvatar.IsInAlliance() && message.AvatarChanges.Size() != 0) { ServerMessageManager.SendMessage(new AllianceAvatarChangesMessage { AccountId = gameDocument.LogicClientAvatar.GetAllianceId(), MemberId = gameDocument.LogicClientAvatar.GetId(), AvatarChanges = message.AvatarChanges }, 11); } GameSession currentSession = gameDocument.CurrentSession; if (currentSession != null) { DateTime utc = DateTime.UtcNow; if (utc.Subtract(currentSession.LastDbSave).TotalSeconds > 2) { GameAvatarManager.Save(gameDocument); currentSession.LastDbSave = utc; } if (message.SessionId != currentSession.Id) { currentSession.SendPiranhaMessage(new OutOfSyncMessage(), 1); currentSession.SendMessage(new StopSessionMessage { Reason = 1 }, 1); return; } if (message.AvatarChanges.Size() != 0) { for (int i = 0; i < message.AvatarChanges.Size(); i++) { if (message.AvatarChanges[i].GetAvatarChangeType() == AvatarChangeType.ALLIANCE_JOINED) { currentSession.BindAllianceServer(); } } } } else { GameAvatarManager.Save(gameDocument); } } }
public void AddServerCommand(LogicServerCommand serverCommand) { this.m_bufferedServerCommands.Add(serverCommand); }