mirror of
https://github.com/CraftyBoss/Starlight-SMO-Example.git
synced 2026-07-14 05:06:43 -07:00
fix some bugs in genpatch and update example
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
{
|
||||
"build_id": "8F461D62E4461B7C89CC337B671FF126",
|
||||
"patchlist": {
|
||||
"patchlist1": {
|
||||
"name": "Example Patch 1",
|
||||
"patch1": {
|
||||
"type": "hex_le",
|
||||
"offset": "EXAMPLE_OFFSET_1",
|
||||
"contents": "0xDEADBEEF"
|
||||
}
|
||||
},
|
||||
"patchlist2": {
|
||||
"name": "Example Patch 2",
|
||||
"patch1": {
|
||||
"type": "hex_le",
|
||||
"offset": "0x42069",
|
||||
"contents": "0xDEADBEEF"
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -70,7 +70,7 @@ for template_key, template_value in template_json.items():
|
||||
# contents are little-endian
|
||||
# patches[patchlist_value['name']] = bytearray.fromhex(patchlist_value['items'].replace('0x', ''))
|
||||
try:
|
||||
patch_offset = int(patchlist_value['offset'])
|
||||
patch_offset = int(patchlist_value['offset'].replace('0x', ''), 16)
|
||||
except ValueError:
|
||||
# try and get the offset from defs if it's not hex
|
||||
if not patchlist_value['offset'] in defs:
|
||||
@@ -87,12 +87,12 @@ with open(sys.argv[3], 'w') as pchtxt:
|
||||
pchtxt.write('@little-endian\n')
|
||||
pchtxt.write('@nsobid-' + template_json['build_id'] + '\n')
|
||||
pchtxt.write('@flag offset_shift 0x100\n')
|
||||
pchtxt.write('\n')
|
||||
for patchlist in patchlists:
|
||||
pchtxt.write('\n')
|
||||
pchtxt.write('// ' + patchlist.name + '\n')
|
||||
pchtxt.write('@enabled\n')
|
||||
for patch in patchlist.patches:
|
||||
offset_hex = hex(patch.offset).replace('0x', '')
|
||||
offset_hex = hex(patch.offset).replace('0x', '').upper()
|
||||
if len(offset_hex) > 8:
|
||||
print('Offset ' + hex(patch.offset) + ' is too large!')
|
||||
sys.exit(7)
|
||||
|
||||
Reference in New Issue
Block a user