aboutsummaryrefslogtreecommitdiff
path: root/src/database
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-04-06 09:52:29 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-04-06 10:52:29 +0200
commit91615f9588420fd716978552fdacf1323b8df11c (patch)
tree951b1c139c09056d0d31bc4b8e0d13fd2d69c8bb /src/database
parent7e3f88f539109955b21a129e4203a1cadb913483 (diff)
downloadminetest-91615f9588420fd716978552fdacf1323b8df11c.tar.gz
minetest-91615f9588420fd716978552fdacf1323b8df11c.tar.bz2
minetest-91615f9588420fd716978552fdacf1323b8df11c.zip
Add player:get_meta(), deprecate player attributes (#7202)
* Add player:get_meta(), deprecate player attributes
Diffstat (limited to 'src/database')
-rw-r--r--src/database/database-postgresql.cpp6
-rw-r--r--src/database/database-sqlite3.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp
index 74651135a..2d9c3b49e 100644
--- a/src/database/database-postgresql.cpp
+++ b/src/database/database-postgresql.cpp
@@ -518,7 +518,7 @@ void PlayerDatabasePostgreSQL::savePlayer(RemotePlayer *player)
}
execPrepared("remove_player_metadata", 1, rmvalues);
- const PlayerAttributes &attrs = sao->getExtendedAttributes();
+ const StringMap &attrs = sao->getMeta().getStrings();
for (const auto &attr : attrs) {
const char *meta_values[] = {
player->getName(),
@@ -527,6 +527,7 @@ void PlayerDatabasePostgreSQL::savePlayer(RemotePlayer *player)
};
execPrepared("save_player_metadata", 3, meta_values);
}
+ sao->getMeta().setModified(false);
endSave();
}
@@ -594,8 +595,9 @@ bool PlayerDatabasePostgreSQL::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
int numrows = PQntuples(results);
for (int row = 0; row < numrows; row++) {
- sao->setExtendedAttribute(PQgetvalue(results, row, 0),PQgetvalue(results, row, 1));
+ sao->getMeta().setString(PQgetvalue(results, row, 0), PQgetvalue(results, row, 1));
}
+ sao->getMeta().setModified(false);
PQclear(results);
diff --git a/src/database/database-sqlite3.cpp b/src/database/database-sqlite3.cpp
index 78c182f86..76935ada4 100644
--- a/src/database/database-sqlite3.cpp
+++ b/src/database/database-sqlite3.cpp
@@ -520,7 +520,7 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
sqlite3_vrfy(sqlite3_step(m_stmt_player_metadata_remove), SQLITE_DONE);
sqlite3_reset(m_stmt_player_metadata_remove);
- const PlayerAttributes &attrs = sao->getExtendedAttributes();
+ const StringMap &attrs = sao->getMeta().getStrings();
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, attr.first);
@@ -528,6 +528,7 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
sqlite3_vrfy(sqlite3_step(m_stmt_player_metadata_add), SQLITE_DONE);
sqlite3_reset(m_stmt_player_metadata_add);
}
+ sao->getMeta().setModified(false);
endSave();
}
@@ -578,8 +579,9 @@ bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
std::string attr = sqlite_to_string(m_stmt_player_metadata_load, 0);
std::string value = sqlite_to_string(m_stmt_player_metadata_load, 1);
- sao->setExtendedAttribute(attr, value);
+ sao->getMeta().setString(attr, value);
}
+ sao->getMeta().setModified(false);
sqlite3_reset(m_stmt_player_metadata_load);
return true;
}