Xmoto.bin

From X-Moto
Revision as of 15:58, 29 March 2007 by Nadenislamarre (talk | contribs) (Pack)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Català - Español

This file, which on Windows is located in the game installation directory and some random place on other systems, contains most of the built-in data you'll find in Xmoto. That is, the built-in levels, the textures, the sounds, and such. It's a very simple file format, there is no compression or anything, as most of the contained files are already compressed.

One might argue that it would be much nicer to have all these contained files as actual files in the file system instead, but for historical reasons this is how it is now; it might change in the future.

Note that xmoto.bin include files which are not architecture dependant.

Pack and unpack xmoto.bin

Unpack

Since xmoto 0.2.3, you can unpack xmoto.bin.

xmoto-edit -unpack BINFILE TARGETDIR [no_lst]  

or

xmoto -unpack BINFILE TARGETDIR [no_lst]  

where BINFILE is the path leading to xmoto.bin and TARGETDIR is its contained files should be extracted to. If no_lst is specified, no package.lst file will be generated, otherwise it will be put in the same directory as the BINFILE.

Pack

To create xmoto.bin, you must have all the necessary files to put into the archive and the file called ./package.lst (which is the list of files to add to xmoto.bin). The easiest way to get all these files is to checkout from cvs. On the cvs, theses files are put into the bin directory. To create xmoto.bin, just go into the bin directory and launch the following command :

xmoto-edit -pack

or

xmoto -pack

Note that you don't really need to launch this command, because when you build xmoto using make, a rule recreates xmoto.bin if package.lst changed.

Update a file of xmoto.bin

xmoto is installed in your machine. However, you want to update your xmoto.bin, but you have not the writting permission on it. No problem. When xmoto is looking for a file, it first looks into ~/.xmoto because looking into xmoto.bin ; therefore, if you want to replace file file Sounds/bike.wav included into the xmoto.bin, just put it under ~/.xmoto/Sounds/bike.wav

Format

4 bytes: XBI1  (FILEID)     # indicates the file format

Following is an entry for each contained file in the package:

1 byte         (NAME_LEN)   # length of file name
NAME_LEN bytes (FILENAME)   # name of file, for instance Sounds/Strawberry.ogg
4 bytes        (FILESIZE)   # size of file, a little-endian integer
FILESIZE bytes (DATA)       # actual file data

Notice that file names don't have \0 in the end. Also notice that there's no information about how many files there are, so you should simply read until you get an EOF.

See Also