diff --git a/db-sqlite3.cpp b/db-sqlite3.cpp index f75a998..b7416f3 100644 --- a/db-sqlite3.cpp +++ b/db-sqlite3.cpp @@ -62,8 +62,8 @@ void DBSQLite3::getBlocksOnZ(std::map &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)); diff --git a/db.h b/db.h index 40770b0..aaf43ac 100644 --- a/db.h +++ b/db.h @@ -16,6 +16,8 @@ public: 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) {