Unpacking the game filesReport
English:Unpacking the game files · Other
To get the region boundaries on the map right, I went and unpacked Kenshi's own files. Boundaries turned out to be the least of it, because even a question as basic as how many regions this world has gets a different answer from the game than from the wiki. This page records the process, what came out of it, and how I decide which side to believe.
- It started with one region in two separate pieces
- The game records regions as colours
- I looked in the wrong folder first
- Three regions that do not exist in the game at all
- A third of the world belongs to no region
- The thing that unsettles me most
- So who do I trust now
- An island with no name
- The height map
- See also
It started with one region in two separate pieces
The interactive map on this site cuts the world into ten thousand-odd cells, and every cell belongs to some region. That lookup table was originally computed, taking the coordinates of known settlements as seeds and growing outwards until they ran into another region. It sounds reasonable and in practice it goes wrong, because some regions grew into two pieces that do not touch, with somebody else's territory in between. The Iron Trail was the worst, with half the map between its two halves.
I patched it several times, and every round was another algorithm making another guess. Somewhere in there I stopped and thought that the game must know where its own region boundaries are, so why am I guessing.
So I went and unpacked the game files.
The game records regions as colours
Kenshi's region definitions sit in rebirth.mod, one record per region, with fields like this:
| Field | Meaning |
|---|---|
| acidic ground | whether the ground here corrodes you |
| acidic water | whether the water does |
| weather strength multiplier | weather strength multiplier |
| num nests | number of nests |
| arrival dialog | which line of dialogue fires when you walk in |
| index | a number |
The first few explain themselves, and the acid rain, weather and bug nests written up on this site come from here. But there was not a single coordinate in any of it. I was stuck on that index number for a long time before working out that it is not a serial number, it is the three RGB channels packed into one integer. The Great Desert is #C86400, Shun is #042C2C, Obedience is #BE8CBE.
So the shape of a region was never stored as numbers, it was painted. There is an image with every region filled in its own colour, and the game looks it up.
That image is areasmap.tga, 256 by 256, with 71 colours in it. 70 of them are regions and the remaining one is pure black.
I looked in the wrong folder first
One detour here is worth writing down. The copy of the game files I already had also contained a land folder, also with an areasmap.tga in it, and when I checked it against the settlements only 3 regions matched, so nearly all of it was wrong. My conclusion at the time was that this approach did not work.
I had been looking in the wrong place. That folder is an early test map with no bearing on the shipped world, and the evidence is that it carries 16 terrain textures where the real world references 266. The real one lives under data/newland and runs to 1.2 GB, which the copy on my disk had skipped when it was made.
With that filled in, the same script hit all 70 regions exactly, with none out of place.
I am recording this because the same thing sat in two places under identical names, with a world of difference in the contents. Partway through I came very close to writing down that the game files do not contain this data.
Three regions that do not exist in the game at all
Checking the painted map against the site, we list 72 regions and the game paints 69 of them. I took the three missing ones for an oversight, went digging through the game files, and found they were not missing at all, since those names never appear anywhere in the game data even once.
These three are names the wiki gave to unnamed ground. On the game's side those places are simply wasteland without a name, and no official record was ever created for any of them.
There is also one called Obedience, which does have a record in the game, but on the painted map it covers only twenty-odd pixels, which amounts to not being painted at all.
I have not taken those three off the site. Where the game paints nothing I still fill the area in by estimate, the map marks it with a star, and opening it says plainly that the extent is estimated. The reason is that players read the wiki and use these names, so deleting them here would only stop people finding things. But "this is the game's name for the place" and "this is the wiki's name for the place" are two different claims, and that is worth spelling out.
A third of the world belongs to no region
The pure black on the painted map covers 32.6%.
I assumed at first that black meant sea, then checked it against coordinates and found otherwise, because a good deal of the black is on land. So close to a third of Kenshi's ground belongs to no named region, and when you walk over it no place name comes up on screen, because the place genuinely has no name.
You do not notice this while playing, since ground with no name usually has nothing happening on it either. But it explains why the "region" given for some ruins never matches whatever source you check. The ruin is standing on nameless ground, and the wiki editor had to pick the nearest region and write that in.
The thing that unsettles me most
Once the painted map was wired in, I tested it against the 153 settlements this site has audited one by one, and 15 did not match.
I assumed the painted map had got them wrong. But I also had a second result from a completely different source, computed from the boundary lines drawn on the official world map, with no relationship to the painted map at all. Comparing the two, on all 15 of them both give exactly the same answer, and both differ from our audit records.
Two unrelated methods wrong in exactly the same way usually means the one that is wrong is us.
The Fishing Villages are the glaring case. There are two of them in the game, and our records put the first on the Northern Coast and the second in the Outlands. Both methods independently came out the other way round.
The others go like this:
| Place | What we wrote | Game files |
|---|---|---|
| Lost Library | Vain | Leviathan Coast |
| Fallen Tower | Arach | Leviathan Coast |
| Old Village | The Great Desert | Cannibal Plains |
| Holy Farm | Okran's Pride | Okran's Valley |
| Waystation | Border Zone | Grey Desert |
I have not changed them yet. These names are scattered across dozens of articles, and changing one means changing a string of others, and I want to put every entry in front of the game files myself before touching anything, rather than papering over the old errors with a fresh batch of new ones. This round only swaps the map's boundaries for the ones the game paints, and which region a settlement belongs to gets handled separately.
So who do I trust now
I work in three layers.
Where the game files say something, the game wins. Region shapes, acid rain, weather, nest counts, the game records all of these itself and there is nothing to discuss.
Where the game records nothing and the wiki does, the wiki is used, with its source marked. Islands of None and the other two work this way, kept on the site with a star on them.
Where the two disagree, it is left alone and flagged until I have checked each entry individually. The table above is that pending list.
After the swap, the number of regions on the map that come in disconnected pieces dropped from 12 to 2. I checked the remaining 2 against the official map, and the game does draw them that way.
An island with no name
After the game's painted map went in, one URL on the site did nothing when you clicked it. Following it through, that cell has a land ratio of 0.93, so it is solid ground, but it has no region. There are 8 such cells on the whole map, all packed into the same patch in the north-west corner.
I went back to the raw painted map, and the whole patch is black, black for twelve cells square around it. Cutting out the base map to look, it is a long thin island sitting on its own off the north-west coast.
Four things can be read out of the files:
| What was checked | That island | For comparison |
|---|---|---|
| Region colour | Black, and black for twelve cells square around it | |
| Object placement | 0 items | Stobe's Gamble has 193 |
| Any zone file | Not one file across the 15 cells covering it | 524 worldwide |
| Height | 1 | Open sea 0, Rebirth 41, The Great Desert 53, Ashlands 91 |
So the game gave it no name, put nothing on it, and its height is barely above the sea.
This is not a special case. 32.6% of the world's ground is in the same state, and most of it is inland, wedged between named regions, so you walk past without noticing. This island happens to be out at sea, which is what makes it stand out.
On the site I merged those 8 cells into the nearest region, 7 to the Iron Trail and 1 to Raptor Island. That was my decision, not the game's.
The height map
fullmap.tif is 537 MB, and scaled down it becomes a 3277-square height map at roughly 90 world units per pixel.
Computing slope from it gives two figures the site did not have before. The highest region by elevation is Royal Valley (92), and the lowest are Raptor Island and Islands of None (1). The most rugged terrain is Wend (mean slope 4.32) and Obedience (3.29), and the flattest are the offshore islands.
That matches the impression the game gives. Royal Valley is up in the mountains, and Fishman Island is flat swamp.
I had wanted to use it for "how steep is this leg of the route" and wire it into the route planner. Looking into it, that does not work, or rather it only half works. Slope tells you how broken the terrain is, but not whether you can get through. What blocks you in Kenshi is the collision mesh on the models rather than the height of the terrain, and that data is not in any file I can unpack.
Incidentally, I had assumed settlements would be built on flat ground. Measured, the median slope under the 259 settlements is 0.71, and the median across all land is also 0.71, with no difference at all.