public void CanBeReset()
        {
            var firstSnapshot = new Snapshot { Name = "first" };
            firstSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value" }));
            firstSnapshot.Add(new MetricData(11, DateTime.Now.AddMinutes(-1.5), new List<string> { "value" }));
            firstSnapshot.Add(new MetricData(15, DateTime.Now.AddMinutes(-1), new List<string> { "value" }));

            var secondSnapshot = new Snapshot { Name = "second" };
            secondSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value2" }));
            secondSnapshot.Add(new MetricData(5, DateTime.Now.AddMinutes(-1.5), new List<string> { "value2" }));
            secondSnapshot.Add(new MetricData(6, DateTime.Now.AddMinutes(-1), new List<string> { "value2" }));

            var name = "testPlotter";

            var config = new PlotterElement("id", name, ".", 0, 15, 1, "");

            var sink = new MultiPlotter(config);

            sink.ResetWith(new [] { firstSnapshot, secondSnapshot });

            var plotFile = Path.Combine(".", Path.ChangeExtension(name, "png"));

            Assert.IsTrue(File.Exists(plotFile));

            File.Delete(plotFile);
        }
示例#2
0
        /// <summary>
        /// Send an Attribute value
        /// </summary>
        /// <param name="objectId">Player Object Id</param>
        /// <param name="attribute">Attribute</param>
        /// <param name="value">Value</param>
        public void SendAttributeValue(UInt32 objectId, UInt16 attribute, Int32 value)
        {
            Snapshot _snap = new Snapshot();

            _snap.StartSnapshot(SnapshotType.SET_VAL);
            _snap.Add <UInt32>(objectId);
            _snap.Add <UInt16>(attribute);
            _snap.Add <Int32>(value);
            this.Send(_snap);
        }
示例#3
0
        /// <summary>
        /// Sends mover destination to all visible clients
        /// </summary>
        public void SendMoverDestination()
        {
            Snapshot _snap = new Snapshot();

            _snap.StartSnapshot((SnapshotType)23);
            _snap.Add <Int32>((Int32)this.ObjectId);
            _snap.Add <Byte[]>(new byte[] { 0x00, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }); //TODO: Figure out how this works.
            _snap.Add <Int32>((Int32)this.Destination.X * 1000);
            _snap.Add <Int32>((Int32)this.Destination.Y * 1000);
            _snap.Add <Int32>((Int32)this.Destination.Z * 1000);
            this.SendToVisiblePlayers(_snap);
        }
示例#4
0
        /// <summary>
        /// Creates an Item
        /// </summary>
        /// <param name="item"></param>
        private void SendCreateItem(Item item)
        {
            Snapshot _snapshot = new Snapshot();

            _snapshot.StartSnapshot(SnapshotType.CREATEITEM);
            _snapshot.Add <Int32>((Int32)this.Owner.ObjectId);
            _snapshot.Add <Byte>(0);
            item.Serialize(_snapshot);
            _snapshot.Add <Byte>(1);
            _snapshot.Add <Byte>(item.Slot);
            _snapshot.Add <Int16>((Int16)item.Quantity);
            this.Owner.Client.Send(_snapshot);
        }
示例#5
0
        public void SendSpawnSelf()
        {
            Snapshot _snapshot = new Snapshot();

            _snapshot.StartSnapshot(SnapshotType.SET_STATE_VER);
            _snapshot.Add <UInt32>(1);
            _snapshot.StartSnapshot(SnapshotType.UPDATE_SERVER_TIME);
            _snapshot.Add <Int32>(DateTime.UtcNow.GetUnixTimestamp());
            this.Player.Serialize(_snapshot, true);
            this.Send(_snapshot);

            this.SendPlayerData();
        }
示例#6
0
文件: CsServer.cs 项目: jcgrethe/tav
    private void UpdateClientWord()
    {
        //send position
        float sendRate = (1f / pps);

        if (accum >= sendRate)
        {
            var snapshot = new Snapshot();
            //generate word
            foreach (var auxCubeEntity in cubeServer)
            {
                var cubeEntity = new CubeEntity(auxCubeEntity.Value, auxCubeEntity.Value.GetComponent <CubeId>().Id);
                snapshot.Add(cubeEntity);
            }
            foreach (var kv in playerIps)
            {
                var auxPlayerId = kv.Key;
                snapshot.packetNumber = lastSnapshot[auxPlayerId];
                lastSnapshot[auxPlayerId]++;
                //serialize
                var packet = Packet.Obtain();
                snapshot.Serialize(packet.buffer);
                packet.buffer.Flush();

                string serverIP = kv.Value;
                int    port     = 9000;
                Send(serverIP, port, channel2, packet);
                // Restart accum
            }
            accum -= sendRate;
        }
    }
        public void ReadLine(string line, Snapshot item)
        {
            // set data row
            var row = new Line(line);

            item.Add(row);
        }
示例#8
0
        /// <summary>
        /// Remove an object
        /// </summary>
        /// <param name="objid">ID Unique de l'objet</param>
        public void SendRemoveObject(UInt32 objid)
        {
            Snapshot _snap = new Snapshot();

            _snap.StartSnapshot(SnapshotType.REMOVEOBJ);
            _snap.Add <UInt32>(objid);
            this.Send(_snap);
        }
示例#9
0
        /// <summary>
        /// Send Player Data
        /// </summary>
        public void SendPlayerData()
        {
            Snapshot      _snap  = new Snapshot();
            List <UInt32> _key   = this.Player.Attributes.Keys;
            List <Int32>  _value = this.Player.Attributes.Values;

            for (Int32 i = 0; i < this.Player.Attributes.Length; ++i)
            {
                if (_value[i] != 0)
                {
                    _snap.StartSnapshot(SnapshotType.SET_VAL);
                    _snap.Add <UInt32>(this.Player.ObjectId);
                    _snap.Add <UInt16>((UInt16)_key[i]);
                    _snap.Add <Int32>(_value[i]);
                }
            }
            this.Send(_snap);
        }
        public Snapshot Snapshot()
        {
            Log.Debug("Querying " + Name);

            var snapshot = new Snapshot { Name = Name };
            snapshot.Add(new MetricData( _counter.NextValue(), DateTime.Now, new List<string> { Name }));

            return snapshot;
        }
示例#11
0
        private void PutExInternal(StorageContext context, byte[] key, byte[] value, StorageFlags flags)
        {
            if (key.Length > MaxStorageKeySize || value.Length > MaxStorageValueSize || context.IsReadOnly)
            {
                throw new ArgumentException();
            }

            int        newDataSize;
            StorageKey skey = new StorageKey
            {
                Id  = context.Id,
                Key = key
            };
            StorageItem item = Snapshot.GetAndChange(skey);

            if (item is null)
            {
                newDataSize             = key.Length + value.Length;
                Snapshot.Add(skey, item = new StorageItem());
            }
            else
            {
                if (item.IsConstant)
                {
                    throw new InvalidOperationException();
                }
                if (value.Length == 0)
                {
                    newDataSize = 1;
                }
                else if (value.Length <= item.Value.Length)
                {
                    newDataSize = (value.Length - 1) / 4 + 1;
                }
                else
                {
                    newDataSize = (item.Value.Length - 1) / 4 + 1 + value.Length - item.Value.Length;
                }
            }
            AddGas(newDataSize * StoragePrice);

            item.Value      = value;
            item.IsConstant = flags.HasFlag(StorageFlags.Constant);
        }
示例#12
0
        /// <summary>
        /// The implementation of System.Storage.Put.
        /// Puts a new entry into the storage.
        /// </summary>
        /// <param name="context">The context of the storage.</param>
        /// <param name="key">The key of the entry.</param>
        /// <param name="value">The value of the entry.</param>
        protected internal void Put(StorageContext context, byte[] key, byte[] value)
        {
            if (key.Length > MaxStorageKeySize || value.Length > MaxStorageValueSize || context.IsReadOnly)
            {
                throw new ArgumentException();
            }

            int        newDataSize;
            StorageKey skey = new()
            {
                Id  = context.Id,
                Key = key
            };
            StorageItem item = Snapshot.GetAndChange(skey);

            if (item is null)
            {
                newDataSize             = key.Length + value.Length;
                Snapshot.Add(skey, item = new StorageItem());
            }
            else
            {
                if (value.Length == 0)
                {
                    newDataSize = 0;
                }
                else if (value.Length <= item.Value.Length)
                {
                    newDataSize = (value.Length - 1) / 4 + 1;
                }
                else if (item.Value.Length == 0)
                {
                    newDataSize = value.Length;
                }
                else
                {
                    newDataSize = (item.Value.Length - 1) / 4 + 1 + value.Length - item.Value.Length;
                }
            }
            AddGas(newDataSize * StoragePrice);

            item.Value = value;
        }
示例#13
0
        /// <summary>
        /// On chat
        /// </summary>
        /// <param name="dp"></param>
        private void OnChat(DataPacket dp)
        {
            Byte   _chatFlag = dp.Read <Byte>();
            String _text     = dp.Read <String>();
            String _infoText = dp.Read <String>();

            String[] _chatCommand = _text.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (_chatCommand.Length == 0)
            {
                return;
            }
            if (_chatCommand[0].Trim().StartsWith("\0.") == true)
            {
                if (this.Player.Account.Authority >= (Int32)Authority.GAMEMASTER)
                {
                    switch (_chatCommand[0])
                    {
                    case ".createitem": this.OnCreateItem(_chatCommand); break;

                    default: Log.Write(LogType.Error, "Unknow command {0}", _chatCommand[0]); break;
                    }
                }
            }
            else
            {
                Snapshot _snap = new Snapshot();
                _snap.StartSnapshot(SnapshotType.NORMALCHAT);
                _snap.Add <UInt32>(this.Player.ObjectId);
                _snap.Add <Int32>(this.Player.Id);
                _snap.Add <Byte>((Byte)ChatFlags.None);
                _snap.Add <String>(_text);
                _snap.Add <String>("");
                _snap.Add <Byte>(0); // issf (???)
                this.SendToVisiblePlayers(_snap);

                //snapshot.SetType(SnapshotType.GET_CLIENT_INFO);

                //snapshot.WriteUInt32(1337); //Source Player Id
                //snapshot.WriteString(splitString[0]);
                //snapshot.WriteString(splitString.Length > 1 ? splitString.Skip(1).Aggregate("", (current, s) => current + s) : "");

                //Snapshot _snap = new Snapshot();
                //_snap.StartSnapshot(SnapshotType.NORMALCHAT);
                //_snap.Add<Byte>((Byte)ChatFlags.None);
                //_snap.Add<String>(_text);
                //_snap.Add<String>("");
                //this.SendToVisiblePlayers(_snap);
            }
        }
        public Snapshot Snapshot()
        {
            Log.Debug("Querying " + Name);

            Process[] processes;

            if (string.IsNullOrEmpty(_machineName))
            {
                processes = Process.GetProcessesByName(_processToMonitor);
            }
            else
            {
                processes = Process.GetProcessesByName(_processToMonitor, _machineName);
            }

            var snapshot = new Snapshot { Name = Name };
            snapshot.Add(new MetricData( processes.Length, DateTime.Now, new List<string> { Name }));

            return snapshot;
        }
        public Snapshot Snapshot()
        {
            Log.Debug("Querying " + Name);

            Process[] processes;

            if (string.IsNullOrEmpty(_machineName))
            {
                processes = Process.GetProcessesByName(_processToMonitor);
            }
            else
            {
                processes = Process.GetProcessesByName(_processToMonitor, _machineName);
            }
            var count = 0;
            var uptime = 0d;
            foreach(var process in processes)
            {
                try
                {
                    uptime += new TimeSpan(DateTime.Now.Ticks - process.StartTime.Ticks).TotalSeconds;
                }
                catch(InvalidOperationException)
                {
                    // _assume_ this is because the process has gone away between getting the process 
                    // list and making the query. Ignore.
                }

                count++;
            }

            var snapshot = new Snapshot { Name = Name };
            snapshot.Add(new MetricData( count == 0 ? 0 : uptime / count, DateTime.Now, new List<string> { Name }));

            return snapshot;
        }
        public Snapshot Snapshot()
        {
            var snapshot = new Snapshot();

            if(! File.Exists(FileName(Name)))
            {
                Log.Warn(string.Format("Attempted to snapshot '{0}', but no underlying file was found.", Name));

                return snapshot;
            }

            using (var file = File.OpenRead(FileName(Name)))
            using (var r = new StreamReader(file))
            {
                string line = r.ReadLine();

                if (line == null) return new Snapshot();

                var labels = line.Split(',').ToList();

                while ((line = r.ReadLine()) != null)
                {
                    var data = line.Split(',').ToList();

                    var dataPoints = new List<double?>();

                    for (int i = 1; i < data.Count; i++)
                    {
                        dataPoints.Add(data[i].Equals("null") ? new double?() : double.Parse(data[i]));
                    }

                    snapshot.Add(new MetricData(dataPoints, DateTime.Parse(data[0]), labels));
                }
            }

            return snapshot;
        }
示例#17
0
		internal void UpdateSnapshot(Snapshot snapshot, bool forceFullRebuild)
		{
            if (SuspendRebuilding)
            {
                return;
            }

			lock (AddLock)
			{
				// Start by rebasing if necessary
				bool forceUpdate = false;
				if (RebaseBlocks)
				{
					snapshot.Rebase(AddressRange.Min, AddressWidth);
					RebaseBlocks = false;
					forceUpdate = true;
				}

				UInt64 maxTime = ArtificialMaxTime;
				if (maxTime == 0)
				{
					maxTime = TimeRange.Max;
				}

				IEnumerable<KeyValuePair<TimeStamp, IPacket>> packets = null;
				bool isBackward = false;
				if (forceFullRebuild)
				{
					snapshot.Reset();
					packets = Get();
				}
				else
				{
					// Determine what entries we need to get based off scrubber position
					UInt64 timeRange = maxTime - TimeRange.Min;

					// Readjust the position if needed
					if (ArtificialMaxTime == 0 && timeRange > 0)
					{
						double rangeScale = (double)LastRange / (double)timeRange;

						if (rangeScale > 0 && Scrubber._Position < 1.0)
						{
							// Hacky
							Scrubber._Position *= rangeScale;
							Scrubber._Position = Scrubber._Position.Clamp(0.0, 1.0);
							Scrubber.FlagRedraw();
						}
					}

					LastRange = timeRange;

					double position = Scrubber.Position;
					UInt64 currentTime = TimeRange.Min + (UInt64)((double)timeRange * position);

					bool nothingToProcess = false;
					if (currentTime > LastTimestamp.Time)
					{
						packets = GetForward(new TimeStamp(currentTime));
					}
					else if (currentTime < LastTimestamp.Time)
					{
						packets = GetBackward(new TimeStamp(currentTime));
						isBackward = true;
					}
					else
					{
						nothingToProcess = true;
					}

					LastTimestamp = new TimeStamp(currentTime);

					if (nothingToProcess && !forceUpdate)
					{
						return;
					}
				}

				if (AddressRange.Max < AddressRange.Min)
				{
					return;
				}

				// Create final list, removing allocations as frees are encountered
				if (packets != null)
				{
					int index = 0;
					foreach (var pair in packets)
					{
						// On a full rebuild, if there's a position specified in
						// the snapshot, only go up to that position
						if (forceFullRebuild && snapshot.Position > 0)
						{
							if (index > snapshot.Position)
							{
								break;
							}
						}

						// TODO: Can allocation and free processing be combined?
						// They should be exact opposites of each other
						if (pair.Value is Allocation)
						{
							Allocation allocation = pair.Value as Allocation;

							if (!isBackward)
							{
								MemoryBlock newBlock = snapshot.Add(
									allocation, AddressRange.Min, AddressWidth);
							}
							else
							{
								snapshot.Remove(allocation.Address);
							}
						}
						else
						{
							Free free = pair.Value as Free;

							if (snapshot.Find(free.Address) != null)
							{
								MemoryBlock removedBlock = snapshot.Remove(free.Address);
								if (removedBlock != null)
								{
									removedBlock.Allocation.AssociatedFree = free;
									free.AssociatedAllocation = removedBlock.Allocation;
								}
							}
							else
							{
								if (isBackward)
								{
									MemoryBlock newBlock = snapshot.Add(
										free.AssociatedAllocation, AddressRange.Min, AddressWidth);
								}
							}
						}

						index++;
					}

					if (!forceFullRebuild || snapshot.Position == 0)
					{
						snapshot.Position = Position;
					}
				}

				if (Rebuilt != null)
				{
					EventArgs e = new EventArgs();
					Rebuilt.Invoke(this, e);
				}
			} //);
		}
