home pictures webcam about me various eu2
inferis.org

eu2 » TBL Files » id.tbl

 
This file is a sort of "hit-test" matrix. With the data contained in this file, you can easily find out which pixel on the map belongs to which province.

File Info
Location » (eu2 root)\map\id.tbl
Size » 4.488.436 bytes (4,28 MB)

File format
File layout This file is made up of two parts: offsets and data.

The offsets are a list of 7296 4-byte integers, which represent an offset into the file pointing to the datablocks. Since there are 7296 offsets, this means that each datablock contains information about each scanline on the map (since the map is 18944x7296 pixels).
The offsets are relative into the file: offset 0 does not mean the beginning of the file, but the first byte right after the offsets are done plus 4 bytes.

# index is the index of the line you want to read (0-7295)
relative_offset = read_file( index )
real_offset = 4 * ( map_height + 1 + relative_offset )

Now we know the offset of the datablock for each line. Each of these lines contains a number of smaller blocks of 6 bytes each.
A small block represents a span in the line. It contains a start X coordinate, an end X coordinate and an province Id.

The blocks are formatted like this:
bytes 1 & 2 bytes 3 & 4 bytes 5 & 6
start X value province ID end X value

So, each line contains a number of spans. All spans combines form a whole line: the first block starts with start-x value 0, the last block has and end-x value of 18944 (the map size). So you know when to stop reading when the end-x value is equal or greater than the map size. The block after the last block (in a line) is the first block of the next line.

A span of smaller blocks

Usability
I guess this file is used for hit testing: all you have to do is find out the offset of the y-coordinate in the file, and read blocks until you found the one which spans your x-coordinate.