Forráskód Böngészése

Map redownload support when checksum doesnt match.

Mihawk 11 éve
szülő
commit
9657a4f6d7
3 módosított fájl, 21 hozzáadás és 13 törlés
  1. 6 5
      ActiveClient.cpp
  2. 13 0
      Client.cpp
  3. 2 8
      ServerQuery.cpp

+ 6 - 5
ActiveClient.cpp

@@ -76,7 +76,7 @@ void ActiveClient::setAddress(const QHostAddress &address, quint16 port)
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 void ActiveClient::queryError(ServerQuery::Error)
 {
-  myQueryTimer->start(myQueryInterval);
+//  myQueryTimer->start(myQueryInterval);
 }
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -87,7 +87,7 @@ void ActiveClient::queryFinished()
   myClient->setPlayerList(playerList);
   myClient->setMaxClients(myQuery->serverRuleValue("maxclients").toInt());
 
-  myQueryTimer->start(myQueryInterval);
+//  myQueryTimer->start(myQueryInterval);
 
   /* If the client is disconnect check if there is at least one player connected to the server */
   if(myClient->state() == Client::DisconnectedState)
@@ -126,10 +126,11 @@ void ActiveClient::run()
   myReplyTimerWasActive = myBroadcastReplyTimer->isActive();
 
   /* Query the serverinfo for player count if not already querying */
-  if(!myQuery->isActive() && !myQueryTimer->isActive())
+  if(!myQueryTimer->isActive())
+  {
     myQuery->query();
-  else
-    myQuery->run();
+    myQueryTimer->start(myQueryInterval);
+  }
 
   /* Run the client */
   if(myClient->state() != Client::DisconnectedState)

+ 13 - 0
Client.cpp

@@ -24,6 +24,7 @@ along with this program.  If not, see < http://www.gnu.org/licenses/ >.
 #include <QStringList>
 #include <QTime>
 #include <QTimer>
+#include <QFile>
 #include "App.h"
 #include "Settings.h"
 
@@ -138,6 +139,18 @@ bool Client::isSpamMuted() const
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 void Client::parsePrintedLine()
 {
+  // Deletes invalid map for redownloading next retry
+  if(!myOnServerFlag)
+  {
+    QRegExp rx("^Map model file does not match \\((.+)\\),");
+    if(rx.indexIn(myPrintLine) != -1)
+    {
+      print("Invalid map, deleting this map for redownload on next retry.\n");
+      QFile::remove(quakeDir() + "/" + gameDir() + "/" + rx.cap(1));
+      return;
+    }
+  }
+
   // Detects whether s-p command is supported
   if(mySPDetectionTimer->isActive())
   {

+ 2 - 8
ServerQuery.cpp

@@ -34,19 +34,12 @@ ServerQuery::ServerQuery(QObject *parent) :
   myCurrentPingIndex(0)
 {
   connect(mySocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));
+  connect(mySocket, SIGNAL(readyRead()), SLOT(parseServerInfo()));
 }
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ServerQuery::~ServerQuery()
 {
-  delete mySocket;
-}
-
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-void ServerQuery::run()
-{
-  if(mySocket->hasPendingDatagrams())
-    parseServerInfo();
 }
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -122,6 +115,7 @@ void ServerQuery::parseServerInfo()
 {
   QByteArray serverData = mySocket->readAll();
 
+//    qDebug() << mySocket->peerAddress() << mySocket->peerPort();
   if(serverData.isEmpty())
   {
     emit error(EmptyResponseError);