Print playername when failing to read playerfile and ignore files starting with .
authorPilzAdam <pilzadam@minetest.net>
Fri, 21 Jun 2013 18:32:28 +0000 (18:32 +0000)
committerPilzAdam <pilzadam@minetest.net>
Sat, 22 Jun 2013 21:39:47 +0000 (21:39 +0000)
src/environment.cpp
src/player.cpp
src/player.h

index 99da5190c0dedaef2985b253e0333e76837695aa..4b785998bdc79adb48b1f54a1864c2b4cabc19ae 100644 (file)
@@ -399,7 +399,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
        std::vector<fs::DirListNode> player_files = fs::GetDirListing(players_path);
        for(u32 i=0; i<player_files.size(); i++)
        {
-               if(player_files[i].dir)
+               if(player_files[i].dir || player_files[i].name[0] == '.')
                        continue;
                
                // Full path to this file
@@ -417,7 +417,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
                                infostream<<"Failed to read "<<path<<std::endl;
                                continue;
                        }
-                       testplayer.deSerialize(is);
+                       testplayer.deSerialize(is, player_files[i].name);
                }
 
                //infostream<<"Loaded test player with name "<<testplayer.getName()<<std::endl;
@@ -529,7 +529,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
                                infostream<<"Failed to read "<<path<<std::endl;
                                continue;
                        }
-                       testplayer.deSerialize(is);
+                       testplayer.deSerialize(is, player_files[i].name);
                }
 
                if(!string_allowed(testplayer.getName(), PLAYERNAME_ALLOWED_CHARS))
@@ -563,7 +563,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
                                infostream<<"Failed to read "<<path<<std::endl;
                                continue;
                        }
-                       player->deSerialize(is);
+                       player->deSerialize(is, player_files[i].name);
                }
 
                if(newplayer)
index a199c9a6c2ff13f6257b5f93b179622e42adccec..ec1e3aff71ea80c4075f21423dfd67b476ebacf2 100644 (file)
@@ -179,7 +179,7 @@ void Player::serialize(std::ostream &os)
        inventory.serialize(os);
 }
 
-void Player::deSerialize(std::istream &is)
+void Player::deSerialize(std::istream &is, std::string playername)
 {
        Settings args;
        
@@ -187,7 +187,7 @@ void Player::deSerialize(std::istream &is)
        {
                if(is.eof())
                        throw SerializationError
-                                       ("Player::deSerialize(): PlayerArgsEnd not found");
+                                       (("Player::deSerialize(): PlayerArgsEnd of player \"" + playername + "\" not found").c_str());
                std::string line;
                std::getline(is, line);
                std::string trimmedline = trim(line);
index 517bd354dad0fed5161e340534ff3f75dd181386..89e4667c4443612503bd084ed67ec7582bc46329 100644 (file)
@@ -197,7 +197,7 @@ public:
                deSerialize stops reading exactly at the right point.
        */
        void serialize(std::ostream &os);
-       void deSerialize(std::istream &is);
+       void deSerialize(std::istream &is, std::string playername);
 
        bool touching_ground;
        // This oscillates so that the player jumps a bit above the surface