mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Use a database for mod storage (#11763)
This commit is contained in:
parent
b81948a14c
commit
bf22569019
21 changed files with 798 additions and 127 deletions
|
@ -80,3 +80,41 @@ void Database_Dummy::listPlayers(std::vector<std::string> &res)
|
|||
res.emplace_back(player);
|
||||
}
|
||||
}
|
||||
|
||||
bool Database_Dummy::getModEntries(const std::string &modname, StringMap *storage)
|
||||
{
|
||||
const auto mod_pair = m_mod_meta_database.find(modname);
|
||||
if (mod_pair != m_mod_meta_database.cend()) {
|
||||
for (const auto &pair : mod_pair->second) {
|
||||
(*storage)[pair.first] = pair.second;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database_Dummy::setModEntry(const std::string &modname,
|
||||
const std::string &key, const std::string &value)
|
||||
{
|
||||
auto mod_pair = m_mod_meta_database.find(modname);
|
||||
if (mod_pair == m_mod_meta_database.end()) {
|
||||
m_mod_meta_database[modname] = StringMap({{key, value}});
|
||||
} else {
|
||||
mod_pair->second[key] = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database_Dummy::removeModEntry(const std::string &modname, const std::string &key)
|
||||
{
|
||||
auto mod_pair = m_mod_meta_database.find(modname);
|
||||
if (mod_pair != m_mod_meta_database.end())
|
||||
return mod_pair->second.erase(key) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Database_Dummy::listMods(std::vector<std::string> *res)
|
||||
{
|
||||
for (const auto &pair : m_mod_meta_database) {
|
||||
res->push_back(pair.first);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue