aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_storage.cpp
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-01-07 13:28:49 -0500
committerGitHub <noreply@github.com>2022-01-07 20:28:49 +0200
commitbf22569019749e421e8ffe0a73cff988a9a9c846 (patch)
tree9e6910c1faf0ddce191ad4b3110f08b0201fc482 /src/script/lua_api/l_storage.cpp
parentb81948a14c138517f6a227dac5b71f0b2facb33c (diff)
downloadminetest-bf22569019749e421e8ffe0a73cff988a9a9c846.tar.gz
minetest-bf22569019749e421e8ffe0a73cff988a9a9c846.tar.bz2
minetest-bf22569019749e421e8ffe0a73cff988a9a9c846.zip
Use a database for mod storage (#11763)
Diffstat (limited to 'src/script/lua_api/l_storage.cpp')
-rw-r--r--src/script/lua_api/l_storage.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp
index 978b315d5..b8f4347a8 100644
--- a/src/script/lua_api/l_storage.cpp
+++ b/src/script/lua_api/l_storage.cpp
@@ -32,19 +32,23 @@ int ModApiStorage::l_get_mod_storage(lua_State *L)
std::string mod_name = readParam<std::string>(L, -1);
- ModMetadata *store = new ModMetadata(mod_name);
+ ModMetadata *store = nullptr;
+
if (IGameDef *gamedef = getGameDef(L)) {
- store->load(gamedef->getModStoragePath());
- gamedef->registerModStorage(store);
+ store = new ModMetadata(mod_name, gamedef->getModStorageDatabase());
+ if (gamedef->registerModStorage(store)) {
+ StorageRef::create(L, store);
+ int object = lua_gettop(L);
+ lua_pushvalue(L, object);
+ return 1;
+ }
} else {
- delete store;
assert(false); // this should not happen
}
- StorageRef::create(L, store);
- int object = lua_gettop(L);
+ delete store;
- lua_pushvalue(L, object);
+ lua_pushnil(L);
return 1;
}