Remove stuff made obsolete by making players more ActiveObject-like and raise protoco...
authorPerttu Ahola <celeron55@gmail.com>
Thu, 1 Dec 2011 21:55:57 +0000 (23:55 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 1 Dec 2011 21:55:57 +0000 (23:55 +0200)
minetest.conf.example
src/client.cpp
src/clientserver.h
src/defaultsettings.cpp
src/server.cpp
src/server.h

index e0c43d72854aa91b70ae971b89b334fe2e981cc4..e936e05fc32660e285bf77392c1a2c4f241791f5 100644 (file)
 # Profiler data print interval. #0 = disable.
 #profiler_print_interval = 0
 #enable_mapgen_debug_info = false
-# Player and object positions are sent at intervals specified by this
-#objectdata_interval = 0.2
 #active_object_send_range_blocks = 3
 #active_block_range = 2
 #max_simultaneous_block_sends_per_client = 2
index a165627e5dcd92c2a14441df6826fd0ffafa70b4..d264713e237410728d7b731d2f0dc02201956288 100644 (file)
@@ -940,222 +940,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                //infostream<<"Adding mesh update task for received block"<<std::endl;
                addUpdateMeshTaskWithEdge(p, true);
        }
-       else if(command == TOCLIENT_PLAYERPOS)
-       {
-               infostream<<"Received deprecated TOCLIENT_PLAYERPOS"
-                               <<std::endl;
-               /*u16 our_peer_id;
-               {
-                       //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
-                       our_peer_id = m_con.GetPeerID();
-               }
-               // Cancel if we don't have a peer id
-               if(our_peer_id == PEER_ID_INEXISTENT){
-                       infostream<<"TOCLIENT_PLAYERPOS cancelled: "
-                                       "we have no peer id"
-                                       <<std::endl;
-                       return;
-               }*/
-
-               { //envlock
-                       //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
-                       
-                       u32 player_size = 2+12+12+4+4;
-                               
-                       u32 player_count = (datasize-2) / player_size;
-                       u32 start = 2;
-                       for(u32 i=0; i<player_count; i++)
-                       {
-                               u16 peer_id = readU16(&data[start]);
-
-                               Player *player = m_env.getPlayer(peer_id);
-
-                               // Skip if player doesn't exist
-                               if(player == NULL)
-                               {
-                                       start += player_size;
-                                       continue;
-                               }
-
-                               // Skip if player is local player
-                               if(player->isLocal())
-                               {
-                                       start += player_size;
-                                       continue;
-                               }
-
-                               v3s32 ps = readV3S32(&data[start+2]);
-                               v3s32 ss = readV3S32(&data[start+2+12]);
-                               s32 pitch_i = readS32(&data[start+2+12+12]);
-                               s32 yaw_i = readS32(&data[start+2+12+12+4]);
-                               /*infostream<<"Client: got "
-                                               <<"pitch_i="<<pitch_i
-                                               <<" yaw_i="<<yaw_i<<std::endl;*/
-                               f32 pitch = (f32)pitch_i / 100.0;
-                               f32 yaw = (f32)yaw_i / 100.0;
-                               v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.);
-                               v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.);
-                               player->setPosition(position);
-                               player->setSpeed(speed);
-                               player->setPitch(pitch);
-                               player->setYaw(yaw);
-
-                               /*infostream<<"Client: player "<<peer_id
-                                               <<" pitch="<<pitch
-                                               <<" yaw="<<yaw<<std::endl;*/
-
-                               start += player_size;
-                       }
-               } //envlock
-       }
-       else if(command == TOCLIENT_PLAYERINFO)
-       {
-               infostream<<"Client received DEPRECATED TOCLIENT_PLAYERINFO"<<std::endl;
-#if 0
-               u16 our_peer_id;
-               {
-                       //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
-                       our_peer_id = m_con.GetPeerID();
-               }
-               // Cancel if we don't have a peer id
-               if(our_peer_id == PEER_ID_INEXISTENT){
-                       infostream<<"TOCLIENT_PLAYERINFO cancelled: "
-                                       "we have no peer id"
-                                       <<std::endl;
-                       return;
-               }
-               
-               //infostream<<"Client: Server reports players:"<<std::endl;
-
-               { //envlock
-                       //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
-                       
-                       u32 item_size = 2+PLAYERNAME_SIZE;
-                       u32 player_count = (datasize-2) / item_size;
-                       u32 start = 2;
-                       // peer_ids
-                       core::list<u16> players_alive;
-                       for(u32 i=0; i<player_count; i++)
-                       {
-                               // Make sure the name ends in '\0'
-                               data[start+2+20-1] = 0;
-
-                               u16 peer_id = readU16(&data[start]);
-
-                               players_alive.push_back(peer_id);
-                               
-                               /*infostream<<"peer_id="<<peer_id
-                                               <<" name="<<((char*)&data[start+2])<<std::endl;*/
-
-                               // Don't update the info of the local player
-                               if(peer_id == our_peer_id)
-                               {
-                                       start += item_size;
-                                       continue;
-                               }
-
-                               Player *player = m_env.getPlayer(peer_id);
-
-                               // Create a player if it doesn't exist
-                               if(player == NULL)
-                               {
-                                       player = new RemotePlayer(this,
-                                                       m_device->getSceneManager()->getRootSceneNode(),
-                                                       m_device,
-                                                       -1);
-                                       player->peer_id = peer_id;
-                                       m_env.addPlayer(player);
-                                       infostream<<"Client: Adding new player "
-                                                       <<peer_id<<std::endl;
-                               }
-                               
-                               player->updateName((char*)&data[start+2]);
-
-                               start += item_size;
-                       }
-                       
-                       /*
-                               Remove those players from the environment that
-                               weren't listed by the server.
-                       */
-                       //infostream<<"Removing dead players"<<std::endl;
-                       core::list<Player*> players = m_env.getPlayers();
-                       core::list<Player*>::Iterator ip;
-                       for(ip=players.begin(); ip!=players.end(); ip++)
-                       {
-                               // Ingore local player
-                               if((*ip)->isLocal())
-                                       continue;
-                               
-                               // Warn about a special case
-                               if((*ip)->peer_id == 0)
-                               {
-                                       infostream<<"Client: Removing "
-                                                       "dead player with id=0"<<std::endl;
-                               }
-
-                               bool is_alive = false;
-                               core::list<u16>::Iterator i;
-                               for(i=players_alive.begin(); i!=players_alive.end(); i++)
-                               {
-                                       if((*ip)->peer_id == *i)
-                                       {
-                                               is_alive = true;
-                                               break;
-                                       }
-                               }
-                               /*infostream<<"peer_id="<<((*ip)->peer_id)
-                                               <<" is_alive="<<is_alive<<std::endl;*/
-                               if(is_alive)
-                                       continue;
-                               infostream<<"Removing dead player "<<(*ip)->peer_id
-                                               <<std::endl;
-                               m_env.removePlayer((*ip)->peer_id);
-                       }
-               } //envlock
-#endif
-       }
-       else if(command == TOCLIENT_SECTORMETA)
-       {
-               infostream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
-#if 0
-               /*
-                       [0] u16 command
-                       [2] u8 sector count
-                       [3...] v2s16 pos + sector metadata
-               */
-               if(datasize < 3)
-                       return;
-
-               //infostream<<"Client received TOCLIENT_SECTORMETA"<<std::endl;
-
-               { //envlock
-                       //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
-                       
-                       std::string datastring((char*)&data[2], datasize-2);
-                       std::istringstream is(datastring, std::ios_base::binary);
-
-                       u8 buf[4];
-
-                       is.read((char*)buf, 1);
-                       u16 sector_count = readU8(buf);
-                       
-                       //infostream<<"sector_count="<<sector_count<<std::endl;
-
-                       for(u16 i=0; i<sector_count; i++)
-                       {
-                               // Read position
-                               is.read((char*)buf, 4);
-                               v2s16 pos = readV2S16(buf);
-                               /*infostream<<"Client: deserializing sector at "
-                                               <<"("<<pos.X<<","<<pos.Y<<")"<<std::endl;*/
-                               // Create sector
-                               assert(m_env.getMap().mapType() == MAPTYPE_CLIENT);
-                               ((ClientMap&)m_env.getMap()).deSerializeSector(pos, is);
-                       }
-               } //envlock
-#endif
-       }
        else if(command == TOCLIENT_INVENTORY)
        {
                if(datasize < 3)
@@ -1190,73 +974,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                        //player->inventory.print(infostream);
                }
        }
-       //DEBUG
-       else if(command == TOCLIENT_OBJECTDATA)
-       {
-               // Strip command word and create a stringstream
-               std::string datastring((char*)&data[2], datasize-2);
-               std::istringstream is(datastring, std::ios_base::binary);
-               
-               u8 buf[12];
-
-               /*
-                       Read players
-               */
-
-               is.read((char*)buf, 2);
-               u16 playercount = readU16(buf);
-               
-               for(u16 i=0; i<playercount; i++)
-               {
-                       is.read((char*)buf, 2);
-                       u16 peer_id = readU16(buf);
-                       is.read((char*)buf, 12);
-                       v3s32 p_i = readV3S32(buf);
-                       is.read((char*)buf, 12);
-                       v3s32 s_i = readV3S32(buf);
-                       is.read((char*)buf, 4);
-                       s32 pitch_i = readS32(buf);
-                       is.read((char*)buf, 4);
-                       s32 yaw_i = readS32(buf);
-                       
-                       Player *player = m_env.getPlayer(peer_id);
-
-                       // Skip if player doesn't exist
-                       if(player == NULL)
-                       {
-                               continue;
-                       }
-
-                       // Skip if player is local player
-                       if(player->isLocal())
-                       {
-                               continue;
-                       }
-       
-                       f32 pitch = (f32)pitch_i / 100.0;
-                       f32 yaw = (f32)yaw_i / 100.0;
-                       v3f position((f32)p_i.X/100., (f32)p_i.Y/100., (f32)p_i.Z/100.);
-                       v3f speed((f32)s_i.X/100., (f32)s_i.Y/100., (f32)s_i.Z/100.);
-                       
-                       player->setPosition(position);
-                       player->setSpeed(speed);
-                       player->setPitch(pitch);
-                       player->setYaw(yaw);
-               }
-
-               /*
-                       Read block objects
-                       NOTE: Deprecated stuff
-               */
-
-               // Read active block count
-               u16 blockcount = readU16(is);
-               if(blockcount != 0){
-                       infostream<<"TOCLIENT_OBJECTDATA: blockcount != 0 "
-                                       "not supported"<<std::endl;
-                       return;
-               }
-       }
        else if(command == TOCLIENT_TIME_OF_DAY)
        {
                if(datasize < 4)
index ff9fc31f97b56cdb772fe1bbd147420eb8557beb..4d6cd716dbff74d53ac08e79faf9031b30524074 100644 (file)
@@ -35,9 +35,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
                Add TOSERVER_INTERACT
                Obsolete TOSERVER_CLICK_ACTIVEOBJECT
                Obsolete TOSERVER_GROUND_ACTION
+       PROTOCOL_VERSION 5:
+               Make players to be handled mostly as ActiveObjects
 */
 
-#define PROTOCOL_VERSION 4
+#define PROTOCOL_VERSION 5
 
 #define PROTOCOL_ID 0x4f457403
 
@@ -76,7 +78,7 @@ enum ToClientCommand
                [N+2+12+12+4] s32 yaw*100
        */
 
-       TOCLIENT_PLAYERINFO = 0x24,
+       TOCLIENT_PLAYERINFO = 0x24, // Obsolete
        /*
                [0] u16 command
                // Followed by an arbitary number of these:
@@ -100,7 +102,7 @@ enum ToClientCommand
                [2] serialized inventory
        */
        
-       TOCLIENT_OBJECTDATA = 0x28,
+       TOCLIENT_OBJECTDATA = 0x28, // Obsolete
        /*
                Sent as unreliable.
 
index a1e3ff99853864d2ac30edc7e7ecd15834a41069..0c1e8e63c85e272ad6ffd0553c4390a5339579b3 100644 (file)
@@ -96,7 +96,6 @@ void set_default_settings(Settings *settings)
 
        settings->setDefault("profiler_print_interval", "0");
        settings->setDefault("enable_mapgen_debug_info", "false");
-       settings->setDefault("objectdata_interval", "0.2");
        settings->setDefault("active_object_send_range_blocks", "3");
        settings->setDefault("active_block_range", "2");
        //settings->setDefault("max_simultaneous_block_sends_per_client", "1");
index 2dceb805ba2259effa93f0c94a36709b91e01165..a461c95e80852e60127c93a9f44a252fff1d8716 100644 (file)
@@ -750,105 +750,6 @@ queue_full_break:
                infostream<<"GetNextBlocks duration: "<<timer_result<<" (!=0)"<<std::endl;*/
 }
 
