![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
08-19-15, 02:11 PM
|
#10 |
|
Difficulties Numbing
|
The ISF file has a section starting with the submarine's type-name (e.g. SSTypeVIIB) and ending with the same.
So, it looks a bit like this (but bigger): ................ .............SST ypeVIIB......... ................ ....007400110004 00200043........ ................ .....SSTypeVIIB. ................ ................ extract_bytes() looks for the first occurrance of the type-name (SSTypeVIIB), and gets all the bytes following, ......... ................ ....007400110004 00200043........ ................ .....SSTypeVIIB. ................ ................ then looks in what it has got and removes the second type-name (SSTypeVIIB), leaving a 'snip' of the required bytes. ......... ................ ....007400110004 00200043........ ................ ..... The year, month, date, hour and minute start at 461 bytes back from the end of the 'snip', so that bit is put into self.extract. 007400110004 00200043 extract_date_and_time() uses the values in self.extract and computes the integer values from the bytes using big-endian conversion. To use it:- Code:
isf = ISFFile() isf.look_for = b"SSTypeVIIB" isf.extract_bytes(r"some_file_path\some_filename.isf") isf.extract_date_and_time() NOTES: The look_for value must be bytes (note the leading b) In Windows, you need to make sure the path is 'raw' or reverse the slashes because the career saves are stored in numbered subfolders: '0', which, of course, with a slash becomes '\0', the 'NUL' character, and '9' which is a tab might cause problems. The code / algorithm should be easily convertable into your favourite programming language. Last edited by ExFishermanBob; 08-21-15 at 09:55 AM. Reason: Notes added |
|
|
| Thread Tools | |
| Display Modes | |
|
|
