diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-02-08 00:15:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 00:15:55 +0100 |
commit | ef6feca501fcf0d5a1fd2021f1d4df96a4533f65 (patch) | |
tree | 58361be1085c91222ab9c0cad507ca70a87dfe8e /src/mods.h | |
parent | 0680c47d6c7d3e98e2b96b823f8cc9ca76d5e7f8 (diff) | |
download | minetest-ef6feca501fcf0d5a1fd2021f1d4df96a4533f65.tar.gz minetest-ef6feca501fcf0d5a1fd2021f1d4df96a4533f65.tar.bz2 minetest-ef6feca501fcf0d5a1fd2021f1d4df96a4533f65.zip |
Add ModMetadata API (#5131)
* mod can create a ModMetadata object where store its values and retrieve it.
* Modmetadata object can only be fetched at mod loading
* Save when modified using same time as map interval or at server stop
* add helper function to get mod storage path
* ModMetadata has exactly same calls than all every other Metadata
Diffstat (limited to 'src/mods.h')
-rw-r--r-- | src/mods.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mods.h b/src/mods.h index af7777d18..61af5e5d1 100644 --- a/src/mods.h +++ b/src/mods.h @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <map> #include <json/json.h> #include "config.h" +#include "metadata.h" #define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_" @@ -205,4 +206,24 @@ struct ModStoreModDetails { bool valid; }; +class ModMetadata: public Metadata +{ +public: + ModMetadata(const std::string &mod_name); + ~ModMetadata() {} + + virtual void clear(); + + bool save(const std::string &root_path); + bool load(const std::string &root_path); + + bool isModified() const { return m_modified; } + const std::string &getModName() const { return m_mod_name; } + + virtual bool setString(const std::string &name, const std::string &var); +private: + std::string m_mod_name; + bool m_modified; +}; + #endif |