summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-15 11:49:13 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-15 11:49:13 -0400
commit9f2a08d3c82e6917e0cb3da00841758a2722a7bb (patch)
tree3a89a5e91fe37634f06804dd72d8ef9bfaf8b0b1 /src
parent1e84e2d6ef9370a3443fcd8472779184f6319594 (diff)
downloadether-9f2a08d3c82e6917e0cb3da00841758a2722a7bb.tar.gz
ether-9f2a08d3c82e6917e0cb3da00841758a2722a7bb.tar.bz2
ether-9f2a08d3c82e6917e0cb3da00841758a2722a7bb.zip
fixed chunks not loading correctly when going up and left
Diffstat (limited to 'src')
-rw-r--r--src/map.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/map.h b/src/map.h index 2235b07..13b2b32 100644 --- a/src/map.h +++ b/src/map.h
@@ -45,16 +45,8 @@ struct Chunk {
45}; 45};
46 46
47inline void toChunkPos(int x, int y, int& cx, int& cy) { 47inline void toChunkPos(int x, int y, int& cx, int& cy) {
48 cx = x / CHUNK_WIDTH; 48 cx = std::floor(static_cast<double>(x) / CHUNK_WIDTH);
49 cy = y / CHUNK_HEIGHT; 49 cy = std::floor(static_cast<double>(y) / CHUNK_HEIGHT);
50 if (x < 0) {
51 cx *= -1;
52 cx--;
53 }
54 if (y < 0) {
55 cy *= -1;
56 cy--;
57 }
58} 50}
59 51
60class Map { 52class Map {