Updated parse_save.py to use PascalString and PrefixedArray
This commit is contained in:
		
							parent
							
								
									1dd2871dfb
								
							
						
					
					
						commit
						79889722ac
					
				
					 1 changed files with 20 additions and 18 deletions
				
			
		|  | @ -1,18 +1,20 @@ | |||
| from construct import * | ||||
| from pprint import pprint | ||||
| ScrapSaveVar = Struct( | ||||
|     'name'/PascalString(Int32ul,encoding='utf-8'), | ||||
|     'data'/PascalString(Int32ul,encoding='utf-8'), | ||||
| ) | ||||
| 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) | ||||
|     print("ID:",save.id) | ||||
|     print("Title:",save.title) | ||||
|     for var in save.data: | ||||
|         print(" - {}: {}".format(var.name,var.data)) | ||||
| from construct import * | ||||
| from pprint import pprint | ||||
| ScrapSaveVar = Struct( | ||||
|     'name'/PascalString(Int32ul,encoding='utf-8'), | ||||
|     'data'/PascalString(Int32ul,encoding='utf-8'), | ||||
| ) | ||||
| 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) | ||||
|     print("ID:",save.id) | ||||
|     print("Title:",save.title) | ||||
|     for var in save.data: | ||||
|         print(" - {}: {}".format(var.name,var.data)) | ||||
|     #for block in save.data: | ||||
|     #    print("{}: {}".format(block.v_name, block.v_data)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue