QTfrontend/net/newnetclient.cpp
changeset 9549 ac5c1f691ce2
parent 9541 312bb4384f33
child 9702 27006953d901
equal deleted inserted replaced
9547:f9e82f34c904 9549:ac5c1f691ce2
   110         RawSendNet(QString("CREATE_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
   110         RawSendNet(QString("CREATE_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
   111 
   111 
   112     isChief = true;
   112     isChief = true;
   113 }
   113 }
   114 
   114 
   115 void HWNewNet::JoinRoom(const QString & room)
   115 void HWNewNet::JoinRoom(const QString & room, const QString &password)
   116 {
   116 {
   117     if(netClientState != InLobby)
   117     if(netClientState != InLobby)
   118     {
   118     {
   119         qWarning("Illegal try to join room!");
   119         qWarning("Illegal try to join room!");
   120         return;
   120         return;
   121     }
   121     }
   122 
   122 
   123     myroom = room;
   123     myroom = room;
   124 
   124 
   125     RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
   125     if(password.isEmpty())
       
   126         RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
       
   127     else
       
   128         RawSendNet(QString("JOIN_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
       
   129 
   126     isChief = false;
   130     isChief = false;
   127 }
   131 }
   128 
   132 
   129 void HWNewNet::AddTeam(const HWTeam & team)
   133 void HWNewNet::AddTeam(const HWTeam & team)
   130 {
   134 {
  1067 void HWNewNet::handleNotice(int n)
  1071 void HWNewNet::handleNotice(int n)
  1068 {
  1072 {
  1069     switch(n)
  1073     switch(n)
  1070     {
  1074     {
  1071         case 0:
  1075         case 0:
  1072         {
       
  1073             emit NickTaken(mynick);
  1076             emit NickTaken(mynick);
  1074             break;
  1077             break;
  1075         }
  1078         case 2:
       
  1079             emit askForRoomPassword();
       
  1080             break;
  1076     }
  1081     }
  1077 }
  1082 }
  1078 
  1083 
  1079 RoomsListModel * HWNewNet::roomsListModel()
  1084 RoomsListModel * HWNewNet::roomsListModel()
  1080 {
  1085 {
  1088 
  1093 
  1089 QAbstractItemModel *HWNewNet::roomPlayersModel()
  1094 QAbstractItemModel *HWNewNet::roomPlayersModel()
  1090 {
  1095 {
  1091     return m_roomPlayersModel;
  1096     return m_roomPlayersModel;
  1092 }
  1097 }
       
  1098 
       
  1099 void HWNewNet::roomPasswordEntered(const QString &password)
       
  1100 {
       
  1101     if(!myroom.isEmpty())
       
  1102         JoinRoom(myroom, password);
       
  1103 }