示例#18
0
        protected virtual void LoadXml(XmlDocument doc)
        {
            XmlNode node = doc.DocumentElement.SelectSingleNode("Name");

            Name = node != null?node.InnerText.Trim() : String.Empty;

            node   = doc.DocumentElement.SelectSingleNode("Author");
            Author = node != null?node.InnerText.Trim() : String.Empty;

            node    = doc.DocumentElement.SelectSingleNode("Version");
            Version = node != null?node.InnerText.Trim() : String.Empty;

            node       = doc.DocumentElement.SelectSingleNode("Compatible");
            Compatible = node != null?node.InnerText.Trim() : String.Empty;

            node = doc.DocumentElement.SelectSingleNode("UpdateTime");
            string udt = node != null?node.InnerText.Trim() : String.Empty;

            DateTime dt;

            DateTime.TryParse(udt, out dt);
            UpdateTime = dt;

            node   = doc.DocumentElement.SelectSingleNode("Enable");
            Enable = node == null ? false : node.InnerText.Trim().ToLower() == "true";

            node        = doc.DocumentElement.SelectSingleNode("IsInstalled");
            IsInstalled = node == null ? false : node.InnerText.Trim().ToLower() == "true";

            node = doc.DocumentElement.SelectSingleNode("Url");
            Url  = node != null?node.InnerText.Trim() : String.Empty;

            node        = doc.DocumentElement.SelectSingleNode("Description");
            Description = node != null?node.InnerText.Trim() : String.Empty;

            node    = doc.DocumentElement.SelectSingleNode("Summary");
            Summary = node != null?node.InnerText.Trim() : String.Empty;

            node = doc.DocumentElement.SelectSingleNode("Pages");
            if (node != null)
            {
                XmlAttribute attr = node.Attributes["defaultPage"];
                Url = attr != null ? attr.Value : String.Empty;

                XmlNodeList nodes = node.SelectNodes("Add");
                Pages.Clear();
                foreach (XmlNode n in nodes)
                {
                    string id       = n.Attributes["ID"] != null ? n.Attributes["ID"].Value : String.Empty;
                    string name     = n.Attributes["Name"] != null ? n.Attributes["Name"].Value : String.Empty;
                    string title    = n.Attributes["Title"] != null ? n.Attributes["Title"].Value : String.Empty;
                    string url      = n.Attributes["Url"] != null ? n.Attributes["Url"].Value : String.Empty;
                    bool   main     = n.Attributes["Main"] != null ? n.Attributes["Main"].Value.ToLower() == "true" ? true : false : false;
                    string entityid = n.Attributes["EntityID"] != null ? n.Attributes["EntityID"].Value : string.Empty;
                    Pages.Add(new UrlItem(id, name, title, url, main, entityid));
                }
            }

            node = doc.DocumentElement.SelectSingleNode("Controls");
            if (node != null)
            {
                Controls = new List <UrlItem>();
                XmlNodeList nodes = node.SelectNodes("Add");

                foreach (XmlNode n in nodes)
                {
                    string name = n.Attributes["Name"] != null ? n.Attributes["Name"].Value : String.Empty;
                    string url  = n.Attributes["Url"] != null ? n.Attributes["Url"].Value : String.Empty;

                    Controls.Add(new UrlItem("", name, "", url, false, ""));
                }
            }

            node = doc.DocumentElement.SelectSingleNode("Deployment");

            if (node != null)
            {
                XmlNodeList nodes = doc.DocumentElement.SelectNodes("Deployment/Install/Item");
                foreach (XmlNode n in nodes)
                {
                    if (!Deployment.Install.Contains(n.InnerText.Trim()))
                    {
                        Deployment.Install.Add(n.InnerText.Trim());
                    }
                }

                nodes = doc.DocumentElement.SelectNodes("//Deployment/Update/Item");
                foreach (XmlNode n in nodes)
                {
                    if (!Deployment.Update.Contains(n.InnerText.Trim()))
                    {
                        Deployment.Update.Add(n.InnerText.Trim());
                    }
                }

                nodes = doc.DocumentElement.SelectNodes("//Deployment/Unstall/Item");
                foreach (XmlNode n in nodes)
                {
                    if (!Deployment.Unstall.Contains(n.InnerText.Trim()))
                    {
                        Deployment.Unstall.Add(n.InnerText.Trim());
                    }
                }

                node = node.SelectSingleNode("Description");
                Deployment.Introduction = node != null?node.InnerText.Trim() : String.Empty;
            }

            node = doc.DocumentElement.SelectSingleNode("Picture");
            if (node != null)
            {
                Thumbnail = node.Attributes["Thumbnail"] != null ? node.Attributes["Thumbnail"].Value.Trim() : String.Empty;
                XmlNodeList nodes = node.SelectNodes("Item");
                foreach (XmlNode n in nodes)
                {
                    Snapshot.Add(n.InnerText.Trim());
                }
                //Snapshot = node.Attributes["Snapshot"] != null ? node.Attributes["Snapshot"].Value.Trim() : String.Empty;
            }

            node      = doc.DocumentElement.SelectSingleNode("Directory");
            Directory = node != null?node.InnerText.Trim() : String.Empty;

            node   = doc.DocumentElement.SelectSingleNode("Others");
            Others = node != null?node.InnerText.Trim() : String.Empty;

            node    = doc.DocumentElement.SelectSingleNode("IsLocal");
            IsLocal = node != null ? (node.InnerText.Trim() == "1") : false;
        }
