ScrapHacks/parse_save.py

21 lines
623 B
Python
Raw Normal View History

from construct import *
from pprint import pprint
2019-09-02 19:44:17 +00:00
ScrapSaveVar = Struct(
2019-09-02 19:44:17 +00:00
"name" / PascalString(Int32ul, encoding="utf-8"),
"data" / PascalString(Int32ul, encoding="utf-8"),
)
2019-09-02 19:44:17 +00:00
ScrapSave = "ScarpSaveGame" / Struct(
"title" / PascalString(Int32ul, encoding="utf-8"),
"id" / PascalString(Int32ul, encoding="utf-8"),
"data" / PrefixedArray(Int32ul, ScrapSaveVar),
Terminated,
)
with open("Save0.sav", "rb") as sav_file:
save = ScrapSave.parse_stream(sav_file)
2019-09-02 19:44:17 +00:00
print("ID:", save.id)
print("Title:", save.title)
for var in save.data:
2019-09-02 19:44:17 +00:00
print(" - {}: {}".format(var.name, var.data))