]> git.lizzy.rs Git - minetest.git/commitdiff
Store the maximum player file tries in a constant
authorShadowNinja <shadowninja@minetest.net>
Mon, 23 Jun 2014 19:55:47 +0000 (15:55 -0400)
committerShadowNinja <shadowninja@minetest.net>
Mon, 23 Jun 2014 19:55:47 +0000 (15:55 -0400)
src/constants.h
src/environment.cpp
src/player.cpp

index 53ef1801eb4687ee8902aecf42eade10a473ac5c..526e44159f3b82f01a69a719aad357c4fd986b24 100644 (file)
@@ -89,6 +89,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 // Maximum hit points of a player
 #define PLAYER_MAX_HP 20
 
+// Number of different files to try to save a player to if the first fails
+// (because of a case-insensitive filesystem)
+// TODO: Use case-insensitive player names instead of this hack.
+#define PLAYER_FILE_ALTERNATE_TRIES 1000
+
 /*
  *    GUI related things
  */
index d068aa788a43100ae433ae69e8b59a13336ccac4..845928a2080ab64a51195ca8ac753b8944897db0 100644 (file)
@@ -455,7 +455,7 @@ Player *ServerEnvironment::loadPlayer(const std::string &playername)
 
        RemotePlayer testplayer(m_gamedef);
        std::string path = players_path + playername;
-       for (u32 i = 0; i < 1000; i++) {
+       for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
                // Open file and deserialize
                std::ifstream is(path.c_str(), std::ios_base::binary);
                if (!is.good()) {
index a52385f20c936e5d08a6d5266d5c8624ea5a881b..0d506ec99a8e4ceb46bc73814afdd84a1c984b4b 100644 (file)
@@ -297,7 +297,7 @@ void RemotePlayer::save(std::string savedir)
 
        savedir += DIR_DELIM;
        std::string path = savedir + m_name;
-       for (u32 i = 0; i < 1000; i++) {
+       for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
                if (!fs::PathExists(path)) {
                        // Open file and serialize
                        std::ostringstream ss(std::ios_base::binary);