Ejemplo n.º 1
0
 internal static void AddMulti(Item item)
 {
     if (!m_Multis.ContainsKey(item.Serial))
     {
         Ultima.MultiComponentList multiinfo = Ultima.Multis.GetComponents(item.ItemID);
         m_Multis[item.Serial] = new RazorEnhanced.Multi.MultiData(item.Position, new Point2D(item.Position.X + multiinfo.Min.X, item.Position.Y + multiinfo.Min.Y), new Point2D(item.Position.X - multiinfo.Min.X, item.Position.Y - multiinfo.Min.Y));
     }
 }
Ejemplo n.º 2
0
        public void MakeHousePacket()
        {
            m_HousePacket = null;

            try
            {
                // 3 locations... which is right? all of them? wtf?
                //"Desktop/{0}/{1}/{2}/Multicache.dat", World.AccountName, World.ShardName, World.OrigPlayerName
                //"Desktop/{0}/{1}/{2}/Multicache.dat", World.AccountName, World.ShardName, World.Player.Name );
                //"Desktop/{0}/Multicache.dat", World.AccountName );
                string path = Ultima.Files.GetFilePath(
                    $"Desktop/{World.AccountName}/{World.ShardName}/{World.OrigPlayerName}/Multicache.dat");
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    return;
                }

                using (StreamReader reader =
                           new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    string line;
                    reader.ReadLine(); // ver
                    int skip  = 0;
                    int count = 0;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (count++ < skip || line == "" || line[0] == ';')
                        {
                            continue;
                        }

                        string[] split = line.Split(' ', '\t');
                        if (split.Length <= 0)
                        {
                            return;
                        }

                        skip = 0;
                        Serial ser   = (uint)Utility.ToInt32(split[0], 0);
                        int    rev   = Utility.ToInt32(split[1], 0);
                        int    lines = Utility.ToInt32(split[2], 0);

                        if (ser == this.Serial)
                        {
                            m_HouseRev = rev;
                            MultiTileEntry[] tiles = new MultiTileEntry[lines];
                            count = 0;

                            Ultima.MultiComponentList mcl = Ultima.Multis.GetComponents(m_ItemID);

                            while ((line = reader.ReadLine()) != null && count < lines)
                            {
                                split = line.Split(' ', '\t');

                                tiles[count]           = new MultiTileEntry();
                                tiles[count].m_ItemID  = (ushort)Utility.ToInt32(split[0], 0);
                                tiles[count].m_OffsetX = (short)(Utility.ToInt32(split[1], 0) + mcl.Center.X);
                                tiles[count].m_OffsetX = (short)(Utility.ToInt32(split[2], 0) + mcl.Center.Y);
                                tiles[count].m_OffsetX = (short)Utility.ToInt32(split[3], 0);

                                count++;
                            }

                            m_HousePacket = new DesignStateDetailed(Serial, m_HouseRev, mcl.Min.X, mcl.Min.Y, mcl.Max.X,
                                                                    mcl.Max.Y, tiles).Compile();
                            break;
                        }
                        else
                        {
                            skip = lines;
                        }

                        count = 0;
                    }
                }
            }
            catch // ( Exception e )
            {
                //Engine.LogCrash( e );
            }
        }