From 46325eca7dcb5f27f8bf43978ab9baab0a7977ad Mon Sep 17 00:00:00 2001 From: driAn Date: Tue, 2 Dec 2008 20:35:17 +0000 Subject: [PATCH] implemented packet queue to write a report on network error git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3829 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 3 +++ source/src/clients2c.cpp | 4 ++++ source/src/pch.h | 1 + source/src/protos.h | 14 ++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/source/src/client.cpp b/source/src/client.cpp index 355c63b7..33561346 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -414,6 +414,9 @@ void gets2c() // get updates from the server break; case ENET_EVENT_TYPE_RECEIVE: + extern packetqueue pkglogger; + pkglogger.queue(*event.packet); + if(discmillis) conoutf("attempting to disconnect..."); else servertoclient(event.channelID, event.packet->data, (int)event.packet->dataLength); enet_packet_destroy(event.packet); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index d693a60b..b373fa1f 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -10,9 +10,13 @@ VARP(networkdebug, 0, 0, 1); extern bool c2sinit, senditemstoserver, watchingdemo; extern string clientpassword; +packetqueue pkglogger(8); + void neterr(const char *s) { conoutf("\f3illegal network message (%s)", s); + pkglogger.flushtolog("packetlog.txt"); + conoutf("\f3wrote network error report to packetlog.txt, please post this file to the bugtracker now!"); disconnect(); } diff --git a/source/src/pch.h b/source/src/pch.h index a53e0001..0c197a21 100644 --- a/source/src/pch.h +++ b/source/src/pch.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/source/src/protos.h b/source/src/protos.h index 07781fa4..18ba4c89 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -208,6 +208,20 @@ extern serverinfo *getconnectedserverinfo(); extern void pingservers(); extern void updatefrommaster(int force); +class packetqueue +{ + size_t queuesize; + std::queue pqueue; + +public: + + packetqueue(size_t size); + ~packetqueue(); + void queue(ENetPacket &p); + bool flushtolog(char *logfile); + void clear(); +}; + // rendergl extern glmatrixf mvmatrix, projmatrix, clipmatrix, mvpmatrix, invmvmatrix, invmvpmatrix; extern void resetcamera();