Tomb Rider 9 (2013) locals.bin
Page 1 of 1

Author:  halfway [ Sat Oct 21, 2017 4:15 am ]
Post subject:  Tomb Rider 9 (2013) locals.bin

i need to edit this locals.bin from Tomb Rider 2013. how can i unpack and repack?

Author:  MajKSA [ Wed Oct 25, 2017 10:02 am ]
Post subject:  Re: Tomb Rider 9 (2013) locals.bin

I tried to make an exporter but no luck,
In the picture below is what i know about the file structure.
i hope this is useful if someone is willing to help you.

Author:  MaKiPL [ Fri Dec 15, 2017 8:58 am ]
Post subject:  Re: Tomb Rider 9 (2013) locals.bin

I have not yet break the header, but I can easily see that at 0x20C you can spot absolute pointer to text file segment. Every text is in UTF8 encoding. This is Polish language and it also uses HTML for marking text language. This file is quite easy format.

uint32 (here 7) - probably Polish language indicator. I don't really know why, but in my job we use '7' for language code for Polish too
uint32 - unknown
uint32 - I though it's text count, but it doesn't calculate.
Looks like header is 584 bytes long, after that normal pointer list (absolute) appears.

Every string is terminated with 0. I'm going for a meeting now, but I will code a tool for you when I get back.

Strings count as stated by MajKSA is wrong. :(

This is standalone file, so manipulating it should be easy, also there's no EOF or sections, but the file has pointers in it, that complicates things a bit, but that's still fine

String at 0x3554 is indeed one string and means "Błąd Tomb Raider". Therefore every special character in this case polish ł and ą are made by using two bytes, this is casual encoding thing. I can't seem to find the header structure (before pointers)

Found pointers count:
uint32 - unknown/ as said above- looks like language ID. Here 7=polish
uint32 - unknown_A
uint32 - unknown_B
Add unknown_A and unknown_B to get all pointers list. Keep in mind you can encounter null pointers!

Author:  MaKiPL [ Mon Dec 18, 2017 1:04 pm ]
Post subject:  Re: Tomb Rider 9 (2013) locals.bin

There you are:

import sys
import struct

curr = 0

lingual = open("locals.bin", "rb")
unk_A = struct.unpack('I', lingual.read(4))[0]
unk_B = struct.unpack('I', lingual.read(4))[0]
ffconst = unk_A + unk_B
pointerlist = []
while (curr < ffconst):
    returnme = lingual.read(4)
    pointerlist.append(struct.unpack('I', returnme)[0])
    curr = curr + 1
curr = 0
while (curr <= len(pointerlist)-1):
    if pointerlist[curr] < ((unk_A+unk_B)*4 ):
        curr = curr + 1
    charr = ""
    char_ = -1
    while (char_ != "\0"):
        char_ = lingual.read(1)
    curr = curr + 1

This will display all texts

For modifying I'm thinking of dumping whole script file and then rebuild the pointers basing on line, but there are some lines that have null pointer, so developer should also take note of it

Author:  WRS [ Mon Dec 18, 2017 8:13 pm ]
Post subject:  Re: Tomb Rider 9 (2013) locals.bin

keep pointerlist as 2 separate arrays - they are different things 8)

the first is something you need to leave as-is - it indexes the second array
the second is the string offsets you can change

the values are either 0 (fallback to default language maybe?) or pointers into the strings. values of 0 should be kept intact too!

strings are utf-8 encoded and must be kept that way - beware there are "special characters" for injecting font glyphs

edit: also note some strings support a html-like syntax! look at colours

<font color="#3C96E1">hello world</font>

Author:  delutto [ Wed Apr 04, 2018 11:09 pm ]
Post subject:  Re: Tomb Rider 9 (2013) locals.bin


Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group