Page 1 of 1

Not working GSText {RAW_STRING}

Posted: 29 Jul 2020 15:36
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 1142 times

Re: Not working GSText {RAW_STRING}

Posted: 30 Jul 2020 11:23
by Eddi
to me that sounds like a giant security hole... which is probably why it's disabled.

Re: Not working GSText {RAW_STRING}

Posted: 30 Jul 2020 11:39
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

Re: Not working GSText {RAW_STRING}

Posted: 04 Aug 2020 16:25
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 986 times