diff options
author | JacobF <queatz@gmail.com> | 2011-09-02 19:07:14 -0400 |
---|---|---|
committer | JacobF <queatz@gmail.com> | 2011-09-02 19:07:14 -0400 |
commit | d1a16f24cfb360a0a6e60fc76ea87d7c4cf24618 (patch) | |
tree | 3358c4e6392a705d6ed5d88d93f22681009d7b02 /src/map.h | |
parent | e3c58eff1c0a0650c3ab4df76cd6941741e727f6 (diff) | |
download | minetest-d1a16f24cfb360a0a6e60fc76ea87d7c4cf24618.tar.gz minetest-d1a16f24cfb360a0a6e60fc76ea87d7c4cf24618.tar.bz2 minetest-d1a16f24cfb360a0a6e60fc76ea87d7c4cf24618.zip |
Initial sqlite3 maps.
* The map will reside in world/map.sqlite
* It will load from the sectors folder but will not save there
Diffstat (limited to 'src/map.h')
-rw-r--r-- | src/map.h | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <jmutexautolock.h> #include <jthread.h> #include <iostream> +#include <sstream> #include "common_irrlicht.h" #include "mapnode.h" @@ -31,6 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "constants.h" #include "voxel.h" +extern "C" { + #include "sqlite3.h" +} + class MapSector; class ServerMapSector; class ClientMapSector; @@ -220,6 +225,10 @@ public: //core::aabbox3d<s16> getDisplayedBlockArea(); //bool updateChangedVisibleArea(); + + // Call these before and after saving of many blocks + virtual void beginSave() {return;}; + virtual void endSave() {return;}; virtual void save(bool only_changed){assert(0);}; @@ -361,6 +370,23 @@ public: v3s16 getBlockPos(std::string sectordir, std::string blockfile); static std::string getBlockFilename(v3s16 p); + /* + Database functions + */ + // Create the database structure + void createDatabase(); + // Verify we can read/write to the database + void verifyDatabase(); + // Get an integer suitable for a block + static int getBlockAsInteger(const v3s16 pos); + + // Returns true if the database file does not exist + bool loadFromFolders(); + + // Call these before and after saving of blocks + void beginSave(); + void endSave(); + void save(bool only_changed); //void loadAll(); @@ -391,6 +417,8 @@ public: // This will generate a sector with getSector if not found. void loadBlock(std::string sectordir, std::string blockfile, MapSector *sector, bool save_after_load=false); MapBlock* loadBlock(v3s16 p); + // Database version + void loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool save_after_load=false); // For debug printing virtual void PrintInfo(std::ostream &out); @@ -419,6 +447,13 @@ private: This is reset to false when written on disk. */ bool m_map_metadata_changed; + + /* + SQLite database and statements + */ + sqlite3 *m_database; + sqlite3_stmt *m_database_read; + sqlite3_stmt *m_database_write; }; /* |