Fix player getting reset to 0,0 at connect if being far from 0,0
authorPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 22:39:36 +0000 (00:39 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 22:39:36 +0000 (00:39 +0200)
src/environment.cpp

index 41ba52a6fd364fe7331970bff7a83b1cebd1ca90..9748f6b71d00c77487554b4c7f395696ee3eac94 100644 (file)
@@ -472,6 +472,8 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
                        newplayer = true;
                }
 
+               ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(player);
+
                // Load player
                {
                        infostream<<"Reading player "<<testplayer.getName()<<" from "
@@ -483,7 +485,9 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
                                infostream<<"Failed to read "<<path<<std::endl;
                                continue;
                        }
-                       player->deSerialize(is);
+                       srp->deSerialize(is);
+                       srp->m_last_good_position = srp->getBasePosition();
+                       srp->m_last_good_position_age = 0;
                }
 
                if(newplayer)