summaryrefslogtreecommitdiffstats
path: root/pacman-c++/server.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-17 20:32:55 +0200
committermanuel <manuel@mausz.at>2011-04-17 20:32:55 +0200
commit2fcca70231dbc34faa46254860fae438169c1e08 (patch)
tree3b9593126c682be47e7925c2e00a2336e895ee3d /pacman-c++/server.cpp
parent19c9c38d28cdaafcc1b496027f53dcd1914037cf (diff)
downloadfoop-2fcca70231dbc34faa46254860fae438169c1e08.tar.gz
foop-2fcca70231dbc34faa46254860fae438169c1e08.tar.bz2
foop-2fcca70231dbc34faa46254860fae438169c1e08.zip
if a player disconnect the player will now be a bot
Diffstat (limited to 'pacman-c++/server.cpp')
-rw-r--r--pacman-c++/server.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp
index 628faa2..e42cfbc 100644
--- a/pacman-c++/server.cpp
+++ b/pacman-c++/server.cpp
@@ -331,14 +331,28 @@ void Server::sendUpdate(Transmission::map_t map)
331 } 331 }
332 332
333 QSharedPointer<QByteArray> data = Util::createPacket(m_updatepacket); 333 QSharedPointer<QByteArray> data = Util::createPacket(m_updatepacket);
334 foreach(QTcpSocket *socket, m_clientConnections) 334 QMutableMapIterator<Color::Color, QTcpSocket *> i(m_clientConnections);
335 while(i.hasNext())
335 { 336 {
337 i.next();
338 QTcpSocket *socket = i.value();
339
336 if (!Util::sendPacket(data.data(), socket)) 340 if (!Util::sendPacket(data.data(), socket))
337 { 341 {
338 qDebug() << "[sendUpdate] Error while sending data to client, exiting..."; 342 qDebug() << "[sendUpdate] Error while sending data to client. Disconnecting...";
339 qApp->quit(); 343 socket->close();
344 qDebug() << "[sendUpdate] Actor" << i.key() << "is now a bot";
345 m_bots.append(i.key());
346 ++m_numbots;
347 i.remove();
340 } 348 }
341 } 349 }
350
351 if (m_maxplayers == m_numbots)
352 {
353 qDebug() << "[sendUpdate] No more real players left. Exiting...";
354 qApp->quit();
355 }
342} 356}
343 357
344void Server::keyPressUpdate() 358void Server::keyPressUpdate()