Closed dmitmel closed 6 years ago
@Hopson97 I've opened this PR a week ago, but there's no changes/discussion about it. So here are some questions:
I understand the motivation for making i32
into uxx
, but I don't see the advantage of doing this.
While i32 can be negative, uxx
is able to underflow, so that is still an issue.
u32
allows for a greater range of numbers, but I doubt I'll be using over 2 billion coordinates. 😄
@Hopson97 Ok, but this PR contains some refactors for chunk rendering logic to work with unsigned types. I'll open a new PR just for that.
Support for negative coordinates has been removed in commit
a0e23a3
, but a lot of functions and constants still use signed integers for coordinates (e.g.: why do you need signed integers in layout constants?). So, I've replaced alli32
s withu32
s where it's possible.This PR consists of one large commit because if you change an argument type in one function, everything breaks. So, here are notes about changes in each file (skip means that a file contains insignificant changes that can be skipped during review):
game/console.rs
– changed only one cast (skip)game/game_state/state_explore.rs
– changed only one function and added player position underflow protectiongame/layout.rs
– replaced alli32
s withu32
s (skip)game/mod.rs
– changed only two lines inGame::draw_logo
(skip)game/player.rs
– changed the type of player's position (skip)game/world/chunk.rs
– refactoredrender
function so that it can work with unsigned integers (this change has been tested, feel free to ask any questions about it)game/world/mod.rs
– replaced types and added chunk position underflow protectiongraphics/renderer.rs
– replaced alli32
s withu32
s, improved border renderinggraphics/sprite.rs
– replaced alli32
s withu32
s (skip)maths/vector.rs
:cast
functionNeg
traitmap
functionVector2D<u32>
toVector2D<i32>
add_signed
function for addingVector2D<i32>
toVector2D<u32>