diff options
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index e13682b..f2c0f1c 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,26 +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())); | ||
| 511 | 500 | ||
| 512 | // create new map | 501 | /* create new map */ |
| 513 | Transmission::map_t map = Util::createDemoMap(); | 502 | Transmission::map_t map = Util::createDemoMap(); |
| 514 | // add content | ||
| 515 | Util::placeActors(map, m_maxplayers, Color::order); | 503 | Util::placeActors(map, m_maxplayers, Color::order); |
| 516 | Util::fillPoints(map); | 504 | Util::fillPoints(map); |
| 517 | 505 | ||
| @@ -532,7 +520,8 @@ void Server::initRoundMap(bool firstPacket) | |||
| 532 | Util::deleteMap(map); | 520 | Util::deleteMap(map); |
| 533 | map = NULL; | 521 | map = NULL; |
| 534 | 522 | ||
| 535 | connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); | 523 | if (firstPacket) |
| 524 | connect(this, SIGNAL(allPointsRemoved()), this, SLOT(onRoundFinished())); | ||
| 536 | } | 525 | } |
| 537 | 526 | ||
| 538 | bool Server::parseCommandline() | 527 | bool Server::parseCommandline() |
