Menu

UW: Game Strings Question

Hackers
2001-12-09
2001-12-10
  • Friedrich Hanisch

    I want to translate Ultima Underworld 2 into German, but I have some problems by extracting the game strings. By using your Unofficial Ultima Underworld Specifications, I got the nodes of the Huffman tree - but I have no idea, how to build a tree with the given informations, as they do not seem to fit into one. Please help.

     
    • Jim Cameron

      Jim Cameron - 2001-12-10

      The info in the specs is a little bit terse, isn't it?

      All game strings use the same hufftree, which is stored at the beginning of the file strings.pak as a flat array with left/right child pointers giving the tree structure. The root of the hufftree is the LAST node stored. The two child pointers are indices into the node array. In C notation, the node nodeArray [n] has children nodearray [nodearray [n].left] and nodearray [nodearray [n].right].

      A leaf node has both its child pointers set to -1 (0xff). In this case the `symbol' field of the node definition contains the character it represents.

      To decode a character, start at the root (last) node, and for each bit read out of the compressed string, take the left child if it is a zero and the right if it is a 1. Repeat until you reach a leaf node, which is the character. The high (0x80) bit of each byte in the file is the first bit to decode.

      I hope this makes things clearer. There is code to read strings in TSSHP, in the file src/gamestring.c . The relevant functions are Str_init() (reads in the hufftree) and puff_uw_string_chunk() (unpacks all the strings in a given chunk).

       
    • Jim Cameron

      Jim Cameron - 2001-12-10

      I don't know, though, if it would be possible to add extra characters to Underworld's fonts for umlauted vowels and the sharp-s. I have a feeling that it wouldn't.

       

Log in to post a comment.