SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SHIII Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 08-19-15, 02:11 PM   #1
ExFishermanBob
Difficulties Numbing
 
Join Date: Aug 2013
Location: AN19
Posts: 444
Downloads: 43
Uploads: 0


Default

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 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
ExFishermanBob is offline   Reply With Quote
Old 08-19-15, 03:01 PM   #2
areo16
Sonar Guy
 
Join Date: Oct 2013
Posts: 382
Downloads: 64
Uploads: 0
Default

Quote:
Originally Posted by ExFishermanBob View Post
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.

I thought career saves are put in the "CareerName"\"Patrol number minus 1" folder?
So the 0 sub folder is actually the 1st patrol of the career, 5 subfolder is 6 patrol, etc...

I'm excited about the script!
areo16 is offline   Reply With Quote
Old 08-21-15, 09:53 AM   #3
ExFishermanBob
Difficulties Numbing
 
Join Date: Aug 2013
Location: AN19
Posts: 444
Downloads: 43
Uploads: 0


Default

Yes, I should have stated that the careers are saved in a numbered folder, so '0' will cause problems, as will (probably) 9 (tab) and possibly 7 (bell).
ExFishermanBob is offline   Reply With Quote
Old 08-21-15, 02:23 PM   #4
areo16
Sonar Guy
 
Join Date: Oct 2013
Posts: 382
Downloads: 64
Uploads: 0
Default

Quote:
Originally Posted by ExFishermanBob View Post
Yes, I should have stated that the careers are saved in a numbered folder, so '0' will cause problems, as will (probably) 9 (tab) and possibly 7 (bell).
Your not actually talking about a directory name?

This is an example:
"C:\Users\John\Documents\SH3\data\cfg\Careers\Test \5"

The above career is called "Test" and the Patrol number is 6. As far as I know you can only save in a career when you are on patrol. If you are not on patrol and in the office you cannot save the game. The game just keeps track of when you are out on patrol or not. The .isf file is in its corresponding patrol number folder.

It keeps track when you are on patrol in the Patrols_0.cfg file. This is the file with patrol that hasn't finished. Patrols.cfg holds patrols that have finished only.
areo16 is offline   Reply With Quote
Old 08-21-15, 03:49 PM   #5
ExFishermanBob
Difficulties Numbing
 
Join Date: Aug 2013
Location: AN19
Posts: 444
Downloads: 43
Uploads: 0


Default

I think you have missed my point. I know all about the saving and so on - what I was pointing out was, that in python, running under Windows a string with only single backslashes for path separators will, for certain values (particularly zero), be evaluated by python as an escape character when passed to file-handling routines.

Thus: "C:\somewhere\anywhere\but\this\0" will be interpreted as
"C:\somewhere\anywhere\but<tab>NUL" and an error will occur. \t is tab, \0 is null.

You must, therefore, in Windows (when programming in Python): use double backslashes (\\0) or forward slashes (/) or use a (so-called) "raw" string (prefixed by r: r"C:\etc") or decompose and recompose the path using the relevant python functions.

The original was easier to read.

So yes, I'm talking about the sub-directory of the "Career/name/" - which, for the first patrol, will be zero, for which see above IF you are using python in Windows and need to specify a path in a string. It catches me every single time, hence my note to others who might either encounter it for the first time, or, like me, continually forget.

For the full horror:

http://www.cisco.com/c/en/us/td/docs...n_r/frf019.pdf
ExFishermanBob is offline   Reply With Quote
Old 08-22-15, 03:54 AM   #6
areo16
Sonar Guy
 
Join Date: Oct 2013
Posts: 382
Downloads: 64
Uploads: 0
Default

Quote:
Originally Posted by ExFishermanBob View Post
I think you have missed my point. I know all about the saving and so on - what I was pointing out was, that in python, running under Windows a string with only single backslashes for path separators will, for certain values (particularly zero), be evaluated by python as an escape character when passed to file-handling routines.

Thus: "C:\somewhere\anywhere\but\this\0" will be interpreted as
"C:\somewhere\anywhere\but<tab>NUL" and an error will occur. \t is tab, \0 is null.

You must, therefore, in Windows (when programming in Python): use double backslashes (\\0) or forward slashes (/) or use a (so-called) "raw" string (prefixed by r: r"C:\etc") or decompose and recompose the path using the relevant python functions.

The original was easier to read.

So yes, I'm talking about the sub-directory of the "Career/name/" - which, for the first patrol, will be zero, for which see above IF you are using python in Windows and need to specify a path in a string. It catches me every single time, hence my note to others who might either encounter it for the first time, or, like me, continually forget.

For the full horror:

http://www.cisco.com/c/en/us/td/docs...n_r/frf019.pdf
Understood. Escape characters.
areo16 is offline   Reply With Quote
Old 08-23-15, 02:53 AM   #7
ExFishermanBob
Difficulties Numbing
 
Join Date: Aug 2013
Location: AN19
Posts: 444
Downloads: 43
Uploads: 0


Default

Ah, yes. I could have just said that.

I develop in Linux for the ease of things, then transfer the code to Windows to polish and check it - and escape characters get me every time.

I have two other bits of code and a tool (the first part of the Kapitan's toolkit) which I hope to release this evening.
ExFishermanBob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright © 1995- 2026 Subsim®
"Subsim" is a registered trademark, all rights reserved.