/// <summary> /// Destructs this instance. /// </summary> public void Destruct() { if (this._level != null) { this._level.Destruct(); this._level = null; } if (this._commandManager != null) { this._commandManager.Destruct(); this._commandManager = null; } if (this._calendar != null) { this._calendar.Destruct(); this._calendar = null; } if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } if (this._replay != null) { this._replay.Destruct(); this._replay = null; } this._configuration = null; }
protected override void Decode(ByteStream stream) { this.LogicClientAvatar.Decode(stream); this.LogicClientHome.Decode(stream); this.ServerCommands.Clear(); this.RecentlyMatchedEnemies.Clear(); this.AllianceBookmarksList.Clear(); this.AvatarStreamList.Clear(); for (int i = stream.ReadVInt(); i > 0; i--) { this.ServerCommands.Add((LogicServerCommand)LogicCommandManager.DecodeCommand(stream)); } for (int i = stream.ReadVInt(); i > 0; i--) { this.RecentlyMatchedEnemies.Add(new RecentlyEnemy(stream.ReadLong(), stream.ReadVInt())); } for (int i = stream.ReadVInt(); i > 0; i--) { this.AllianceBookmarksList.Add(stream.ReadLong()); } for (int i = stream.ReadVInt(); i > 0; i--) { this.AvatarStreamList.Add(stream.ReadLong()); } this.SaveTime = stream.ReadVInt(); this.MaintenanceTime = stream.ReadVInt(); }
public override void Decode(ByteStream stream) { this.SessionId = stream.ReadLongLong(); this.AvatarChanges = new LogicArrayList <AvatarChange>(); for (int i = stream.ReadVInt(); i > 0; i--) { this.AvatarChanges.Add(AvatarChangeFactory.Decode(stream)); } this.LogicClientAvatar = new LogicClientAvatar(); this.LogicClientAvatar.Decode(stream); if (stream.ReadBoolean()) { this.ExecutedServerCommands = new LogicArrayList <LogicServerCommand>(); for (int i = stream.ReadVInt(); i > 0; i--) { this.ExecutedServerCommands.Add((LogicServerCommand)LogicCommandManager.DecodeCommand(stream)); } this.SaveTime = stream.ReadVInt(); this.RemainingShieldTime = stream.ReadVInt(); this.RemainingGuardTime = stream.ReadVInt(); this.NextPersonalBreakTime = stream.ReadVInt(); this.HomeJSON = stream.ReadBytes(stream.ReadBytesLength(), 900000); } }
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 Resources() { Configuration = new Configuration(); Configuration.Initialize(); _logger = new Logger(); Csv = new Csv(); Fingerprint = new Fingerprint(); _mysql = new MySQL(); if (!string.IsNullOrEmpty(Configuration.RedisPassword) && !string.IsNullOrEmpty(Configuration.RedisServer)) { _redis = new Redis(); } _messagefactory = new LogicMagicMessageFactory(); _commandfactory = new LogicCommandManager(); _debugcommandfactory = new DebugCommandFactory(); Levels = new Levels(); PlayerCache = new PlayerCache(); AllianceCache = new AllianceCache(); LeaderboardCache = new LeaderboardCache(); ChatManager = new LogicGlobalChatManager(); Gateway = new Gateway(); }
public override void Encode(ByteStream stream) { stream.WriteLongLong(this.SessionId); stream.WriteVInt(this.AvatarChanges.Size()); for (int i = 0; i < this.AvatarChanges.Size(); i++) { AvatarChangeFactory.Encode(stream, this.AvatarChanges[i]); } this.LogicClientAvatar.Encode(stream); if (this.HomeJSON != null) { stream.WriteBoolean(true); stream.WriteVInt(this.ExecutedServerCommands.Size()); for (int i = 0; i < this.ExecutedServerCommands.Size(); i++) { LogicCommandManager.EncodeCommand(stream, this.ExecutedServerCommands[i]); } stream.WriteVInt(this.SaveTime); stream.WriteVInt(this.RemainingShieldTime); stream.WriteVInt(this.RemainingGuardTime); stream.WriteVInt(this.NextPersonalBreakTime); stream.WriteBytes(this.HomeJSON, this.HomeJSON.Length); } else { stream.WriteBoolean(false); } }
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(); }
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> /// 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); } } }
internal override void Handle() { if (this.Message.StartsWith(LogicCommandManager.Delimiter)) { string[] commands = this.Message.Remove(0, 1).Split(' '); if (commands.Length > 0) { string command = commands[0]; string[] arguments = commands.Skip(1).ToArray(); LogicChatCommand debug = LogicCommandManager.CreateChatCommand(command, this.Connection, arguments); if (debug != null) { Debugger.Info($"Chat Command {command} has been handled."); try { debug.Process(); } catch (Exception exception) { Debugger.Error($"Failed to handle the chat command : {command}!"); } } } } else { this.Connection.SendChatMessage(this.Message, false); } }
/// <summary> /// Initializes a new instance of the <see cref="LogicGameMode" /> class. /// </summary> public LogicGameMode() { this._level = new LogicLevel(this); this._commandManager = new LogicCommandManager(this._level); this._calendar = new LogicCalendar(); this._configuration = new LogicConfiguration(); this._currentTimestamp = -1; }
/// <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> /// 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 override void Encode(ByteStream stream) { base.Encode(stream); stream.WriteVInt(this.MaintenanceTime); stream.WriteVInt(this.LayoutId); stream.WriteVInt(this.MapId); for (int i = 0; i < this.ServerCommands.Size(); i++) { LogicCommandManager.EncodeCommand(stream, this.ServerCommands[i]); } }
public override void Decode(ByteStream stream) { base.Decode(stream); this.MaintenanceTime = stream.ReadVInt(); this.LayoutId = stream.ReadVInt(); this.MapId = stream.ReadVInt(); this.ServerCommands = new LogicArrayList <LogicServerCommand>(); for (int i = stream.ReadVInt(); i > 0; i--) { this.ServerCommands.Add((LogicServerCommand)LogicCommandManager.DecodeCommand(stream)); } }
public void Dispose() { Csv = null; Gateway = null; PlayerCache = null; Configuration = null; Levels = null; Fingerprint = null; _messagefactory = null; _commandfactory = null; _debugcommandfactory = null; _mysql = null; _logger = null; }
/// <summary> /// Encodes this instance. /// </summary> public override void Encode(ChecksumEncoder encoder) { base.Encode(encoder); encoder.WriteInt(this._villageType); if (this._command != null) { encoder.WriteBoolean(true); LogicCommandManager.EncodeCommand(encoder, this._command); } else { encoder.WriteBoolean(false); } }
public override void Decode(ByteStream stream) { this.SubTick = stream.ReadVInt(); int count = stream.ReadVInt(); if (count >= 0) { this.Commands = new LogicArrayList <LogicCommand>(count); for (int i = 0; i < count; i++) { this.Commands.Add(LogicCommandManager.DecodeCommand(stream)); } } }
/// <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 Encode(ByteStream stream) { stream.WriteVInt(this.SubTick); if (this.Commands != null) { stream.WriteVInt(this.Commands.Size()); for (int i = 0; i < this.Commands.Size(); i++) { LogicCommandManager.EncodeCommand(stream, this.Commands[i]); } } else { stream.WriteVInt(-1); } }
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(); } } } } } }
public override void Encode() { base.Encode(); this.m_stream.WriteInt(this.m_subTick); this.m_stream.WriteInt(this.m_checksum); if (this.m_commands != null) { this.m_stream.WriteInt(this.m_commands.Size()); for (int i = 0; i < this.m_commands.Size(); i++) { LogicCommandManager.EncodeCommand(this.m_stream, this.m_commands[i]); } } else { this.m_stream.WriteInt(-1); } }
public override void Encode() { base.Encode(); this.m_stream.WriteVInt(this.m_serverSubTick); this.m_stream.WriteVInt(this.m_viewerCount); this.m_stream.WriteVInt(this.m_enemyViewerCount); if (this.m_commands != null) { this.m_stream.WriteInt(this.m_commands.Size()); for (int i = 0; i < this.m_commands.Size(); i++) { LogicCommandManager.EncodeCommand(this.m_stream, this.m_commands[i]); } } else { this.m_stream.WriteInt(0); } }
public Resources() { Configuration = new Configuration(); Configuration.Initialize(); _logger = new Logger(); Logger.Log($"ENV: {(Utils.IsLinux ? "Linux" : "Windows")}"); Csv = new Csv(); Fingerprint = new Fingerprint(); _playerDb = new PlayerDb(); _replayDb = new ReplayDb(); _allianceDb = new AllianceDb(); if (!string.IsNullOrEmpty(Configuration.RedisPassword) && !string.IsNullOrEmpty(Configuration.RedisServer)) { _redis = new Redis(); } _messagefactory = new LogicMagicMessageFactory(); _commandfactory = new LogicCommandManager(); _debugcommandfactory = new DebugCommandFactory(); Levels = new Levels(); PlayerCache = new PlayerCache(); AllianceCache = new AllianceCache(); LeaderboardCache = new LeaderboardCache(); ChatManager = new LogicGlobalChatManager(); Gateway = new Gateway(); StartDateTime = DateTime.UtcNow; Gateway.StartAsync().Wait(); }
/// <summary> /// Encodes this instance. /// </summary> public override void Encode(ChecksumEncoder encoder) { encoder.WriteInt(this._resourceCount); encoder.WriteDataReference(this._resourceData); encoder.WriteInt(this._resource2Count); if (this._resource2Count > 0) { encoder.WriteDataReference(this._resource2Data); } if (this._command != null) { encoder.WriteBoolean(true); LogicCommandManager.EncodeCommand(encoder, this._command); } else { encoder.WriteBoolean(false); } base.Encode(encoder); }
protected override void Encode(ByteStream stream) { this.LogicClientAvatar.Encode(stream); this.LogicClientHome.Encode(stream); stream.WriteVInt(this.ServerCommands.Size()); for (int i = 0; i < this.ServerCommands.Size(); i++) { LogicCommandManager.EncodeCommand(stream, this.ServerCommands[i]); } stream.WriteVInt(this.RecentlyMatchedEnemies.Size()); for (int i = 0; i < this.RecentlyMatchedEnemies.Size(); i++) { stream.WriteLong(this.RecentlyMatchedEnemies[i].AvatarId); stream.WriteVInt(this.RecentlyMatchedEnemies[i].Timestamp); } stream.WriteVInt(this.AllianceBookmarksList.Size()); for (int i = 0; i < this.AllianceBookmarksList.Size(); i++) { stream.WriteLong(this.AllianceBookmarksList[i]); } stream.WriteVInt(this.AvatarStreamList.Size()); for (int i = 0; i < this.AvatarStreamList.Size(); i++) { stream.WriteLong(this.AvatarStreamList[i]); } stream.WriteVInt(this.SaveTime); stream.WriteVInt(this.MaintenanceTime); }
/// <summary> /// Initializes the <see cref="Loader"/> class. /// </summary> internal static void Init() { if (Loader.Initialized) { return; } Loader.Random = new LogicRandom(); LogicCommandManager.Init(); MessageManager.Init(); Fingerprint.Init(); CSV.Init(); Globals.Init(); if (Settings.Database == DBMS.Mongo) { Mongo.Init(); } Connections.Init(); Avatars.Init(); Alliances.Init(); Battles.Init(); ServerConnection.Init(); APIHandler.Init(); ServerTimers.Init(); Loader.Initialized = true; EventsHandler.Init(); Tests.Init(); }
public override void Encode() { base.Encode(); this.m_stream.WriteString(this.m_streamHeaderJson); this.m_stream.WriteBytes(this.m_compressedstreamHeaderJson, this.m_compressedstreamHeaderJson.Length); this.m_stream.WriteInt(this.m_serverSubTick); if (this.m_commands != null) { this.m_stream.WriteInt(this.m_commands.Size()); for (int i = 0; i < this.m_commands.Size(); i++) { LogicCommandManager.EncodeCommand(this.m_stream, this.m_commands[i]); } } else { this.m_stream.WriteInt(0); } this.m_stream.WriteInt(0); }
/// <summary> /// Encodes this instance. /// </summary> public override void Encode() { base.Encode(); LogicCommandManager.EncodeCommand(this.Stream, this._serverCommand); }