1 /* 2 database-dummy.cpp 3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> 4 */ 5 6 /* 7 This file is part of Freeminer. 8 9 Freeminer is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Freeminer is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Freeminer. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 /* 24 Dummy "database" class 25 */ 26 27 28 #include "database-dummy.h" 29 30 #include "map.h" 31 #include "mapblock.h" 32 #include "serialization.h" 33 #include "main.h" 34 #include "settings.h" 35 #include "log.h" 36 Database_Dummy(ServerMap * map)37Database_Dummy::Database_Dummy(ServerMap *map) 38 { 39 srvmap = map; 40 } 41 Initialized(void)42int Database_Dummy::Initialized(void) 43 { 44 return 1; 45 } 46 beginSave()47void Database_Dummy::beginSave() {} endSave()48void Database_Dummy::endSave() {} 49 saveBlock(v3s16 blockpos,std::string & data)50bool Database_Dummy::saveBlock(v3s16 blockpos, std::string &data) 51 { 52 m_database.set(getBlockAsString(blockpos), data); 53 return true; 54 } 55 loadBlock(v3s16 blockpos)56std::string Database_Dummy::loadBlock(v3s16 blockpos) 57 { 58 if (m_database.count(getBlockAsString(blockpos))) 59 return m_database.get(getBlockAsString(blockpos)); 60 else 61 return ""; 62 } 63 listAllLoadableBlocks(std::list<v3s16> & dst)64void Database_Dummy::listAllLoadableBlocks(std::list<v3s16> &dst) 65 { 66 for(auto &x : m_database) 67 { 68 v3s16 p = getStringAsBlock(x.first); 69 //dstream<<"block_i="<<block_i<<" p="<<PP(p)<<std::endl; 70 dst.push_back(p); 71 } 72 } 73 ~Database_Dummy()74Database_Dummy::~Database_Dummy() 75 { 76 m_database.clear(); 77 } 78