aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoïc Blot <loic.blot@unix-experience.fr>2019-01-04 10:06:46 +0100
committerLoïc Blot <loic.blot@unix-experience.fr>2019-01-04 10:06:46 +0100
commit07177190734b0e5c17be18d0bf5d509c5226af2f (patch)
tree85d0ca1f0577338b6241201f069a3db227b8efb5 /src
parentcf224c9d6b72f81d19e9b2eca9d23f589b6a1392 (diff)
downloadminetest-07177190734b0e5c17be18d0bf5d509c5226af2f.tar.gz
minetest-07177190734b0e5c17be18d0bf5d509c5226af2f.tar.bz2
minetest-07177190734b0e5c17be18d0bf5d509c5226af2f.zip
Player file directory must be only created when using file backend.
Also ensure on each player save that the directory exists
Diffstat (limited to 'src')
-rw-r--r--src/database/database-files.cpp7
-rw-r--r--src/database/database-files.h2
-rw-r--r--src/serverenvironment.cpp3
3 files changed, 8 insertions, 4 deletions
diff --git a/src/database/database-files.cpp b/src/database/database-files.cpp
index 09d76240e..f42535348 100644
--- a/src/database/database-files.cpp
+++ b/src/database/database-files.cpp
@@ -31,6 +31,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// This backend is intended to be used on Minetest 0.4.16 only for the transition backend
// for player files
+PlayerDatabaseFiles::PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir)
+{
+ fs::CreateDir(m_savedir);
+}
+
void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player)
{
// Utilize a Settings object for storing values
@@ -58,6 +63,8 @@ void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player
void PlayerDatabaseFiles::savePlayer(RemotePlayer *player)
{
+ fs::CreateDir(m_savedir);
+
std::string savedir = m_savedir + DIR_DELIM;
std::string path = savedir + player->getName();
bool path_found = false;
diff --git a/src/database/database-files.h b/src/database/database-files.h
index 218815cf7..cb830a3ed 100644
--- a/src/database/database-files.h
+++ b/src/database/database-files.h
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class PlayerDatabaseFiles : public PlayerDatabase
{
public:
- PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir) {}
+ PlayerDatabaseFiles(const std::string &savedir);
virtual ~PlayerDatabaseFiles() = default;
void savePlayer(RemotePlayer *player);
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp
index 4837449e6..b25840528 100644
--- a/src/serverenvironment.cpp
+++ b/src/serverenvironment.cpp
@@ -544,9 +544,6 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
void ServerEnvironment::saveLoadedPlayers()
{
- std::string players_path = m_path_world + DIR_DELIM + "players";
- fs::CreateDir(players_path);
-
for (RemotePlayer *player : m_players) {
if (player->checkModified() || (player->getPlayerSAO() &&
player->getPlayerSAO()->getMeta().isModified())) {