Move TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD and TOCLIENT_ACTIVE_OBJECT_MESSAGES to private functions

This commit is contained in:
Loic Blot 2015-03-16 12:01:40 +01:00
parent b560294050
commit e7736ffdd6
2 changed files with 23 additions and 17 deletions

@ -758,16 +758,11 @@ void Server::AsyncRunStep(bool initial_step)
obj->m_known_by_count++; obj->m_known_by_count++;
} }
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0, client->peer_id); u32 pktSize = SendActiveObjectRemoveAdd(client->peer_id, data_buffer);
pkt.putRawString(data_buffer.c_str(), data_buffer.size());
verbosestream << "Server: Sent object remove/add: " verbosestream << "Server: Sent object remove/add: "
<< removed_objects.size() << " removed, " << removed_objects.size() << " removed, "
<< added_objects.size() << " added, " << added_objects.size() << " added, "
<< "packet size is " << pkt.getSize() << std::endl; << "packet size is " << pktSize << std::endl;
Send(&pkt);
} }
m_clients.Unlock(); m_clients.Unlock();
} }
@ -846,19 +841,11 @@ void Server::AsyncRunStep(bool initial_step)
Send them. Send them.
*/ */
if(reliable_data.size() > 0) { if(reliable_data.size() > 0) {
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES, SendActiveObjectMessages(client->peer_id, reliable_data);
0, client->peer_id);
pkt.putRawString(reliable_data.c_str(), reliable_data.size());
Send(&pkt);
} }
if(unreliable_data.size() > 0) { if(unreliable_data.size() > 0) {
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES, SendActiveObjectMessages(client->peer_id, unreliable_data);
0, client->peer_id);
pkt.putRawString(unreliable_data.c_str(), unreliable_data.size());
Send(&pkt);
} }
} }
m_clients.Unlock(); m_clients.Unlock();
@ -1898,6 +1885,23 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)
Send(&pkt); Send(&pkt);
} }
u32 Server::SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas)
{
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0, peer_id);
pkt.putRawString(datas.c_str(), datas.size());
Send(&pkt);
return pkt.getSize();
}
void Server::SendActiveObjectMessages(u16 peer_id, const std::string &datas)
{
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES,
0, peer_id);
pkt.putRawString(datas.c_str(), datas.size());
Send(&pkt);
}
s32 Server::playSound(const SimpleSoundSpec &spec, s32 Server::playSound(const SimpleSoundSpec &spec,
const ServerSoundParams &params) const ServerSoundParams &params)
{ {

@ -463,6 +463,8 @@ private:
float expirationtime, float size, float expirationtime, float size,
bool collisiondetection, bool vertical, std::string texture); bool collisiondetection, bool vertical, std::string texture);
u32 SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas);
void SendActiveObjectMessages(u16 peer_id, const std::string &datas);
/* /*
Something random Something random
*/ */