Exemple #1
0
 public unsafe ItemData(NewItemTileDataMul mulstruct)
 {
     m_Name        = TileData.ReadNameString(mulstruct.name);
     m_Flags       = (TileFlag)mulstruct.flags;
     m_Unk1        = mulstruct.unk1;
     m_Weight      = mulstruct.weight;
     m_Quality     = mulstruct.quality;
     m_Quantity    = mulstruct.quantity;
     m_Value       = mulstruct.value;
     m_Height      = mulstruct.height;
     m_Animation   = mulstruct.anim;
     m_Hue         = mulstruct.hue;
     m_StackOffset = mulstruct.stackingoffset;
     m_MiscData    = mulstruct.miscdata;
     m_Unk2        = mulstruct.unk2;
     m_Unk3        = mulstruct.unk3;
 }
Exemple #2
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();
                    }
                }
            }
        }
Exemple #3
0
 public unsafe ItemData(NewItemTileDataMul mulstruct)
 {
     m_Name = TileData.ReadNameString(mulstruct.name);
     m_Flags = (TileFlag)mulstruct.flags;
     m_Unk1 = mulstruct.unk1;
     m_Weight = mulstruct.weight;
     m_Quality = mulstruct.quality;
     m_Quantity = mulstruct.quantity;
     m_Value = mulstruct.value;
     m_Height = mulstruct.height;
     m_Animation = mulstruct.anim;
     m_Hue = mulstruct.hue;
     m_StackOffset = mulstruct.stackingoffset;
     m_MiscData = mulstruct.miscdata;
     m_Unk2 = mulstruct.unk2;
     m_Unk3 = mulstruct.unk3;
 }