From 8b13a88127a70da7a4e307df828d65811ae5d0f1 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 2 May 2011 17:12:11 +0200 Subject: smaller output --- pacman-c++/server.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'pacman-c++/server.cpp') diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 2b43bb9..a7ff89a 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -30,10 +30,10 @@ bool Server::run() m_tickTimer->setInterval(Constants::tick); connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); - qDebug() << "[Server] Running server..."; - qDebug() << "[Server] Max players:" << m_maxplayers; - qDebug() << "[Server] Number of bots:" << m_numbots; - qDebug() << "[Server] Number of rounds:" << m_rounds; + std::cout << "[Server] Running server..." << std::endl + << "[Server] Max players: " << m_maxplayers << std::endl + << "[Server] Number of bots: " << m_numbots << std::endl + << "[Server] Number of rounds: " << m_rounds << std::endl; if (!waitForClientConnections()) return false; @@ -240,6 +240,8 @@ invalid_direction: foreach(Color::Color color, movements.keys()) m_actors[color]->setPos(mapPositionToCoord(movements[color].first)); +#ifndef QT_NO_DEBUG + /* collision sanity check: colors must be unique */ foreach(Color::Color col, m_eatingorder.toSet()) { QList found; @@ -252,8 +254,9 @@ invalid_direction: } } if (found.count() > 1) - qDebug() << "found" << found << "fields with color=" << col; + qCritical() << "[Collision] found" << found << "fields with color=" << col; } +#endif return map; } @@ -360,11 +363,11 @@ bool Server::waitForClientConnections() qCritical() << "Error while creating socket:" << qPrintable(tcpSrv->errorString()); return false; } - qDebug() << "[Server] Listening on:" + std::cout << "[Server] Listening on: " << qPrintable(QString("%1:%2").arg(tcpSrv->serverAddress().toString()) - .arg(tcpSrv->serverPort())); + .arg(tcpSrv->serverPort())) << std::endl; - qDebug() << "[Server] Waiting for clients"; + std::cout << "[Server] Waiting for clients" << std::endl; ProtoBuf::Init packet; packet.set_maxplayers(m_maxplayers); for (unsigned int i = 0; i < (m_maxplayers - m_numbots); ++i) @@ -380,7 +383,7 @@ bool Server::waitForClientConnections() m_clientConnections[color] = socket; packet.set_color(color); Util::sendPacket(packet, socket); - qDebug() << "[Connect] New Player: color=" << color; + std::cout << "[Connect] New Player: color=" << qPrintable(Util::colorToString(color)) << std::endl; } for (unsigned int i = (m_maxplayers - m_numbots); i < m_maxplayers; ++i) @@ -425,9 +428,10 @@ void Server::sendUpdate(Transmission::map_t map, bool firstPacket) if (!Util::sendPacket(data.data(), socket)) { - qDebug() << "[sendUpdate] Error while sending data to client. Disconnecting..."; + qWarning() << "[Connect] Error while sending data to client" << i.key() << "-> Disconnecting..."; socket->close(); - qDebug() << "[sendUpdate] Actor" << i.key() << "is now a bot"; + std::cout << "[Connect] Actor color=" << qPrintable(Util::colorToString(i.key())) + << " is now a bot" << std::endl; m_bots.append(i.key()); ++m_numbots; i.remove(); @@ -436,7 +440,7 @@ void Server::sendUpdate(Transmission::map_t map, bool firstPacket) if (m_maxplayers == m_numbots) { - qDebug() << "[sendUpdate] No more real players left. Exiting..."; + std::cout << "[Connect] No more real players left. Exiting..." << std::endl; qApp->quit(); } } @@ -594,7 +598,7 @@ void Server::keyPressUpdate() void Server::initRoundMap() { - qDebug() << "[initRoundMap] New round starts..."; + std::cout << "[Game] New round starts..." << std::endl; m_tickTimer->stop(); /* reset scene and clean up items */ @@ -605,7 +609,7 @@ void Server::initRoundMap() Util::placeActors(map, m_maxplayers, Color::order); Util::fillPoints(map); -#if 0 // actor eating actor tests +#if 0 // actor eating actor tests - TODO: remove m_actorMovements.clear(); #if 0 //works @@ -706,6 +710,8 @@ void Server::stopGame(bool delay) return; } + std::cout << "[Game] Round finished..." << std::endl; + /* do next-round work */ ++m_curRound; if(m_rounds == 0 || m_curRound < m_rounds) @@ -713,12 +719,11 @@ void Server::stopGame(bool delay) else { /* end of game */ - qDebug() << "All round finished. Exiting..."; + std::cout << "[Game] All round finished. Exiting..." << std::endl; qApp->quit(); } } - void Server::setFinishRound() { m_finishRound = true; -- cgit v1.2.3