-void RemoteClient::SendObjectData(
-               Server *server,
-               float dtime,
-               core::map<v3s16, bool> &stepped_blocks
-       )
-{
-       DSTACK(__FUNCTION_NAME);
-
-       // Can't send anything without knowing version
-       if(serialization_version == SER_FMT_VER_INVALID)
-       {
-               infostream<<"RemoteClient::SendObjectData(): Not sending, no version."
-                               <<std::endl;
-               return;
-       }
-
-       /*
-               Send a TOCLIENT_OBJECTDATA packet.
-               Sent as unreliable.
-
-               u16 command
-               u16 number of player positions
-               for each player:
-                       u16 peer_id
-                       v3s32 position*100
-                       v3s32 speed*100
-                       s32 pitch*100
-                       s32 yaw*100
-               u16 count of blocks
-               for each block:
-                       block objects
-       */
-
-       std::ostringstream os(std::ios_base::binary);
-       u8 buf[12];
-       
-       // Write command
-       writeU16(buf, TOCLIENT_OBJECTDATA);
-       os.write((char*)buf, 2);
-       
-       /*
-               Get and write player data
-       */
-       
-       // Get connected players
-       core::list<Player*> players = server->m_env->getPlayers(true);
-
-       // Write player count
-       u16 playercount = players.size();
-       writeU16(buf, playercount);
-       os.write((char*)buf, 2);
-
-       core::list<Player*>::Iterator i;
-       for(i = players.begin();
-                       i != players.end(); i++)
-       {
-               Player *player = *i;
-
-               v3f pf = player->getPosition();
-               v3f sf = player->getSpeed();
-
-               v3s32 position_i(pf.X*100, pf.Y*100, pf.Z*100);
-               v3s32 speed_i   (sf.X*100, sf.Y*100, sf.Z*100);
-               s32   pitch_i   (player->getPitch() * 100);
-               s32   yaw_i     (player->getYaw() * 100);
-               
-               writeU16(buf, player->peer_id);
-               os.write((char*)buf, 2);
-               writeV3S32(buf, position_i);
-               os.write((char*)buf, 12);
-               writeV3S32(buf, speed_i);
-               os.write((char*)buf, 12);
-               writeS32(buf, pitch_i);
-               os.write((char*)buf, 4);
-               writeS32(buf, yaw_i);
-               os.write((char*)buf, 4);
-       }
-       
-       /*
-               Get and write object data (dummy, for compatibility)
-       */
-
-       // Write block count
-       writeU16(buf, 0);
-       os.write((char*)buf, 2);
-
-       /*
-               Send data
-       */
-       
-       //infostream<<"Server: Sending object data to "<<peer_id<<std::endl;
-
-       // Make data buffer
-       std::string s = os.str();
-       SharedBuffer<u8> data((u8*)s.c_str(), s.size());
-       // Send as unreliable
-       server->m_con.Send(peer_id, 0, data, false);
-}
-
 void RemoteClient::GotBlock(v3s16 p)
 {
        if(m_blocks_sending.find(p) != NULL)
@@ -1914,25 +1815,6 @@ void Server::AsyncRunStep()
                
        }
 
