Skip to content

Commit 089fc01

Browse files
committedJun 23, 2014
Store the maximum player file tries in a constant
1 parent e491f8c commit 089fc01

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed
 

‎src/constants.h

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
8989
// Maximum hit points of a player
9090
#define PLAYER_MAX_HP 20
9191

92+
// Number of different files to try to save a player to if the first fails
93+
// (because of a case-insensitive filesystem)
94+
// TODO: Use case-insensitive player names instead of this hack.
95+
#define PLAYER_FILE_ALTERNATE_TRIES 1000
96+
9297
/*
9398
* GUI related things
9499
*/

‎src/environment.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ Player *ServerEnvironment::loadPlayer(const std::string &playername)
455455

456456
RemotePlayer testplayer(m_gamedef);
457457
std::string path = players_path + playername;
458-
for (u32 i = 0; i < 1000; i++) {
458+
for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
459459
// Open file and deserialize
460460
std::ifstream is(path.c_str(), std::ios_base::binary);
461461
if (!is.good()) {

‎src/player.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void RemotePlayer::save(std::string savedir)
297297

298298
savedir += DIR_DELIM;
299299
std::string path = savedir + m_name;
300-
for (u32 i = 0; i < 1000; i++) {
300+
for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
301301
if (!fs::PathExists(path)) {
302302
// Open file and serialize
303303
std::ostringstream ss(std::ios_base::binary);

0 commit comments

Comments
 (0)
Please sign in to comment.