• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RME .otbm file structure

qeels123

New Member
Joined
Apr 30, 2009
Messages
9
Reaction score
2
I'm wondering if someone can explain me structure of .otbm file

Thats just simple 256x256 map with 3 tiles mapped
Code:
0000 0000 fe00 0200 0000 0001 0001 0300
0000 3800 0000 fe02 0122 0053 6176 6564
2077 6974 6820 5265 6d65 7265 2773 204d
6170 2045 6469 746f 7220 332e 3201 1d00
4e6f 206d 6170 2064 6573 6372 6970 7469
6f6e 2061 7661 696c 6162 6c65 2e0b 1400
556e 7469 746c 6564 2d31 2d73 7061 776e
2e78 6d6c 0d14 0055 6e74 6974 6c65 642d
312d 686f 7573 652e 786d 6cfe 0400 0000
0007 fe05 7c7f 0980 01ff fe05 7d7f 0964
00fe 06bf 12ff fe06 bf11 ffff fe05 7e7f
09ae 11fe 067b 03ff fe06 7c03 fffe 067d
03ff fe06 2909 ffff fffe 0cff fe0f ffff
ff
I know that first lines are responsible for map description/name of houses and spawn files
I just wanna know what all of those hex numbers means and how each tile is described in .otbm file

Please, help me!
 
Last edited:
Probably nobody's going to tell you that, because if you didn't look it up in the sources (TFS or RME) yourself, you're probably not going to understand it. AFAIK there are some headers and additional descriptors at the beggining and then there's a list of tile areas (each area has full coordinates) and each area has a list of tiles that have offsets instead, to save space. The file has an overall tree structure.
 
Let's decode first line (it's hex, so 2 letters is 1 byte:
PHP:
0000 0000 fe00 0200 0000 0001 0001 0300

'0000 0000'
It's binary '0000' and it's loaded here:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L47 // load 4 characters from input
and check verified if it's '0000' or 'OTBM':
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L50 // memcmp - memory compare

'FE' is 254 [5th byte must be always 254] and it's checked here:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L53 // BinaryTreePtr root = fin->getBinaryTree();
which reefers to:
https://github.com/edubart/otclient...dae64b/src/framework/core/filestream.cpp#L336 // uint8 byte = getU8();
and then it make sure that it's binary tree - must start from BINARYTREE_NODE_START:
https://github.com/edubart/otclient...826dae64b/src/framework/core/binarytree.h#L31 // BINARYTREE_NODE_START = 0xFE

After FE there is check if this is really start of binary tree (must be '00'):
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L54 // if(root->getU8()) - if values is higher then 0, then turn off loading

Next 4 bytes '0200 0000' is 32 bit number of OTBM version:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L57 // uint32 headerVersion = root->getU32();
How to decode that number to decimal? It's easy:
'02' + '00' * 2^8 + '00' * 2^16 + '00' * 2^24 = 2

Next 2 bytes '0001' (16 bit number) is width of map:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L61 // setWidth(root->getU16());
00 + '01' * 2^8 = 0 + 1 * 256 = 256

Next 2 bytes '0001' (16 bit number) is height of map:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L62 // setHeight(root->getU16());
00 + '01' * 2^8 = 0 + 1 * 256 = 256

Next 1 byte '03' is major version of items (it check compability of MAP.OTBM and ITEMS.OTB versions):
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L64 // uint32 headerMajorItems = root->getU8();

Next 1 byte from first line and 2 bytes from second line '00 0000' are bytes for 'future use' (if it will be needed to keep more files versions then simple 1 byte items.otb version), so it's skipped in current loading:
https://github.com/edubart/otclient/blob/master/src/client/mapio.cpp#L70 // root->skip(3); - ignore 3 bytes




That was boring part of every OTBM file, now only 2 more 'checks' of version and start of items/tiles/house/protection zone/tile areas/towns/waypoints :)

Important function, it unserialize one node of binary tree [ignore start/end of node, give you access to pure 'data']:
https://github.com/edubart/otclient...6dae64b/src/framework/core/binarytree.cpp#L56

Code that load one item attributes from map:
https://github.com/edubart/otclient...e3b0016625a826dae64b/src/client/item.cpp#L119
 
Back
Top