@@ -758,16 +758,11 @@ void Server::AsyncRunStep(bool initial_step)
758
758
obj->m_known_by_count ++;
759
759
}
760
760
761
- NetworkPacket pkt (TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0 , client->peer_id );
762
- pkt.putRawString (data_buffer.c_str (), data_buffer.size ());
763
-
764
-
761
+ u32 pktSize = SendActiveObjectRemoveAdd (client->peer_id , data_buffer);
765
762
verbosestream << " Server: Sent object remove/add: "
766
763
<< removed_objects.size () << " removed, "
767
764
<< added_objects.size () << " added, "
768
- << " packet size is " << pkt.getSize () << std::endl;
769
-
770
- Send (&pkt);
765
+ << " packet size is " << pktSize << std::endl;
771
766
}
772
767
m_clients.Unlock ();
773
768
}
@@ -846,19 +841,11 @@ void Server::AsyncRunStep(bool initial_step)
846
841
Send them.
847
842
*/
848
843
if (reliable_data.size () > 0 ) {
849
- NetworkPacket pkt (TOCLIENT_ACTIVE_OBJECT_MESSAGES,
850
- 0 , client->peer_id );
851
-
852
- pkt.putRawString (reliable_data.c_str (), reliable_data.size ());
853
- Send (&pkt);
844
+ SendActiveObjectMessages (client->peer_id , reliable_data);
854
845
}
855
846
856
847
if (unreliable_data.size () > 0 ) {
857
- NetworkPacket pkt (TOCLIENT_ACTIVE_OBJECT_MESSAGES,
858
- 0 , client->peer_id );
859
-
860
- pkt.putRawString (unreliable_data.c_str (), unreliable_data.size ());
861
- Send (&pkt);
848
+ SendActiveObjectMessages (client->peer_id , unreliable_data);
862
849
}
863
850
}
864
851
m_clients.Unlock ();
@@ -1898,6 +1885,23 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)
1898
1885
Send (&pkt);
1899
1886
}
1900
1887
1888
+ u32 Server::SendActiveObjectRemoveAdd (u16 peer_id, const std::string &datas)
1889
+ {
1890
+ NetworkPacket pkt (TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0 , peer_id);
1891
+ pkt.putRawString (datas.c_str (), datas.size ());
1892
+ Send (&pkt);
1893
+ return pkt.getSize ();
1894
+ }
1895
+
1896
+ void Server::SendActiveObjectMessages (u16 peer_id, const std::string &datas)
1897
+ {
1898
+ NetworkPacket pkt (TOCLIENT_ACTIVE_OBJECT_MESSAGES,
1899
+ 0 , peer_id);
1900
+
1901
+ pkt.putRawString (datas.c_str (), datas.size ());
1902
+ Send (&pkt);
1903
+ }
1904
+
1901
1905
s32 Server::playSound (const SimpleSoundSpec &spec,
1902
1906
const ServerSoundParams ¶ms)
1903
1907
{
0 commit comments