1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Use a database for mod storage (#11763)

This commit is contained in:
Jude Melton-Houghton 2022-01-07 13:28:49 -05:00 committed by GitHub
parent b81948a14c
commit bf22569019
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 798 additions and 127 deletions

View file

@ -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;
}