-       /*
-               Send object positions
-       */
-       {
-               float &counter = m_objectdata_timer;
-               counter += dtime;
-               if(counter >= g_settings->getFloat("objectdata_interval"))
-               {
-                       JMutexAutoLock lock1(m_env_mutex);
-                       JMutexAutoLock lock2(m_con_mutex);
-
-                       //ScopeProfiler sp(g_profiler, "Server: sending player positions");
-
-                       SendObjectData(counter);
-
-                       counter = 0.0;
-               }
-       }
-       
        /*
                Trigger emergethread (it somehow gets to a non-triggered but
                bysy state sometimes)
@@ -2286,7 +2168,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                SendTextures(peer_id);
                
                // Send player info to all players
-               SendPlayerInfos();
+               //SendPlayerInfos();
 
                // Send inventory to player
                UpdateCrafting(peer_id);
@@ -3953,64 +3835,6 @@ void Server::SendCraftItemDef(con::Connection &con, u16 peer_id,
        Non-static send methods
 */
 
-void Server::SendObjectData(float dtime)
-{
-       DSTACK(__FUNCTION_NAME);
-
-       core::map<v3s16, bool> stepped_blocks;
-       
-       for(core::map<u16, RemoteClient*>::Iterator
-               i = m_clients.getIterator();
-               i.atEnd() == false; i++)
-       {
-               u16 peer_id = i.getNode()->getKey();
-               RemoteClient *client = i.getNode()->getValue();
-               assert(client->peer_id == peer_id);
-               
-               if(client->serialization_version == SER_FMT_VER_INVALID)
-                       continue;
-               
-               client->SendObjectData(this, dtime, stepped_blocks);
-       }
-}
-
-void Server::SendPlayerInfos()
-{
-       DSTACK(__FUNCTION_NAME);
-
-       //JMutexAutoLock envlock(m_env_mutex);
-       
-       // Get connected players
-       core::list<Player*> players = m_env->getPlayers(true);
-       
-       u32 player_count = players.getSize();
-       u32 datasize = 2+(2+PLAYERNAME_SIZE)*player_count;
-
-       SharedBuffer<u8> data(datasize);
-       writeU16(&data[0], TOCLIENT_PLAYERINFO);
-       
-       u32 start = 2;
-       core::list<Player*>::Iterator i;
-       for(i = players.begin();
-                       i != players.end(); i++)
-       {
-               Player *player = *i;
-
-               /*infostream<<"Server sending player info for player with "
-                               "peer_id="<<player->peer_id<<std::endl;*/
-               
-               writeU16(&data[start], player->peer_id);
-               memset((char*)&data[start+2], 0, PLAYERNAME_SIZE);
-               snprintf((char*)&data[start+2], PLAYERNAME_SIZE, "%s", player->getName());
-               start += 2+PLAYERNAME_SIZE;
-       }
-
-       //JMutexAutoLock conlock(m_con_mutex);
-
-       // Send as reliable
-       m_con.SendToAll(0, data, true);
-}
-
 void Server::SendInventory(u16 peer_id)
 {
        DSTACK(__FUNCTION_NAME);
@@ -5042,7 +4866,7 @@ void Server::handlePeerChange(PeerChange &c)
                m_clients.remove(c.peer_id);
 
                // Send player info to all remaining clients
-               SendPlayerInfos();
+               //SendPlayerInfos();
                
                // Send leave chat message to all remaining clients
                BroadcastChatMessage(message);
index 7568463b2fb2b608c62591d6d7e42d4fd3f4dc40..0fe1979b7c9d59c886a77a0cc683d006cb349977 100644 (file)
@@ -273,17 +273,6 @@ public:
        void GetNextBlocks(Server *server, float dtime,
                        core::array<PrioritySortedBlockTransfer> &dest);
 
-       /*
-               Connection and environment should be locked when this is called.
-               steps() objects of blocks not found in active_blocks, then
-               adds those blocks to active_blocks
-       */
-       void SendObjectData(
-                       Server *server,
-                       float dtime,
-                       core::map<v3s16, bool> &stepped_blocks
-               );
-
        void GotBlock(v3s16 p);
 
        void SentBlock(v3s16 p);
@@ -541,8 +530,6 @@ private:
        */
 
        // Envlock and conlock should be locked when calling these
-       void SendObjectData(float dtime);
-       void SendPlayerInfos();
        void SendInventory(u16 peer_id);
        // send wielded item info about player to all
        void SendWieldedItem(const Player *player);