public override void Decode() { base.Decode(); this.m_streamHeaderJson = this.m_stream.ReadString(900000); this.m_compressedstreamHeaderJson = this.m_stream.ReadBytes(this.m_stream.ReadBytesLength(), 900000); this.m_serverSubTick = this.m_stream.ReadInt(); int count = this.m_stream.ReadInt(); if (count <= 512) { if (count > 0) { this.m_commands = new LogicArrayList <LogicCommand>(count); for (int i = 0; i < count; i++) { LogicCommand command = LogicCommandManager.DecodeCommand(this.m_stream); if (command != null) { this.m_commands.Add(command); } } } } else { Debugger.Error(string.Format("LiveReplayHeaderMessage::decode() command count is too high! ({0})", count)); } this.m_stream.ReadInt(); }
/// <summary> /// Decodes this instance. /// </summary> public override void Decode() { base.Decode(); this._subTick = this.Stream.ReadInt(); this._checksum = this.Stream.ReadInt(); int arraySize = this.Stream.ReadInt(); if (arraySize <= 512) { if (arraySize > 0) { this._commands = new LogicArrayList <LogicCommand>(arraySize); do { LogicCommand command = LogicCommandManager.DecodeCommand(this.Stream); if (command == null) { break; } this._commands.Add(command); } while (--arraySize != 0); } } }
private static LogicCommand[] CreateFunctions() { LogicCommand[] cmds = new LogicCommand[] { new LogicCommand(0), new LogicCommand(LogicFunctionCode.EqualN, LogicArgumentType.Variable, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.EqualV, LogicArgumentType.Variable, LogicArgumentType.Variable), new LogicCommand(LogicFunctionCode.LessN, LogicArgumentType.Variable, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.LessV, LogicArgumentType.Variable, LogicArgumentType.Variable), new LogicCommand(LogicFunctionCode.GreaterN, LogicArgumentType.Variable, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.GreaterV, LogicArgumentType.Variable, LogicArgumentType.Variable), new LogicCommand(LogicFunctionCode.IsSet, LogicArgumentType.Flag), new LogicCommand(LogicFunctionCode.IsSetV, LogicArgumentType.Variable), new LogicCommand(LogicFunctionCode.Has, LogicArgumentType.InventoryObject), new LogicCommand(LogicFunctionCode.ObjInRoom, LogicArgumentType.InventoryObject, LogicArgumentType.Variable), new LogicCommand(LogicFunctionCode.PosN, LogicArgumentType.ScreenObject, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.Controller, LogicArgumentType.Control), new LogicCommand(LogicFunctionCode.HaveKey), new LogicCommand(LogicFunctionCode.Said), new LogicCommand(LogicFunctionCode.CompareStrings, LogicArgumentType.String, LogicArgumentType.String), new LogicCommand(LogicFunctionCode.ObjInBox, LogicArgumentType.ScreenObject, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.CenterPosN, LogicArgumentType.ScreenObject, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number), new LogicCommand(LogicFunctionCode.RightPosN, LogicArgumentType.ScreenObject, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number, LogicArgumentType.Number), }; return(cmds); }
internal override void Handle() { if (this.Commands != null) { while (this.Commands.Size > 0) { LogicCommand command = this.Commands[0]; if (command.ExecuteSubTick != -1) { if (command.ExecuteSubTick <= this.SubTick) { if (this.Connection.Avatar.Time.ClientSubTick <= command.ExecuteSubTick) { this.Connection.Avatar.Time.ClientSubTick = command.ExecuteSubTick; this.Connection.Avatar.Tick(); command.Execute(); } } else { Debugger.Error($"Execute command failed! Command should already executed. (type={command.Type}, server_tick)"); } } else { Debugger.Error("Execute command failed! subtick is not valid."); } this.Commands.RemoveAt(0); } } }
public LogicCommand RemoveServerCommand() { LogicCommand tmp = this.m_serverCommand; this.m_serverCommand = null; return(tmp); }
public override void Decode() { base.Decode(); this.m_serverSubTick = this.m_stream.ReadVInt(); this.m_viewerCount = this.m_stream.ReadVInt(); this.m_enemyViewerCount = this.m_stream.ReadVInt(); int count = this.m_stream.ReadInt(); if (count <= 512) { if (count > 0) { this.m_commands = new LogicArrayList <LogicCommand>(count); for (int i = 0; i < count; i++) { LogicCommand command = LogicCommandManager.DecodeCommand(this.m_stream); if (command != null) { this.m_commands.Add(command); } } } } else { Debugger.Error(string.Format("LiveReplayDataMessage::decode() command count is too high! ({0})", count)); } }
public override void Decode() { base.Decode(); this.m_subTick = this.m_stream.ReadInt(); this.m_checksum = this.m_stream.ReadInt(); int arraySize = this.m_stream.ReadInt(); if (arraySize <= 512) { if (arraySize > 0) { this.m_commands = new LogicArrayList <LogicCommand>(arraySize); do { LogicCommand command = LogicCommandManager.DecodeCommand(this.m_stream); if (command == null) { break; } this.m_commands.Add(command); } while (--arraySize != 0); } } else { Debugger.Error(string.Format("BattleEndClientTurn::decode() command count is too high! ({0})", arraySize)); } }
/// <summary> /// Initializes a new instance of the <see cref="LogicBuyResourcesCommand" /> class. /// </summary> public LogicBuyResourcesCommand(LogicResourceData data, int resourceCount, LogicResourceData resource2Data, int resource2Count, LogicCommand resourceCommand) { this._resourceData = data; this._resource2Data = resource2Data; this._command = resourceCommand; this._resourceCount = resourceCount; this._resource2Count = resource2Count; }
public override void CommandExecuted(LogicCommand command) { if (command.IsServerCommand()) { this.m_bufferedServerCommands.Remove(this.m_bufferedServerCommands.IndexOf((LogicServerCommand)command)); this.m_executedServerCommands.Add((LogicServerCommand)command); } }
/// <summary> /// Records the command. /// </summary> public void RecordCommand(LogicCommand command) { LogicJSONArray commandArray = this._replayObject.GetJSONArray("cmd"); LogicJSONObject commandObject = new LogicJSONObject(); LogicCommandManager.SaveCommandToJSON(commandObject, command); commandArray.Add(commandObject); }
/// <summary> /// Destructs this instance. /// </summary> public override void Destruct() { base.Destruct(); if (this._command != null) { this._command.Destruct(); this._command = null; } }
/// <summary> /// Decodes this instnace. /// </summary> public override void Decode(ByteStream stream) { base.Decode(stream); this._villageType = stream.ReadInt(); if (stream.ReadBoolean()) { this._command = LogicCommandManager.DecodeCommand(stream); } }
public void CheckExecutableServerCommands(int endSubTick, LogicArrayList <LogicCommand> commands) { for (int i = 0; i < commands.Size(); i++) { LogicCommand command = commands[i]; if (command.IsServerCommand()) { commands.Remove(i--); } } }
/// <summary> /// Destructs this instance. /// </summary> public override void Destruct() { base.Destruct(); if (this._command != null) { this._command.Destruct(); this._command = null; } this._resourceData = null; this._resource2Data = null; }
private LogicArrayList <LogicCommand> GetCommands(int minSubTick, int maxSubTick) { LogicArrayList <LogicCommand> commands = new LogicArrayList <LogicCommand>(); for (int i = 0; i < this.m_commands.Size(); i++) { LogicCommand command = this.m_commands[i]; if (command.GetExecuteSubTick() >= minSubTick && command.GetExecuteSubTick() < maxSubTick) { commands.Add(command); } } return(commands); }
/// <summary> /// Decodes this instnace. /// </summary> public override void Decode(ByteStream stream) { this._resourceCount = stream.ReadInt(); this._resourceData = (LogicResourceData)stream.ReadDataReference(2); this._resource2Count = stream.ReadInt(); if (this._resource2Count > 0) { this._resource2Data = (LogicResourceData)stream.ReadDataReference(2); } if (stream.ReadBoolean()) { this._command = LogicCommandManager.DecodeCommand(stream); } base.Decode(stream); }
public override void Decode(ByteStream stream) { this.m_resourceCount = stream.ReadInt(); this.m_resourceData = (LogicResourceData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.RESOURCE); this.m_resource2Count = stream.ReadInt(); if (this.m_resource2Count > 0) { this.m_resource2Data = (LogicResourceData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.RESOURCE); } if (stream.ReadBoolean()) { this.m_command = LogicCommandManager.DecodeCommand(stream); } base.Decode(stream); }
internal override void Decode() { this.SubTick = this.Stream.ReadInt(); this.Checksum = this.Stream.ReadInt(); this.CommandCount = this.Stream.ReadInt(); if (this.CommandCount <= 512) { if (this.CommandCount > 0) { this.Commands = new LogicArrayList <LogicCommand>(this.CommandCount); for (int i = 0; i < this.CommandCount; i++) { int commandID = this.Stream.ReadInt(); Debugger.Debug(commandID); return; if (commandID >= 600) { LogicCommand command = LogicCommandManager.CreateCommand(commandID, this.Connection, this.Stream); if (command != null) { // if (LogicCommandManager.IsCommandAllowedInCurrentState(command)) { Debugger.Info($"Battle Command {command.GetType().Name.Pad(34)} received from {this.Connection.EndPoint}."); command.Decode(); this.Commands.Add(command); } } else { this.ShowBuffer(); } } } } } }
internal override void Handle() { if (this.Commands != null) { while (this.Commands.Size > 0) { LogicCommand command = this.Commands[0]; if (command.ExecuteSubTick != -1) { if (command.ExecuteSubTick <= this.SubTick) { if (this.Connection.Avatar.Time.ClientSubTick <= command.ExecuteSubTick) { this.Connection.Avatar.Time.ClientSubTick = command.ExecuteSubTick; this.Connection.Avatar.Tick(); command.Execute(); } } else { Debugger.Error($"Execute command failed! Command should already executed. (type={command.Type}, server_tick)"); } } else { Debugger.Error("Execute command failed! subtick is not valid."); } this.Commands.RemoveAt(0); } } this.Connection.Avatar.Time.ClientSubTick = this.SubTick; this.Connection.Avatar.Tick(); Debugger.Debug($"Client Time : MS={this.Connection.Avatar.Time.TotalMS} SECS={this.Connection.Avatar.Time.TotalSecs}."); Debugger.Debug($"Checksum : CLIENT={this.Checksum - this.Connection.Avatar.Time.ClientSubTick} SERVER={this.Connection.Avatar.Checksum}."); }
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; } } }
public virtual void NotEnoughWorkers(LogicCommand command, int villageType) { }
public void SetServerCommand(LogicCommand command) { this.m_serverCommand = command; }
/// <summary> /// Initializes a new instance of the <see cref="LogicBuyResourcesCommand" /> class. /// </summary> public LogicFreeWorkerCommand(LogicCommand resourceCommand, int villageType) { this._command = resourceCommand; this._villageType = villageType; }
public override void CommandExecuted(LogicCommand command) { }
public void Trace(LogicCommand command, int operatorIndex, bool said, int result, int messageIndexOffset) { if (command == null) { throw new ArgumentNullException(nameof(command)); } this.WindowManager.PushTextPosition(); this.WindowManager.PushTextColor(); this.WindowManager.SetTextColor(0, 0x0f); this.ScrollTraceWindow(); if (this.Logic0Called) { this.Logic0Called = false; this.WindowManager.PrintFormatted(UserInterface.TraceSeparatorLine); this.ScrollTraceWindow(); } LogicResource originalLogic = this.LogicInterpreter.CurrentLogic; if (this.TraceLogicIndex == 0 || (this.LogicInterpreter.CurrentLogic = this.ResourceManager.FindLogic(this.TraceLogicIndex)) == null) { this.WindowManager.PrintFormatted(UserInterface.TraceProcedureNumber, originalLogic.ResourceIndex, command.Code); } else { if (command.Code == 0) { this.WindowManager.PrintFormatted(UserInterface.TraceProcedureText, originalLogic.ResourceIndex, UserInterface.TraceProcedureReturn); } else { string message = this.LogicInterpreter.CurrentLogic.GetMessage(command.Code + messageIndexOffset); if (message != null) { this.WindowManager.PrintFormatted(UserInterface.TraceProcedureText, this.LogicInterpreter.CurrentLogic.ResourceIndex, message); } else { if (result != 0xffff) { this.WindowManager.PrintFormatted(UserInterface.TraceFunctionNumber, this.LogicInterpreter.CurrentLogic.ResourceIndex, command.Code); } else { this.WindowManager.PrintFormatted(UserInterface.TraceProcedureNumber, this.LogicInterpreter.CurrentLogic.ResourceIndex, command.Code); } } } } this.LogicInterpreter.CurrentLogic = originalLogic; this.TraceParameters(command, operatorIndex, said); if (result != 0xffff) { this.WindowManager.GotoPosition(new TextPosition(this.TraceBottom, (byte)(this.TraceRight - 2))); this.WindowManager.PrintFormatted(UserInterface.TraceFunctionResult, result == 0 ? UserInterface.TraceFunctionResultFalse : UserInterface.TraceFunctionResultTrue); } this.WindowManager.UpdateTextRegion(); this.TraceState = this.Poll(); this.WindowManager.PopTextPosition(); this.WindowManager.PopTextColor(); this.WindowManager.UpdateTextRegion(); }
public virtual void CommandExecuted(LogicCommand command) { // CommandExecuted. }
public override void Destruct() { base.Destruct(); this.m_serverCommand = null; }
public virtual void NotEnoughResources(LogicResourceData data1, int count1, LogicResourceData data2, int count2, LogicCommand command, bool unk) { }
public override void Decode() { base.Decode(); this.m_serverCommand = LogicCommandManager.DecodeCommand(this.m_stream); }
private void TraceParameters(LogicCommand command, int operatorIndex, bool said) { int parameterCount = command.ParameterCount; this.WindowManager.PushTextPosition(); if (said) { parameterCount = this.LogicInterpreter.CurrentLogic.GetCode(operatorIndex++); } this.WindowManager.DisplayCharacter(UserInterface.TraceParameterStart[0]); for (int param = 0; param < parameterCount; param++) { int val = this.GetTraceParameterValue(operatorIndex, param, said); if (said) { this.WindowManager.PrintFormatted(UserInterface.TraceParameterSigned, val); } else { this.WindowManager.PrintFormatted(UserInterface.TraceParameterUnsigned, val); } if (param < (parameterCount - 1)) { this.WindowManager.DisplayCharacter(UserInterface.TraceParameterSeparator[0]); } } this.WindowManager.DisplayCharacter(UserInterface.TraceParameterEnd[0]); bool anyVariables = false; if (!said) { for (int param = 0; param < parameterCount; param++) { LogicArgumentType type = command.GetParameterType(param); if (type == LogicArgumentType.Variable) { anyVariables = true; } } } if (anyVariables) { this.ScrollTraceWindow(); } this.WindowManager.PopTextPosition(); if (anyVariables) { this.WindowManager.DisplayCharacter(UserInterface.TraceParameterStart[0]); for (int param = 0; param < parameterCount; param++) { int val = this.GetTraceParameterValue(operatorIndex, param, said); LogicArgumentType type = command.GetParameterType(param); if (type == LogicArgumentType.Variable) { this.WindowManager.PrintFormatted(UserInterface.TraceParameterSigned, this.State.Variables[val]); } else { this.WindowManager.PrintFormatted(UserInterface.TraceParameterSigned, val); } if (param < (parameterCount - 1)) { this.WindowManager.DisplayCharacter(UserInterface.TraceParameterSeparator[0]); } } this.WindowManager.DisplayCharacter(UserInterface.TraceParameterEnd[0]); } }