aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constants.h5
-rw-r--r--src/environment.cpp2
-rw-r--r--src/player.cpp2
3 files changed, 7 insertions, 2 deletions
diff --git a/src/constants.h b/src/constants.h
index 53ef1801e..526e44159 100644
--- a/src/constants.h
+++ b/src/constants.h
@@ -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
*/
diff --git a/src/environment.cpp b/src/environment.cpp
index d068aa788..845928a20 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -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()) {
diff --git a/src/player.cpp b/src/player.cpp
index a52385f20..0d506ec99 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -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);