GetLegalItemID() public static method

public static GetLegalItemID ( int itemID, bool checkmaxid = true ) : ushort
itemID int
checkmaxid bool
return ushort
Ejemplo n.º 1
0
 public void Set(ushort id, sbyte z, sbyte flag, int unk1)
 {
     Id   = Art.GetLegalItemID(id);
     Z    = z;
     Flag = flag;
     Unk1 = unk1;
 }
Ejemplo n.º 2
0
 public MTile(ushort id, sbyte z)
 {
     m_ID     = Art.GetLegalItemID(id);
     m_Z      = z;
     m_Flag   = TileFlag.Background;
     m_Solver = 0;
 }
Ejemplo n.º 3
0
 public void Set(ushort id, sbyte z, sbyte flag, int unk1)
 {
     m_ID   = Art.GetLegalItemID(id);
     m_Z    = z;
     m_Flag = flag;
     m_Unk1 = unk1;
 }
Ejemplo n.º 4
0
 public MTile(ushort id, sbyte z, TileFlag flag)
 {
     m_ID     = Art.GetLegalItemID(id);
     m_Z      = z;
     m_Flag   = flag;
     m_Solver = 0;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes Static index <see cref="m_Removed"/>
        /// </summary>
        /// <param name="index"></param>
        public static void RemoveStatic(int index)
        {
            index  = Art.GetLegalItemID(index);
            index += 0x4000;

            m_Removed[index] = true;
            Modified         = true;
        }
Ejemplo n.º 6
0
 public MTile(ushort id, sbyte z)
 {
     m_ID     = Art.GetLegalItemID(id);
     m_Z      = z;
     m_Flag   = 1;
     m_Solver = 0;
     m_Unk1   = 0;
 }
Ejemplo n.º 7
0
 public MTile(ushort id, sbyte z, sbyte flag, int unk1)
 {
     m_ID     = Art.GetLegalItemID(id);
     m_Z      = z;
     m_Flag   = flag;
     m_Solver = 0;
     m_Unk1   = unk1;
 }
Ejemplo n.º 8
0
 public MTile(ushort id, sbyte z, sbyte flag, int unk1)
 {
     Id     = Art.GetLegalItemID(id);
     Z      = z;
     Flag   = flag;
     Solver = 0;
     Unk1   = unk1;
 }
Ejemplo n.º 9
0
 public MTile(ushort id, sbyte z)
 {
     Id     = Art.GetLegalItemID(id);
     Z      = z;
     Flag   = 1;
     Solver = 0;
     Unk1   = 0;
 }
Ejemplo n.º 10
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            bool useNewMultiFormat = Multis.PostHSFormat || Art.IsUOAHS();

            m_Min         = m_Max = Point.Empty;
            m_SortedTiles = new MultiTileEntry[count];
            for (int i = 0; i < count; ++i)
            {
                m_SortedTiles[i].m_ItemID  = Art.GetLegalItemID(reader.ReadUInt16());
                m_SortedTiles[i].m_OffsetX = reader.ReadInt16();
                m_SortedTiles[i].m_OffsetY = reader.ReadInt16();
                m_SortedTiles[i].m_OffsetZ = reader.ReadInt16();
                m_SortedTiles[i].m_Flags   = reader.ReadInt32();
                if (useNewMultiFormat)
                {
                    m_SortedTiles[i].m_Unk1 = reader.ReadInt32();
                }
                else
                {
                    m_SortedTiles[i].m_Unk1 = 0;
                }

                MultiTileEntry e = m_SortedTiles[i];

                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;
                }
            }

            ConvertList();
            reader.Close();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Sets bmp of index in <see cref="m_Cache"/> of Static
        /// </summary>
        /// <param name="index"></param>
        /// <param name="bmp"></param>
        public static void ReplaceStatic(int index, Bitmap bmp)
        {
            index  = Art.GetLegalItemID(index);
            index += 0x4000;

            m_Cache[index]   = bmp;
            m_Removed[index] = false;
            if (m_patched.Contains(index))
            {
                m_patched.Remove(index);
            }
            Modified = true;
        }
