diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 17:40:12 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 17:40:12 +0000 |
commit | 30d192259e6913a210156da2abce16e05b5a5825 (patch) | |
tree | 5c618bf3ffde465ae836d23156bdd761dc2b2a14 /src/netcomputer.cpp | |
parent | c2717aecc26d52d8be6d1b9350e9b0ff9dec1fc8 (diff) | |
download | manaserv-30d192259e6913a210156da2abce16e05b5a5825.tar.gz manaserv-30d192259e6913a210156da2abce16e05b5a5825.tar.bz2 manaserv-30d192259e6913a210156da2abce16e05b5a5825.tar.xz manaserv-30d192259e6913a210156da2abce16e05b5a5825.zip |
Applied patch by Rogier, adding a stream operator to NetComputer for logging purposes.
Diffstat (limited to 'src/netcomputer.cpp')
-rw-r--r-- | src/netcomputer.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/netcomputer.cpp b/src/netcomputer.cpp index fd9bec5e..c27dd327 100644 --- a/src/netcomputer.cpp +++ b/src/netcomputer.cpp @@ -25,13 +25,11 @@ #include <iosfwd> #include <queue> -#include <iostream> #include <enet/enet.h> #include "defines.h" #include "messageout.h" -#include "connectionhandler.h" #include "utils/logger.h" @@ -69,7 +67,7 @@ NetComputer::send(const MessageOut &msg, bool reliable, unsigned int channel) { LOG_INFO("Sending packet of length " << msg.getLength() << " to " - << ip4ToString(mPeer->address.host), 2); + << *this, 2); ENetPacket *packet; packet = enet_packet_create(msg.getData(), @@ -85,3 +83,15 @@ NetComputer::send(const MessageOut &msg, bool reliable, LOG_WARN("Failure to create packet!", 0); } } + +std::ostream& +operator <<(std::ostream &os, const NetComputer &comp) +{ + // address.host contains the ip-address in network-byte-order + + os << ((comp.mPeer->address.host & 0xff000000) >> 24) << "." + << ((comp.mPeer->address.host & 0x00ff0000) >> 16) << "." + << ((comp.mPeer->address.host & 0x0000ff00) >> 8) << "." + << ((comp.mPeer->address.host & 0x000000ff) >> 0); + return os; +} |