FLAMEGPU / FLAMEGPU2

FLAME GPU 2 is a GPU accelerated agent based modelling framework for CUDA C++ and Python
https://flamegpu.com
MIT License
106 stars 22 forks source link

[Bug] `JSONStateWriter` pretty print feature prints minified. #1231

Closed Robadob closed 1 month ago

Robadob commented 2 months ago

Bug Description

JSONStateWriter casts the pretty writer pointer to a regular writer, I'm not totally sure why this compiles given rapidjson::PrettyWriter extends rapidjson::Writer, however none of the methods are virtual. Hence, once the pointer is cast, all calls hit rapidjson::Writer and skip the pretty print prefixes.

This bug is not present in JSONLogger, but due to how JSONStateWriter is structured for partial outputs, it will need a more complex solution (e.g. factory and templated class, or two internal writer pointers being tested at use 🤮).

To Reproduce

Run IOTtest.JSON_WriteRead and breakpoint it after the file has been output (pretty print is enabled by default) and check test.json found in tests/.

Expected Behaviour

Pretty print output should be across multiple lines with indentation.

Additional Information

I'll probably write a fix tonight/tomorrow. I'm not going to write a dedicated test for this, because that would require manually parsing the json and checking for newlines/tab, but I'm not that keen.