Ejemplo n.º 12
0
        private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            if (!StaticIndexInit)
            {
                InitStatics();
            }

            if (_statics?.CanRead != true || !_statics.CanSeek)
            {
                _statics = _staticsPath == null
                    ? null
                    : new FileStream(_staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            }

            if (_statics == null)
            {
                return(EmptyStaticBlock);
            }

            int lookup = _staticIndex[(x * BlockHeight) + y].Lookup;
            int length = _staticIndex[(x * BlockHeight) + y].Length;

            if (lookup < 0 || length <= 0)
            {
                return(EmptyStaticBlock);
            }

            int count = length / 7;

            _statics.Seek(lookup, SeekOrigin.Begin);

            if (_buffer == null || _buffer.Length < length)
            {
                _buffer = new byte[length];
            }

            GCHandle gc = GCHandle.Alloc(_buffer, GCHandleType.Pinned);

            try
            {
                _statics.Read(_buffer, 0, length);

                if (_lists == null)
                {
                    _lists = new HuedTileList[8][];

                    for (int i = 0; i < 8; ++i)
                    {
                        _lists[i] = new HuedTileList[8];

                        for (int j = 0; j < 8; ++j)
                        {
                            _lists[i][j] = new HuedTileList();
                        }
                    }
                }

                HuedTileList[][] lists = _lists;

                for (int i = 0; i < count; ++i)
                {
                    var ptr = new IntPtr((long)gc.AddrOfPinnedObject() + (i * sizeof(StaticTile)));
                    var cur = (StaticTile)Marshal.PtrToStructure(ptr, typeof(StaticTile));
                    lists[cur.X & 0x7][cur.Y & 0x7].Add(Art.GetLegalItemID(cur.Id), cur.Hue, cur.Z);
                }

                var tiles = new HuedTile[8][][];

                for (int i = 0; i < 8; ++i)
                {
                    tiles[i] = new HuedTile[8][];

                    for (int j = 0; j < 8; ++j)
                    {
                        tiles[i][j] = lists[i][j].ToArray();
                    }
                }

                return(tiles);
            }
            finally
            {
                gc.Free();
            }
        }
Ejemplo n.º 13
0
        private int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            using (
                FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read),
                fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader indexReader = new BinaryReader(fsIndex), lookupReader = new BinaryReader(fsLookup))
                {
                    int count = Math.Min((int)(indexReader.BaseStream.Length / 4), (int)(lookupReader.BaseStream.Length / 12));

                    var lists = new HuedTileList[8][];

                    for (int x = 0; x < 8; ++x)
                    {
                        lists[x] = new HuedTileList[8];

                        for (int y = 0; y < 8; ++y)
                        {
                            lists[x][y] = new HuedTileList();
                        }
                    }

                    for (int i = 0; i < count; ++i)
                    {
                        int blockID = indexReader.ReadInt32();
                        int blockX  = blockID / matrix.BlockHeight;
                        int blockY  = blockID % matrix.BlockHeight;

                        int offset = lookupReader.ReadInt32();
                        int length = lookupReader.ReadInt32();
                        lookupReader.ReadInt32(); // Extra

                        if (offset < 0 || length <= 0)
                        {
                            if (StaticBlocks[blockX] == null)
                            {
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                            }

                            StaticBlocks[blockX][blockY] = TileMatrix.EmptyStaticBlock;
                            continue;
                        }

                        fsData.Seek(offset, SeekOrigin.Begin);

                        int tileCount = length / 7;

                        if (m_TileBuffer.Length < tileCount)
                        {
                            m_TileBuffer = new StaticTile[tileCount];
                        }

                        StaticTile[] staTiles = m_TileBuffer;

                        GCHandle gc = GCHandle.Alloc(staTiles, GCHandleType.Pinned);
                        try
                        {
                            if (m_Buffer == null || m_Buffer.Length < length)
                            {
                                m_Buffer = new byte[length];
                            }

                            fsData.Read(m_Buffer, 0, length);

                            Marshal.Copy(m_Buffer, 0, gc.AddrOfPinnedObject(), length);

                            for (int j = 0; j < tileCount; ++j)
                            {
                                StaticTile cur = staTiles[j];
                                lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
                            }

                            var tiles = new HuedTile[8][][];

                            for (int x = 0; x < 8; ++x)
                            {
                                tiles[x] = new HuedTile[8][];

                                for (int y = 0; y < 8; ++y)
                                {
                                    tiles[x][y] = lists[x][y].ToArray();
                                }
                            }

                            if (StaticBlocks[blockX] == null)
                            {
                                StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                            }

                            StaticBlocks[blockX][blockY] = tiles;
                        }
                        finally
                        {
                            gc.Free();
                        }
                    }

                    return(count);
                }
            }
        }
