From 6af8e7795da1e86745364af1538fa76d4e0fc07e Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 12 Apr 2011 20:23:33 +0200 Subject: minor improvments: better debug messages + no tabs :D --- pacman-c++/server.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'pacman-c++/server.cpp') diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index b7cd1a0..1c42174 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -10,9 +10,9 @@ Server::Server(QWidget *parent) : SceneHolder(parent) { - qDebug() << "waiting for clients"; + qDebug() << "[Server] Waiting for clients"; waitForClientConnections(); - qDebug() << "clients connected"; + qDebug() << "[Server] All Clients connected"; updateMap(Util::createDemoMap()); @@ -23,7 +23,7 @@ Server::Server(QWidget *parent) void Server::tick() { - qDebug() << "doing srv update"; + qDebug() << "[Tick] Doing server update"; Transmission::map_t map = calculateUpdates(); updateMap(map); @@ -49,7 +49,8 @@ invalid_direction: ++turn; Actor *actor = m_actors.value(i.key()); QPoint mapPosition = CoordToMapPosition(actor->pos().toPoint()); - qDebug() << "actor " << i.key() << " is at " << mapPosition << "moving " << i.value(); + qDebug() << "[Calc] Actor wants to move: color=" << i.key() + << "pos=" << mapPosition << "direction=" << i.value(); QPoint newMapPosition = mapPosition; switch (i.value()) @@ -90,11 +91,12 @@ invalid_direction: GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()]; if (item != NULL && oldItem != item) { - qDebug() << "item at new actor location found"; + qDebug() << "[Calc] Found item at new actor location"; if (!item->checkEnter(actor)) { /* movement invalid. e.g. move against wall */ newMapPosition = mapPosition; + qDebug() << "[Calc] Item blocks actor"; } else { @@ -115,7 +117,7 @@ invalid_direction: if (turn == 1 && i.value() != actor->direction()) { /* set direction back to last known direction and try again */ - qDebug() << "Movement was blocked. Try last known direction"; + qDebug() << "[Calc] Movement was blocked. Trying last known actor direction"; m_actorMovements[i.key()] = actor->direction(); goto invalid_direction; } @@ -123,6 +125,7 @@ invalid_direction: { /* second turn didn't work too -> stop movement */ m_actorMovements[i.key()] = Actor::None; + qDebug() << "[Calc] No good direction known. Movement stopped"; } } @@ -159,7 +162,6 @@ QSharedPointer Server::createUpdatePacket(Transmission::map updatePacket->add_game_points(m_actors.value(Color::order[i])->getGamePoints()); } - //qDebug() << "field sz "<< updatePacket->field_size(); return updatePacket; } @@ -191,7 +193,7 @@ void Server::waitForClientConnections() packet.set_color(color); Util::sendPacket(packet, socket); - qDebug() << "new player of col " << color; + qDebug() << "[Connect] New Player: color=" << color; } } @@ -219,7 +221,7 @@ void Server::keyPressUpdate() bool worked = packet.ParseFromString(dataStr); Q_ASSERT(worked); Transmission::field_t direction = packet.newkey(); - qDebug() << "[keypress] actor=" << color << ", direction=" << direction; + qDebug() << "[KeyPress] actor=" << color << "direction=" << direction; m_actorMovements[color] = Util::transmissionMovementToActor(direction); } } -- cgit v1.2.3