1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-20 03:35:18 +02:00

Cherry-pick most commits since 15c0376

Commits not directly related to network changes were cherry-picked
on a best-effort basis, as some cause difficult merge conflicts.

Commits skipped over:
0d1eedcccc
aa474e4501
82482ecd9d
b214cde5b4
2066655aae
7e088fdfe3
40bf1d7b5f
1b2f64473e
7e56637ed0
64ff966bae
51057a56f5
009149a073
cf4045ff0f
e357577cb2
49f84b76bc
b019221c30
7880ff74b6
146f77fdb7
a704c04f00

Commits with conflicts:
038d3a31df
e9eda2b0d0
708337dfc2 ~~ modified client.cpp manually; shadow changes to packethandlers/client.cpp
36e8ba9ce2 ~~ modified main.cpp manually; add ALLOW_ZWRITE_ON_TRANSPARENT set
3b6480c5b0 ~~ modified server.cpp manually; change wrapDegrees -> modulo360f
5a5854ea9d
c09d026f05
3c91ad8fc2
This commit is contained in:
kwolekr
2015-03-07 16:25:15 -05:00
parent 32352e90da
commit 8e08e92eb4
139 changed files with 4975 additions and 3374 deletions

View File

@@ -22,57 +22,54 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#if USE_LEVELDB
#include "database-leveldb.h"
#include "leveldb/db.h"
#include "map.h"
#include "mapsector.h"
#include "mapblock.h"
#include "serialization.h"
#include "main.h"
#include "settings.h"
#include "log.h"
#include "filesys.h"
#include "exceptions.h"
#include "util/string.h"
#include "leveldb/db.h"
#define ENSURE_STATUS_OK(s) \
if (!(s).ok()) { \
throw FileNotGoodException(std::string("LevelDB error: ") + (s).ToString()); \
throw FileNotGoodException(std::string("LevelDB error: ") + \
(s).ToString()); \
}
Database_LevelDB::Database_LevelDB(ServerMap *map, std::string savedir)
Database_LevelDB::Database_LevelDB(const std::string &savedir)
{
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, savedir + DIR_DELIM + "map.db", &m_database);
leveldb::Status status = leveldb::DB::Open(options,
savedir + DIR_DELIM + "map.db", &m_database);
ENSURE_STATUS_OK(status);
srvmap = map;
}
int Database_LevelDB::Initialized(void)
Database_LevelDB::~Database_LevelDB()
{
return 1;
delete m_database;
}
void Database_LevelDB::beginSave() {}
void Database_LevelDB::endSave() {}
bool Database_LevelDB::saveBlock(v3s16 blockpos, std::string &data)
bool Database_LevelDB::saveBlock(const v3s16 &pos, const std::string &data)
{
leveldb::Status status = m_database->Put(leveldb::WriteOptions(),
i64tos(getBlockAsInteger(blockpos)), data);
i64tos(getBlockAsInteger(pos)), data);
if (!status.ok()) {
errorstream << "WARNING: saveBlock: LevelDB error saving block "
<< PP(blockpos) << ": " << status.ToString() << std::endl;
<< PP(pos) << ": " << status.ToString() << std::endl;
return false;
}
return true;
}
std::string Database_LevelDB::loadBlock(v3s16 blockpos)
std::string Database_LevelDB::loadBlock(const v3s16 &pos)
{
std::string datastr;
leveldb::Status status = m_database->Get(leveldb::ReadOptions(),
i64tos(getBlockAsInteger(blockpos)), &datastr);
i64tos(getBlockAsInteger(pos)), &datastr);
if(status.ok())
return datastr;
@@ -80,20 +77,20 @@ std::string Database_LevelDB::loadBlock(v3s16 blockpos)
return "";
}
bool Database_LevelDB::deleteBlock(v3s16 blockpos)
bool Database_LevelDB::deleteBlock(const v3s16 &pos)
{
leveldb::Status status = m_database->Delete(leveldb::WriteOptions(),
i64tos(getBlockAsInteger(blockpos)));
i64tos(getBlockAsInteger(pos)));
if (!status.ok()) {
errorstream << "WARNING: deleteBlock: LevelDB error deleting block "
<< PP(blockpos) << ": " << status.ToString() << std::endl;
<< PP(pos) << ": " << status.ToString() << std::endl;
return false;
}
return true;
}
void Database_LevelDB::listAllLoadableBlocks(std::list<v3s16> &dst)
void Database_LevelDB::listAllLoadableBlocks(std::vector<v3s16> &dst)
{
leveldb::Iterator* it = m_database->NewIterator(leveldb::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) {
@@ -103,8 +100,5 @@ void Database_LevelDB::listAllLoadableBlocks(std::list<v3s16> &dst)
delete it;
}
Database_LevelDB::~Database_LevelDB()
{
delete m_database;
}
#endif
#endif // USE_LEVELDB