Author Topic: Game crashes if hit log contains accented characters  (Read 499 times)

Offline dunee

  • Zombie Food
  • *
  • Posts: 3
    • View Profile
Game crashes if hit log contains accented characters
« on: September 10, 2016, 01:59:48 PM »
So I'm working on the Hungarian localization and have hit a game breaking bug.

(click to show/hide)

Up until a few days ago, if the hit log notification contained an accented character, it just displayed some garbage character, as seen above. Since a few days ago, the game straight out crashes.

However, this only happens when a ranged weapon hits. I'm still getting garbage characters with melee hits, but the game does not crash.

Is it possible to replace the terminal font used to display these messages with a Unicode font as well? I'm already using Cousine-Bold.ttf as a replacement font for the other typeface.

I'm using the latest experimental, build 5463, Windows x86 tiles (0.C-18110-g368db5e). If I change Cata's language settings to English I do not get a crash.

The MO I'm using is at https://dl.dropboxusercontent.com/u/140157/cataclysm-dda.mo

Thanks!
« Last Edit: September 10, 2016, 02:01:50 PM by dunee »

Offline dunee

  • Zombie Food
  • *
  • Posts: 3
    • View Profile
Re: Game crashes if hit log contains accented characters
« Reply #1 on: February 15, 2017, 08:44:37 PM »
Resurrecting this old threat, because zombies and also because I still can't figure out what's wrong.

So I'm still getting a crash, currently on a fresh install of build 6228 on Windows (0.c-21120-g65e976fea). The crash is with the Hungarian MO that I've converted from a partly translated English PO, itself obtained from the CDDA github. The translated PO is also available on request. Converting from the PO to the MO using msgfmt yields the following messages, but looking at the PO I see nothing out of place:

Code: [Select]
dunee@DUNEE-WIN10:/mnt/c/Users/Dunee/Desktop/hu-HU$ msgfmt cataclysm-dda.po -o cataclysm-dda.mo
cataclysm-dda.po:94806: 'msgid' and 'msgstr' entries do not both end with '\n'
cataclysm-dda.po:96626: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:96654: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:96679: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:96702: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:96735: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:96787: 'msgid' and 'msgstr' entries do not both end with '\n'
cataclysm-dda.po:96829: 'msgid' and 'msgstr' entries do not both end with '\n'
cataclysm-dda.po:96871: 'msgid' and 'msgstr' entries do not both end with '\n'
cataclysm-dda.po:96911: 'msgid' and 'msgstr' entries do not both end with '\n'
cataclysm-dda.po:96969: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:118251: 'msgid' and 'msgstr' entries do not both begin with '\n'
cataclysm-dda.po:125672: 'msgid' and 'msgstr' entries do not both end with '\n'
msgfmt: found 16 fatal errors

To reproduce the crash, use the MO from https://dl.dropboxusercontent.com/u/140157/cataclysm-dda.mo, copy it to lang\mo\fr\LC_MESSAGES, start the game, set language to French and restart the game. Spawn any ranged weapon and hit any creature nearby. The game crashes. Other than that, the Hungarian text shows up fine, especially with the new Unicode font.

I don't even know where to start looking, debug.log has nothing. Its last line is:
Code: [Select]
21:24:36.22 INFO : Added requirement: inline_vehins_base_xlhalfboard_vertical
I have figured out since my initial post that the garbage characters have nothing to do with the crash. First, I've replaced all hit related text with non-accented characters. Second, the garbage characters still show up fine on a melee attack, so the issue is presumably related to some string being called when ranged weapons are fired.

I'm at a complete loss, please help!

Offline dunee

  • Zombie Food
  • *
  • Posts: 3
    • View Profile
Re: Game crashes if hit log contains accented characters
« Reply #2 on: May 16, 2017, 09:21:49 PM »
Necroing the post again, as I've finally figured out what went wrong.

(click to show/hide)

Apparently a long while ago I've changed the word order, so instead of "You hit the %s for %d" the Hungarian localization went "For %d damage you hit the %s" (more logical word order).

So that crashed to the desktop on Windows and even caused a segfault on my Ubuntu machine. Had to learn how to debug a segfault, but found it! Changed the word order back as it should be and killed my first bug (that I've caused in the first place).

Nothing to do with accented characters, in the end. The game displays a different string when you hit someone with a ranged weapon, something else when you melee. The errors thrown by gettext conversion don't seem to be relevant either.

In conclusion, if you're working on a localization, don't assume that changing the order of variables in a string is an bulletproof thing to do.