aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-16 12:01:40 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-16 12:01:40 +0100
commite7736ffdd6ce7ce252920e782a02f8d92608bd44 (patch)
tree4731b4a6b7da330387cfa5cf3f46cd572990f9b2 /src
parentb560294050e662a32b6b885ccf0e0f3b492cf5c4 (diff)
downloadminetest-e7736ffdd6ce7ce252920e782a02f8d92608bd44.tar.gz
minetest-e7736ffdd6ce7ce252920e782a02f8d92608bd44.tar.bz2
minetest-e7736ffdd6ce7ce252920e782a02f8d92608bd44.zip
Move TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD and TOCLIENT_ACTIVE_OBJECT_MESSAGES to private functions
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp38
-rw-r--r--src/server.h2
2 files changed, 23 insertions, 17 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 6f384e743..35405851f 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -758,16 +758,11 @@ void Server::AsyncRunStep(bool initial_step)
obj->m_known_by_count++;
}
- NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0, client->peer_id);
- pkt.putRawString(data_buffer.c_str(), data_buffer.size());
-
-
+ u32 pktSize = SendActiveObjectRemoveAdd(client->peer_id, data_buffer);
verbosestream << "Server: Sent object remove/add: "
<< removed_objects.size() << " removed, "
<< added_objects.size() << " added, "
- << "packet size is " << pkt.getSize() << std::endl;
-
- Send(&pkt);
+ << "packet size is " << pktSize << std::endl;
}
m_clients.Unlock();
}
@@ -846,19 +841,11 @@ void Server::AsyncRunStep(bool initial_step)
Send them.
*/
if(reliable_data.size() > 0) {
- NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES,
- 0, client->peer_id);
-
- pkt.putRawString(reliable_data.c_str(), reliable_data.size());
- Send(&pkt);
+ SendActiveObjectMessages(client->peer_id, reliable_data);
}
if(unreliable_data.size() > 0) {
- NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES,
- 0, client->peer_id);
-
- pkt.putRawString(unreliable_data.c_str(), unreliable_data.size());
- Send(&pkt);
+ SendActiveObjectMessages(client->peer_id, unreliable_data);
}
}
m_clients.Unlock();
@@ -1898,6 +1885,23 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)
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,
const ServerSoundParams &params)
{
diff --git a/src/server.h b/src/server.h
index 546a44a20..900a1eaaa 100644
--- a/src/server.h
+++ b/src/server.h
@@ -463,6 +463,8 @@ private:
float expirationtime, float size,
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
*/