summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobF <queatz@gmail.com>2011-09-04 17:01:28 -0400
committerJacobF <queatz@gmail.com>2011-09-04 17:01:28 -0400
commitd670c831c2183967a5b5e2cdd104fd07a40bb3f4 (patch)
treeb83f5a7beeea912f903b9716919bf81c7b8f6921
parentd1a16f24cfb360a0a6e60fc76ea87d7c4cf24618 (diff)
downloadminetest-d670c831c2183967a5b5e2cdd104fd07a40bb3f4.tar.gz
minetest-d670c831c2183967a5b5e2cdd104fd07a40bb3f4.tar.bz2
minetest-d670c831c2183967a5b5e2cdd104fd07a40bb3f4.zip
These numbers were well exceeding 2^32...
-rw-r--r--src/map.cpp9
-rw-r--r--src/map.h2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 41c4e17d2..46ee5b53f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2849,8 +2849,9 @@ bool ServerMap::loadFromFolders() {
return false;
}
-int ServerMap::getBlockAsInteger(const v3s16 pos) {
- return (pos.Z+2048)*16777216 + (pos.Y+2048)*4096 + pos.X;
+sqlite3_int64 ServerMap::getBlockAsInteger(const v3s16 pos) {
+ return (sqlite3_int64)pos.Z*16777216 +
+ (sqlite3_int64)pos.Y*4096 + (sqlite3_int64)pos.X;
}
void ServerMap::createDirs(std::string path)
@@ -3318,7 +3319,7 @@ void ServerMap::saveBlock(MapBlock *block)
std::string tmp = o.str();
const char *bytes = tmp.c_str();
- if(sqlite3_bind_int(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK)
+ if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK)
dstream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) // TODO this mught not be the right length
dstream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
@@ -3484,7 +3485,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
if(!loadFromFolders()) {
verifyDatabase();
- if(sqlite3_bind_int(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
+ if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
dstream<<"WARNING: Could not bind block position for load: "
<<sqlite3_errmsg(m_database)<<std::endl;
if(sqlite3_step(m_database_read) == SQLITE_ROW) {
diff --git a/src/map.h b/src/map.h
index 411a7ae51..e0b67eb6e 100644
--- a/src/map.h
+++ b/src/map.h
@@ -378,7 +378,7 @@ public:
// Verify we can read/write to the database
void verifyDatabase();
// Get an integer suitable for a block
- static int getBlockAsInteger(const v3s16 pos);
+ static sqlite3_int64 getBlockAsInteger(const v3s16 pos);
// Returns true if the database file does not exist
bool loadFromFolders();