equal
deleted
inserted
replaced
71 quint16 HWNetServer::getRunningPort() const |
71 quint16 HWNetServer::getRunningPort() const |
72 { |
72 { |
73 return ds_port; |
73 return ds_port; |
74 } |
74 } |
75 |
75 |
|
76 HWConnectedClient* HWNetServer::getChiefClient() const |
|
77 { |
|
78 for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) { |
|
79 // watch for first fully connected client (with confirmed nick) |
|
80 if((*it)->getClientNick()!="") return *it; |
|
81 } |
|
82 return 0; |
|
83 } |
|
84 |
76 bool HWNetServer::isChiefClient(HWConnectedClient* cl) const |
85 bool HWNetServer::isChiefClient(HWConnectedClient* cl) const |
77 { |
86 { |
78 for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) { |
87 return getChiefClient()==cl; |
79 // watch for first fully connected client (with confirmed nick) and test it for chief |
88 } |
80 if((*it)->getClientNick()=="") continue; |
89 |
81 if(*it==cl) return true; |
90 QStringList HWNetServer::getGameCfg() const |
82 else return false; |
91 { |
83 } |
92 for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) { |
|
93 if(isChiefClient(*it)) return (*it)->gameCfg; |
|
94 } |
|
95 // error happened if we are here |
|
96 return QStringList(); |
84 } |
97 } |
85 |
98 |
86 bool HWNetServer::haveNick(const QString& nick) const |
99 bool HWNetServer::haveNick(const QString& nick) const |
87 { |
100 { |
88 for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) { |
101 for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) { |
197 client_nick=lst[1]; |
210 client_nick=lst[1]; |
198 qDebug() << "send connected"; |
211 qDebug() << "send connected"; |
199 RawSendNet(QString("CONNECTED")); |
212 RawSendNet(QString("CONNECTED")); |
200 m_hwserver->teamChanged(); |
213 m_hwserver->teamChanged(); |
201 if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED")); |
214 if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED")); |
|
215 else RawSendNet(QString("CONFIGURED")+delimeter+m_hwserver->getGameCfg().join(QString(delimeter))); |
202 return; |
216 return; |
203 } |
217 } |
204 if(client_nick=="") return; |
218 if(client_nick=="") return; |
205 |
219 |
206 if (lst[0]=="START:") { |
220 if (lst[0]=="START:") { |
207 readyToStart=true; |
221 readyToStart=true; |
208 if(m_hwserver->shouldStart(this)) { |
222 if(m_hwserver->shouldStart(this)) { |
209 // start |
223 // start |
210 m_hwserver->sendAll(QString("CONFIGURED")+delimeter+m_hwserver->prepareConfig(gameCfg)+delimeter+"!"+delimeter); |
|
211 } |
224 } |
212 return; |
225 return; |
213 } |
226 } |
214 |
227 |
215 if(lst[0]=="CONFIGANSWER") { |
228 if(lst[0]=="CONFIGANSWER") { |