From 04a55c02a730a0c3aca2df0c4dd99ca478582cb7 Mon Sep 17 00:00:00 2001 From: gmueller Date: Tue, 25 Jan 2011 23:21:03 +0100 Subject: [PATCH] small logging fixes --- src/common/Network.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/Network.cpp b/src/common/Network.cpp index 2439d61..740e9bf 100644 --- a/src/common/Network.cpp +++ b/src/common/Network.cpp @@ -44,7 +44,7 @@ void Network::initialize(const std::string &hostname) { throw "An error occurred while trying to create an ENet client host."; } - std::cout << "[Network] connect to " << host << std::endl; + std::cout << "[Network] connect to " << hostname << std::endl; enet_address_set_host(&address, hostname.c_str()); address.port = 1234; @@ -58,7 +58,7 @@ void Network::initialize(const std::string &hostname) { /* Wait up to 5 seconds for the connection attempt to succeed. */ if (enet_host_service(host, &event, 2000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) { - std::cout << "[Network] connected" << host << std::endl; + std::cout << "[Network] connected" << std::endl; } else { /* Either the 5 seconds are up or a disconnect event was */ /* received. Reset the peer in the event the 5 seconds */ @@ -402,9 +402,11 @@ void Network::service(uint32_t timeout) { while (enet_host_service(host, &event, timeout) > 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: { - std::cout << "A new client connected from " - << event.peer->address.host << " " - << event.peer->address.port << std::endl; + char hostname[256]; + enet_address_get_host(&event.peer->address, hostname, + sizeof(hostname)); + std::cout << "[Network] A new client connected from " << hostname + << std::endl; // bring new client up to date size_t i; for (i = 0; i < GAME_PLAYER_COUNT; i++) {