PDA

View Full Version : Ancient ClanLib resource file



kanteen
05-17-2013, 03:49 AM
Hello,

I have taken over a game of which the author lost interest many years ago.
Unfortunately he only have the source code and the resource file, but the original artwork and sound effects are gone.

So what I am trying to do is to extract the assets back into their original files, but without success. :(


At the top of the resource file it says; "ClanSoft datafile version 3.0c"

So I went back in time to fetch v0.5.0 of ClanLib which is supposedly the last one to support that format version.
But compiling that old one on a modern Linux distribution was harder than I expected, and after many tried to fix it I gave up.

Again, I went back in time and fetched Debian v2.0 which I hoped would be in a state where I could at least compile ClanLib.
And again without success, just too much hassle to fix it.


So now I am asking here if anyone have a tool or code snippet to extract the assets of the resource file.
I am not a super-skilled coder, but I guess I could write one of my own if I knew how the format of the file is structured.


Anyone have a suggestion?

Regards
K.

Judas
05-17-2013, 08:15 AM
Okay, by looking at the old sources I believe the format looks like the following. Hopefully that will help you get the data out and into something more useful.

The base format:

uint8[29] FileIdentifier "ClanSoft datafile version 3.0"
uint32 FileOffsetToIndex

After reading that, seek to the index position in the file. It has the following format:

uint32 NumFiles
for (File = 0; File < NumFiles; File++)
{

uint16 NameLength
uint8[NameLength] Name
uint32 FileOffsetToData
uint32 DataSize
}

Each file has its own separate format. One file is special and it is named "_script_section". It contains the original .scr file used to generate the datafile. The format of the other files depends on the type as described in the "_script_section" file.

There are the following other file formats:

type "raw", "module" or "sample":

uint8[] RawData

type "surface":

uint32 Width
uint32 Height
uint32 NumFrames
uint32 ColorKey (0xffffffff = no color key)
uint8 HasPalette
if (HasPalette)
{

uint8 Palette[3*256]
}
uint8 IsIndexed
uint32 RedMask
uint32 GreenMask
uint32 BlueMask
uint32 AlphaMask
uint32 Depth
uint8 Pixels[Width * ((Depth + 7) / 8) * Height * NumFrames]

type "font":

uint32 SpaceLength
uint32 SubtractWidth
uint32 LettersLength
uint8[LettersLength-1] Letters
uint8 AlwaysZero
for (Letter = 0; Letter < LettersLength - 1; Letter++)
{

uint32 Width
uint32 Height
uint32 NumFrames
uint32 ColorKey (0xffffffff = no color key)
uint8 HasPalette
if (HasPalette)
{

uint8 Palette[3*256]
}
uint8 IsIndexed
uint32 RedMask
uint32 GreenMask
uint32 BlueMask
uint32 AlphaMask
uint32 Depth
uint8 Pixels[Width * ((Depth + 7) / 8) * Height * NumFrames]
}

kanteen
05-19-2013, 02:45 PM
Thank you very much!
It was more than I hoped for, but indeed was very useful.

As I wrote, I am not very skilled yet but I have managed to extract the data at least (very interesting experience involving zlib).
I think I should manage from now.

Again, many thanks.

Regards
K.