diff options
author | lhofhansl <lhofhansl@yahoo.com> | 2018-07-25 17:54:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 17:54:23 +0200 |
commit | 7454deb1bf04ab3478b4e2dc6b2821ae86f4514f (patch) | |
tree | 9d35ccee90a3f4a21015b2dded3da60f42ec1197 /src | |
parent | 9537cfd3f8264700619f58d15741829489e1099e (diff) | |
download | minetest-7454deb1bf04ab3478b4e2dc6b2821ae86f4514f.tar.gz minetest-7454deb1bf04ab3478b4e2dc6b2821ae86f4514f.tar.bz2 minetest-7454deb1bf04ab3478b4e2dc6b2821ae86f4514f.zip |
Allow an optional readonly base database (#7544)
* Allow an optional readonly base database
* Added basic documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 14 | ||||
-rw-r--r-- | src/map.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/map.cpp b/src/map.cpp index 801027ae2..0114867e0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1159,7 +1159,10 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef, } std::string backend = conf.get("backend"); dbase = createDatabase(backend, savedir, conf); - + if (conf.exists("readonly_backend")) { + std::string readonly_dir = savedir + DIR_DELIM + "readonly"; + dbase_ro = createDatabase(conf.get("readonly_backend"), readonly_dir, conf); + } if (!conf.updateConfigFile(conf_path.c_str())) errorstream << "ServerMap::ServerMap(): Failed to update world.mt!" << std::endl; @@ -1230,6 +1233,8 @@ ServerMap::~ServerMap() Close database if it was opened */ delete dbase; + if (dbase_ro) + delete dbase_ro; #if 0 /* @@ -1869,6 +1874,8 @@ void ServerMap::listAllLoadableBlocks(std::vector<v3s16> &dst) << "all blocks that are stored in flat files." << std::endl; } dbase->listAllLoadableBlocks(dst); + if (dbase_ro) + dbase_ro->listAllLoadableBlocks(dst); } void ServerMap::listAllLoadedBlocks(std::vector<v3s16> &dst) @@ -2107,6 +2114,11 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos) dbase->loadBlock(blockpos, &ret); if (!ret.empty()) { loadBlock(&ret, blockpos, createSector(p2d), false); + } else if (dbase_ro) { + dbase_ro->loadBlock(blockpos, &ret); + if (!ret.empty()) { + loadBlock(&ret, blockpos, createSector(p2d), false); + } } else { // Not found in database, try the files @@ -469,6 +469,7 @@ private: */ bool m_map_metadata_changed = true; MapDatabase *dbase = nullptr; + MapDatabase *dbase_ro = nullptr; }; |