/// <summary>
        /// Encodes the <see cref="Message" />, using the <see cref="Writer" /> instance.
        /// </summary>
        internal override void Encode()
        {
            this.Data.AddVInt(2);
            this.Data.AddVInt(0);
            this.Data.AddString(null);

            this.Data.AddVInt(this.Clans.Count());

            foreach (Clan Clan in this.Clans)
            {
                this.Data.AddVInt(Clan.HighID);
                this.Data.AddVInt(Clan.LowID);

                this.Data.AddVInt(1);
                this.Data.AddVInt(Clan.Trophies);
                this.Data.AddVInt(2);

                this.Data.AddString(Clan.Name);
                this.Data.AddVInt(Clan.Members.Entries.Count);

                this.Data.AddVInt(GlobalID.GetType(Clan.Badge));
                this.Data.AddVInt(GlobalID.GetID(Clan.Badge));
            }

            this.Data.AddHexa("05-02-01-00");
            this.Data.AddString(this.Device.Player.Region);

            // 02-00  FF-FF-FF-FF        02  01  01  01  29  02  00-00-00-05  74-65-73-74-69  02  08  0E  00  03  02  05  02  00-00-00-0C  54-72-69-62-65  20-47-61-6D-69-6E-67-03-08-05  05-02-01-00  00-00-00-02-46-52
            // 02-00  00-00-00-02-46-49  02  01  01  01  29  02  00-00-00-05  74-65-73-74-69  02  08  0E  00  03  02  05  02  00-00-00-0C  54-72-69-62-65  20-47-61-6D-69-6E-67-03-08-05  05-02-01-00  00-00-00-02-46-52
        }
Example #2
0
        public Data GetDataById(int id)
        {
            var classId = GlobalID.GetClassID(id) - 1;
            var dt      = m_vDataTables[classId];

            return(dt.GetItemById(id));
        }
Example #3
0
        public Data GetDataById(int id)
        {
            int       classId = GlobalID.GetClassID(id) - 1;
            DataTable dt      = this.m_vDataTables[classId];

            return(dt.GetItemById(id));
        }
Example #4
0
        // 02  01  19  01  00-00-00-00  00-00-15-DD  00-00-00-08  42-75-73-68-2D-6D-65-6E  08  05  01  02  A4-03  00-00

        /// <summary>
        /// Encodes the <see cref="Message" />, using the <see cref="Writer" /> instance.
        /// </summary>
        internal override void Encode()
        {
            if (this.Clan != null)
            {
                this.Data.AddVInt(this.Clan.Members.Entries.Count); // Online F****t

                this.Data.AddBool(true);
                {
                    this.Data.AddVInt(25);
                    this.Data.AddVInt((int)this.Clan.Members.Entries[this.Device.Player.LowID].Role);

                    this.Data.AddInt(this.Clan.HighID);
                    this.Data.AddInt(this.Clan.LowID);

                    this.Data.AddString(this.Clan.Name);

                    this.Data.AddVInt(GlobalID.GetType(this.Clan.Badge));
                    this.Data.AddVInt(GlobalID.GetID(this.Clan.Badge));

                    this.Data.AddVInt((int)this.Clan.Type);

                    this.Data.AddVInt(this.Clan.Members.Entries.Count);

                    this.Data.AddVInt(this.Clan.Trophies);
                    this.Data.AddVInt(this.Clan.Required_Trophies);

                    this.Data.AddVInt(0);
                }
            }
            else
            {
                this.Data.AddVInt(0);
                this.Data.AddVInt(0);
            }
        }
