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

Script API: remove 2048 length limit for the variadic text functions #2398

Open
ivan-mogilko opened this issue Apr 29, 2024 · 1 comment
Open
Labels
context: script api type: enhancement a suggestion or necessity to have something improved

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Apr 29, 2024

Historically, all the text printing script functions have a limit of resulting string. It was an arbitrary 3000 bytes around 3.6.0, in current master it's 2048, but that's not the point. Because AGS Strings may contain up to INT32_MAX bytes, there should not be any restriction on a length of a string that a user may create using e.g. String.Format.

Printing script args is done using ScriptSprintf function. I propose to fix this function to make it act in compliance with standard snprintf: that is let pass a null buffer in which case it would only calculate and return necessary size. Formatting will be done in two steps: first calculate the necessary buffer length, then allocate a StringBuffer, print text, and create ScriptString, or use this text elsewhere as necessary.

@ivan-mogilko ivan-mogilko added type: enhancement a suggestion or necessity to have something improved context: script api labels Apr 29, 2024
@ericoporto
Copy link
Member

I was playing with this by looking into the function before I realized I don't know where the call to this is

ericoporto@5f485b1

Beyond the tests, I can't figure how this actually get called in String.Format, and don't know how to modify to take the null buffer, but maybe my initial sketch is useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: script api type: enhancement a suggestion or necessity to have something improved
Projects
None yet
Development

No branches or pull requests

2 participants