map_format

MangoQuest and MangoPeeler file format (.bmq)
Maps for versions 0.6.3 and 0.6.3a
by Clément "phneutre" Bourdarias
Programmer of The Blue Mango Quest
In this short text I'll explain the format of the file I use to stock maps.
If you just want to make maps, read the MangoPeeler user's manual .
The first thing to know is that maps are compressed using zlib with level 9 of compression.
Thus, it must be opened with someting like :
gzFile map_file=0;
if (!(map_file = gzopen(filename, "rb9")))
{
fprintf(stderr, "\nError opening file %s.\n", filename);
exit(1);
}
There are two main parts in a map file :

- Header (3 chars and 8 integers, that is 19 bytes)
- Datas (map in itself and world geometry)

1. Header
The header can be called quick description of the map.
1. The 3 first bytes are 3 chars that are used for the map verification. They must be respectively 'B', 'M' and 'Q'. It they're not, we can be sure that the map is corrupted.
Then, there is the compatibility number (integer), that is a number for the version of the map format.
2. The next 14 bytes are 7 integers that represent, in this order:
- size of the map (can be 14, 20 or 28)
- world of the map (can be 0, 1, 2 or 3, each number is one of the 4 worlds)
- time limit, in seconds (no limit if 0)
- number of huts, must be > 0
- number of shmolluxes, must be > 0
- number of lives at the beginning of the map
- square of the winning post (no winning post if -1)
2. Datas (map and world geometry)
There is two parts in the datas.
1. Map only
We will note the size of the map S.
A map is a big square of S * S little squares. On each square, we will put walls and ceiling or walls, and maybe a bonus with his parameter, and maybe a special object for his parameter. We will need 7 integers. thus or array will be an array of integers of S*S*7 size.
You can acces to it by a for loop:
int i=0;
for (i = 0; i < S* S* 7; i += 7)
{
array[i] is the ground texture for square i;
array[i + 1] is the ceiling texture for square i;
array[i + 2] is wall texture for square i;
array[i + 3] is bonus on square i;
array[i + 4] is bonus parameter on square i;
array[i + 5] is special object on square i;
array[i + 6] is parameter for special object on square i;
}
2. World geometry
(but I won't discuss here how to do a portal engine...)
The fist datas thare are written are the portals.
- Number of portals (integer)
and, for each portal:
- X1 (double)
- Z1 (double)
- X2 (double)
- Z2 (double)
- Type (can be 0 or 1 for Horizontal or Vertical)
- Number (each portal has a number)
Then, we found the big sectors datas. In each sector, we found :