Example #5
0
        public override async Task OnCommand(CommandArguments command)
        {
            await Task.Yield();

            if (command.Message.Length == 0)
            {
                command.Reply("Usage:{0} gid <globalid>", Colors.OLIVE);

                return;
            }

            if (!ulong.TryParse(command.Message, out var uGid))
            {
                command.Reply("Invalid GlobalID.");

                return;
            }

            GlobalID gid = uGid;

            command.Reply("{0} (SeqCount: {1}{2}{3}, StartTime: {4}{5}{6}, ProcessID: {7}{8}{9}, BoxID: {10}{11}{12})",
                          (ulong)gid,
                          Colors.LIGHTGRAY, gid.SequentialCount, Colors.NORMAL,
                          Colors.LIGHTGRAY, gid.StartTime, Colors.NORMAL,
                          Colors.LIGHTGRAY, gid.ProcessID, Colors.NORMAL,
                          Colors.LIGHTGRAY, gid.BoxID, Colors.NORMAL
                          );
        }
        private int GenerateGameObjectGlobalId(GameObject go)
        {
            var index = m_vGameObjectsIndex[go.ClassId];

            m_vGameObjectsIndex[go.ClassId]++;
            return(GlobalID.CreateGlobalID(go.ClassId + 500, index));
        }
Example #7
0
        public override void OnCommand(CommandArguments command)
        {
            if (command.Message.Length == 0)
            {
                CommandHandler.ReplyToCommand(command, "Usage:{0} gid <globalid>", Colors.OLIVE);

                return;
            }

            ulong uGid;

            if (!ulong.TryParse(command.Message, out uGid))
            {
                CommandHandler.ReplyToCommand(command, "Invalid GlobalID.");

                return;
            }

            GlobalID gid = uGid;

            CommandHandler.ReplyToCommand(command, "{0} (SeqCount: {1}{2}{3}, StartTime: {4}{5}{6}, ProcessID: {7}{8}{9}, BoxID: {10}{11}{12})",
                                          (ulong)gid,
                                          Colors.LIGHTGRAY, gid.SequentialCount, Colors.NORMAL,
                                          Colors.LIGHTGRAY, gid.StartTime, Colors.NORMAL,
                                          Colors.LIGHTGRAY, gid.ProcessID, Colors.NORMAL,
                                          Colors.LIGHTGRAY, gid.BoxID, Colors.NORMAL
                                          );
        }
Example #8
0
        internal int GenerateGameObjectGlobalId(GameObject go)
        {
            var index = this.GameObjectsIndex[go.ClassId];

            this.GameObjectsIndex[go.ClassId]++;
            return(GlobalID.CreateGlobalID(go.ClassId + 500, index));
        }
Example #9
0
        /// <summary>
        /// Minuses the specified resource value.
        /// </summary>
        /// <param name="Resource">The resource.</param>
        /// <param name="Value">The value.</param>
        internal void Minus(Enums.Resource Resource, int Value)
        {
            int Global = GlobalID.Create(5, (int)Resource);

            if (this.ContainsKey(Global))
            {
                this[Global].Count -= Value;
            }
        }
Example #10
0
        public GameObject GetBuilderVillageGameObjectByID(int id)
        {
            var classId = GlobalID.GetType(id) - 493;

            if (this.GameObjects.Capacity < classId)
            {
                return(null);
            }
            return(this.GameObjects[classId].Find(g => g.GlobalId == id));
        }
        public static LogicData ReadDataReference(ByteStream stream, LogicDataType tableIndex)
        {
            int globalId = stream.ReadInt();

            if (GlobalID.GetClassID(globalId) == (int)tableIndex + 1)
            {
                return(LogicDataTables.GetDataById(globalId));
            }
            return(null);
        }
        //public ObstacleManager GetObstacleManager() => m_vObstacleManager;

        public GameObject GetGameObjectByID(int id)
        {
            var classId = GlobalID.GetType(id) - 500;

            if (m_vGameObjects.Capacity < classId)
            {
                return(null);
            }
            return(m_vGameObjects[classId].Find(g => g.GlobalId == id));
        }
Example #13
0
        void DisplayAsGlobalID(object sender, EventArgs e)
        {
            var gid      = new GlobalID((ulong)Convert.ChangeType(value, typeof(ulong)));
            var children = new[]
            {
                new TreeNodeObjectExplorer("Box", gid.BoxID, configuration).TreeNode,
                new TreeNodeObjectExplorer("Process ID", gid.ProcessID, configuration).TreeNode,
                new TreeNodeObjectExplorer("Sequential Count", gid.SequentialCount, configuration).TreeNode,
                new TreeNodeObjectExplorer("StartTime", gid.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), configuration).TreeNode
            };

            SetValueForDisplay(null, childNodes: children);
        }
