Map Database  •  FAQ  •  RSS  •  Login

mapelem.dat decoded

<<

JBSnorro

Barbarian

Posts: 106

Joined: 20 Nov 2007, 23:00

Post 17 May 2009, 19:53

mapelem.dat decoded

So, after some progress in houses.dat and unit.dat I decided to take a look at mapelem.dat, because I thought it wasn't decoded yet.
It contains an array[254] of
{
short[30] Animation;
short Count;
int X, Y;
Boolean Choppable;
Boolean UnWalkable;
Boolean Unknown;
Boolean Vineyard_or_Cornfield;
Boolean Growable;
Boolean PreservePlantingDistance;
sbyte TreeTrunk;
Boolean Buildable;
}
There are two things I should note, the booleans are saved as integer and have the value 1 for true and zero for false. Secondly, the boolean Growable is also true for treetrunks, which is a little unexptected.
Then there is only one boolean undecoded, and I've assembled an image containing the textures for which this boolean is true, and as you can see the boolean probably doesn't mean anything important. Feel free to guess in what way the textures in that image are different from all others.
<<

JBSnorro

Barbarian

Posts: 106

Joined: 20 Nov 2007, 23:00

Post 19 May 2009, 18:51

I might as well post what I've found out about pattern.dat, although it isn't much.
it contains:
an array of part1 with count 256.
an 2D array of part2 with counts 30.
After each dimension, a byte is stored, with unknown meaning.

Also very important is the symmetrie along the diagonal of the 2D array(for example, array[4,1] == array[1,4] and array[8,6] == array[6,8] and so on). There are 4 exceptions which break this symmetry though.

struct part1
{
byte MinimapColor;//index to color in bbm files
bool Walkable;
bool Buildable;
byte Type;//for example grass, desert or ironmountain.
bool Unknown1;
byte Unknown2;//ranges from 0 to 9
}
struct part2
{
byte[3] Unknowns3;
bool[7] Unknowns4;
}

I haven't been able to figure out what the data in part2 means, because the game functions perfectly even if you set all bytes to 0 or 255.... It's hard to decode a file if you don't notice any change in KaM....

Anywayz, except for maybe the minimapcolor, buildablility and walkability, this information isn't of much importance.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 20 May 2009, 06:12

Great find JBSnorro!
  Code:
struct part1 { byte MinimapColor;//index to color in bbm files bool Walkable; bool Buildable; byte Type;//for example grass, desert or ironmountain. bool Unknown1; byte Unknown2;//ranges from 0 to 9 }[/quote] I'm certainly sure 'Type' is used in passability/buildability computations. Just to remind - we can't build fields on anything but soil, mines can be built only on mountains, crabs can walk only on sand, and etc.. So it is rather usefull data )) [code]struct part2 { byte[3] Unknowns3; bool[7] Unknowns4; }[/quote] Looks like tiling table. I have similar thing in KaM Editor and it is mirrored diagonally! It can have allowed tile-tile combinations and blends. Rather neat it would be :) Man, I wish I could join the decoding and test it thoroughly.. but I have exams soon and that stresses me enough already It's great to see there's decodale stuff in pattern.dat :)
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

harold

Knight

Posts: 562

Joined: 19 Nov 2007, 23:00

Post 20 May 2009, 09:40

So, what would that table be used for?
Random guess: the way in which the grass tiles should appear when mining a stone hill?
<<

JBSnorro

Barbarian

Posts: 106

Joined: 20 Nov 2007, 23:00

Post 20 May 2009, 17:39

@ Krom: Hihi, you seem to value the findings more than I do :P

Anyways, the Type is indeed probably used to identify tiles for fields, mines and crabs. I was actually looking for data which specifies which trees can be planted at what tile, but if it isn't in pattern.dat, it will probably be hardcoded in the exe :(

But i've got exams next week, so i'll be busy doing other stuff to. I kinda dismissed the "tiling table", because I didn't have a clue what it might contain, but I did see some bytes that might be references to textures.

Edit:
So indeed, the table at the end appears to contain data regarding texturetypes. The image with the data translated to textures, looks like as if the data was used for mapcreation. That makes sense, since the game functions perfectly without the data.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 01 Jun 2009, 18:44

About Pattern.dat - how do you know these Walkable; Buildable; values are boolean, not a bitfield? How did you tested them?

Cos I took a quick look at them and whole thing looks like more of a bitfield thingy:
  Code:
  PatternDAT:array[1..256]of packed record     MinimapColor:byte;     Walkable:byte;  //This looks like a bitfield, but everything besides <>0 seems to have no logical explanation     Buildable:byte; //This looks like a bitfield, but everything besides <>0 seems to have no logical explanation     TileType:byte;  //This looks like a 0..31 bitfield, --||--     u1:byte; //Boolean IsTransitionTile?     u2:byte;   end;[/quote]
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

JBSnorro

Barbarian

Posts: 106

Joined: 20 Nov 2007, 23:00

Post 02 Jun 2009, 20:34

The only test I did was placing a file with exactly the same length, but it contained only zeros. The only difference I notited in KaM was a yellow minimapbackground, but nothing else. So the values probably aren't used any more in KaM, but were ment for mapcreation. Placing a file wasn't even necessary, because if you remove the pattern.dat file KaM will function as if the entire contents of that file were zero.

So I practically didn't "test" anything, I only reasoned about the meaning of the values.

And btw, I checked, you're right about the u1 IsTransitionTile.

Return to “Other Creations”

Who is online

Users browsing this forum: No registered users and 13 guests