]> git.lizzy.rs Git - minetest.git/blobdiff - src/database-sqlite3.cpp
Fix a formspec crash triggered by ae9b5e00989756bb676429530dfe81039009001c
[minetest.git] / src / database-sqlite3.cpp
index 22765c8d22cb4e4446080c3295d434810ec80b82..78c182f8685bb5a6e9141b85eaa35f0c5b7098dd 100644 (file)
@@ -521,10 +521,10 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
        sqlite3_reset(m_stmt_player_metadata_remove);
 
        const PlayerAttributes &attrs = sao->getExtendedAttributes();
-       for (PlayerAttributes::const_iterator it = attrs.begin(); it != attrs.end(); ++it) {
+       for (const auto &attr : attrs) {
                str_to_sqlite(m_stmt_player_metadata_add, 1, player->getName());
-               str_to_sqlite(m_stmt_player_metadata_add, 2, it->first);
-               str_to_sqlite(m_stmt_player_metadata_add, 3, it->second);
+               str_to_sqlite(m_stmt_player_metadata_add, 2, attr.first);
+               str_to_sqlite(m_stmt_player_metadata_add, 3, attr.second);
                sqlite3_vrfy(sqlite3_step(m_stmt_player_metadata_add), SQLITE_DONE);
                sqlite3_reset(m_stmt_player_metadata_add);
        }
@@ -565,7 +565,7 @@ bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
                        if (itemStr.length() > 0) {
                                ItemStack stack;
                                stack.deSerialize(itemStr);
-                               invList->addItem(sqlite_to_uint(m_stmt_player_load_inventory_items, 0), stack);
+                               invList->changeItem(sqlite_to_uint(m_stmt_player_load_inventory_items, 0), stack);
                        }
                }
                sqlite3_reset(m_stmt_player_load_inventory_items);