From 29928aa7af2a204fa0b0a9713c6bce127e30a5b7 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 14 May 2010 23:48:45 +0000 Subject: [PATCH] data counters git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4862 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/enet/host.c | 5 +++++ source/enet/include/enet/enet.h | 4 ++++ source/enet/protocol.c | 8 +++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/source/enet/host.c b/source/enet/host.c index 9edceb23..67accd93 100755 --- a/source/enet/host.c +++ b/source/enet/host.c @@ -79,6 +79,11 @@ enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 inc host -> receivedAddress.port = 0; host -> receivedDataLength = 0; + host -> totalSentData = 0; + host -> totalSentPackets = 0; + host -> totalReceivedData = 0; + host -> totalReceivedPackets = 0; + enet_list_clear (& host -> dispatchQueue); for (currentPeer = host -> peers; diff --git a/source/enet/include/enet/enet.h b/source/enet/include/enet/enet.h index 04b416ec..7d4ac334 100755 --- a/source/enet/include/enet/enet.h +++ b/source/enet/include/enet/enet.h @@ -322,6 +322,10 @@ typedef struct _ENetHost ENetAddress receivedAddress; enet_uint8 receivedData [ENET_PROTOCOL_MAXIMUM_MTU]; size_t receivedDataLength; + enet_uint32 totalSentData; /**< total data sent, user should reset to 0 as needed to prevent overflow */ + enet_uint32 totalSentPackets; /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */ + enet_uint32 totalReceivedData; /**< total data received, user should reset to 0 as needed to prevent overflow */ + enet_uint32 totalReceivedPackets; /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */ } ENetHost; /** diff --git a/source/enet/protocol.c b/source/enet/protocol.c index 1362179d..21460b1b 100755 --- a/source/enet/protocol.c +++ b/source/enet/protocol.c @@ -1005,7 +1005,10 @@ enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event) return 0; host -> receivedDataLength = receivedLength; - + + host -> totalReceivedData += receivedLength; + host -> totalReceivedPackets ++; + switch (enet_protocol_handle_incoming_commands (host, event)) { case 1: @@ -1424,6 +1427,9 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch if (sentLength < 0) return -1; + + host -> totalSentData += sentLength; + host -> totalSentPackets ++; } return 0;