Quote:
Originally Posted by Ian*
Probably not a binary reader lol, dmaps are like..
0 = invalid coords
1 = valid coords
so for 0 draw a pixel of black for 1 draw a pixel of white.
|
You read the .dmap format with a binary reader. Heres the entire file:
Code:
_FileStream.Seek(268, SeekOrigin.Begin);
Map.PopulateTiles(Reader.ReadUInt32(), Reader.ReadUInt32());
for (ushort y = 0; y < Map.Height; y++)
{
for (ushort x = 0; x < Map.Width; x++)
{
Map.SetWalk(x, y, !Convert.ToBoolean(Reader.ReadUInt16()));
_FileStream.Seek(2, SeekOrigin.Current);
if (_Height)
Map.SetHeight(x, y, Reader.ReadUInt16());
else
_FileStream.Seek(2, SeekOrigin.Current);
}
_FileStream.Seek(4, SeekOrigin.Current);
}
uint PortalCount = Reader.ReadUInt32();
Map.PopulatePortals(PortalCount);
for (ushort y = 0; y < PortalCount; y++)
{
DMapPortal portal = new DMapPortal();
portal.XCord = (ushort)Reader.ReadUInt32();
portal.YCord = (ushort)Reader.ReadUInt32();
Map.SetPortal(y, portal);
_FileStream.Seek(4, SeekOrigin.Current);
}
Between access and height is a third variable which denotes the type of tile, not really necessary for private servers. Also i seek the first section of the file as its not necessary for loading the tiles.
And of course portals at the end of the file.
Edit: And also i just noticed that someone posted a copy of my loader from the CUOSP project, that loader is custom made to be used with my .smap format, it determines access based on the bits used in a byte to compress the size even further and reduce loading time. It will
not work with standard dmap files.