Skip to content
New issue

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

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

Already on GitHub? # to your account

Terrn2 StartPosition does not parse non-spaced, comma-separated values #2837

Closed
danmackey opened this issue Dec 25, 2021 · 1 comment · Fixed by #2838
Closed

Terrn2 StartPosition does not parse non-spaced, comma-separated values #2837

danmackey opened this issue Dec 25, 2021 · 1 comment · Fixed by #2838

Comments

@danmackey
Copy link
Contributor

If you set a StartPosition in .terrn2 to be 0,0,0 instead of 0, 0, 0 the parser fails and defaults to 512, 0, 512.
https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/resources/terrn2_fileformat/Terrn2FileFormat.cpp#L78

This seems to be because the function used to parse this requires space delimited values.
https://ogrecave.github.io/ogre/api/1.11/class_ogre_1_1_string_converter.html#a4de896cef79f4620355149a42c43dff6

Just spent a good 10 minutes trying to find out why my terrain wouldn't change its spawn position until I found this.

If not changing how it parses, maybe log a warning to tell the user that the value was not correctly parsed?

@ohlidalp
Copy link
Member

ohlidalp commented Dec 25, 2021

Apparently, Ogre::StringConverter::parseVector3() only accepts spaces as delimiter, see this internal helper: https://github.com/OGRECave/ogre/blob/05b8dd5ce1b3cc90d9b8b00275803d6a2f24e79d/OgreMain/src/OgreStringConverter.cpp#L326. The reason commas+spaces worked is that Ogre::StringConverter* generally ignores trailing garbage when parsing numbers.

Anyway, I'll create our own helper which works better. Thanks for reporting.

Update: I ended up keeping the existing OGRE helpers, just using their error-checking variants and reporting errors.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants