Show whole topic Feb 15, 2019 9:30 pm
riess Offline
Approved Member
Registered since: Feb 09, 2019
Location: -

Subject: Re: M.A.X 2 Data Extractor
I've moved on to WLD files yesterday. Those files store game worlds (maps) and after few hours of fiddling around I've worked out the file format.

First part of file is 9-bytes long header:

DownloadSource code (Text):
  1.     Offset  Length  Description
  2.     0       3       Ascii string spelling "WLD"
  3.     3       2       Unknown, seems to equal to "1" in all maps
  4.     5       2       Integer, map's grid width
  5.     7       2       Integer, map's grid height

Width and height order is presumed because it looks like that all WLD maps size is 112 x 112.

Next width x height bytes is minimap. Each byte is id of color from file's palette.

This is followed by width x height x 2 bytes. This is list of numbers (each being 2-bytes long), describing the order in which map data is laid out.

Order is followed by height map, which is (width + 1) x (height + 1) long, with every byte representing next vertice's height.

At the end of height map there is two-bytes number containing number of grid cells. It equals to width x height, and seems to always be 12544 because all maps are 112 x 112.

Next is list of pixels. It's organized into blocks of 32 x 32 length. Order of blocks is specified earlier in the file, and every cell/sector has 1024 bytes. This amounts to 12845056 bytes total for 112 x 112 map.

List of pixels is followed by 768 bytes that contain color palette for the map (used by main image and minimap).

Palette is followed by width * height bytes, each byte representing map's cell/sector type (water, blocked, etc.). This map is split into 4 blocks of even length, each representing other quarter of the world.
This post has been edited 1 times. Last edit on Feb 15, 2019 9:37 pm by riess.