The International Simutrans Forum

 

Author Topic: [wingdi r4384] Changing translation for automatic stop naming crashes the game  (Read 1863 times)

0 Members and 1 Guest are viewing this topic.

Offline IgorEliezer br

  • Devotee
  • Administrator
  • *
  • Posts: 4087
  • Cake recipes are cool... REALLY!
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
I was trying to change some bad translations in text/pt.tab, then I tried to insert a bus stop in the city. Simutrans returned me Application error: The memory can't be "read".

The text/pt.tab was:

Code: [Select]
%s city %d %s
%s - %dª %s urbana

My city already had some bus stops inserted and, as I was seeing the ª character is badly "drawn" in the screen, I changed it to:

Code: [Select]
%s city %d %s
%s %s %d urbana

I inserted another bus stop: crash.

Savegame: http://simutrans-germany.com/files/upload/March_2011.sve

EDIT:

The workaround for this bug: I removed the "bad" character from all bus stops. I inserted another bus stop in the city: no crash.
« Last Edit: April 01, 2011, 07:44:30 PM by IgorEliezer »

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
This is not a bug that can be "fixed". You must give format arguments exactly in the same order as they appear, end of discussion. The only fix possible is exchanging the conversion functions for something custom.

Translator's life generally sucks, yeah :-/
« Last Edit: April 01, 2011, 08:24:34 PM by VS »

Offline IgorEliezer br

  • Devotee
  • Administrator
  • *
  • Posts: 4087
  • Cake recipes are cool... REALLY!
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Simple, I removed the "%d" from translation.

Code: [Select]
%s city %d %s
%s %s urbana

%s land %d %s
%s %s rural

Worked.

EDIT:

No, the bug is back.

Trying another thing that makes sense in Latin syntax :S
« Last Edit: April 01, 2011, 08:15:35 PM by IgorEliezer »

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Programmer info:

It seems there is a non-C99 extension widely available on linux [1] [2] [3] [4] [5] that allows changes to order. Not available for Microsoft compilers though (yeah, we love you...). Alternatives include: Boost format library [6], which at a glance seems to be unnecessarily bloated as it uses streams internally. And that's it, hooray :-/ There is some discussion on this [7]...

[1] http://linux.die.net/man/3/snprintf
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
[3] http://linux.about.com/library/cmd/blcmdl3_snprintf.htm
[4] http://manpages.ubuntu.com/manpages/intrepid/man3/printf.3.html
[5] http://www.openbsd.org/cgi-bin/man.cgi?query=printf&sektion=3
[6] http://www.boost.org/doc/libs/1_46_1/libs/format/doc/format.html
[7] http://stackoverflow.com/questions/3913009/is-there-any-alternative-for-printf
« Last Edit: April 01, 2011, 08:43:16 PM by VS »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9565
  • Languages: De,EN,JP
We had the discussion several times already. There are various libraries which could fix this, and all of them are either bloated, suck or both or not compatible with artistic licence ...