diff --git a/.gitignore b/.gitignore index 5761abc..d6152e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *.o +*.a +examples/bin/* +!examples/bin/.gitkeep +!lib/.gitkeep diff --git a/README.md b/README.md index ef4b92f..837f3b3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ When cloning use the `--recurse-submodules` flag to retrieve the enet and zlib l `git clone --recurse-submodules https://github.com/rna88/irrnet.git` -Then run `make` in the `source/` directory to build the library. +Then run `make` in the `source/` directory to build the library, which will be placed in `lib/`. ## Building examples @@ -22,9 +22,9 @@ or to build them with optimizations: `./linux_buildAllExamples.sh release` -The compiled binaries will be found in `examples/bin/` +The compiled binaries will be found in `examples/bin/`. ## License -Refer to `source/ReadMe.txt` +Refer to `source/ReadMe.txt`. diff --git a/examples/03.ClientManagement/main.cpp b/examples/03.ClientManagement/main.cpp index f27629a..c137c95 100644 --- a/examples/03.ClientManagement/main.cpp +++ b/examples/03.ClientManagement/main.cpp @@ -103,6 +103,7 @@ public: message += " has just left the building."; packet << message; netManager->sendOutPacket(packet); + std::cout << "Client number " << playerId << " disconnected" << std::endl; } // Handle the packets, as usual. @@ -213,11 +214,14 @@ int main() netManager->sendOutPacket(packet); } - // Here is the update loop, we will exit if there is a connection problem. - while(netManager->getConnectionStatus() != net::EICS_FAILED) + // Here is the update loop, we will exit if there is a connection problem + // or after running for 10 seconds. + int i = 0; + while(netManager->getConnectionStatus() != net::EICS_FAILED && i < 10) { // Here we update. netManager->update(1000); + ++i; } // Clean up. diff --git a/examples/bin/.gitkeep b/examples/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/examples/bin/Example1 b/examples/bin/Example1 deleted file mode 100755 index 46b2875..0000000 Binary files a/examples/bin/Example1 and /dev/null differ diff --git a/examples/bin/Example2 b/examples/bin/Example2 deleted file mode 100755 index ebeefd2..0000000 Binary files a/examples/bin/Example2 and /dev/null differ diff --git a/examples/bin/Tutorial b/examples/bin/Tutorial deleted file mode 100755 index 28c6b61..0000000 Binary files a/examples/bin/Tutorial and /dev/null differ diff --git a/lib/.gitkeep b/lib/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/libirrnet.a b/lib/libirrnet.a deleted file mode 100644 index 20fe24f..0000000 Binary files a/lib/libirrnet.a and /dev/null differ diff --git a/source/CNetManager.cpp b/source/CNetManager.cpp index 1b7e750..48993a4 100644 --- a/source/CNetManager.cpp +++ b/source/CNetManager.cpp @@ -29,6 +29,14 @@ namespace irr CNetManager::~CNetManager(void) { + + if(mode == ENM_CLIENT) + { + ENetEvent event; + enet_peer_disconnect(peer, 0); + enet_host_service(host, &event, 0); + } + if(host) enet_host_destroy(host);