From UFOpaedia
Jump to navigation Jump to search

Hi Zombie. I've just checked and the maximum length of an Aquanaut name that can be entered in-game is 19 characters. 20 bytes including a null-terminating byte? It would also be good to hack the name and see if it's possible to display more than 19 characters, I'll try that next. Spike 14:49, 10 November 2008 (CST)

Actually you can enter 21 characters within the game. There is room to hex edit the name up to 27 characters (doesn't need to be null terminated, the final 27th character shows up just fine). The name is the reason why EU's and TFTD's file sizes differ (68 vs. 70 bytes). The programmers gave TFTD 2 more characters to play around with. I'm using the Collector's Edition by the way. --Zombie 15:46, 10 November 2008 (CST)

Interesting. I'm using the Steam version which is also CE I think. Looks like the character name input in-game is limited to some maximum pixel width, or 21 bytes, whichever is less. E.g. use all capital Ws for the name and you only get to enter 14 bytes. Use digit 1 (narrowest character?) or lower case a and you can enter 21 bytes.

I could hex edit 26 + null and it displayed, but overwrote the next column in the Aquanaut display - probably why there is a pixel width limit. I didn't try non null terminated. That's also interesting as it suggests they may be storing the string length somewhere, which could be one of the Unknown records. Spike 04:15, 11 November 2008 (CST)

Ah, I was using lowercase letters to fill the string - that's why I had 21 characters. Apparently the game uses the BIGLETS.DAT character set for editing soldier names. Each character block is 16x16 pixels, but the game doesn't use whitespace. This limits the max height to something like 13 pixels. For the capital letter W, you can have 14 characters total in the display, and that breaks down to 13 pixels wide for a total string length of 182 pixels. For the capital letter I you can put 21 of them in the display. Each letter is 4 pixels wide for a total width of 84 pixels. The max display width possible without wraparound is 21 large characters (such as W or M) which works out to 273 pixels.
For the Aquanaut listing screen, it uses the SMALLSET.DAT character set so things are a little different there. To prevent the name from running into the rank field, the max length is 19 large letters such as W or M. Effective length is around 115 pixels. Surprisingly, the biggest characters in the smallset list is the number sign or the asterisk. Those fill the entire field, and the game actually overwrites part of one character on to the next one so instead of 8 pixels, it breaks down to a little over 6. The programmers should have changed those characters to include a 1-pixel whitespace buffer to prevent overwriting, but maybe that would have made the character look strange. Eh, whatever. --Zombie 21:44, 11 November 2008 (CST)

Just a little note here on null terminated strings (c-strings or "ASCIIZ") -- while you can handle fixed width strings in C with custom functions or some of the more exotic uses of v/s/printf, it's generally not used. I'd like to warn people that name[27] is followed by bravery_improvement, which is likely zero on most soldiers.

As a test, I filled in a soldier's name with lowercase 'i', as it's nice and narrow, and then 'b' after the 27th byte (it was originally 'a' and 'b' but it was hard to see the results due to font size). My soldier ended up with 720 bravery, but the name continued. I then continued on, filling in any zero bytes, and the soldier became even more screwy, with an ever increasing name length.

I'd STRONGLY recommend limiting string usage to a proper char string[27] length -- that is, null terminate the string at the 27th character, ie, string[26]=0. Assuming that the byte(s) at the end ARE part of the string, and not some stat which is doing something strange. Like, an unknown 'luck' stat or something. ~ Renegrade 08:18, 12 August 2010 (EDT)

Hi, I've some issue with bravery but putting 100 (0x64) at the offset 64 (0x40) for the inital bravery but in the game I see that my soldiers have -890 (!) for bravery. This web pages indicate the formula to have the good bravery : Bravery uses the formula below to calculate:

                          110 - Bravery 
              Hex Value = -------------
     I.e.: If your soldier has Bravery 70 points, the hex value is:
                          110 - 70
                          -------- = 04

Also, the same info here Offset 34 - Bravery - Possible values = Bravery is calculated like so ((110 - Bravery) / 10) = value of Offset. So if your Bravery is 80, the Offset value would be 03

Can you confirm me to update this wiki page ? thks

Bravery and Bravery Improvement are indeed stored in increments of 10. I think this page only really chronicles the order that the data is structured in the TFTD soldier.dat file, which is different from UFO for some reason. All the more specific information is on how everything works is in SOLDIER.DAT. NKF (talk) 00:40, 30 September 2014 (EDT)