Fix ActiveObject creation for fast player respawns
authorPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 15:30:22 +0000 (17:30 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 15:30:22 +0000 (17:30 +0200)
src/server.cpp
src/serverremoteplayer.h

index cb515e0d0e6565f0163ea8898350486606590381..b8bdd883060c7c5ed7acfd7065774581898c6a0a 100644 (file)
@@ -1348,6 +1348,15 @@ void Server::AsyncRunStep()
                        if(player->m_hp_not_sent){
                                SendPlayerHP(player);
                        }
+
+                       /*
+                               Add to environment if is not in respawn screen
+                       */
+                       if(!player->m_is_in_environment && !player->m_respawn_active){
+                               player->m_removed = false;
+                               player->setId(0);
+                               m_env->addActiveObject(player);
+                       }
                }
        }
        
@@ -2127,11 +2136,6 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                        return;
                }
 
-               // Add PlayerSAO
-               player->m_removed = false;
-               player->setId(0);
-               m_env->addActiveObject(player);
-
                /*
                        Answer with a TOCLIENT_INIT
                */
@@ -2887,10 +2891,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                
                actionstream<<player->getName()<<" respawns at "
                                <<PP(player->getPosition()/BS)<<std::endl;
-               
-               srp->m_removed = false;
-               srp->setId(0);
-               m_env->addActiveObject(srp);
+
+               // ActiveObject is added to environment in AsyncRunStep after
+               // the previous addition has been succesfully removed
        }
        else if(command == TOSERVER_INTERACT)
        {
index 1ef14ca93833ad3b5069ca93c6eb57c1d5ae47ed..15a9ebc38cd4dba467faafa5acddf557d1d0be11 100644 (file)
@@ -92,9 +92,9 @@ public:
        bool m_inventory_not_sent;
        bool m_hp_not_sent;
        bool m_respawn_active;
+       bool m_is_in_environment;
 
 private:
-       bool m_is_in_environment;
        bool m_position_not_sent;
 };