Closed Supalosa closed 1 year ago
At the moment, the validation that a Point(2d) has a coordinate >= 0 and <= 255 happens at toSc2Api time.
This causes a crash that can sometimes be a bit hard to debug, since there is often no link back to the code that constructed the point.
Would it be reasonable to validate this when the Point2d is constructed, instead? https://github.com/ocraft/ocraft-s2client/blob/master/ocraft-s2client-protocol/src/main/java/com/github/ocraft/s2client/protocol/spatial/Point2d.java#L76
The reason it was done this way is because Point2d can be used for various calculations and intermediate values may be out of scale, only the final result should be validated.
At the moment, the validation that a Point(2d) has a coordinate >= 0 and <= 255 happens at toSc2Api time.
This causes a crash that can sometimes be a bit hard to debug, since there is often no link back to the code that constructed the point.
Would it be reasonable to validate this when the Point2d is constructed, instead? https://github.com/ocraft/ocraft-s2client/blob/master/ocraft-s2client-protocol/src/main/java/com/github/ocraft/s2client/protocol/spatial/Point2d.java#L76