ReadUOAString() public static method

public static ReadUOAString ( BinaryReader bin ) : string
bin System.IO.BinaryReader
return string
Ejemplo n.º 1
0
        public MultiComponentList(string FileName, Multis.ImportType Type)
        {
            m_Min = m_Max = Point.Empty;
            int itemcount;

            switch (Type)
            {
            case Multis.ImportType.TXT:
                itemcount = 0;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        itemcount++;
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        string[] split = line.Split(' ');

                        string tmp = split[0];
                        tmp = tmp.Replace("0x", "");

                        m_SortedTiles[itemcount].m_ItemID =
                            ushort.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
                        m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                        m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                        m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                        m_SortedTiles[itemcount].m_Flags   = Convert.ToInt32(split[4]);
                        m_SortedTiles[itemcount].m_Unk1    = 0;

                        MultiTileEntry e = m_SortedTiles[itemcount];

                        if (e.m_OffsetX < m_Min.X)
                        {
                            m_Min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > m_Max.X)
                        {
                            m_Max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > m_maxHeight)
                        {
                            m_maxHeight = e.m_OffsetZ;
                        }

                        itemcount++;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    int i = 0;
                    for (; i < m_SortedTiles.Length; i++)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;

            case Multis.ImportType.UOA:
                itemcount = 0;

                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++itemcount;
                        if (itemcount == 4)
                        {
                            string[] split = line.Split(' ');
                            itemcount = Convert.ToInt32(split[0]);
                            break;
                        }
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    int    i = -1;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++i;
                        if (i < 4)
                        {
                            continue;
                        }
                        string[] split = line.Split(' ');

                        m_SortedTiles[itemcount].m_ItemID  = Convert.ToUInt16(split[0]);
                        m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                        m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                        m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                        m_SortedTiles[itemcount].m_Flags   = Convert.ToInt32(split[4]);
                        m_SortedTiles[itemcount].m_Unk1    = 0;

                        MultiTileEntry e = m_SortedTiles[itemcount];

                        if (e.m_OffsetX < m_Min.X)
                        {
                            m_Min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > m_Max.X)
                        {
                            m_Max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > m_maxHeight)
                        {
                            m_maxHeight = e.m_OffsetZ;
                        }

                        ++itemcount;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    i     = 0;
                    for (; i < m_SortedTiles.Length; ++i)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;

            case Multis.ImportType.UOAB:
                using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (BinaryReader reader = new BinaryReader(fs))
                    {
                        if (reader.ReadInt16() != 1) //Version check
                        {
                            return;
                        }
                        string tmp;
                        tmp = Multis.ReadUOAString(reader); //Name
                        tmp = Multis.ReadUOAString(reader); //Category
                        tmp = Multis.ReadUOAString(reader); //Subsection
                        int width   = reader.ReadInt32();
                        int height  = reader.ReadInt32();
                        int uwidth  = reader.ReadInt32();
                        int uheight = reader.ReadInt32();

                        int count = reader.ReadInt32();
                        itemcount     = count;
                        m_SortedTiles = new MultiTileEntry[itemcount];
                        itemcount     = 0;
                        m_Min.X       = 10000;
                        m_Min.Y       = 10000;
                        for (; itemcount < count; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_ItemID  = (ushort)reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetX = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetY = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetZ = reader.ReadInt16();
                            reader.ReadInt16(); // level
                            m_SortedTiles[itemcount].m_Flags = 1;
                            reader.ReadInt16(); // hue
                            m_SortedTiles[itemcount].m_Unk1 = 0;

                            MultiTileEntry e = m_SortedTiles[itemcount];

                            if (e.m_OffsetX < m_Min.X)
                            {
                                m_Min.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetX > m_Max.X)
                            {
                                m_Max.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetZ > m_maxHeight)
                            {
                                m_maxHeight = e.m_OffsetZ;
                            }
                        }

                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min     = m_Max = Point.Empty;
                        itemcount = 0;
                        for (; itemcount < m_SortedTiles.Length; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_OffsetX -= (short)centerx;
                            m_SortedTiles[itemcount].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[itemcount].m_OffsetX < m_Min.X)
                            {
                                m_Min.X = m_SortedTiles[itemcount].m_OffsetX;
                            }
                            if (m_SortedTiles[itemcount].m_OffsetX > m_Max.X)
                            {
                                m_Max.X = m_SortedTiles[itemcount].m_OffsetX;
                            }

                            if (m_SortedTiles[itemcount].m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = m_SortedTiles[itemcount].m_OffsetY;
                            }
                            if (m_SortedTiles[itemcount].m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = m_SortedTiles[itemcount].m_OffsetY;
                            }
                        }
                    }

                break;

            case Multis.ImportType.WSC:
                itemcount = 0;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            ++itemcount;
                        }
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string         line;
                    MultiTileEntry tempitem = new MultiTileEntry();
                    tempitem.m_ItemID = 0xFFFF;
                    tempitem.m_Flags  = 1;
                    tempitem.m_Unk1   = 0;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            if (tempitem.m_ItemID != 0xFFFF)
                            {
                                m_SortedTiles[itemcount] = tempitem;
                                ++itemcount;
                            }

                            tempitem.m_ItemID = 0xFFFF;
                        }
                        else if (line.StartsWith("ID"))
                        {
                            line = line.Remove(0, 2);
                            line = line.Trim();
                            tempitem.m_ItemID = Convert.ToUInt16(line);
                        }
                        else if (line.StartsWith("X"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetX = Convert.ToInt16(line);
                            if (tempitem.m_OffsetX < m_Min.X)
                            {
                                m_Min.X = tempitem.m_OffsetX;
                            }
                            if (tempitem.m_OffsetX > m_Max.X)
                            {
                                m_Max.X = tempitem.m_OffsetX;
                            }
                        }
                        else if (line.StartsWith("Y"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetY = Convert.ToInt16(line);
                            if (tempitem.m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = tempitem.m_OffsetY;
                            }
                            if (tempitem.m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = tempitem.m_OffsetY;
                            }
                        }
                        else if (line.StartsWith("Z"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetZ = Convert.ToInt16(line);
                            if (tempitem.m_OffsetZ > m_maxHeight)
                            {
                                m_maxHeight = tempitem.m_OffsetZ;
                            }
                        }
                    }

                    if (tempitem.m_ItemID != 0xFFFF)
                    {
                        m_SortedTiles[itemcount] = tempitem;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    int i = 0;
                    for (; i < m_SortedTiles.Length; i++)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;
            }

            ConvertList();
        }
Ejemplo n.º 2
0
        public MultiComponentList(string fileName, Multis.ImportType type)
        {
            _min = _max = Point.Empty;

            int itemCount;

            switch (type)
            {
            case Multis.ImportType.TXT:
            {
                itemCount = 0;
                using (var ip = new StreamReader(fileName))
                {
                    while (ip.ReadLine() != null)
                    {
                        itemCount++;
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        string[] split = line.Split(' ');

                        string tmp = split[0];
                        tmp = tmp.Replace("0x", "");

                        SortedTiles[itemCount].m_ItemID  = ushort.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
                        SortedTiles[itemCount].m_OffsetX = Convert.ToInt16(split[1]);
                        SortedTiles[itemCount].m_OffsetY = Convert.ToInt16(split[2]);
                        SortedTiles[itemCount].m_OffsetZ = Convert.ToInt16(split[3]);
                        SortedTiles[itemCount].m_Flags   = Convert.ToInt32(split[4]);
                        SortedTiles[itemCount].m_Unk1    = 0;

                        MultiTileEntry e = SortedTiles[itemCount];

                        if (e.m_OffsetX < _min.X)
                        {
                            _min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < _min.Y)
                        {
                            _min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > _max.X)
                        {
                            _max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > _max.Y)
                        {
                            _max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > MaxHeight)
                        {
                            MaxHeight = e.m_OffsetZ;
                        }

                        itemCount++;
                    }
                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    int i = 0;
                    for (; i < SortedTiles.Length; i++)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }
                break;
            }

            case Multis.ImportType.UOA:
            {
                itemCount = 0;

                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++itemCount;

                        if (itemCount != 4)
                        {
                            continue;
                        }

                        string[] split = line.Split(' ');
                        itemCount = Convert.ToInt32(split[0]);
                        break;
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    int    i = -1;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++i;
                        if (i < 4)
                        {
                            continue;
                        }

                        string[] split = line.Split(' ');

                        SortedTiles[itemCount].m_ItemID  = Convert.ToUInt16(split[0]);
                        SortedTiles[itemCount].m_OffsetX = Convert.ToInt16(split[1]);
                        SortedTiles[itemCount].m_OffsetY = Convert.ToInt16(split[2]);
                        SortedTiles[itemCount].m_OffsetZ = Convert.ToInt16(split[3]);
                        SortedTiles[itemCount].m_Flags   = Convert.ToInt32(split[4]);
                        SortedTiles[itemCount].m_Unk1    = 0;

                        MultiTileEntry e = SortedTiles[itemCount];

                        if (e.m_OffsetX < _min.X)
                        {
                            _min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < _min.Y)
                        {
                            _min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > _max.X)
                        {
                            _max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > _max.Y)
                        {
                            _max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > MaxHeight)
                        {
                            MaxHeight = e.m_OffsetZ;
                        }

                        ++itemCount;
                    }

                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    i    = 0;
                    for (; i < SortedTiles.Length; ++i)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;
            }

            case Multis.ImportType.UOAB:
            {
                using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var reader = new BinaryReader(fs))
                    {
                        if (reader.ReadInt16() != 1) // Version check
                        {
                            return;
                        }

                        _ = Multis.ReadUOAString(reader);
                        _ = Multis.ReadUOAString(reader); // Category
                        _ = Multis.ReadUOAString(reader); // Subsection

                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();

                        int count = reader.ReadInt32();
                        itemCount   = count;
                        SortedTiles = new MultiTileEntry[itemCount];
                        itemCount   = 0;
                        _min.X      = 10000;
                        _min.Y      = 10000;
                        for (; itemCount < count; ++itemCount)
                        {
                            SortedTiles[itemCount].m_ItemID  = (ushort)reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetX = reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetY = reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetZ = reader.ReadInt16();
                            reader.ReadInt16(); // level
                            SortedTiles[itemCount].m_Flags = 1;
                            reader.ReadInt16(); // hue
                            SortedTiles[itemCount].m_Unk1 = 0;

                            MultiTileEntry e = SortedTiles[itemCount];

                            if (e.m_OffsetX < _min.X)
                            {
                                _min.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY < _min.Y)
                            {
                                _min.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetX > _max.X)
                            {
                                _max.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY > _max.Y)
                            {
                                _max.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetZ > MaxHeight)
                            {
                                MaxHeight = e.m_OffsetZ;
                            }
                        }
                        int centerx = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                        int centery = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                        _min      = _max = Point.Empty;
                        itemCount = 0;
                        for (; itemCount < SortedTiles.Length; ++itemCount)
                        {
                            SortedTiles[itemCount].m_OffsetX -= (short)centerx;
                            SortedTiles[itemCount].m_OffsetY -= (short)centery;
                            if (SortedTiles[itemCount].m_OffsetX < _min.X)
                            {
                                _min.X = SortedTiles[itemCount].m_OffsetX;
                            }

                            if (SortedTiles[itemCount].m_OffsetX > _max.X)
                            {
                                _max.X = SortedTiles[itemCount].m_OffsetX;
                            }

                            if (SortedTiles[itemCount].m_OffsetY < _min.Y)
                            {
                                _min.Y = SortedTiles[itemCount].m_OffsetY;
                            }

                            if (SortedTiles[itemCount].m_OffsetY > _max.Y)
                            {
                                _max.Y = SortedTiles[itemCount].m_OffsetY;
                            }
                        }
                    }
                break;
            }

            case Multis.ImportType.WSC:
            {
                itemCount = 0;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            ++itemCount;
                        }
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    var    tempItem = new MultiTileEntry
                    {
                        m_ItemID = 0xFFFF,
                        m_Flags  = 1,
                        m_Unk1   = 0
                    };

                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            if (tempItem.m_ItemID != 0xFFFF)
                            {
                                SortedTiles[itemCount] = tempItem;
                                ++itemCount;
                            }
                            tempItem.m_ItemID = 0xFFFF;
                        }
                        else if (line.StartsWith("ID"))
                        {
                            line = line.Remove(0, 2);
                            line = line.Trim();
                            tempItem.m_ItemID = Convert.ToUInt16(line);
                        }
                        else if (line.StartsWith("X"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetX = Convert.ToInt16(line);
                            if (tempItem.m_OffsetX < _min.X)
                            {
                                _min.X = tempItem.m_OffsetX;
                            }

                            if (tempItem.m_OffsetX > _max.X)
                            {
                                _max.X = tempItem.m_OffsetX;
                            }
                        }
                        else if (line.StartsWith("Y"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetY = Convert.ToInt16(line);
                            if (tempItem.m_OffsetY < _min.Y)
                            {
                                _min.Y = tempItem.m_OffsetY;
                            }

                            if (tempItem.m_OffsetY > _max.Y)
                            {
                                _max.Y = tempItem.m_OffsetY;
                            }
                        }
                        else if (line.StartsWith("Z"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetZ = Convert.ToInt16(line);
                            if (tempItem.m_OffsetZ > MaxHeight)
                            {
                                MaxHeight = tempItem.m_OffsetZ;
                            }
                        }
                    }
                    if (tempItem.m_ItemID != 0xFFFF)
                    {
                        SortedTiles[itemCount] = tempItem;
                    }

                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    int i = 0;
                    for (; i < SortedTiles.Length; i++)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }
                break;
            }
            }
            ConvertList();
        }