فهرست منبع

Floodprot timer wraparound fixed.

Mihawk 12 سال پیش
والد
کامیت
d115420455
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      Client.cpp

+ 8 - 2
Client.cpp

@@ -20,7 +20,6 @@ Client::Client(App *app, ActiveClient* ac):
   myJoinMessagePrinted(false),
   myJoinMessageScheduled(false)
 {
-  myEndFloodTime = QTime::currentTime();
   myQWBroadcastFloodTime = myEndFloodTime;
   mySpamBroadcastFloodTime = myEndFloodTime;
   myJoinMessageTimer->setSingleShot(true);
@@ -34,6 +33,8 @@ Client::~Client()
 void Client::connect(const char *host, quint16 port)
 {
   myJoinMessageScheduled = true; //Hi message only scheduled at bot connection
+  myEndFloodTime = QTime::currentTime();
+
   QWClient::connect(host, port);
 }
 
@@ -160,7 +161,7 @@ void Client::parsePrintedLine()
 		}
 		return;
 	}
-  myEndFloodTime = QTime::currentTime().addSecs(Settings::globalInstance()->floodProtTime());
+  myEndFloodTime = currentTime.addSecs(Settings::globalInstance()->floodProtTime());
   myFloodMsgPrinted = false;
 
   QString command = regex.capturedTexts().at(1);
@@ -321,6 +322,11 @@ void Client::run()
     say("Hi, I am QWNET's bot, type .help to see my commands.");
     myJoinMessagePrinted = true;
   }
+
+  /* Avoid wrap around */
+  if(QTime::currentTime().secsTo(myEndFloodTime) < -16000)
+    myEndFloodTime = QTime::currentTime();
+
   QWClient::run();
 }