Example #14
0
        /// <summary>
        /// Creates the compressed.
        /// </summary>
        /// <param name="Data">The data.</param>
        /// <param name="BaseType">Type of the base.</param>
        /// <returns></returns>
        internal static int CreateCompressed(int Data, int BaseType)
        {
            int ID   = GlobalID.GetID(Data) + 1;
            int Type = GlobalID.GetType(Data);

            if (Type > BaseType)
            {
                while (Type > BaseType)
                {
                    ID += CSV.Tables.Get(BaseType++).Datas.Count;
                }
            }

            return(ID);
        }
Example #15
0
        /// <summary>
        /// Creates the compressed data from the specified base type.
        /// </summary>
        internal static int CreateCompressed(int data, int baseType)
        {
            int id   = GlobalID.GetID(data) + 1;
            int type = GlobalID.GetType(data);

            if (type > baseType)
            {
                while (type > baseType)
                {
                    id += CSV.Tables.Get(baseType++).Datas.Size;
                }
            }

            return(id);
        }
        /// <summary>
        /// Adds a gameobject in list.
        /// </summary>
        internal void AddGameObject(GameObject GameObject, int Map)
        {
            int GType = GameObject.Type;

            if (GType > 0)
            {
            }
            else
            {
                Building     Building = (Building)GameObject;
                BuildingData Data     = Building.BuildingData;

                if (Data.Bunker)
                {
                    this.Bunker = Building;
                }

                if (Data.IsTownHall)
                {
                    this.TownHall = Building;
                }

                if (Data.IsTownHall2)
                {
                    this.TownHall2 = Building;
                }

                if (Data.IsLaboratory)
                {
                    this.Laboratory = Building;
                }

                if (Data.IsWorker)
                {
                    this.Level.WorkerManager.WorkerCount++;
                }
            }

            GameObject.Id = GlobalID.Create(500 + GType, this.GameObjects[GType][Map].Count);

            this.GameObjects[GType][Map].Add(GameObject);
            this.Level.TileMap.AddGameObject(GameObject);
        }
Example #17
0
        /// <summary>
        /// Pluses the specified resource value.
        /// </summary>
        /// <param name="Resource">The resource.</param>
        /// <param name="Value">The value.</param>
        internal void Plus(Enums.Resource Resource, int Value)
        {
            int Global = GlobalID.Create(5, (int)Resource);
            int Cap    = (CSV.Tables.Get(Enums.Gamefile.Resources).GetDataWithID(Global) as Files.CSV_Logic.Resources).Cap;

            if (this.ContainsKey(Global))
            {
                if (Cap > 0 && this[Global].Count + Value > 0)
                {
                    this[Global].Count = Cap;
                }
                else
                {
                    this[Global].Count += Value;
                }
            }
            else
            {
                this.Set(Resource, Value > Cap ? Cap : Value);
            }
        }
Example #18
0
        /// <summary>
        /// Encodes the <see cref="Message" />, using the <see cref="Writer" /> instance.
        /// </summary>
        internal override void Encode()
        {
            this.Data.AddInt(this.Clan.HighID);
            this.Data.AddInt(this.Clan.LowID);

            this.Data.AddString(this.Clan.Name);

            this.Data.AddVInt(GlobalID.GetType(this.Clan.Badge));
            this.Data.AddVInt(GlobalID.GetID(this.Clan.Badge));

            this.Data.AddVInt((int)this.Clan.Type);

            this.Data.AddVInt(this.Clan.Members.Entries.Count);
            this.Data.AddVInt(this.Clan.Trophies);

            this.Data.AddVInt(this.Clan.Required_Trophies);
            this.Data.AddVInt(0);

            this.Data.AddString(this.Clan.Description);

            this.Data.AddVInt(this.Clan.Members.Entries.Count);

            foreach (Member Member in this.Clan.Members.Entries.Values.ToArray())
            {
                this.Data.AddInt(Member.HighID);
                this.Data.AddInt(Member.LowID);

                this.Data.AddString(Member.Username);

                this.Data.AddVInt((int)Member.Role);

                this.Data.AddVInt(Member.Level);
                this.Data.AddVInt(Member.Trophies);

                this.Data.AddVInt(28); // Thumbnail Type
                this.Data.AddVInt(Member.Thumbnail);
            }

            // 01  00-00-00-00  00-00-39-84  00-00-00-09-EC-95-84-EC-9D-B4-EC-9C-A0  02  06  A1-01  1C  00
        }
Example #19
0
        public override async Task OnCommand(CommandArguments command)
        {
            await Task.Yield();

            if (command.Message.Length == 0)
            {
                command.Reply($"Usage:{Colors.OLIVE} gid <globalid>");

                return;
            }

            if (!ulong.TryParse(command.Message, out var uGid))
            {
                command.Reply("Invalid GlobalID.");

                return;
            }

            GlobalID gid = uGid;

            command.Reply($"{(ulong)gid} (SeqCount: {Colors.LIGHTGRAY}{gid.SequentialCount}{Colors.NORMAL}, StartTime: {Colors.LIGHTGRAY}{gid.StartTime}{Colors.NORMAL}, ProcessID: {Colors.LIGHTGRAY}{gid.ProcessID}{Colors.NORMAL}, BoxID: {Colors.LIGHTGRAY}{gid.BoxID}{Colors.NORMAL})");
        }
Example #20
0
        protected override void OnRun(CommandDetails details)
        {
            if (details.Args.Length == 0)
            {
                IRC.Instance.Send(details.Channel, "{0}: GID argument required", details.Sender.Nickname);
                return;
            }

            var inputGid = details.Args[0];

            ulong ulGid;

            if (!ulong.TryParse(inputGid, out ulGid))
            {
                IRC.Instance.Send(details.Channel, "{0}: Invalid GID", details.Sender.Nickname);
                return;
            }

            GlobalID gid = ulGid;

            IRC.Instance.Send(details.Channel, "{0}: {1}", details.Sender.Nickname, SteamUtils.ExpandGID(gid));
        }
Example #21
0
        public Data GetItemById(int id)
        {
            var instanceId = GlobalID.GetInstanceID(id);

            return(m_vData[instanceId]);
        }
Example #22
0
 /// <summary>
 /// Gets the identifier from the specified global identifier.
 /// </summary>
 internal static int GetID(int globalID)
 {
     return(globalID - (GlobalID.GetType(globalID) * 1000000));
 }
Example #23
0
        /// <summary>
        /// Encodes the specified packet.
        /// </summary>
        /// <param name="Packet">The packet.</param>
        public void Encode(List <byte> Packet)
        {
            DateTime UTCNow = DateTime.UtcNow;

            Packet.AddVInt(UTCNow.Year * 1000 + UTCNow.DayOfYear);
            Packet.AddVInt(UTCNow.Second + UTCNow.Minute * 60 + UTCNow.Hour * 3600);

            Packet.AddVInt(this.Trophies);
            Packet.AddVInt(this.Trophies);

            Packet.AddVInt(999999999); // Exp
            Packet.AddVInt(0);

            Packet.AddVInt(GlobalID.GetType(this.Thumbnail));
            Packet.AddVInt(GlobalID.GetID(this.Thumbnail));

            Packet.AddVInt(1); // Array
            {
                Packet.AddVInt(1);
            }

            Packet.AddVInt(0); // Array (data reference)
            Packet.AddVInt(0); // Array (data reference)

            Packet.AddBool(false);

            int GoldReward = this.Player.Resources.Get(5000001) - this.Gold;

            if (GoldReward < 0)
            {
                GoldReward = 0;
            }

            Packet.AddVInt(GoldReward);

            Packet.AddVInt(this.JoystickMode);
            Packet.AddBool(this.HintsEnabled);

            Packet.AddVInt(0);
            Packet.AddVInt((int)TimeSpan.FromHours(0).TotalSeconds);

            Packet.AddBool(false);

            {
                Packet.AddHexa("8C-01");
                Packet.AddHexa("1E");

                Packet.AddHexa("90-01");
                Packet.AddHexa("28");
            }

            {
                Packet.AddHexa("8C-04");
                Packet.AddHexa("28");

                Packet.AddHexa("A1-04");
                Packet.AddHexa("32");
            }

            Packet.AddData(2, 6);

            Packet.AddVInt(0);

            Packet.AddBools(true, true);
        }
Example #24
0
 public int GetInstanceID()
 {
     return(GlobalID.GetInstanceID(m_vGlobalID));
 }
Example #25
0
 public Data(CSVRow row, DataTable dt)
 {
     m_vCSVRow    = row;
     m_vDataTable = dt;
     m_vGlobalID  = GlobalID.CreateGlobalID(dt.GetTableIndex() + 1, dt.GetItemCount());
 }
		void DisplayAsGlobalID(object sender, EventArgs e)
		{
			SetAsRadioSelected(sender);

			var gid = new GlobalID((ulong)Convert.ChangeType(value, typeof(ulong)));
			var children = new[]
			{
				new TreeNodeObjectExplorer("Box", gid.BoxID).TreeNode,
				new TreeNodeObjectExplorer("Process ID", gid.ProcessID).TreeNode,
				new TreeNodeObjectExplorer("Sequential Count", gid.SequentialCount).TreeNode,
				new TreeNodeObjectExplorer("StartTime", gid.StartTime.ToString("yyyy-MM-dd HH:mm:ss")).TreeNode
			};

			SetValueForDisplay(null, childNodes: children);
		}
        static void AddUInt64Value(TreeNode node, ulong value)
        {
            var nodeName = node.Text;

            SetNodeValue(node, value.ToString());
            SetNodeContextMenuForValueCopy(node);
            SetNodeContextMenuForEnumDisplay(node, nodeName, value);

            node.ContextMenu.MenuItems.Add("-");             // Separator

            MenuItem initialMenuItem;

            node.ContextMenu.MenuItems.Add((initialMenuItem = new MenuItem("Unsigned 64-bit Integer", delegate(object sender, EventArgs e)
            {
                SetAsRadioSelected(sender);
                node.Nodes.Clear();

                var strUll = value.ToString();
                SetNodeValue(node, nodeName, strUll);
            })
            {
                RadioCheck = true, Checked = true
            }));

            node.ContextMenu.MenuItems.Add(new MenuItem("SteamID (Steam2)", delegate(object sender, EventArgs e)
            {
                SetAsRadioSelected(sender);
                node.Nodes.Clear();

                var strSteamID2 = new SteamID(value).Render(steam3: false);
                SetNodeValue(node, nodeName, strSteamID2);
            })
            {
                RadioCheck = true
            });

            node.ContextMenu.MenuItems.Add(new MenuItem("SteamID (Steam3)", delegate(object sender, EventArgs e)
            {
                SetAsRadioSelected(sender);
                node.Nodes.Clear();

                var strSteamID3 = new SteamID(value).Render(steam3: true);
                SetNodeValue(node, nodeName, strSteamID3);
            })
            {
                RadioCheck = true
            });

            node.ContextMenu.MenuItems.Add(new MenuItem("GlobalID", delegate(object sender, EventArgs e)
            {
                SetAsRadioSelected(sender);
                node.Nodes.Clear();

                var gid = new GlobalID(value);
                node.Nodes.Add(CreateNode("BoxID", gid.BoxID.ToString()));
                node.Nodes.Add(CreateNode("ProcessID", gid.ProcessID.ToString()));
                node.Nodes.Add(CreateNode("StartTime", gid.StartTime.ToString("yyyy-MM-dd HH:mm:ss")));
                node.Nodes.Add(CreateNode("SequentialCount", gid.SequentialCount.ToString()));

                node.Text = nodeName;
                SetNodeValueToCopy(node, value.ToString());
                node.Expand();
            })
            {
                RadioCheck = true
            });


            var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            node.ContextMenu.MenuItems.Add(new MenuItem("Date/Time", delegate(object sender, EventArgs e)
            {
                SetAsRadioSelected(sender);
                node.Nodes.Clear();

                string dateTimeValue;
                try
                {
                    dateTimeValue = unixEpoch.AddSeconds((double)value).ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch (ArgumentOutOfRangeException)
                {
                    dateTimeValue = "Out of range!";
                }

                SetNodeValue(node, nodeName, dateTimeValue);
            })
            {
                RadioCheck = true
            });
        }
Example #28
0
 public static void AddGlobalID(this List <byte> _Packet, int _Value)
 {
     _Packet.AddVInt(GlobalID.GetID(_Value));
     _Packet.AddVInt(GlobalID.GetType(_Value));
 }
Example #29
0
        public GameObject GetGameObjectByID(int id)
        {
            var classId = GlobalID.GetClassID(id) - 500;

            return(m_vGameObjects[classId].Find(g => g.GlobalId == id));
        }
Example #30
0
        /// <summary>
        /// Encodes the <see cref="Message" />, using the <see cref="Writer" /> instance.
        /// </summary>
        internal override void Encode()
        {
            this.Data.AddVInt(this.Player.HighID);
            this.Data.AddVInt(this.Player.LowID);

            this.Data.AddString(this.Player.Name);
            this.Data.AddBool(false);

            this.Data.AddVInt(this.Player.Deck.Count);
            {
                this.Data.AddRange(this.Player.Deck.ToBytes);
            }

            this.Data.AddVInt(8);
            {
                this.Data.AddVInt(1);
                this.Data.AddVInt(this.Player.Wins);

                this.Data.AddVInt(2);
                this.Data.AddVInt(this.Player.Info.Experience);

                this.Data.AddVInt(3);
                this.Data.AddVInt(this.Player.Info.Trophies);

                this.Data.AddVInt(4);
                this.Data.AddVInt(this.Player.Info.HighTrophies);

                this.Data.AddVInt(5);
                this.Data.AddVInt(this.Player.Deck.Count);

                this.Data.AddVInt(6);
                this.Data.AddVInt(0);

                this.Data.AddVInt(7);
                this.Data.AddVInt(this.Player.Info.Thumbnail);

                this.Data.AddVInt(8);
                this.Data.AddVInt(this.Player.Info.SurvTrophies);
            }

            if (this.Player.ClanLowID > 0)
            {
                Clan Clan = this.Player.Clan;

                if (Clan != null)
                {
                    Member Member;

                    if (Clan.Members.Entries.TryGetValue(this.Player.PlayerID, out Member))
                    {
                        this.Data.AddBool(true);

                        this.Data.AddInt(Clan.HighID);
                        this.Data.AddInt(Clan.LowID);

                        this.Data.AddString(Clan.Name);

                        this.Data.AddVInt(GlobalID.GetType(Clan.Badge));
                        this.Data.AddVInt(GlobalID.GetID(Clan.Badge));

                        this.Data.AddVInt((int)Clan.Type);

                        this.Data.AddVInt(Clan.Members.Entries.Count);
                        this.Data.AddVInt(Clan.Trophies);
                        this.Data.AddVInt(Clan.Required_Trophies);
                        this.Data.AddVInt(0);

                        this.Data.AddVInt(0x19);             // Role Type
                        this.Data.AddVInt((int)Member.Role); // Role ID
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Member was null.");

                        this.Data.AddBool(false);
                        this.Data.AddBool(false);
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Clan was null.");

                    this.Data.AddBool(false);
                    this.Data.AddBool(false);
                }
            }
            else
            {
                this.Data.AddBool(false);
                this.Data.AddBool(false);
            }
        }
Example #31
0
        public Data GetItemById(int id)
        {
            int instanceID = GlobalID.GetInstanceID(id);

            return(this.m_vData[instanceID]);
        }