Forum Index
SUBSIM Forum Search

The Web's #1 BBS for all submarine and naval simulations!
[ SUBSIM Review ] [ SUBSIM STORE ]
Current Forum | Archives 2002-2003 |

Extracting TGA files from .dat files (tool inside)
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> SH3 Mods Workshop
View previous topic :: View next topic  
Author Message
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Sat Mar 26, 2005 4:44 am    Post subject: Extracting TGA files from .dat files (tool inside) Reply with quote

I've made an extract tool to extract the TGA files from the dat files in the data directory.

You can download it here: http://rapidshare.de/files/1088379/extract.zip.html
EDIT: Updated to a version that works. Please download again.
EDIT: Updated to version 0.2. Regular expression updated to accurately extract correct filename.

Its a command line tool, and it has some vague help if you type 'extract -h'.

Basically, a tga file is a pretty simple format, however, not knowing the format of the dat file doesnt help things.

Basically, in order to extract a tga file from the dat file I've created a regular expression:
Code:
\x00(\w+?\.tga)\W{1,15}?(\x00\x00\x02\x00\x00\x00\x00.....(..)(..)([\x08\x10\x18\x20]).*?TRUEVISION-XFILE.\x00)


Now, that may look complicated, but its not.

\x00 is a byte with decimal value 00. It doesnt print so well.
(\w+?\.tga) matches one or more alphanumeric characters (including _) ending in .tga. In other words, a filename.
\W{1,15}? matches only one at most 15 non-alphanumeric bytes.
(\x00\x00\x02\x00\x00\x00\x00..... matches the first 12 bytes of the tga file.
(..)(..) These four bytes are 2 for the width, and 2 for the height. Note that the first byte is the offset of the second byte * 256.
([\x08\x10\x18\x20]) This bit matches the colour depth. It expects 8, 16, 24 or 32 bits.
.*? Surprisingly this is the entire rest of the file containing all the data, right up to the last few bytes of the header.
TRUEVISION-XFILE.\x00) And finally, this is the last few bytes of the tga file.


Now, forget all of that, and onto extracting some tga's.

Unzip the tool into a temp folder.
Copy a dat file, such as:
C:\...\SilentHunterIII\data\Library\flag.dat
into the temp folder.

Open up a command prompt in the folder,

Then type

extract -l flag.dat

This will list all the filenames in that dat file.
To extract them all, just type

extract flag.dat

If everything goes alright (and at the moment, its a bit hit and miss), you should get some tga files being extracted.

Now, if you do try it with that flag.dat, you'll see that there are 26 .tga filenames in the file, but there are 28 tga footers. What does this mean? I dont know.


In some dat files, filenames are repeated, but the images are different. I didnt want to overwrite files, so the tool will append a duplicate number on the file. If you really want it to overwrite, just use the -o flag.

You can also extract a specific filename, using the -t <filename> option. If you want the second 'foo.tga' file, then add -n 2 as well. If you want the 5th, change it to -n 5 etc.

The extract program does some counting of file names, etc. If you find thats taking a lot of time, -s will skip the counting, and get straight to the extracting.

-h help
-d debug
-v verbose provide some help and more info.

And if you're really good with regular expressions, -r will let you change it, but beware, you can break it very easily.


Okay, so at this point, we can extract (nearly all) the tga files. Now what? Well, i've extracted a texture, edited it, then using a hex editor added it back into the dat file.



The result? Who wouldnt want to spray their name on the side of the Bismark?


It should be relatively easy to write another tool to inject the file back in there, but something to be careful about is after editing the file, your editor may put some extra comments on the end of the file, such as "this is was edited this file". I'm unsure as to whether this matters, but if the file sizes are different, and the dat file requires them to be a certain size then it will fail. More experimentation is needed.


Any questions?


Last edited by etchasketch on Fri Apr 01, 2005 2:32 pm; edited 2 times in total
Back to top
View user's profile Send private message
Augie64



Joined: 15 Mar 2005
Posts: 255

PostPosted: Sat Mar 26, 2005 4:47 am    Post subject: Reply with quote

the repeatable files with diffrent flags most likely is Warship and merchant ship from those countries.

so have you found anything good in the dat files =)

Im still trying to mod my torpedo to have 'up yours' written on it =)
Back to top
View user's profile Send private message Visit poster's website
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Sat Mar 26, 2005 4:53 am    Post subject: Reply with quote

Augie64 wrote:
so have you found anything good in the dat files =)

Im still trying to mod my torpedo to have 'up yours' written on it =)