示例#19
0
文件: WebStats.cs 项目: LordEnigma/UO
        public static bool UpdateStats(bool forceUpdate)
        {
            if (!forceUpdate && _LastFlags == CMOptions.RequestFlags && DateTime.UtcNow - _LastUpdate < CMOptions.UpdateInterval)
            {
                return(false);
            }

            _LastUpdate = DateTime.UtcNow;
            _LastFlags  = CMOptions.RequestFlags;

            var states = NetState.Instances.Where(ns => ns != null && ns.Socket != null && ns.Mobile != null).ToArray();

            Snapshot.Clear();

            foreach (var ns in states)
            {
                IPEndPoint ep = (IPEndPoint)ns.Socket.RemoteEndPoint;

                if (!Snapshot.ContainsKey(ep.Address))
                {
                    Snapshot.Add(ep.Address, new List <NetState>());
                }

                Snapshot[ep.Address].Add(ns);
            }

            #region Uptime
            TimeSpan uptime = DateTime.UtcNow - Clock.ServerStart;

            Stats["uptime"].Value = uptime;

            if (Stats["uptime_peak"].Cast <TimeSpan>() < uptime)
            {
                Stats["uptime_peak"].Value = uptime;
            }
            #endregion

            #region Online
            int connected = states.Length;

            Stats["online"].Value = connected;

            if (Stats["online_max"].Cast <int>() < connected)
            {
                Stats["online_max"].Value = connected;
            }

            if (Stats["online_peak"].Cast <int>() < connected)
            {
                Stats["online_peak"].Value = connected;
            }
            #endregion

            #region Unique
            int unique = Snapshot.Count;

            Stats["unique"].Value = unique;

            if (Stats["unique_max"].Cast <int>() < unique)
            {
                Stats["unique_max"].Value = unique;
            }

            if (Stats["unique_peak"].Cast <int>() < unique)
            {
                Stats["unique_peak"].Value = unique;
            }
            #endregion

            #region Items
            int items = World.Items.Count;

            Stats["items"].Value = items;

            if (Stats["items_max"].Cast <int>() < items)
            {
                Stats["items_max"].Value = items;
            }

            if (Stats["items_peak"].Cast <int>() < items)
            {
                Stats["items_peak"].Value = items;
            }
            #endregion

            #region Mobiles
            int mobiles = World.Mobiles.Count;

            Stats["mobiles"].Value = mobiles;

            if (Stats["mobiles_max"].Cast <int>() < mobiles)
            {
                Stats["mobiles_max"].Value = mobiles;
            }

            if (Stats["mobiles_peak"].Cast <int>() < mobiles)
            {
                Stats["mobiles_peak"].Value = mobiles;
            }
            #endregion

            #region Guilds
            int guilds = BaseGuild.List.Count;

            Stats["guilds"].Value = guilds;

            if (Stats["guilds_max"].Cast <int>() < guilds)
            {
                Stats["guilds_max"].Value = guilds;
            }

            if (Stats["guilds_peak"].Cast <int>() < guilds)
            {
                Stats["guilds_peak"].Value = guilds;
            }
            #endregion

            return(true);
        }
示例#20
0
 /// <summary>
 /// add a line to the snapshot
 /// </summary>
 /// <param name="line"></param>
 public void AddLine(Line line)
 {
     Snapshot.Add(line);
 }
