huderlem / poryscript

High-level scripting language for gen 3 pokemon decompilation projects
https://www.huderlem.com/poryscript-playground/
MIT License
197 stars 22 forks source link

Fix bug where MaxLineLength configuration didn't apply #55

Closed Stevebel closed 1 year ago

Stevebel commented 1 year ago

I set up a font_config.json with two fonts with different maxLineLengths to handle different dialogue windows in my mod but found that applying those font IDs weren't changing the line length. Set up a test to reproduce along with a fix.

huderlem commented 1 year ago

I want to make sure I'm properly understanding the context of this fix. I believe the bug would only occur when a line length is explicitly specified as a negative number for format(). (For example, format("blah", -1)). But that begs the question of "why were you explicitly specifying -1 in your script"? Is that an actual use case for you?

Stevebel commented 1 year ago

Sorry for the late response. It's the opposite, that variable is -1 if nothing is specified. The problem is that it was checking before the variable was populated with the configuration. You can see the updated test fails with the old code and passes with the new code

huderlem commented 1 year ago

Ahhh, I see now. It's the fontID that was being read to early. Thanks for fixing. As you can see, the current format-related tests aren't great. I'll beef those up after merging this PR.