Posted by: hephep
« on: September 29, 2020, 06:48:10 AM »I don't know what the internals of Aurora look like, but all inputs should be sanitised anyway as best practice (or standard practice for web dev) - when devs don't do this you end up with security holes; less of a problem with a game, but still.
You just need two core functions:
string number_format(dynamic in_num) - takes in any type and outputs it as a formatted string using the system preferences. For bonus points parameters for number of decimals etc.
float/int parse_number(string in_str) - takes in a string and tries to parse it into a float/int as appropriate.
C# has a bunch of functions to help with this:
https://docs. microsoft. com/en-us/dotnet/api/system. globalization?view=netcore-3. 1
All user-inputted numbers should use parse_number before being used internally, and everything that's a number should go through number_format before being printed. I suspect its on these where Aurora currently fails.
Throw in some unit tests for both functions and you've got some rock solid code that can handle number input/output, and a swath of bug reports just disappears.
You just need two core functions:
string number_format(dynamic in_num) - takes in any type and outputs it as a formatted string using the system preferences. For bonus points parameters for number of decimals etc.
float/int parse_number(string in_str) - takes in a string and tries to parse it into a float/int as appropriate.
C# has a bunch of functions to help with this:
https://docs. microsoft. com/en-us/dotnet/api/system. globalization?view=netcore-3. 1
All user-inputted numbers should use parse_number before being used internally, and everything that's a number should go through number_format before being printed. I suspect its on these where Aurora currently fails.
Throw in some unit tests for both functions and you've got some rock solid code that can handle number input/output, and a swath of bug reports just disappears.