1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Remove stuff made obsolete by making players more ActiveObject-like and raise protocol version number by one (because it is not compatible at all anymore)

This commit is contained in:
Perttu Ahola 2011-12-01 23:55:57 +02:00
parent af32240545
commit 08a10b8a6a
6 changed files with 7 additions and 480 deletions

View 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)