Пример #1
0
		public unsafe LandData(NewLandTileDataMul mulstruct)
		{
			m_TexID = mulstruct.texID;
			m_Flags = (TileFlag)mulstruct.flags;
			m_Unk1 = mulstruct.unk1;
			m_Name = TileData.ReadNameString(mulstruct.name);
		}
Пример #2
0
 public unsafe LandData(NewLandTileDataMul mulstruct)
 {
     m_TexID = mulstruct.texID;
     m_Flags = (TileFlag)mulstruct.flags;
     m_Unk1  = mulstruct.unk1;
     m_Name  = TileData.ReadNameString(mulstruct.name);
 }
Пример #3
0
/*
 * // TODO: unused?
 *      public LandData(string name, int texId, TileFlag flags, int unk1)
 *      {
 *          Name = name;
 *          this.TextureID = (short)texId;
 *          Flags = flags;
 *          Unk1 = unk1;
 *      }
 */

        public unsafe LandData(NewLandTileDataMul mulStruct)
        {
            TextureID = mulStruct.texID;
            Flags     = (TileFlag)mulStruct.flags;
            Unk1      = mulStruct.unk1;
            Name      = TileData.ReadNameString(mulStruct.name);
        }
Пример #4
0
        public unsafe static void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    bool useNeWTileDataFormat = Art.IsUOAHS();
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[]   buffer  = new byte[fs.Length];
                    GCHandle gc      = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long     currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        for (int i = 0; i < 0x4000; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos        += 4;
                            landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewLandTileDataMul);
                                    NewLandTileDataMul cur =
                                        (NewLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                                else
                                {
                                    currpos += sizeof(OldLandTileDataMul);
                                    OldLandTileDataMul cur =
                                        (OldLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        long remaining  = buffer.Length - currpos;
                        int  structsize = useNeWTileDataFormat ? sizeof(NewItemTileDataMul) : sizeof(OldItemTileDataMul);
                        itemheader = new int[(remaining / ((structsize * 32) + 4))];
                        int itemlength = itemheader.Length * 32;

                        m_ItemData    = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        for (int i = 0; i < itemlength; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos        += 4;
                            itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewItemTileDataMul);
                                    NewItemTileDataMul cur =
                                        (NewItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewItemTileDataMul));
                                    m_ItemData[i + count]    = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                                else
                                {
                                    currpos += sizeof(OldItemTileDataMul);
                                    OldItemTileDataMul cur =
                                        (OldItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldItemTileDataMul));
                                    m_ItemData[i + count]    = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }