MAP File Format

From WinWolf3D/WDC

WDC has its own MAP file format used to export maps.

In all versions, the map code data is stored like this:

for (y = 0; y < mapHeight; y++) {
  for (x = 0; x < mapWidth; x++) {
    writeMapCode(map[x][y]);
  }
}

Also, for all versions, the following pseudo-code illustrates how you would write to a MAP file:

WDC31Header header = loadFileHeader();
writeHeader(header);
for (map = 0; map < numberOfMaps; map++) {
  WDC31MapInfo mapInfo = loadMapInfo(map);
  writeMapInfo(mapInfo);
}

NOTE: When the mapName is not to be copied into the current map slot when the file is imported, all mapName chars must be set to 0xff.

Contents

WDC3.1

This is the version that WDC currently uses when exporting. This version added the ability to adjust the maximum map name length.

typedef struct {
  char   fileVersion[6]; // "WDC3.1"
  long   numberOfMaps;
  int    numberOfMapPlanes;
  int    maxMapNameLength;
} WDC31Header
typedef struct {
  char   mapName[maxMapNameLength];
  int    mapWidth;
  int    mapHeight;
  int    mapData[numberOfMapPlanes * mapWidth * mapHeight]
} WDC31MapInfo

WDC3.0

This version added the ability to store any given number of map planes in the file.

typedef struct {
  char   fileVersion[6]; // "WDC3.0"
  long   numberOfMaps;
  int    numberOfMapPlanes;
} WDC30Header
typedef struct {
  char   mapName[16];
  int    mapWidth;
  int    mapHeight;
  int    mapData[numberOfMapPlanes * mapWidth * mapHeight]
} WDC30MapInfo

WDC2.1

Other than fileVersion, I can see no difference from WDC2.0. WDC handles both versions the same way.

typedef struct {
  char   fileVersion[6]; // "WDC2.1"
  long   numberOfMaps;
} WDC21Header
typedef struct {
  char   mapName[16];
  int    mapWidth;
  int    mapHeight;
  int    mapData[3 * mapWidth * mapHeight]
} WDC21MapInfo

WDC2.0

This version changed the number of stored map planes to three.

typedef struct {
  char   fileVersion[6]; // "WDC2.0"
  long   numberOfMaps;
} WDC20Header
typedef struct {
  char   mapName[16];
  int    mapWidth;
  int    mapHeight;
  int    mapData[3 * mapWidth * mapHeight]
} WDC20MapInfo

WDC1.0

The original version was similar to MapEdit's FLR file format and FloEdit's LVL file format. It's important to note that it only allows two map planes per map.

typedef struct {
  char   fileVersion[6]; // "WDC1.0"
  long   numberOfMaps;
} WDC10Header
typedef struct {
  char   mapName[16];
  int    mapWidth;
  int    mapHeight;
  int    mapData[2 * mapWidth * mapHeight]
} WDC10MapInfo