home pictures webcam about me various eu2
inferis.org

eu2 » TBL Files » adjacent.tbl

 
This file contains the information about "adjacent" provinces: for each province, it lists the provinces that are adjacent to that province. This also includes rivers, which are considered provinces.

File Info
Location » (eu2 root)\map\adjacent.tbl
Size » 112.976 bytes (110 KB)

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

The offsets are a list of 1616 4-byte integers, which represent an offset into the file pointing to the datablocks. There are 1615 provinces defined in province.csv, thus we've got one offset too much? Nope: what we actually have here are pairs of offsets, where the last offset of a pair is also the first offset of the next pair. So, we still got 1615 pairs of offsets, this means that each datablock contains information for each province.

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. Additionally, since each item in a datablock is 12 bytes long (see later), we'll have to multiply the offset by 12 before adding it to the base offset (1616*4):

# province_count is the number of provinces (typically 1615)
# index is the index of the line you want to read (0-province_count)
relative_offset = read_file( index )
real_offset = (province_count+1)*4 + relative_offset * 12;

Now we know the offset of the datablock for each province. A datablock is a list of 12 byte items, each representing a link to an adjacent province.

Each item is formatted like this:
bytes 1-4 bytes 5-8 bytes 9-12
province ID river flag filler

  • The province ID denotes the "linked" province, ie the province adjacent to the current province.
  • The river flag is a flag marking if you need to cross a river to reach the linked province. It doesn't specify what river, but it'll be in the same list, of course.
  • The filler is always 0xCDCD. It has no special meaning, as far as I could find out.
  • A span of smaller blocks

    The get a full list of adjacent provinces, you find out the offsets as described above, start reading at the begin offset, and stop when you reached the end offset. It's as simple as that.

    Usability
    I guess this information is used in creating a path to go from one province to another. After all, you need to know which province is adjacent to another for that, right?