Skip to content
Snippets Groups Projects
Commit 80acdab9 authored by Perttu Ahola's avatar Perttu Ahola
Browse files

Commented out some debug output about saving players on server.

parent 1c776c3d
No related branches found
No related tags found
No related merge requests found
...@@ -322,7 +322,7 @@ void Environment::serializePlayers(const std::string &savedir) ...@@ -322,7 +322,7 @@ void Environment::serializePlayers(const std::string &savedir)
// Full path to this file // Full path to this file
std::string path = players_path + "/" + player_files[i].name; std::string path = players_path + "/" + player_files[i].name;
dstream<<"Checking player file "<<path<<std::endl; //dstream<<"Checking player file "<<path<<std::endl;
// Load player to see what is its name // Load player to see what is its name
ServerRemotePlayer testplayer; ServerRemotePlayer testplayer;
...@@ -337,18 +337,18 @@ void Environment::serializePlayers(const std::string &savedir) ...@@ -337,18 +337,18 @@ void Environment::serializePlayers(const std::string &savedir)
testplayer.deSerialize(is); testplayer.deSerialize(is);
} }
dstream<<"Loaded test player with name "<<testplayer.getName()<<std::endl; //dstream<<"Loaded test player with name "<<testplayer.getName()<<std::endl;
// Search for the player // Search for the player
std::string playername = testplayer.getName(); std::string playername = testplayer.getName();
Player *player = getPlayer(playername.c_str()); Player *player = getPlayer(playername.c_str());
if(player == NULL) if(player == NULL)
{ {
dstream<<"Didn't find matching player, ignoring file."<<std::endl; dstream<<"Didn't find matching player, ignoring file "<<path<<std::endl;
continue; continue;
} }
dstream<<"Found matching player, overwriting."<<std::endl; //dstream<<"Found matching player, overwriting."<<std::endl;
// OK, found. Save player there. // OK, found. Save player there.
{ {
...@@ -370,15 +370,15 @@ void Environment::serializePlayers(const std::string &savedir) ...@@ -370,15 +370,15 @@ void Environment::serializePlayers(const std::string &savedir)
Player *player = *i; Player *player = *i;
if(saved_players.find(player) != NULL) if(saved_players.find(player) != NULL)
{ {
dstream<<"Player "<<player->getName() /*dstream<<"Player "<<player->getName()
<<" was already saved."<<std::endl; <<" was already saved."<<std::endl;*/
continue; continue;
} }
std::string playername = player->getName(); std::string playername = player->getName();
// Don't save unnamed player // Don't save unnamed player
if(playername == "") if(playername == "")
{ {
dstream<<"Not saving unnamed player."<<std::endl; //dstream<<"Not saving unnamed player."<<std::endl;
continue; continue;
} }
/* /*
...@@ -399,24 +399,26 @@ void Environment::serializePlayers(const std::string &savedir) ...@@ -399,24 +399,26 @@ void Environment::serializePlayers(const std::string &savedir)
} }
if(found == false) if(found == false)
{ {
dstream<<"Didn't find free file for player"<<std::endl; dstream<<"WARNING: Didn't find free file for player"<<std::endl;
continue; continue;
} }
{ {
dstream<<"Saving player "<<player->getName()<<" to " /*dstream<<"Saving player "<<player->getName()<<" to "
<<path<<std::endl; <<path<<std::endl;*/
// Open file and serialize // Open file and serialize
std::ofstream os(path.c_str(), std::ios_base::binary); std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"Failed to overwrite "<<path<<std::endl; dstream<<"WARNING: Failed to overwrite "<<path<<std::endl;
continue; continue;
} }
player->serialize(os); player->serialize(os);
saved_players.insert(player, true); saved_players.insert(player, true);
} }
} }
//dstream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
} }
void Environment::deSerializePlayers(const std::string &savedir) void Environment::deSerializePlayers(const std::string &savedir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment