The file hullfunc.dat is generated by PHost when you use the option -l (print ship list) to invoke PHost. It contains the special ship functions in an easily machine-readable binary format. Utility programs such as EchoView use this file instead of having to parse shiplist.txt resp. hullfunc.txt.
The file consists of the following parts:
- Header
- Functions assigned to hulls
- Level-restricted ship functions (optional)
- Functions assigned to ships (optional)
- Trailer
The parts are packed tightly together, without gaps. The header contains pointers to the optional parts to make it easier to find them. Up to PHost 4.0k, only the three mandatory parts are written. Future PHost versions may add more data before the trailer, so you should locate the trailer's position from the end of the file.
Format of Header:
+0 DWORD Magic Number 0xB1297F35 +4 BYTE PHost Minor Version (e.g. 0) +5 BYTE PHost Major Version (e.g. 4) +6 32 BYTEs Game Name (space-padded) +38 DWORD Pointer to Level-restricted ship functions +42 DWORD Pointer to Functions assigned to Ships +46 8 BYTEs Reserved, always zero
The "Pointer" fields are zero if the respective sections do not exist. This is the default in all versions of PHost up to 4.0k.
Format of Functions assigned to Hulls: This section describes the functions which are assigned to hulls (AssignTo=Hull). For example, if a ship is reported as being cloakable if it belongs to Lizards, it will only be cloakable when it actually belongs to the Lizards.
+0 WORD Number of Records following +2 n RECORDs of variable length: +0 WORD Hull Number +2 WORD Number of special functions assigned to this hull +4 n RECORDs of 4 bytes each: +0 WORD Special Function. +2 WORD Player bitfield. Bits 1 to 11 mark players who can use this function. Bits 0 and 12..15 are undefined
The Special Function field contains one of the following:
- a function number (field Numeric Value in the Hull Function Descriptions)
- the identifier of a level-restricted ship function, as described in the next section
- a not-yet-defined value from a future PHost version or add-on program
Format of Level-restricted ship functions: This section describes functions modified with a Level statement.
+0 WORD Number of functions +2 WORD Size of each record +4 n RECORDs of the size specified above: +0 WORD Function Id +2 WORD Basic Function +4 WORD Experience Level Mask
The format of the definition records is the same as util.dat record 57, see there for more information. Its size may increase in the future with new data appended at the end. Note that the Function Ids reported in hullfunc.dat may differ from those in utilX.dat, because hullfunc.dat is generally generated only once at the beginning of the game, whereas utilX.dat represents the current state. The Function Ids reported here are valid only to interpret the Special Function fields in the Functions assigned to Hulls and Functions assigned to Ships sections in this file.
Format of Functions assigned to Ships: The format of this section is the same as the Functions assigned to Hulls field. It describes functions assigned to ships when they are built (AssignTo=Ship). For example, if a ship type is reported as being cloakable if it is built by the Lizards, all these ships built by the Lizards are cloakable, no matter who currently owns them. This field is only useful to predict what abilities a newly-built ship will have. The current assignments for existing ships are reported in util.dat record 52.
Format of Trailer:
+0 DWORD Signature 0x1F0C219A +4 DWORD Checksum
The Checksum is the word-wise sum (16-bit little-endian words) of all words in the file, excluding the checksum field itself. For example, the Magic Number field has the value 0xB1297F35, and thus consists of the words 0xB129 and 0x7F35, giving a checksum of 0x1305E.