Thread overview
Empire Map File Format
Nov 05, 2016
Jim Hohorst
Nov 21, 2016
Jim Hyslop
Dec 26, 2016
Jim Hyslop
November 05, 2016
I'm interested in generating new maps for Empire (outside of the map editor) and have been trying to figure out the file format.  I've figured out the structure of the map itself, but after the map data there come a series of bytes separated by 0s.  As they match the number of cities on the map, I assume they have something to do with them, but haven't been able to understand the purpose. I would have thought they somehow indicated whether the city was on the water (and could build ships) and whether it could be a starting place for a game (not on single-city islands), but don't see any pattern (unless I'm reading them from the wrong direction).

Anyone know more about how the map files are structured?  I'm using Version 2.05c through DosBox on a Windows 10 machine.
November 21, 2016
On Saturday, 5 November 2016 at 03:35:16 UTC, Jim Hohorst wrote:
> I'm interested in generating new maps for Empire (outside of the map editor) and have been trying to figure out the file format.  I've figured out the structure of the map itself, but after the map data there come a series of bytes separated by 0s.  As they match the number of cities on the map, I assume they have something to do with them, but haven't been able to understand the purpose. I would have thought they somehow indicated whether the city was on the water (and could build ships) and whether it could be a starting place for a game (not on single-city islands), but don't see any pattern (unless I'm reading them from the wrong direction).
>
> Anyone know more about how the map files are structured?  I'm using Version 2.05c through DosBox on a Windows 10 machine.

Hi,

I don't know about 2.05c, but I have downloaded and examined the source for 2.03. This may or may not help, I don't know.

The format for 2.03 is a form of Run Length Encoding. The two least significant bits encode the map element (1=City, 2=Sea, 3=Land). The other six bits encode the number of sequential tiles of that element. Add 1 to the six-bit value to get the value. In C, you would write

int type;
int number;

number = (mapbyte >> 2 ) & 63;
type = mapbyte & 3;

The map data starts at the bottom right corner and works from right to left, bottom to top. A byte with the value 0 signifies the end of the data.

Here are the first couple of rows from Map A:
ubyte aDotMap[] =
[
	0x1a,0x13,0x06,0x13,0x36,0x07,0x76,0x07,
	0x06,0x1b,0x02,0x0f,0x66,0x2f,0xb2,0x2f,

0x1a: >> 2 gives 6; & 3 gives 2; so it is a sequence of 7 sea tiles
0x13: >> 2 gives 4; & 3 gives 3; so it is a sequence of 5 land tiles
and so on.

The map data is stored in a single-dimension array. The row/column numbering is inferred from the position within the array: Row is position/100, and column is position%100. Conversely, position = row*100 + column.

As I said, I don't know how much this will help, as it sounds like the map format has changed between 2.03 and 2.05c. This might give you some clues, though.
December 26, 2016
On Saturday, 5 November 2016 at 03:35:16 UTC, Jim Hohorst wrote:
> I'm interested in generating new maps for Empire (outside of the map editor) and have been trying to figure out the file format.  I've figured out the structure of the map itself, but after the map data there come a series of bytes separated by 0s.  As they match the number of cities on the map, I assume they have something to do with them, but haven't been able to understand the purpose.

Hi, again!

I found 2.05C on abandonia.com and downloaded it. Ahhh, that's the game I remember!

Anyway, I examined the map files and played with the built-in map generator. The extra bytes at the end of the file seem to indicate how many cities are on each continent. I'm guessing the first pair of bytes corresponds to the first city encountered (going from left-to-right, top-to-bottom), the second pair corresponds to the second city, and so on. Since you can have more than 256 cities on a map (and therefore on a continent), you need two bytes for the count. It appears to be stored big-endian, i.e. most-significant byte first.

For example, suppose you have two continents - one at the top of the map and one at the bottom. The top continent has 4 cities, and the bottom continent has 5. I would expect the last 18 bytes to be:

04 00 04 00 04 00 04 00 05 00 05 00 05 00 05 00 05 00