Page 2 of 2

Re: SpellForce 2 .cff files

Posted: Fri Nov 07, 2008 9:56 am
by kramla
Csimbi wrote:Hi all,
is there a different way to extract said CFF file without the script above?
Thank you!
You can do it, when you split the cff archive into files with hexaeditor (this files must only contains "data of files" from cff).
Then you can decompress it with zlibc (in this forum) by this instruction
"zlibc -d C:\xxxx\xxx.dat C:\xxxx\uncompressedxxx.dat" (this instruction must be writen into cmd.exe - windows dos)
xxx.dat is name of compressed file and uncompressedxxx.dat is the result of decompression.

Re: SpellForce 2 .cff files

Posted: Fri Nov 07, 2008 9:18 pm
by Csimbi
Hi kramla,
thanks for the detailed instructions and screen shots in your PM.
Based on those, I have created a template for the Sweetscape 010 Editor - it should be easy to save the zlib pieces one by one.

Code: Select all

//--------------------------------------
//--- 010 Editor v3.0.3 Binary Template
//
// File: Spellforce 2 CFF file template
// Author: Csimbi
// Revision: 1.0.0
// Purpose: Game hacking
//--------------------------------------
struct FILE
{
    struct HEADER
    {
        uint32 Header;         // ? =0x12DD72DD
        uint32 ArchiveVersion; // ? =3
        uint32 Padding[3];     // ? =0
    } header;
    do
    {
        struct RECORD
        {
            uint32 FileID;           // ?
            uint16 Unknown1;         // ? =1 or =2
            uint32 CompressedSize;
            uint16 Unknown2;         // ? =1, =2 or =4
            uint32 UnCompressedSize;
            char CompressedData [CompressedSize];
        } record;
    } while (!FEof() && record.CompressedSize != 0);
} file;

Re: SpellForce 2 .cff files

Posted: Sat Nov 08, 2008 10:10 pm
by Csimbi
Here's a tool I just made to unpack the CFF files via command line - zlib decompression not included, so you will need another command line tool to do that.
Readme included, source code is available on request - just PM me. I used BCB6, but it should work with any C++ compiler.

Re: SpellForce 2 .cff files

Posted: Sun Nov 09, 2008 6:10 pm
by Csimbi
Hi all,
here's a command-line tool (an upgrade of the previous tool) that allows you to pack/unpack the CFF files. This one includes zlib (de)compression as needed.
Readme is included - though there is not much to read, the help will be dumped into the command-line window.
Source code is available on request - though I am not going to give you the source of my libraries and without those, it won't be worth much - PM me if you want it. I used BCB6, so you will need that, too.

Re: SpellForce 2 .cff files

Posted: Mon Nov 10, 2008 5:13 pm
by pixellegolas
this might be a stupid question but what files will come out? Any 3d files i can use? Like .3ds or .obj?

Re: SpellForce 2 .cff files

Posted: Mon Nov 10, 2008 8:24 pm
by kramla
pixellegolas wrote:this might be a stupid question but what files will come out? Any 3d files i can use? Like .3ds or .obj?
From language files (like english.cff), you will get files with text, and from the others there are some scripts, databases etc.. Maybe there are some compressed objects in cff files. You must to try it.

Kramla

Re: SpellForce 2 .cff files

Posted: Mon Nov 10, 2008 11:33 pm
by Csimbi
pixellegolas wrote:this might be a stupid question but what files will come out? Any 3d files i can use? Like .3ds or .obj?
If you want to mod maps, scripts, models, textures, sounds, music, etc, you need to extract the contents of the PAK files (no need to repack them, if they are in the right path, the game will use them). Take a look there: viewtopic.php?f=15&t=1902

From gamedata.cff you get a bunch of index files that essentially make up the items/spells/buildings/units/heroes/NPCs (and generally all objects). I am working on decrypting them, though it is a slow process. If you want to edit items and other things, you need to mess with the chunks in gamedata.cff

From the localization files (such as English.cff) you get a bunch of string tables. Some are simple unicode strings, some are pairs of unicode and UTF8 strings, and some are complex tables. If you want to translate the game to another language, you will need to mess with these files because they include all strings from the game...

Here are some templates that I found out the formats for (they might not be correct, but they do work):
1. This applies to most files (see list of flie IDs inside):

Code: Select all

//--------------------------------------
//--- 010 Editor v3.0.3 Binary Template
//
// File: uncompressed data chunks of CFF files in Spellforce 2.
// Appropriate files IDs in base\English.cff and addon1\English.cff:
    // 9018 (1/1)
    // 9035 (1/1)
    // 9036 (1/1)
    // 9037 (1/1)
    // 9039 (1/1)
    // 9040 (1/1)
    // 9041 (1/1)
    // 9042 (1/1) (empty in \base and \addon1)
    // 9044 (1/1)
    // 9045 (1/1)
    // 9046 (1/1)
    // 9047 (1/1)
    // 9053 (1/1)
    // 9055 (1/1) (empty in \base)
    // 9057 (1/1) (empty in \base)
