QTfrontend/net/newnetclient.cpp
branchwebgl
changeset 8444 75db7bb8dce8
parent 8330 aaefa587e277
parent 8436 b89aacebb9db
child 8833 c13ebed437cb
equal deleted inserted replaced
8340:46a9fde631f4 8444:75db7bb8dce8
    26 #include "newnetclient.h"
    26 #include "newnetclient.h"
    27 #include "proto.h"
    27 #include "proto.h"
    28 #include "game.h"
    28 #include "game.h"
    29 #include "roomslistmodel.h"
    29 #include "roomslistmodel.h"
    30 #include "playerslistmodel.h"
    30 #include "playerslistmodel.h"
       
    31 #include "servermessages.h"
       
    32 #include "HWApplication.h"
    31 
    33 
    32 char delimeter='\n';
    34 char delimeter='\n';
    33 
    35 
    34 HWNewNet::HWNewNet() :
    36 HWNewNet::HWNewNet() :
    35     isChief(false),
    37     isChief(false),
   249         return ;
   251         return ;
   250 
   252 
   251     if (lst[0] == "ERROR")
   253     if (lst[0] == "ERROR")
   252     {
   254     {
   253         if (lst.size() == 2)
   255         if (lst.size() == 2)
   254             emit Error(lst[1]);
   256             emit Error(HWApplication::translate("server", lst[1].toAscii().constData()));
   255         else
   257         else
   256             emit Error("Unknown error");
   258             emit Error("Unknown error");
   257         return;
   259         return;
   258     }
   260     }
   259 
   261 
   260     if (lst[0] == "WARNING")
   262     if (lst[0] == "WARNING")
   261     {
   263     {
   262         if (lst.size() == 2)
   264         if (lst.size() == 2)
   263             emit Warning(lst[1]);
   265             emit Warning(HWApplication::translate("server", lst[1].toAscii().constData()));
   264         else
   266         else
   265             emit Warning("Unknown warning");
   267             emit Warning("Unknown warning");
   266         return;
   268         return;
   267     }
   269     }
   268 
   270 
   577             return;
   579             return;
   578         }
   580         }
   579         if (lst[1] == "Authentication failed")
   581         if (lst[1] == "Authentication failed")
   580         {
   582         {
   581             emit AuthFailed();
   583             emit AuthFailed();
       
   584             m_game_connected = false;
       
   585             Disconnect();
       
   586             //omitted 'emit disconnected()', we don't want the error message
       
   587             return;
       
   588         }
   582         m_game_connected = false;
   589         m_game_connected = false;
   583         Disconnect();
   590         Disconnect();
   584         //omitted 'emit disconnected()', we don't want the error message
   591         emit disconnected(HWApplication::translate("server", lst[1].toAscii().constData()));
   585         return;
       
   586         }
       
   587         m_game_connected = false;
       
   588         Disconnect();
       
   589         emit disconnected(lst[1]);
       
   590         return;
   592         return;
   591     }
   593     }
   592 
   594 
   593     if (lst[0] == "ADMIN_ACCESS")
   595     if (lst[0] == "ADMIN_ACCESS")
   594     {
   596     {
   924         RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick));
   926         RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick));
   925         isChief = false;
   927         isChief = false;
   926     }
   928     }
   927 }
   929 }
   928 
   930 
       
   931 void HWNewNet::consoleCommand(const QString & cmd)
       
   932 {
       
   933     RawSendNet(QString("CMD%1%2").arg(delimeter).arg(cmd));
       
   934 }
       
   935 
       
   936 bool HWNewNet::allPlayersReady()
       
   937 {
       
   938     int ready = 0;
       
   939     for (int i = 0; i < m_roomPlayersModel->rowCount(); i++)
       
   940         if (m_roomPlayersModel->index(i, 0).data(PlayersListModel::Ready).toBool()) ready++;
       
   941 
       
   942     return (ready == m_roomPlayersModel->rowCount());
       
   943 }
       
   944 
   929 void HWNewNet::startGame()
   945 void HWNewNet::startGame()
   930 {
   946 {
   931     RawSendNet(QString("START_GAME"));
   947     RawSendNet(QString("START_GAME"));
   932 }
   948 }
   933 
   949