diff options
| author | manuel <manuel@mausz.at> | 2011-04-19 22:35:35 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-19 22:35:35 +0200 |
| commit | 9ac2b59da5a900c000e2bdd52d72c5c874f75fbb (patch) | |
| tree | a06541867bdf2bafa1657b9547238c6de4c66ae2 | |
| parent | 11224354131c29f656fb7e5e439c6946aff13458 (diff) | |
| download | foop-9ac2b59da5a900c000e2bdd52d72c5c874f75fbb.tar.gz foop-9ac2b59da5a900c000e2bdd52d72c5c874f75fbb.tar.bz2 foop-9ac2b59da5a900c000e2bdd52d72c5c874f75fbb.zip | |
coding conventions
| -rw-r--r-- | pacman-c++/sceneholder.cpp | 6 | ||||
| -rw-r--r-- | pacman-c++/server.cpp | 54 | ||||
| -rw-r--r-- | pacman-c++/util.cpp | 5 |
3 files changed, 10 insertions, 55 deletions
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 | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | /* an item must be removed by an actor */ | 75 | /* an item must be removed by an actor */ |
| 76 | if (actor == NULL) { | 76 | if (actor == NULL) |
| 77 | Q_ASSERT(false); | 77 | Q_ASSERT(false); |
| 78 | } | ||
| 79 | oldItem->onDie(actor); | 78 | oldItem->onDie(actor); |
| 80 | 79 | ||
| 81 | /* register item for removal in next update */ | 80 | /* register item for removal in next update */ |
| @@ -201,9 +200,8 @@ unsigned int SceneHolder::pointsLeft() | |||
| 201 | void SceneHolder::decrementPoints() | 200 | void SceneHolder::decrementPoints() |
| 202 | { | 201 | { |
| 203 | --m_pointsLeft; | 202 | --m_pointsLeft; |
| 204 | if (m_pointsLeft == 0) { | 203 | if (m_pointsLeft == 0) |
| 205 | emit allPointsRemoved(); | 204 | emit allPointsRemoved(); |
| 206 | } | ||
| 207 | } | 205 | } |
| 208 | 206 | ||
| 209 | void SceneHolder::setEatingOrder(QList<Color::Color> &order) | 207 | void SceneHolder::setEatingOrder(QList<Color::Color> &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() | |||
| 37 | connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); | 37 | connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); |
| 38 | m_tickTimer->start(Constants::tick); | 38 | m_tickTimer->start(Constants::tick); |
| 39 | 39 | ||
| 40 | /* finish round every 3 sec | ||
| 41 | QTimer *timer2 = new QTimer(this); | ||
| 42 | connect(timer2, SIGNAL(timeout()), this, SLOT(onRoundFinished())); | ||
| 43 | timer2->start(3000); | ||
| 44 | // */ | ||
| 45 | |||
| 46 | connect(this, SIGNAL(allPointsRemoved()), SLOT(onRoundFinished())); | ||
| 47 | |||
| 48 | return true; | 40 | return true; |
| 49 | } | 41 | } |
| 50 | 42 | ||
| @@ -492,57 +484,22 @@ void Server::keyPressUpdate() | |||
| 492 | 484 | ||
| 493 | void Server::onRoundFinished() | 485 | void Server::onRoundFinished() |
| 494 | { | 486 | { |
| 495 | foreach(Actor *actor, m_actors) { | 487 | foreach(Actor *actor, m_actors) |
| 496 | actor->finishRound(); | 488 | actor->finishRound(); |
| 497 | } | ||
| 498 | 489 | ||
| 499 | initRoundMap(); | 490 | initRoundMap(); |
| 500 | ++m_curRound; | 491 | ++m_curRound; |
| 501 | 492 | ||
| 502 | if(m_curRound >= m_rounds) { | 493 | /* end of game */ |
| 503 | // end of game | 494 | if(m_curRound >= m_rounds) |
| 504 | m_tickTimer->stop(); | 495 | m_tickTimer->stop(); |
| 505 | } | ||
| 506 | } | 496 | } |
| 507 | 497 | ||
| 508 | void Server::initRoundMap(bool firstPacket) | 498 | void Server::initRoundMap(bool firstPacket) |
| 509 | { | 499 | { |
| 510 | disconnect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); | 500 | /* create new map */ |
| 511 | if (!firstPacket) { | ||
| 512 | // clear old map | ||
| 513 | for (unsigned int i=0; i<visualMap.size(); ++i) { | ||
| 514 | for (unsigned int j=0; j<visualMap[0].size(); ++j) { | ||
| 515 | GameEntity *e = visualMap[i][j]; | ||
| 516 | if (e != NULL) { | ||
| 517 | if (qgraphicsitem_cast<Actor *>(e) == NULL) { | ||
| 518 | removeItem(e); | ||
| 519 | delete e; | ||
| 520 | } | ||
| 521 | } | ||
| 522 | visualMap[i][j] = 0; | ||
| 523 | } | ||
| 524 | } | ||
| 525 | } | ||
| 526 | |||
| 527 | // create new map | ||
| 528 | Transmission::map_t map = Util::createDemoMap(); | 501 | Transmission::map_t map = Util::createDemoMap(); |
| 529 | // add content | ||
| 530 | Util::placeActors(map, m_maxplayers, Color::order); | 502 | Util::placeActors(map, m_maxplayers, Color::order); |
| 531 | /* | ||
| 532 | if (!firstPacket) { | ||
| 533 | for (unsigned int i=0; i<Constants::map_size.width; ++i) { | ||
| 534 | for (unsigned int j=0; j<Constants::map_size.height; ++j) { | ||
| 535 | if (map[i][j] & Transmission::pacman) { | ||
| 536 | Color::Color color = static_cast<Color::Color>(map[i][j] & Transmission::color_mask); | ||
| 537 | Actor *actor = m_actors.value(color, NULL); | ||
| 538 | qDebug() << "setting actor to " << i << j << mapPositionToCoord(i, j); | ||
| 539 | actor->setPos(mapPositionToCoord(i, j)); | ||
| 540 | } | ||
| 541 | } | ||
| 542 | } | ||
| 543 | } | ||
| 544 | */ | ||
| 545 | |||
| 546 | Util::fillPoints(map); | 503 | Util::fillPoints(map); |
| 547 | 504 | ||
| 548 | /* save positions of blocks for later usage */ | 505 | /* save positions of blocks for later usage */ |
| @@ -562,7 +519,8 @@ void Server::initRoundMap(bool firstPacket) | |||
| 562 | Util::deleteMap(map); | 519 | Util::deleteMap(map); |
| 563 | map = NULL; | 520 | map = NULL; |
| 564 | 521 | ||
| 565 | connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); | 522 | if (firstPacket) |
| 523 | connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); | ||
| 566 | } | 524 | } |
| 567 | 525 | ||
| 568 | bool Server::parseCommandline() | 526 | 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 | |||
| 144 | for (unsigned int y = 0; y < Constants::map_size.height; ++y) | 144 | for (unsigned int y = 0; y < Constants::map_size.height; ++y) |
| 145 | { | 145 | { |
| 146 | Transmission::field_t &cur = map[x][y]; | 146 | Transmission::field_t &cur = map[x][y]; |
| 147 | if (cur == Transmission::none) { | 147 | if (cur == Transmission::none) |
| 148 | cur = type; | 148 | cur = type; |
| 149 | } else if (cur == Transmission::point) { | 149 | else if (cur == Transmission::point) |
| 150 | cur = Transmission::none; | 150 | cur = Transmission::none; |
| 151 | } | ||
| 152 | } | 151 | } |
| 153 | } | 152 | } |
| 154 | } | 153 | } |
