Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added save game decoding. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ def bytes_(i: int, data: bytes, chunksize=1, length: int = None, end: int = None
raise Exception('Invalid arguments to bytes_ typefunc')
return endpoint-i, data[i:endpoint]

def plugininfo(i: int, data: bytes, length=None) -> Tuple[int, dict]:
i_old = i
ln, pluginCount = uint8(i, data)
i+=ln # add read length
json={}
json["pluginCount"] = pluginCount
json["plugins"] = list()
for x in range(0, pluginCount):
ln, pluginFileName = wstring(i, data)
i+= ln
json["plugins"].append(pluginFileName)
# end for
assert(i_old + length == i)
return length, json

def encode_bytes(data: bytes) -> bytes:
return data

Expand Down Expand Up @@ -140,7 +155,7 @@ def encode_flags(flags: Set[int]) -> bytes:
(uint8, 'formversion', {}),
(wstring, 'gameversion', {'game': 'fallout4'}),
(uint32, 'plugininfosize', {}),
(bytes_, 'plugininfo', {'length': 'plugininfosize'}),
(plugininfo, 'plugininfo', {'length': 'plugininfosize'}),
# File location table
(uint32, 'formidarraycountoffset', {}),
(uint32, 'unknowntable3offset', {}),
Expand Down Expand Up @@ -432,6 +447,7 @@ def parse_savedata(rawdata: bytes) -> Tuple[str, Dict[str, Any]]:
for k,v in rawargs.items() if k != 'game'}
offset, data[key] = typefunc(i, rawdata, **args)
i += offset
assert i <= len(rawdata)
assert i == len(rawdata)
return game, data

Expand Down