Not working GSText {RAW_STRING}

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

Not working GSText {RAW_STRING}

Post by Firrel »

In OpenTTD Language and Strings documentation there is a string parameter type {RAW_STRING}. When trying to use it in a game script, there is no error and I could not manage to display string with it. I tried to peak into the source code and found that it seems to be disabled specifically for game scripts. Is there some reason behind it, that it was deliberately disabled or it was left not implemented?

Being able to use it would really benefit in creating some texts in game script where the parameter limit blocks adding more information even when the text is still well shorter than the character limit. For example in Renewed Village Growth, the parameters required/supplied/stockpiled could be one {RAW_STRING} instead of three {NUM}, allowing for more displayed information while maintaining the formatting.

Screenshot from 2020-07-29 17-20-35.png
Screenshot from 2020-07-29 17-20-35.png (50.15 KiB) Viewed 1140 times
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: Not working GSText {RAW_STRING}

Post by Eddi »

to me that sounds like a giant security hole... which is probably why it's disabled.
_dp_
Transport Coordinator
Transport Coordinator
Posts: 276
Joined: 18 Dec 2013 12:32

Re: Not working GSText {RAW_STRING}

Post by _dp_ »

If properly implemented this doesn't seem to be any more of a security hole than any other part of the game that deals with user text input.

I didn't dig too deep but so far it just looks like current implementation couldn't validate the arguments so it was disabled instead of being fixed. https://github.com/OpenTTD/OpenTTD/comm ... 0bf63aa190

P.S. Though I think the initial problem should be fixed by allowing more string arguments, but RAW_STRING is useful for other things.

UPD. A bit more digging shows that it's actually all in one function, it discards type information in L892 and then suddenly can't validate the string anymore in L1006. :P
User avatar
Firrel
Engineer
Engineer
Posts: 118
Joined: 13 Aug 2019 17:06

Re: Not working GSText {RAW_STRING}

Post by Firrel »

_dp_ wrote: 30 Jul 2020 11:39 If properly implemented this doesn't seem to be any more of a security hole than any other part of the game that deals with user text input.

I didn't dig too deep but so far it just looks like current implementation couldn't validate the arguments so it was disabled instead of being fixed. https://github.com/OpenTTD/OpenTTD/comm ... 0bf63aa190

P.S. Though I think the initial problem should be fixed by allowing more string arguments, but RAW_STRING is useful for other things.

UPD. A bit more digging shows that it's actually all in one function, it discards type information in L892 and then suddenly can't validate the string anymore in L1006. :P
Thank you _dp_ for looking into it.

I agree that increasing the maximum number of parameters is the optimal solution. I saw in a post that it was already looked into and found complicated, so I was looking into next viable option. But the limit of 20 parameters is too restrictive.

Actually commenting out the gamescript condition on L1006 allowed to print the RAW_STRING, so it seems it might not be that difficult to make it work properly. I will look more into it to see if I can solve it or I will make a feature request.

Screenshot from 2020-07-30 16-38-28.png
Screenshot from 2020-07-30 16-38-28.png (62.04 KiB) Viewed 984 times
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: Google Adsense [Bot] and 9 guests