vice city online: the bare online core

This commit is contained in:
CRTkafa 2026-11-17 14:27:34 +07:00
commit 2f98475c19
256 changed files with 144219 additions and 0 deletions

60
tools/make-turkish-gxt.py Normal file
View file

@ -0,0 +1,60 @@
# Builds text/turkish.gxt: the Turkish text of the Gta Turk City mod (by Serdar "radreSword" Kilic),
# with the keys it lacks (settings this engine added) taken from the game's own american.gxt.
# Usage: python tools/make-turkish-gxt.py <mod american.gxt> <game american.gxt> <output>
import struct, sys
def read(path):
d = open(path, 'rb').read()
assert d[:4] == b'TABL', path
n = struct.unpack('<I', d[4:8])[0] // 12
out = {}
for i in range(n):
name = d[8 + i * 12:16 + i * 12]
off = struct.unpack('<I', d[16 + i * 12:20 + i * 12])[0]
p = off + (8 if i else 0)
assert d[p:p + 4] == b'TKEY', name
size = struct.unpack('<I', d[p + 4:p + 8])[0]
keys = p + 8
data = keys + size + 8
entries = {}
for k in range(size // 12):
o = struct.unpack('<I', d[keys + k * 12:keys + k * 12 + 4])[0]
key = d[keys + k * 12 + 4:keys + k * 12 + 12]
q = e = data + o
while d[e:e + 2] != b'\0\0':
e += 2
entries[key] = d[q:e]
out[name] = entries
return out
def write(path, tables):
names = [n for n in tables if n.rstrip(b'\0') == b'MAIN'] + sorted(n for n in tables if n.rstrip(b'\0') != b'MAIN')
body = bytearray()
start = 8 + 12 * len(names)
index = bytearray()
for i, name in enumerate(names):
offset = start + len(body)
index += name + struct.pack('<I', offset)
if i:
body += name
keys, text = bytearray(), bytearray()
for key in sorted(tables[name]):
keys += struct.pack('<I', len(text)) + key
text += tables[name][key] + b'\0\0'
body += b'TKEY' + struct.pack('<I', len(keys)) + keys + b'TDAT' + struct.pack('<I', len(text)) + text
if len(body) % 4:
body += b'\0' * (4 - len(body) % 4)
open(path, 'wb').write(b'TABL' + struct.pack('<I', len(index)) + index + body)
mod, game = read(sys.argv[1]), read(sys.argv[2])
added = 0
for name, entries in game.items():
target = mod.setdefault(name, {})
for key, value in entries.items():
if key not in target:
target[key] = value
added += 1
write(sys.argv[3], mod)
check = read(sys.argv[3])
assert check.keys() == mod.keys() and all(check[n] == mod[n] for n in mod)
print(f'{sum(len(t) for t in mod.values())} keys, {added} taken from the game')