diff --git a/README.rst b/README.rst index ec881ea..444deaf 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,7 @@ Requirements * libgd * sqlite3 +* leveldb (optional, set ENABLE_LEVELDB=1 in CMake to enable leveldb support) Compilation ----------- diff --git a/db-leveldb.cpp b/db-leveldb.cpp index 4324501..d44c0df 100644 --- a/db-leveldb.cpp +++ b/db-leveldb.cpp @@ -18,7 +18,6 @@ inline std::string i64tos(int64_t i) { DBLevelDB::DBLevelDB(const std::string &mapdir) : m_blocksReadCount(0), - m_blocksCachedCount(0), m_blocksUnCachedCount(0) { leveldb::Options options; @@ -39,7 +38,7 @@ int DBLevelDB::getBlocksReadCount(void) int DBLevelDB::getBlocksCachedCount(void) { - return m_blocksCachedCount; + return 0; } int DBLevelDB::getBlocksUnCachedCount(void) @@ -62,9 +61,10 @@ DB::Block DBLevelDB::getBlockOnPos(const BlockPos &pos) std::string datastr; leveldb::Status status; + m_blocksReadCount++; + status = m_db->Get(leveldb::ReadOptions(), i64tos(pos.databasePos()), &datastr); if(status.ok()) { - m_blocksReadCount++; m_blocksUnCachedCount++; return Block(pos, ustring(reinterpret_cast(datastr.c_str()), datastr.size())); } diff --git a/db-leveldb.h b/db-leveldb.h index 6335eb8..f3bac2e 100644 --- a/db-leveldb.h +++ b/db-leveldb.h @@ -16,7 +16,6 @@ public: ~DBLevelDB(); private: int m_blocksReadCount; - int m_blocksCachedCount; int m_blocksUnCachedCount; leveldb::DB *m_db; BlockPosList m_blockPosList;