From 9ac2b59da5a900c000e2bdd52d72c5c874f75fbb Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 19 Apr 2011 22:35:35 +0200 Subject: coding conventions --- pacman-c++/sceneholder.cpp | 6 ++---- pacman-c++/server.cpp | 54 ++++++---------------------------------------- pacman-c++/util.cpp | 5 ++--- 3 files changed, 10 insertions(+), 55 deletions(-) (limited to 'pacman-c++') diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index 37db691..3f92860 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp @@ -73,9 +73,8 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x } /* an item must be removed by an actor */ - if (actor == NULL) { + if (actor == NULL) Q_ASSERT(false); - } oldItem->onDie(actor); /* register item for removal in next update */ @@ -201,9 +200,8 @@ unsigned int SceneHolder::pointsLeft() void SceneHolder::decrementPoints() { --m_pointsLeft; - if (m_pointsLeft == 0) { + if (m_pointsLeft == 0) emit allPointsRemoved(); - } } void SceneHolder::setEatingOrder(QList &order) diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 1c3caf9..39a6ee7 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -37,14 +37,6 @@ bool Server::run() connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); m_tickTimer->start(Constants::tick); - /* finish round every 3 sec - QTimer *timer2 = new QTimer(this); - connect(timer2, SIGNAL(timeout()), this, SLOT(onRoundFinished())); - timer2->start(3000); - // */ - - connect(this, SIGNAL(allPointsRemoved()), SLOT(onRoundFinished())); - return true; } @@ -492,57 +484,22 @@ void Server::keyPressUpdate() void Server::onRoundFinished() { - foreach(Actor *actor, m_actors) { + foreach(Actor *actor, m_actors) actor->finishRound(); - } initRoundMap(); ++m_curRound; - if(m_curRound >= m_rounds) { - // end of game + /* end of game */ + if(m_curRound >= m_rounds) m_tickTimer->stop(); - } } void Server::initRoundMap(bool firstPacket) { - disconnect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); - if (!firstPacket) { - // clear old map - for (unsigned int i=0; i(e) == NULL) { - removeItem(e); - delete e; - } - } - visualMap[i][j] = 0; - } - } - } - - // create new map + /* create new map */ Transmission::map_t map = Util::createDemoMap(); - // add content Util::placeActors(map, m_maxplayers, Color::order); - /* - if (!firstPacket) { - for (unsigned int i=0; i(map[i][j] & Transmission::color_mask); - Actor *actor = m_actors.value(color, NULL); - qDebug() << "setting actor to " << i << j << mapPositionToCoord(i, j); - actor->setPos(mapPositionToCoord(i, j)); - } - } - } - } - */ - Util::fillPoints(map); /* save positions of blocks for later usage */ @@ -562,7 +519,8 @@ void Server::initRoundMap(bool firstPacket) Util::deleteMap(map); map = NULL; - connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); + if (firstPacket) + connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); } bool Server::parseCommandline() diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index 070c716..d83ea3c 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp @@ -144,11 +144,10 @@ namespace Util for (unsigned int y = 0; y < Constants::map_size.height; ++y) { Transmission::field_t &cur = map[x][y]; - if (cur == Transmission::none) { + if (cur == Transmission::none) cur = type; - } else if (cur == Transmission::point) { + else if (cur == Transmission::point) cur = Transmission::none; - } } } } -- cgit v1.2.3