Compare commits

..

3 Commits

Author SHA1 Message Date
c2b287c228 Added comment showing how shit I am 2024-07-26 10:17:56 +10:00
641fcad840 Added key lookup 2024-07-26 10:16:33 +10:00
da607f3158 Added new notes on save game research 2024-07-26 10:16:21 +10:00
2 changed files with 21 additions and 5 deletions

BIN
notes.md

Binary file not shown.

View File

@ -1,9 +1,15 @@
import struct
# BUG: I am dumb and used struct.pack to read values like a moron
# need to move to using struct.unpack and loading the size from the
# save file to make sure the entire label is retrieved
# Format for structure in notes.md
class OFFSETS:
VERSION = 0x42e
KEYS = 0x12DB
KEYS_LABEL = 0x12DB
KEYS_VALUE = 0x12F9
ACCOUNT_LEVEL = 0x12AD
@ -20,13 +26,22 @@ def load_save(save_file_name):
print(f"Failed to read save file: {e}")
def get_key_value(save):
try:
data = struct.pack(">i", save[OFFSETS.KEYS_VALUE])
return data
except struct.error as e:
print(f"{e}")
def verify_save(save):
try:
struct.pack("bbbb", *save[:4]) == b"GVAS"
token = _bytes_to_string(read_token_at_offset(save, OFFSETS.VERSION))
if token == "CrabChampionsVersion":
return True
except struct.error:
except struct.error as e:
print(f"{e}")
return False
@ -44,7 +59,7 @@ def read_token_at_offset(save, offset, size=1):
save = load_save("./test.sav")
if verify_save(save):
print("Save appears to be a save file of some kind")
print("Save is a valid Crab Champions save")
else:
print("The fuck is this shit mate")
exit()
@ -53,5 +68,6 @@ else:
# Should be fine to do shit here
# print(read_token_at_offset(save, 0x12DB)) # Keys
# print(read_token_at_offset(save, 0x12AD)) # AccountLevel
token = read_token_at_offset(save, OFFSETS.KEYS)
print(_bytes_to_string(token))
token = read_token_at_offset(save, OFFSETS.KEYS_LABEL)
# print(_bytes_to_string(token))
print(f"You have {int.from_bytes(get_key_value(save))} keys")