Yep, there's torpedo textures.
Back to top
View user's profile Send private message
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Sat Mar 26, 2005 4:59 am    Post subject: Reply with quote

This interested me:



Any ever seen this little guy?
Back to top
View user's profile Send private message
Augie64



Joined: 15 Mar 2005
Posts: 255

PostPosted: Sat Mar 26, 2005 5:03 am    Post subject: Reply with quote

im still loking for the info that shows where a ships vulnerabilities are. would love to make a mod of target ships for multi player.

im guessing that could be a helmet device or har device?

il lstart looking around for something that looks like that.
Back to top
View user's profile Send private message Visit poster's website
sergbuto



Joined: 14 Sep 2002
Posts: 2530
Location: Sweden

PostPosted: Sat Mar 26, 2005 5:49 am    Post subject: Reply with quote

That is great, etchasketch. It seems like decoding for the rest of the dat files will be needed because it is doubtful that once promised SDK will be released by Devs due to SH4 plans.
Back to top
View user's profile Send private message Send e-mail
Sheppard



Joined: 17 Mar 2005
Posts: 369

PostPosted: Sat Mar 26, 2005 12:00 pm    Post subject: Reply with quote

Uhm, this needs PERL... I think...
Back to top
View user's profile Send private message AIM Address
R48



Joined: 22 Nov 2002
Posts: 222

PostPosted: Sat Mar 26, 2005 12:28 pm    Post subject: Reply with quote

I'd love to be able to edit the TGA files. But I'd probably need a tool to insert them back. I hope if one ever becomes available mention of it will be made here.
Back to top
View user's profile Send private message
sergbuto



Joined: 14 Sep 2002
Posts: 2530
Location: Sweden

PostPosted: Sat Mar 26, 2005 12:31 pm    Post subject: Reply with quote

Unfortunately, this does not work for me.

It says
"...couldn't find diagnostic data in C:\Perl\lib/pods/perldiag.pod PERL2EXE_STORAGE" and something about compilation.
Back to top
View user's profile Send private message Send e-mail
timetraveller



Joined: 23 Dec 2004
Posts: 967
Location: Atlantic Shipping Lanes

PostPosted: Sat Mar 26, 2005 12:31 pm    Post subject: Reply with quote

Another great job, etchasketch.

This had been on my task list of things to do when I get some time. I wrote the GUI file extractor for the Codename: Panzers game, including a file convertor (out and back) for the graphic files. Never could crack the 3D files though (with the prorietary format).

-timetraveller
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Seeadler



Joined: 14 Mar 2001
Posts: 1992
Location: Germany

PostPosted: Sat Mar 26, 2005 9:51 pm    Post subject: Reply with quote

The DAT files are compressed with the Data Compression Library from PKWare.
Back to top
View user's profile Send private message Send e-mail
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Sun Mar 27, 2005 1:19 am    Post subject: Reply with quote

Seeadler wrote:
The DAT files are compressed with the Data Compression Library from PKWare.


The dat files are not compressed. If they were, I wouldnt be seeing plain text in them.
Back to top
View user's profile Send private message
Jace11



Joined: 16 Mar 2005
Posts: 1091

PostPosted: Sun Mar 27, 2005 2:54 pm    Post subject: Reply with quote

Can extracted tgas be placed in the texture folder so the game uses them in preference to the ones in the original dat.

I thought this was what happened in the bismark mod that had correct symbol on the bow..
Back to top
View user's profile Send private message
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Sun Mar 27, 2005 10:06 pm    Post subject: Reply with quote

Jace11 wrote:
Can extracted tgas be placed in the texture folder so the game uses them in preference to the ones in the original dat.

I thought this was what happened in the bismark mod that had correct symbol on the bow..


This is a good question, and I had really hoped it would work too.

However, I tried this with the NBB_BismarkNewest.tga file, and it did not seem to make any difference. It may require more than just placing a file in Textures\TNormal\tex.

Theres also the problem of duplicate filenames.

The reverse seems to be true, for instance, if you delete the NBB_BismarkC.tga file from that directory, it reverts to the original packed tga, which has the swastika on the bow and stern.
Back to top
View user's profile Send private message
etchasketch



Joined: 22 Mar 2005
Posts: 76

PostPosted: Mon Mar 28, 2005 9:31 am    Post subject: Reply with quote

If you are interested in this, please read:

http://subsim.com/phpBB/viewtopic.php?t=31339
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> SH3 Mods Workshop All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group