Ejemplo n.º 1
0
        private static void LoadLandTiles(byte[] data, InternalLandTile[] landTiles)
        {
            MemoryStream ms = new MemoryStream(data, false);
            BinaryReader bin = new BinaryReader(ms);

            // TODO: Is this robust enough?
            ms.Seek(36, SeekOrigin.Begin);
            string name = ASCIIEncoding.ASCII.GetString(bin.ReadBytes(20)).TrimEnd('\0');
            if (name == "VOID!!!!!!")
                oldFormat = true;
            ms.Seek(0, SeekOrigin.Begin);

            if (oldFormat)
            {
                for (int i = 0; i < 0x4000; ++i)
                {
                    if (i == 0 || (i > 0 && (i & 0x1f) == 0))
                    {
                        bin.ReadInt32(); // block header
                    }

                    landTiles[i].Flags = (TileFlags)bin.ReadInt32();
                    landTiles[i].ID = bin.ReadInt16();
                    landTiles[i].Name = ASCIIEncoding.ASCII.GetString(bin.ReadBytes(20)).TrimEnd('\0');
                }
            }
            else
            {
                for (int i = 0; i < 0x4000; ++i)
                {
                    if (i == 1 || (i > 0 && (i & 0x1f) == 0))
                    {
                        bin.ReadInt32(); // block header
                    }

                    landTiles[i].Flags = (TileFlags)bin.ReadInt64();
                    landTiles[i].ID = bin.ReadInt16();
                    landTiles[i].Name = ASCIIEncoding.ASCII.GetString(bin.ReadBytes(20)).TrimEnd('\0');
                }
            }

            ms.Close();
        }
Ejemplo n.º 2
0
 internal LandTile(InternalLandTile landTile)
 {
     this.Flags = landTile.Flags;
     this.ID    = landTile.ID;
     this.Name  = landTile.Name;
 }