示例#21
0
        /// <summary>
        /// Serialize the character into a Snapshot packet (for join world)
        /// </summary>
        /// <param name="packet">Snapshot packet</param>
        /// <param name="me">Me or not</param>
        public void Serialize(Snapshot packet, Boolean me = false)
        {
            packet.StartSnapshot(SnapshotType.ADDOBJ);

            Dictionary <String, Int32> _checkValues = new Dictionary <String, Int32>
            {
                { "base", 0x77777777 },
                { "extend", 0x11111111 },
                { "inventory", 0x22222222 },
                { "taskbar", 0x33333333 },
                { "quest", 0x44444444 },
                { "messenger", 0x55555555 },
                { "skill", 0x66666666 },
                { "tbag", 0x7777777a },
                { "credit", 0x7777777b },
                { "faction", 0x7777777c },
                { "lover", 0x77777790 },
                { "closet", 0x77777791 },
                { "vessel", 0x77777792 },
                { "hotkey", 0x77777793 },
                { "spirittatoo", 0x77777794 },
                { "advent", 0x77777795 },
                { "domesticate", 0x77777796 }
            };

            base.Serialize(packet);

            packet.Add <Int32>(this.Id);                               // Character Id   self.m_player_id,
            packet.Add <Byte>((Byte)this.Gender);                      // Character gender
            packet.Add <Int32>(this.Job);                              // Character job
            packet.Add <Int32>((Int32)this.Account.Authority);         // Client authority
            packet.Add <Int32>(Configuration.Get <Int32>("ServerId")); // Server Id
            packet.Add <String>("");                                   // uXinEmu (VIP Bar name ???) self.m_vipbar_name

            packet.Add <UInt32>(this.ModelId);                         // Model Id
            packet.Add <UInt32>(0xFFFFFFFF);                           //link_id
            packet.Add <String>(this.Name);                            // Character Name
            packet.Add <Int16>(9);                                     //m_constellation
            packet.Add <Int16>(1);                                     //m_city
            packet.Add <Byte>((Byte)this.HairMesh);                    // Character Hair Model
            packet.Add <UInt32>((UInt32)this.HairColor);               // Character Hair Color
            packet.Add <Byte>((Byte)this.HeadMesh);                    // Character Head Model
            packet.Add <UInt32>(0x7FFFFFFF);                           //m_option
            packet.Add <UInt32>(0);                                    //m_team_id
            packet.Add <String>("");                                   // Vendor string
            packet.Add <Int32>(0);                                     // PK Kills m_slaughter
            packet.Add <Int32>(0);                                     // PK Deaths  .m_kill_num
            packet.Add <Int32>(0x64);                                  // PK Fame  m_fame
            packet.Add <Byte>(0);                                      // PK Mode m_pk_mode
            packet.Add <Byte>(0);                                      // PK Name
            packet.Add <Int32>(0);                                     // PK Grey time
            packet.Add <Int32>(0x5322AFDF);                            // PK Protection cooldown  m_prot_cool_down_start
            packet.Add <Int32>(0);                                     // (sf ??)  issf

            packet.Add <Position>(this.Position);
            packet.Add <Single>(0);   // Angle
            packet.Add <Single>(0);   //anglex
            packet.Add <UInt16>(100); // player scale

            packet.Add <UInt16>(9);
            packet.Add <Byte[]>(new Byte[] { 0x76, 0x31, 0x24, 0x32, 0x34, 0x2C, 0x24, 0x24, 0x24 });

            /* Stream data */
            Dictionary <Define, Int32> _streamData = new Dictionary <Define, Int32>
            {
                { Define.HP, 397 },                                //HP
                { Define.MP, 254 },                                //MP
                { Define.GP, 2 },
                { Define.LV, this.Level },                         // Character Level
                { Define.FLV, 1 },
                { Define.VIT, 120 },
                { Define.FHP, 450 },
                { Define.MOVE_SPEED, 6000 },                 // Character Speed

                { Define.STR, this.Attributes[Define.STR] }, // Strength
                { Define.STA, this.Attributes[Define.STA] }, // Stamina
                { Define.INT, this.Attributes[Define.INT] }, // Intelligence
                { Define.FMP, 290 },                         // Fly Intelligence
                { Define.DEX, this.Attributes[Define.DEX] }, // Dexterity
                { Define.SPI, this.Attributes[Define.SPI] }, // Spirit
            };

            packet.Add <Int32>(_streamData.Count);
            foreach (var pair in _streamData)
            {
                packet.Add <Int16>((short)pair.Key);
                packet.WriteX(pair.Value);
            }

            /* Buffs */
            packet.Add <Byte>(0); //00 00 00 00 (Stream Buff Size => ?) stream_buff count

            /* Equipement */
            packet.Add <UInt32>(0); // Equipement count

            packet.Add <Byte>(0);

            packet.Add <UInt32>(0); //00 00 00 00 (Player Title Count)
            packet.Add <UInt32>(7); //07 00 00 00 (Player Title Flag => ?)
            packet.Add <Byte>(0);   //00 (Player Title Count => ?)

            /* Kingdom */
            packet.Add <Byte>(0);    //00 self.m_k_job
            packet.Add <Byte>(0);    //self.m_k_sub_job
            packet.Add <UInt32>(0);  //00 00 00 00 (Family Id)
            packet.Add <String>(""); //00 00 (Family Name)
            packet.Add <Byte>(0);    //00 (Family Job)
            packet.Add <Byte>(0);    //00 (Title Id => ?)
            packet.Add <UInt32>(0);  //00 00 00 00 (Family Popularity)
            packet.Add <UInt32>(0);  //00 00 00 00 (Family Rank)
            packet.Add <Byte>(0);    //00 (Family Icon Id)
            packet.Add <UInt32>(0);  //self.m_alliance_id
            packet.Add <Byte>(0);    //00 self.m_alliance_job
            packet.Add <String>(""); //00 00 m_alliance_name

            /* Master */
            packet.Add <String>(""); //00 00 (Master Name)
            packet.Add <String>(""); //00 00 (Master Faction Name => ?)
            packet.Add <String>(""); //00 00 (Faction Name => ?)
            packet.Add <Int32>(0);   //00 00 00 00 (m_close_points_total_with_master)


            packet.Add <UInt32>(0); //0C 00 00 00 (Safety Immunity => ?)
            packet.Add <Byte>(0);   //00 (Lover Count)

            /* Weding */
            packet.Add <Boolean>(true); //01 (Marriage System Enabled)
            packet.Add <Byte>(0);       //00 (Marriage System Kind => ?)

            /* Closet */
            packet.Add <Int32>(this.Inventory.GetEquipedCloset().Count);
            foreach (ClosetItem _closet in this.Inventory.GetEquipedCloset())
            {
                packet.Add <Int32>(_closet.Id); //index
            }

            /* Vessel */
            packet.Add <UInt32>(0);                //?? ?? ?? ?? (Vessel Refine Level => ?)
            packet.Add <UInt32>(0);                //?? ?? ?? ?? (Vessel Equip Index => ?)
            packet.Add <Boolean>(false);           //?? (Vessel Equipped => ?)

            packet.Add <Byte>((Byte)(me ? 1 : 0)); //flag
            if (me == false)
            {
                return;
            }


            packet.Add <Int32>(_checkValues["base"]); //77 77 77 77 (Data Check => Constant)

            packet.Add <Byte>(0);                     // m_need_activate_game
            packet.Add <Byte>(1);                     // m_game_flag
            packet.Add <UInt32>(1394954851);          // m_last_logout_time
            packet.Add <UInt32>(0);                   // 00 00 00 00 (Pet ID)

            /* Title */
            packet.Add <UInt32>(0); // 00 00 00 00 (Title Count)

            packet.Add <Int32>(0);  //02 00 00 00 (title_list_count Count =>)
            //packet.Add<Int32>(24000); //C0 5D 00 00 (Renown Title => ?)
            //packet.Add<Int32>(26000); //90 65 00 00 (Renown Title => ?)

            packet.Add <Byte>(0); //00 (Renown Title Host Count => ?)

            /* Inventory */
            this.Inventory.Serialize(packet);
            packet.Add <Int32>(_checkValues["inventory"]);

            /* Quest Inventory: */
            packet.Add <Byte>((byte)Define.MAX_INVENTORY); //m_item_max
            packet.Add <Byte>((byte)Define.MAX_INVENTORY); //m_index_num
            packet.Add <Byte[]>(new byte[]
            {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
                0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
                0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29
            });                                 //Slots?
            packet.Add <Byte>(0);
            packet.Add <Int32>(_checkValues["tbag"]);

            /* Taskbar */
            packet.Add <Int32>(0);
            packet.Add <Int32>(0);
            packet.Add <Int32>(0); //CWndTaskSubVer
            packet.Add <Int32>(4);
            packet.Add <Byte[]>(new Byte[] { 1, 2, 3, 4 });
            packet.Add <Int32>(0);
            packet.Add <Int32>(_checkValues["taskbar"]);

            /* Skills */
            packet.Add <UInt32>(0); //03 00 00 00 (Skill Count)
            packet.Add <UInt32>(0); //self.m_domesticate_skill_time = LAr:ReadDword(ar)
            packet.Add <Int32>(_checkValues["skill"]);

            /* Quests */
            packet.Add <Byte>(1); //01 (Quest Change Flag => Always 1?)

            /* Quests in progress */
            packet.Add <UInt32>(0); //01 00 00 00 (Quest Count)

            /* Quests finished */
            packet.Add <UInt32>(0); //05 00 00 00 (Completed Quest Count)

            /* Repeat quests */
            packet.Add <UInt16>(0); //00 00 ('repeat_quest' => ?)

            packet.Add <Int32>(_checkValues["quest"]);

            /* Friends */
            packet.Add <Int32>(0);  //00 00 00 00 ('my_state' => ?)  self.m_my_state = LAr:ReadInt(ar)
            packet.Add <Int32>(0);  //00 00 00 00 ('favor_value' => ?) self.m_favor_value = LAr:ReadInt(ar)
            packet.Add <Int32>(0);  //00 00 00 00 ('flower_count' => ?) local flower_count = LAr:ReadInt(ar)

            packet.Add <UInt32>(0); //00 00 00 00 (Friend Count)

            packet.Add <Int32>(0);  //00 00 00 00 (Blacklist Count) local black_count = LAr:ReadInt(ar)

            packet.Add <Int32>(0);  //00 00 00 00 (Murderer Count) local murderer_count = LAr:ReadInt(ar)

            packet.Add <Int32>(_checkValues["messenger"]);

            /* Faction */
            packet.Add <Boolean>(false); //00 (Faction Master Flag)  local is_master = LAr:ReadByte(ar)
            packet.Add <Int32>(0);       //00 00 00 00 (Faction Protege Count => ?)
            packet.Add <Int32>(0);       //00 00 00 00 (Faction Honor Points => ?)
            packet.Add <Int32>(0);       //00 00 00 00 (Faction Honor Points Total => ?)
            packet.Add <Int32>(0);       //00 00 00 00 (Faction Level Points => ?)
            packet.Add <Boolean>(false); //00 (Faction Is Faction => ?)
            packet.Add <String>("");     //00 00 (Faction Name)
            packet.Add <Int32>(_checkValues["faction"]);

            /* Memorised position */
            packet.Add <Int32>(0); //00 00 00 00 (Position Count => ?)

            /* PVP */
            packet.Add <Int32>(0);   //00 00 00 00 (Duels Won)
            packet.Add <Int32>(0);   //00 00 00 00 (Duels Tied)
            packet.Add <Int32>(0);   //00 00 00 00 (Duels Lost)
            packet.Add <Int32>(0);   //00 00 00 00 (PKs Won)
            packet.Add <Int32>(0);   //00 00 00 00 (Total PKs)
            packet.Add <Int32>(135); //87 00 00 00 ('adv' Stamina => ?)
            packet.Add <Byte>(1);    //01 (Auto Assign => ?)

            /* Credit card */
            packet.Add <Byte>(0);   //00 (Credit Card Type => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Limit => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Current Limit => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Recharge => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card 'Pay Recharge' => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Preferential => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card One Day Consume => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Total Consume => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Last Consume Date => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card One Day Trade => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Last Trade Date => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Recharged Money => ?)
            packet.Add <Int32>(-1); //FF FF FF FF (Credit Card Trade Points => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Credit Card Recharge Reward => ?)
            packet.Add <Int32>(_checkValues["credit"]);

            /* VIP */

            packet.Add <Byte>(0);   //00 (VIP Level Game => ?)
            packet.Add <Byte>(0);   //00 (VIP Level GM => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (VIP Expiry Date => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Last Wage Time Game => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Last Wage Time GM => ?)

            /* Equip attr bonus */
            packet.Add <Byte>(0x0F); //00 (Equipment Attribute Stone STR Bonus => ?)
            packet.Add <Byte>(0x0F); //00 (Equipment Attribute Stone DEX Bonus => ?)
            packet.Add <Byte>(0x2D); //2D (Equipment Attribute Stone STA Bonus => ?)
            packet.Add <Byte>(0x0F); //0A (Equipment Attribute Stone SPI Bonus => ?)
            packet.Add <Byte>(0x0A); //2D (Equipment Attribute Stone INT Bonus => ?)

            /* Lovers */
            packet.Add <UInt32>(0); //00 00 00 00 (Lovers Count)
            packet.Add <Int32>(_checkValues["lover"]);

            /* Closet */
            packet.Add <Int32>(8);                                       //character.Closet.Capacity); //08 00 00 00 (Closet Capacity)
            packet.Add <Int32>(1);                                       //character.Closet.Level); //01 00 00 00 (Closet Level)
            packet.Add <Int32>(this.Inventory.GetEquipedCloset().Count); //00 00 00 00 (Fate Number => ?)
            foreach (ClosetItem _closet in this.Inventory.GetEquipedCloset())
            {
                packet.Add <Int32>(_closet.Index);
                packet.Add <Int32>(_closet.Id);
                packet.Add <Int32>(_closet.Level);
                packet.Add <Int32>(_closet.Equiped ? 1 : 0);
                packet.Add <Int32>(_closet.Date.GetUnixTimestamp());
                for (Int32 i = 0; i < 15; i++)
                {
                    packet.Add <Int32>(0);
                }
            }
            packet.Add <Int32>(_checkValues["closet"]);

            /* Vessel */
            packet.Add <UInt32>(1); //01 00 00 00 (Vessel Level => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Vessel Equip Slot => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Vessel Spirit => ?)
            packet.Add <UInt32>(0); //00 00 00 00 (Vessel Battle => ?
            packet.Add <UInt32>(0); //00 00 00 00 (Vessel Slots => ?)
            packet.Add <Int32>(_checkValues["vessel"]);

            /* Hotkey */
            for (Int32 i = 0; i < 47; ++i)
            {
                packet.Add <Int32>(0);
                packet.Add <Int32>(0);
            }
            packet.Add <Int32>(_checkValues["hotkey"]);

            /* Spirittatoo */
            packet.Add <String>("1,10,2,0,1,10,3,0,1,10,2,0,1,10,1,0,1,10,4,0,1,10,4,0,");
            packet.Add <Int32>(_checkValues["spirittatoo"]);

            /* Serialize advent */
            packet.Add <Int32>(1);
            packet.Add <Int32>(0);
            packet.Add <Int32>(1);
            packet.Add <Int32>(0);
            packet.Add <Int32>(1);
            packet.Add <String>("1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;");
            packet.Add <Int32>(_checkValues["advent"]);

            /* Pet domesticate */
            packet.Add <Int32>(0);
            packet.Add <Int32>(0);
            packet.Add <Int32>(_checkValues["domesticate"]);

            /* End */
            packet.Add <Int32>(0); //m_cbg_sign_time
            packet.Add <Int32>(0); //m_cbg_sign_player
            packet.Add <Int32>(0); //m_cbg_sell_player
            packet.Add <UInt32>(7621499);
        }