Ejemplo n.º 14
0
 public void Set(ushort id, sbyte z)
 {
     Id = Art.GetLegalItemID(id);
     Z  = z;
 }
Ejemplo n.º 15
0
 public void Set(ushort id, sbyte z, sbyte flag)
 {
     m_ID   = Art.GetLegalItemID(id);
     m_Z    = z;
     m_Flag = flag;
 }
Ejemplo n.º 16
0
 public void Set(ushort id, sbyte z)
 {
     m_ID = Art.GetLegalItemID(id);
     m_Z  = z;
 }
Ejemplo n.º 17
0
 public void Set(ushort id, sbyte z, sbyte flag)
 {
     Id   = Art.GetLegalItemID(id);
     Z    = z;
     Flag = flag;
 }
Ejemplo n.º 18
0
        private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
        {
            try
            {
                if (!StaticIndexInit)
                {
                    InitStatics();
                }
                if (m_Statics == null || !m_Statics.CanRead || !m_Statics.CanSeek)
                {
                    if (staticsPath == null)
                    {
                        m_Statics = null;
                    }
                    else
                    {
                        m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    }
                }

                if (m_Statics == null)
                {
                    return(EmptyStaticBlock);
                }

                int lookup = m_StaticIndex[(x * BlockHeight) + y].lookup;
                int length = m_StaticIndex[(x * BlockHeight) + y].length;

                if (lookup < 0 || length <= 0)
                {
                    return(EmptyStaticBlock);
                }
                else
                {
                    int count = length / 7;

                    m_Statics.Seek(lookup, SeekOrigin.Begin);

                    if (m_Buffer == null || m_Buffer.Length < length)
                    {
                        m_Buffer = new byte[length];
                    }

                    GCHandle gc = GCHandle.Alloc(m_Buffer, GCHandleType.Pinned);
                    try
                    {
                        m_Statics.Read(m_Buffer, 0, length);

                        if (m_Lists == null)
                        {
                            m_Lists = new HuedTileList[8][];

                            for (int i = 0; i < 8; ++i)
                            {
                                m_Lists[i] = new HuedTileList[8];

                                for (int j = 0; j < 8; ++j)
                                {
                                    m_Lists[i][j] = new HuedTileList();
                                }
                            }
                        }

                        HuedTileList[][] lists = m_Lists;

                        for (int i = 0; i < count; ++i)
                        {
                            IntPtr     ptr = new IntPtr((long)gc.AddrOfPinnedObject() + i * sizeof(StaticTile));
                            StaticTile cur = (StaticTile)Marshal.PtrToStructure(ptr, typeof(StaticTile));
                            lists[cur.m_X & 0x7][cur.m_Y & 0x7].Add(Art.GetLegalItemID(cur.m_ID), cur.m_Hue, cur.m_Z);
                        }

                        HuedTile[][][] tiles = new HuedTile[8][][];

                        for (int i = 0; i < 8; ++i)
                        {
                            tiles[i] = new HuedTile[8][];

                            for (int j = 0; j < 8; ++j)
                            {
                                tiles[i][j] = lists[i][j].ToArray();
                            }
                        }

                        return(tiles);
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
            finally
            {
                //if (m_Statics != null)
                //    m_Statics.Close();
            }
        }