equal
deleted
inserted
replaced
73 void HWNewNet::Disconnect() |
73 void HWNewNet::Disconnect() |
74 { |
74 { |
75 if (m_game_connected) |
75 if (m_game_connected) |
76 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
76 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
77 m_game_connected = false; |
77 m_game_connected = false; |
78 |
78 |
79 NetSocket.disconnectFromHost(); |
79 NetSocket.disconnectFromHost(); |
80 } |
80 } |
81 |
81 |
82 void HWNewNet::CreateRoom(const QString & room) |
82 void HWNewNet::CreateRoom(const QString & room) |
83 { |
83 { |
84 if(netClientState != 2) |
84 if(netClientState != 2) |
85 { |
85 { |
86 qWarning("Illegal try to create room!"); |
86 qWarning("Illegal try to create room!"); |
87 return; |
87 return; |
88 } |
88 } |
89 |
89 |
90 RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room)); |
90 RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room)); |
91 isChief = true; |
91 isChief = true; |
92 } |
92 } |
93 |
93 |
94 void HWNewNet::JoinRoom(const QString & room) |
94 void HWNewNet::JoinRoom(const QString & room) |
96 if(netClientState != 2) |
96 if(netClientState != 2) |
97 { |
97 { |
98 qWarning("Illegal try to join room!"); |
98 qWarning("Illegal try to join room!"); |
99 return; |
99 return; |
100 } |
100 } |
101 |
101 |
102 RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room)); |
102 RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room)); |
103 isChief = false; |
103 isChief = false; |
104 } |
104 } |
105 |
105 |
106 void HWNewNet::AddTeam(const HWTeam & team) |
106 void HWNewNet::AddTeam(const HWTeam & team) |
177 } |
177 } |
178 |
178 |
179 void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
179 void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
180 { |
180 { |
181 emit Disconnected(); |
181 emit Disconnected(); |
182 |
182 |
183 switch (socketError) { |
183 switch (socketError) { |
184 case QAbstractSocket::RemoteHostClosedError: |
184 case QAbstractSocket::RemoteHostClosedError: |
185 break; |
185 break; |
186 case QAbstractSocket::HostNotFoundError: |
186 case QAbstractSocket::HostNotFoundError: |
187 emit showMessage(tr("The host was not found. Please check the host name and port settings.")); |
187 emit showMessage(tr("The host was not found. Please check the host name and port settings.")); |
303 emit setMyReadyStatus(true); |
303 emit setMyReadyStatus(true); |
304 emit setReadyStatus(lst[i], true); |
304 emit setReadyStatus(lst[i], true); |
305 } |
305 } |
306 return; |
306 return; |
307 } |
307 } |
308 |
308 |
309 if (lst[0] == "NOT_READY") { |
309 if (lst[0] == "NOT_READY") { |
310 if(lst.size() < 2) |
310 if(lst.size() < 2) |
311 { |
311 { |
312 qWarning("Net: Malformed NOT_READY message"); |
312 qWarning("Net: Malformed NOT_READY message"); |
313 return; |
313 return; |
361 if(lst.size() < 2) |
361 if(lst.size() < 2) |
362 { |
362 { |
363 qWarning("Net: Bad JOINED message"); |
363 qWarning("Net: Bad JOINED message"); |
364 return; |
364 return; |
365 } |
365 } |
366 |
366 |
367 for(int i = 1; i < lst.size(); ++i) |
367 for(int i = 1; i < lst.size(); ++i) |
368 { |
368 { |
369 if (lst[i] == mynick) |
369 if (lst[i] == mynick) |
370 { |
370 { |
371 netClientState = 3; |
371 netClientState = 3; |
384 if(lst.size() < 2) |
384 if(lst.size() < 2) |
385 { |
385 { |
386 qWarning("Net: Bad JOINED message"); |
386 qWarning("Net: Bad JOINED message"); |
387 return; |
387 return; |
388 } |
388 } |
389 |
389 |
390 for(int i = 1; i < lst.size(); ++i) |
390 for(int i = 1; i < lst.size(); ++i) |
391 { |
391 { |
392 if (lst[i] == mynick) |
392 if (lst[i] == mynick) |
393 { |
393 { |
394 netClientState = 2; |
394 netClientState = 2; |