Subfolder locations in PRJ

Binary formats and related hacking.

Moderator: Skyfaller

User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: Subfolder locations in PRJ

Post 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
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: Subfolder locations in PRJ

Post 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).
User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: Subfolder locations in PRJ

Post by Sir MMPD Radick »

good point.
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: Subfolder locations in PRJ

Post 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.
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell »

Hopefully you'll be able to shed some light and figure it out, quota. This stuff goes far beyond me. :?
MechWarrior 2: 31stCC
Image
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: Subfolder locations in PRJ

Post 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
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: Subfolder locations in PRJ

Post 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.
Post Reply