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()
isf.year, isf.month, isf.day, isf.hour and isf.minute then hold the values.
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 the subfolder '
0', which, of course, with a slash becomes '
\0', the '
NUL' character.
The code / algorithm should be easily convertable into your favourite programming language.