Skip to content

war3map.wpm Pathing

Stijn Herfst edited this page Jan 7, 2019 · 9 revisions

This is the pathing map. It contains information about which tiles are walkable/buildable/flyable/etc. Note that the pathing map only holds pathing information for doodads and not for destructibles (trees/pathing blockers) nor units.

Format

Here is the file format:

char[4]		magic_number
uint32		format_version
uint32		width
uint32		height  

And then width * height bytes.

uint8		flags

Explanation

char[4]		magic_number

A constant string at the start of the war3map.wpm file used to identify it.

uint32		format_version

The version. Seems to always be 0? Needs more investigation

uint32		width
uint32		height

The width and height of the pathing map. Note that this is actually 4 * terrain_width and 4 * terrain_height. Thus a tile is divided into 4x4 squares.

uint8		flags

Holds information about the pathability of the tile. Each bit is a boolean for a certain property.

0x01: 0 (unused)
0x02: 1=no walk, 0=walk ok
0x04: 1=no fly, 0=fly ok
0x08: 1=no build, 0=build ok
0x10: 0 (unused)
0x20: 1=blight, 0=normal
0x40: 1=no water, 0=water
0x80: 1=no amphibious, 0= amphibious ok

Implementation

A reference implementation in C++ is available here.

Extracting the relevant information is relatively simple:

uint8_t byte = reader.read<uint8_t>();
walkable =	!(byte & 0b00000010);
flyable = 	!(byte & 0b00000100);
buildable = 	!(byte & 0b00001000);
blight = 	!(byte & 0b00100000);
water = 	!(byte & 0b01000000);
amphibious = 	!(byte & 0b10000000);

The color of the pathing map in the editor is determined as such:

int r = walkable ? 0 : 255;
int g = flyable ? 0 : 255;
int b = buildable ? 0 : 255;

Bugs and Oddities

The circled red peasant when given the command to move to the red cross should take the black route. Instead it takes the blue route even though the black route is possible (and the shortest).

One Width Pathing Routes

This is because the black path only is 1 wide at a certain point. The game only calculates paths for 1 width when it is very close to its destination. This is due to performance concerns

One Width Hightlight

But this range for 1 cell calculations is very very small. I think that it is like that because the original developers never found a need for such detailed mapping, but the code is there in the game.