aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database/database-files.cpp3
-rw-r--r--src/database/database-postgresql.cpp3
-rw-r--r--src/database/database-sqlite3.cpp3
-rw-r--r--src/remoteplayer.cpp9
-rw-r--r--src/remoteplayer.h2
5 files changed, 15 insertions, 5 deletions
diff --git a/src/database/database-files.cpp b/src/database/database-files.cpp
index f42535348..b1c79c94a 100644
--- a/src/database/database-files.cpp
+++ b/src/database/database-files.cpp
@@ -105,7 +105,8 @@ void PlayerDatabaseFiles::savePlayer(RemotePlayer *player)
if (!fs::safeWriteToFile(path, ss.str())) {
infostream << "Failed to write " << path << std::endl;
}
- player->setModified(false);
+
+ player->on_successful_save();
}
bool PlayerDatabaseFiles::removePlayer(const std::string &name)
diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp
index eec838ef0..f5f8e3adf 100644
--- a/src/database/database-postgresql.cpp
+++ b/src/database/database-postgresql.cpp
@@ -527,8 +527,9 @@ void PlayerDatabasePostgreSQL::savePlayer(RemotePlayer *player)
};
execPrepared("save_player_metadata", 3, meta_values);
}
- sao->getMeta().setModified(false);
endSave();
+
+ player->on_successful_save();
}
bool PlayerDatabasePostgreSQL::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
diff --git a/src/database/database-sqlite3.cpp b/src/database/database-sqlite3.cpp
index aa156bbbd..7a79fb187 100644
--- a/src/database/database-sqlite3.cpp
+++ b/src/database/database-sqlite3.cpp
@@ -528,9 +528,10 @@ 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();
+
+ player->on_successful_save();
}
bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
diff --git a/src/remoteplayer.cpp b/src/remoteplayer.cpp
index d54caf924..18749d5ff 100644
--- a/src/remoteplayer.cpp
+++ b/src/remoteplayer.cpp
@@ -79,8 +79,6 @@ void RemotePlayer::serializeExtraAttributes(std::string &output)
}
output = fastWriteJson(json_root);
-
- m_sao->getMeta().setModified(false);
}
@@ -225,3 +223,10 @@ const RemotePlayerChatResult RemotePlayer::canSendChatMessage()
m_chat_message_allowance -= 1.0f;
return RPLAYER_CHATRESULT_OK;
}
+
+void RemotePlayer::on_successful_save()
+{
+ setModified(false);
+ if (m_sao)
+ m_sao->getMeta().setModified(false);
+}
diff --git a/src/remoteplayer.h b/src/remoteplayer.h
index ed0f21b42..212741df8 100644
--- a/src/remoteplayer.h
+++ b/src/remoteplayer.h
@@ -139,6 +139,8 @@ public:
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
+ void on_successful_save();
+
private:
/*
serialize() writes a bunch of text that can contain