summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-08-14 18:49:50 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-08-14 18:49:50 -0300
commit3db36684b183adbec93cce9fe91182186e389e06 (patch)
treea324f3a336d1a77e7e3bd3d3bfc7258ccf8b06b5 /modules
parent01bdfe1ff6033c012d0833ee165f6055fed69724 (diff)
Added high level networked multiplayer to Godot.
It's complete, but absolutely and completely untested, undocumented and NSFW. Have fun :-)
Diffstat (limited to 'modules')
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp12
-rw-r--r--modules/enet/networked_multiplayer_enet.h4
2 files changed, 13 insertions, 3 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 64f08a90ef..aebdfe03a5 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -81,6 +81,8 @@ Error NetworkedMultiplayerENet::create_client(const IP_Address& p_ip,int p_port,
//technically safe to ignore the peer or anything else.
connection_status=CONNECTION_CONNECTING;
+ active=true;
+ server=false;
return OK;
}
@@ -144,7 +146,13 @@ void NetworkedMultiplayerENet::poll(){
}
}
-void NetworkedMultiplayerENet::disconnect() {
+bool NetworkedMultiplayerENet::is_server() const {
+ ERR_FAIL_COND_V(!active,false);
+
+ return server;
+}
+
+void NetworkedMultiplayerENet::close_connection() {
ERR_FAIL_COND(!active);
@@ -258,6 +266,6 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet(){
NetworkedMultiplayerENet::~NetworkedMultiplayerENet(){
if (active) {
- disconnect();
+ close_connection();
}
}
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index 20eb53990d..ec6b084d66 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -52,10 +52,12 @@ public:
Error create_server(int p_port, int p_max_clients=32, int p_max_channels=1, int p_in_bandwidth=0, int p_out_bandwidth=0);
Error create_client(const IP_Address& p_ip,int p_port, int p_max_channels=1, int p_in_bandwidth=0, int p_out_bandwidth=0);
- void disconnect();
+ void close_connection();
virtual void poll();
+ virtual bool is_server() const;
+
virtual int get_available_packet_count() const;
virtual Error get_packet(const uint8_t **r_buffer,int &r_buffer_size) const; ///< buffer is GONE after next get_packet
virtual Error put_packet(const uint8_t *p_buffer,int p_buffer_size);