Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to completely remove custom text from a town after setting it (via game script) #7673

Closed
James103 opened this issue Jul 30, 2019 · 1 comment

Comments

@James103
Copy link
Contributor

James103 commented Jul 30, 2019

Version of OpenTTD

Tested on 20190723-master-g2e686ad5d5, but bug exists since many versions ago.

Expected result

Game Script can completely clear custom text of a town, allowing town windows to shrink back to the original size (without the custom text).

dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with NULL: true
dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with empty raw string: true
dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with empty GSText string: true

Actual result

Game Script is unable to completely clear custom text of a town after setting it. Attempting to clear the custom town text via passing NULL and an empty string both fail (as indicated by the output). Clearing the custom text with an empty GSText string works, but leaves an empty line at the bottom of the town window that may be undesirable for some. Clearing the custom town name via NULL succeeds and resets the town's name to the default.

dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with NULL: false
dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with empty raw string: false
dbg: [script] [18] [I] GSTown.SetText with a test string: true
dbg: [script] [18] [I] GSTown.SetText with empty GSText string: true

Steps to reproduce

Put the following code in a Game Script and run it (ignore the [headings]).

[main.nut]
GSLog.Info("GSTown.SetText with a test string: "+GSTown.SetText(0, "test"));
GSLog.Info("GSTown.SetText with NULL: "+GSTown.SetText(0, null));
GSLog.Info("GSTown.SetText with a test string: "+GSTown.SetText(0, "test"));
GSLog.Info("GSTown.SetText with empty raw string: "+GSTown.SetText(0, ""));
GSLog.Info("GSTown.SetText with a test string: "+GSTown.SetText(0, "test"));
GSLog.Info("GSTown.SetText with empty GSText string: "+GSTown.SetText(0, GSText(GSText.STR_NONE)));
[lang\english.txt]
STR_NONE:
@glx22
Copy link
Contributor

glx22 commented Nov 14, 2019

Same happens for other XXX.SetName() where the text is in theory resettable by using empty strings. I think adding GSTown.ResetText(townid) would be a better option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants