Page 1 of 1

[0.18.22] rendering.draw_text cannot access Scenario's locale when savefile loaded

Posted: Thu May 07, 2020 9:44 pm
by Hanakocz
Hi,

I wanted to include localized rendered text in my scenario. This looks like very easy thing to do and it was, as rendering.draw_text supports localized strings. So I included my own locale file into the scenario and added the localized message.

This works fine when spawning the renders, but when you save the game and load it again, all scenario-localized rendering texts change to Unknown key error messages. Localized texts using vanilla locales load fine. Creating new renderings with same locale keys also work fine, until one saves the game and loads it again. Localization is loading properly for chat messages and gui and everything.

I created absolutely tiny scenario to demonstrate this (attachments). Steps to reproduce are then :
1) start a scenario that uses own locale files
2) use draw_text that use localized string from the scenario's locale
3) save the game, exit, and load the game again. Scenario's locales will be broken.

When game opened first time and scenario creates cars with added render texts bound to them, the top left one has

Code: Select all

text = {"entity-name.car"}
while the other has

Code: Select all

text = {"my_locale.car"}
which takes the entry from scenario added locale:
locale1.png
locale1.png (1.15 MiB) Viewed 1846 times
When I save the game, exit and load again, this same stuff turns into this:
locale2.png
locale2.png (1.16 MiB) Viewed 1846 times
Is there a way to fix this behaviour? I am not really a fan of tracking all rendertexts into global table and re-drawing them whenever player joins (as rendering class is unaccessible from on_load() event). Static texts also aren't really viable as some people just don't understand all the languages.

Re: [0.18.22] rendering.draw_text cannot access Scenario's locale when savefile loaded

Posted: Sun Aug 02, 2020 12:22 pm
by posila
Thanks for the report.
Fixed for 0.18.41