Skip to content

Commit

Permalink
Fix getting MapBlocks for abs(z) > 2048 with sqlite3 backend (fixed #31)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Sep 18, 2016
1 parent ae9321d commit 4db3040
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db-sqlite3.cpp
Expand Up @@ -62,8 +62,8 @@ void DBSQLite3::getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos)
int result;

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

SQLOK(bind_int64(stmt_get_blocks_z, 1, minPos));
SQLOK(bind_int64(stmt_get_blocks_z, 2, maxPos));
Expand Down
2 changes: 2 additions & 0 deletions db.h
Expand Up @@ -16,6 +16,8 @@ class BlockPos {
int16_t y;
int16_t z;

BlockPos() : x(0), y(0), z(0) {}
BlockPos(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {}
bool operator < (const BlockPos &p) const
{
if (z > p.z) {
Expand Down

0 comments on commit 4db3040

Please sign in to comment.