Kingdom Hearts .ctd and .ctdl files

How to translate the files of a game
GrzybDev
Posts: 22
Joined: Fri Apr 26, 2019 10:18 am

Kingdom Hearts .ctd and .ctdl files

Post by GrzybDev »

Hello everyone,

As you may or may not know i've created tool for extracting locale files from Kingdom Hearts 1.5+2.5/2.8 into "translatable" format (.po).

It seems that format they're using (.ctdl, but my script wrongly saves it as .ctd (it's just takes magic value and save it as extension - works in most cases :)) have 3 "variations", i successfully can extract strings from 2 "variations" (more details below), but have problem with 3rd one.

Details on how i read and named first variation:

Code: Select all

int magicValue = 0x44545340; # Always "@CTD"
int unknown1 = 503; # Some kind of indicator (strings with that are saved in UTF-16)
int unknown2;
short unknown3;

short loc_count, addr_offset, padding, hash_offset, padding, data_offset;

struct addr_block {
   short[loc_count] loc_id, set_id, offset, unknown;
}

struct hash_block {
   string[loc_count] # Hash, 32 bytes (0x20 bytes)
}

struct data_block {
   string[loc_count] # Double null terminated UTF-16 encoded
}


Second "variation":

Code: Select all

int magicValue = 0x44545340; # Always "@CTD"
int unknown1; # If this value is not 503, strings are utf-8
int unknown2;
short unknown3;

short loc_count, addr_offset, padding, hash_offset, padding, data_offset;

struct addr_block {
   short[loc_count] loc_id, set_id, offset, unknown;
   int unknown2;
}

struct hash_block {
   string[loc_count] # Hash, 32 bytes (0x20 bytes)
}

struct data_block {
   string[loc_count] # Null terminated UTF-8 encoded
}


As you can see, these two variants are relatively similar. But third variant is an exception. And it really confuses me.

I attached all variations,
Can someone help with "documenting" the third variation (also, if someone have better idea what "unknown" values in my structs are)

Thanks in advance
gameside
Posts: 66
Joined: Sun Nov 08, 2020 1:07 pm

Re: Kingdom Hearts .ctd and .ctdl files

Post by gameside »

so far, I don't know much about unknown block yet

Code: Select all

// Header
   4 - Magic
   2 - number of unknown blocks
   2 - number of strings
   4 - offset to offset table
   4 - offset to string table
   
// For each unknown block
   48 - unknown, need to check it later
   
// For each string
   4 - offset of string (start from zero, (offset to string index + offset of string = actual offset))

X - String null-terminated