Page 3 of 3

Re: Subfolder locations in PRJ

Posted: Wed Dec 31, 2008 7:18 am
by Sir MMPD Radick
0.5 MB is quite abit of space for BWD files though, that would be a good temporary solution for adding maps.
BWD files on average only are 1-15 KB

Re: Subfolder locations in PRJ

Posted: Wed Dec 31, 2008 7:22 am
by quota4stupid
True, but that space isn't contiguous :-( In the mercs PRJ file, there are only 13 FREE blocks that are over 10K (plus another ~50 that are over 1K).

Re: Subfolder locations in PRJ

Posted: Wed Dec 31, 2008 8:48 am
by Sir MMPD Radick
good point.

Re: Subfolder locations in PRJ

Posted: Mon Feb 02, 2009 8:26 pm
by quota4stupid
quota4stupid wrote:
struct MW2_PRJ_directory_header {
char marker[4]; // Marker string INDX
DWORD structSize; // Size of this record, plus MW2_PRJ_Directory_Entries, minus 8
DWORD unknown;
char directoryName[4];
WORD maxEntries; // (see below)
WORD entryCount; // Number of entries after this header, including an initial NULL record
WORD unknown2; // (see below)
}; // 22 bytes
I've got an update on this that I stumbled upon while trying to decode the TBL files:

0 - 3 : "INDX"
4 - 7 : Record size - 8
8 - 11 : ??
12 - 15 : Directory name
16 - 17 : maxCount - Maximum entries in table (for current size)
18 - 19 : validCount - Number of valid entries in table (see below)
20 - 21 : entryCount - Number of entries that follow (see below)

In most cases those last two fields will be the same, but in some (ie: the MEK folder for DOS 31cc) the number of entries is greater than the number of valid entries. In a nutshell, you would examine "entryCount" number of records after the INDX header, of which "validCount" are valid entries (the rest are NULL - all zeros). In these counts, the initial NULL record (ID 0) appears to count as a valid record.

The only place this logic doesn't seem to hold is in the FREE table, where "entryCount" is always 1 and "validCount" gives the number of entries that point to FREE records.

Re: Subfolder locations in PRJ

Posted: Tue Feb 03, 2009 4:32 pm
by Col.Kell
Hopefully you'll be able to shed some light and figure it out, quota. This stuff goes far beyond me. :?

Re: Subfolder locations in PRJ

Posted: Tue Feb 03, 2009 6:51 pm
by quota4stupid
I *think* I've got most of the essentials worked out now, although there are still a few fields that I can't figure (I tried looking for some pattern in them the other night and eventually gave up). With any luck I'll finish the project for my missus soon and then I can go gangbusters on MW2 again :-D

Re: Subfolder locations in PRJ

Posted: Sun Jun 14, 2009 1:39 pm
by quota4stupid
Additional: the 32-bit field at offset 8 of the DDIT, INDX, SYMB and DATA chunks is a checksum field. It is a simple unsigned sum of all of the bytes in the chunk (header & payload) excluding the first 12 bytes (the tag, size and checksum fields). I've tested this successfully against all of the DOS versions, and mostly successfully against the TT version of Mercs (there were a few mismatches, but by the look of it that project file has a bunch of other errors anyway, so suspect it may just be faulty - will have a closer look later).

This doesn't appear to be the case for the field at offset 8 of the main header (PROJ). In all of the files I've checked this is the constant value 0x0c070162 (I've checked the DOS & TT versions of 31cc/GBL/Mercs for this), so I doubt it's a checksum.