// Author: Csimbi
// Revision: 1.0.0
// Purpose: Game hacking
//--------------------------------------
struct FILE
{
    struct HEADER
    {
        uint32 RecordCount;
    } header;
    local int i=0;
    local char bMulti=0;
    if(header.RecordCount>0) do
    {
        struct RECORD
        {
            uint16 ItemID;        // See base\script\gds\definitions\gdsdbexport.lua
            uint16 Unknown1;
            uint16 Unknown2;
            if(Unknown2==0)
            {
                uint16 Unknown3;
                bMulti=0;
            }
            else
            {
                FSkip(-sizeof(uint16));
                bMulti=1;
            }
            uint32 StringLen;
            if(StringLen>0) char String [StringLen*2];
            if(bMulti==1)
            {
                uint32 StringLen2;
                if(StringLen2>0) char String2 [StringLen2*2];
            }
        } record;
        ++i;
    } while (!FEof() && i<header.RecordCount);
} file; 
2. This applies to only one file as well (see file ID inside):

Code: Select all

//--------------------------------------
//--- 010 Editor v3.0.3 Binary Template
//
// File: uncompressed data chunks of CFF files in Spellforce 2.
// Appropriate files IDs in base\English.cff and addon1\English.cff:
    // 9051 (1/1)
// Author: Csimbi
// Revision: 1.0.0
// Purpose: Game hacking
//--------------------------------------
struct FILE
{
    struct HEADER
    {
        uint32 RecordCount;
    } header;
    local int i=0;
    if(header.RecordCount>0) do
    {
        struct RECORD
        {
            uint16 ItemID;        // See base\script\gds\definitions\gdsdbexport.lua
            uint16 Unknown1; // =0;
            uint16 Unknown2;
            uint32 StringLen;
            if(StringLen>0) char String [StringLen*2];
        } record;
        ++i;
    } while (!FEof() && i<header.RecordCount);
} file; 
3. This applies to only one file as well (see file ID inside):

Code: Select all

//--------------------------------------
//--- 010 Editor v3.0.3 Binary Template
//
// File: uncompressed data chunks of CFF files in Spellforce 2.
// Appropriate files IDs in base\English.cff and addon1\English.cff:
    // 9052 (1/1) - item qualifiers
// Author: Csimbi
// Revision: 1.0.0
// Purpose: Game hacking
//--------------------------------------
struct FILE
{
    struct HEADER
    {
        uint32 RecordCount;
    } header;
    local int i=0;
    if(header.RecordCount>0) do
    {
        struct RECORD
        {
            uint16 ItemID;        // See base\script\gds\definitions\gdsdbexport.lua
            uint16 Unknown1; // =0;
            char Unknown2; // 2, 2, 1, 1, 3, 3
            char Unknown3; // 0, 1, 0, 1, 0, 1
            char Unknown4; // =0;
            uint32 StringLen;
            if(StringLen>0) char String [StringLen*2];
        } record;
        ++i;
    } while (!FEof() && i<header.RecordCount);
} file; 
4. This applies to two files (see list of flie IDs inside):

Code: Select all

//--------------------------------------
//--- 010 Editor v3.0.3 Binary Template
//
// File: uncompressed data chunks of CFF files in Spellforce 2.
// Appropriate files IDs in base\English.cff and addon1\English.cff:
    // 9003 (1/1)
    // 9050 (1/1)
// Author: Csimbi
// Revision: 1.0.0
// Purpose: Game hacking
//--------------------------------------
struct FILE
{
    struct HEADER
    {
        uint32 RecordCount;
    } header;
    local int i=0;
    local char bMulti=0;
    if(header.RecordCount>0) do
    {
        struct RECORD
        {
            char Unknown; // =1
            uint32 StringLen;
            if(StringLen>0) char String [StringLen];
            uint32 StringLen2;
            if(StringLen>0) char String2 [StringLen2*2];
        } record;
        ++i;
    } while (!FEof() && i<header.RecordCount);
} file; 

Re: SpellForce 2 .cff files

Posted: Tue Nov 11, 2008 1:43 am
by pixellegolas
nah, i don\t want to mod as in putting in other models. I just want to have models separate to place in my engine and marvel at :)

Re: SpellForce 2 .cff files

Posted: Fri Nov 21, 2008 7:03 am
by Csimbi
I am trying to decode the item database. I am happy to report that I am half way through. Here is an example:
http://spellforce.jowood.com/forum/show ... hp?t=51942
But. There are some structures that I could not decode yet. In order to create an item editor, I need to figure out the rest of the structures. PM me if you feel like helping.
Thanks.

Re: SpellForce 2 .cff files

Posted: Mon Jun 25, 2012 11:57 pm
by Pesmontis
Here's some quick descriptions of the files contained in the gamedata.cff from your UberEquip mod v1.1:
I thought I'd add some meaning to them.

0000-9038_1_1.dat German texts
0001-9007_1_2.dat building effects
0002-9008_1_4.dat buildable objects
0003-9013_1_1.dat heroes hair/head/body models
0004-9033_1_1.dat
0005-9001_1_4.dat items (many bugged)
0006-9030_1_4.dat items
0007-9031_1_1.dat item categories
0008-9032_1_1.dat item attribute types
0009-9034_1_1.dat quest objects
0010-9056_1_1.dat (empty?)
0011-9014_1_2.dat objects
0012-9029_1_1.dat
0013-9025_1_1.dat quests
0014-9004_1_1.dat
0015-9015_1_2.dat sprites
0016-9027_1_2.dat skill tree
0017-9002_1_2.dat spells
0018-9026_1_1.dat 40-byte records
0019-9028_1_2.dat
0020-9049_1_1.dat heroes
0021-9005_1_1.dat enemy units
0022-9006_1_1.dat units
0023-9000_1_1.dat
0024-9054_1_1.dat (empty?)
0025-9020_1_1.dat
0026-9012_1_2.dat