summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-02 15:39:11 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-02 15:43:36 -0600
commiteaa8288a73872cb8d8b3d0b3455d79ce2579f438 (patch)
treea08c2e3f4180065d2c19f704dfe220484804e95c /src/net
parentb176a462662c719cca6d9d444ff1c5892c7c77d3 (diff)
downloadmanaserv-eaa8288a73872cb8d8b3d0b3455d79ce2579f438.tar.gz
manaserv-eaa8288a73872cb8d8b3d0b3455d79ce2579f438.tar.bz2
manaserv-eaa8288a73872cb8d8b3d0b3455d79ce2579f438.tar.xz
manaserv-eaa8288a73872cb8d8b3d0b3455d79ce2579f438.zip
Add support for enet 1.3
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/net')
-rw-r--r--src/net/connection.cpp16
-rw-r--r--src/net/connectionhandler.cpp11
2 files changed, 27 insertions, 0 deletions
diff --git a/src/net/connection.cpp b/src/net/connection.cpp
index 8bb37821..790b6ac7 100644
--- a/src/net/connection.cpp
+++ b/src/net/connection.cpp
@@ -36,16 +36,32 @@ bool Connection::start(const std::string &address, int port)
enet_address_set_host(&enetAddress, address.c_str());
enetAddress.port = port;
+#if ENET_VERSION_MAJOR != 1
+#error Unsuported enet version!
+#elif ENET_VERSION_MINOR < 3
mLocal = enet_host_create(NULL /* create a client host */,
1 /* allow one outgoing connection */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
+#else
+ mLocal = enet_host_create(NULL /* create a client host */,
+ 1 /* allow one outgoing connection */,
+ 0 /* unlimited channel count */,
+ 0 /* assume any amount of incoming bandwidth */,
+ 0 /* assume any amount of outgoing bandwidth */);
+#endif
if (!mLocal)
return false;
// Initiate the connection, allocating channel 0.
+#if ENET_VERSION_MAJOR != 1
+#error Unsuported enet version!
+#elif ENET_VERSION_MINOR < 3
mRemote = enet_host_connect(mLocal, &enetAddress, 1);
+#else
+ mRemote = enet_host_connect(mLocal, &enetAddress, 1, 0);
+#endif
ENetEvent event;
if (enet_host_service(mLocal, &event, 10000) <= 0 ||
diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp
index 61e373ef..6aa58569 100644
--- a/src/net/connectionhandler.cpp
+++ b/src/net/connectionhandler.cpp
@@ -40,11 +40,22 @@ bool ConnectionHandler::startListen(enet_uint16 port,
enet_address_set_host(&address, listenHost.c_str());
LOG_INFO("Listening on port " << port << "...");
+#if ENET_VERSION_MAJOR != 1
+#error Unsuported enet version!
+#elif ENET_VERSION_MINOR < 3
host = enet_host_create(
&address /* the address to bind the server host to */,
Configuration::getValue("net_maxClients", 1000) /* allowed connections */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
+#else
+ host = enet_host_create(
+ &address /* the address to bind the server host to */,
+ Configuration::getValue("net_maxClients", 1000) /* allowed connections */,
+ 0 /* unlimited channel count */,
+ 0 /* assume any amount of incoming bandwidth */,
+ 0 /* assume any amount of outgoing bandwidth */);
+#endif
return host != 0;
}