This repository was archived by the owner on May 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathkvs_archive.py
More file actions
39 lines (30 loc) · 1.3 KB
/
kvs_archive.py
File metadata and controls
39 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import glob
import argparse
parser = argparse.ArgumentParser(description="AOT2 .ktsl2stbin files archiving tool.")
parser.add_argument("folder", help="folder with .kvs files")
args = parser.parse_args()
kfolder = args.folder
def read_bytes(filename):
print("Reading file " + filename)
b_list = []
f = open(filename, 'rb')
while True:
piece = f.read(1024)
if not piece:
break
b_list.append(piece)
f.close()
return b_list
def write_file(name):
print("Writing file "+name)
# First 96 bytes (0x60)
# This probably only works with AOT2 because the header might be different in each game
header = b'KTSR\x02\x94\xdd\xfc\x01\x00\x00\x016\x0e\xf4\x05\x00\x00\x00\x00\x00\x00\x00\x00\x10\xf7\x05&\x10\xf7\x05&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\xd4\xf4\x15 \xe9\x88\x00\xca\xab\xa8\xa9 \x00\x00\x00\xf7\xe8\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
new_file = open(name, "wb")
new_file.write(header + b"".join(fbytes))
new_file.close()
files = glob.glob(kfolder+'/*.[kK][vV][sS]')
fbytes = []
for f in files:
fbytes.append(b"".join(read_bytes(f)))
write_file("mod.ktsl2stbin")