Skip to content

Commit 4db3040

Browse files
committedSep 18, 2016
Fix getting MapBlocks for abs(z) > 2048 with sqlite3 backend (fixed #31)
1 parent ae9321d commit 4db3040

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎db-sqlite3.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void DBSQLite3::getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos)
6262
int result;
6363

6464
// Magic numbers!
65-
int64_t minPos = (zPos * 0x1000000) - 0x800000;
66-
int64_t maxPos = (zPos * 0x1000000) + 0x7FFFFF;
65+
int64_t minPos = encodeBlockPos(BlockPos(0, -2048, zPos));
66+
int64_t maxPos = encodeBlockPos(BlockPos(0, 2048, zPos)) - 1;
6767

6868
SQLOK(bind_int64(stmt_get_blocks_z, 1, minPos));
6969
SQLOK(bind_int64(stmt_get_blocks_z, 2, maxPos));

‎db.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class BlockPos {
1616
int16_t y;
1717
int16_t z;
1818

19+
BlockPos() : x(0), y(0), z(0) {}
20+
BlockPos(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {}
1921
bool operator < (const BlockPos &p) const
2022
{
2123
if (z > p.z) {

0 commit comments

Comments
 (0)
Please sign in to comment.