summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/mainwidget.cpp1
-rw-r--r--pacman-c++/sceneholder.cpp6
-rw-r--r--pacman-c++/server.cpp23
-rw-r--r--pacman-c++/util.cpp5
4 files changed, 11 insertions, 24 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index f2e1b31..f81961f 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -154,6 +154,7 @@ void MainWidget::tick()
154 QList<Color::Color> order; 154 QList<Color::Color> order;
155 for(int i = 0; i < m_updatepacket.eating_order_size(); ++i) 155 for(int i = 0; i < m_updatepacket.eating_order_size(); ++i)
156 order.append(static_cast<Color::Color>(m_updatepacket.eating_order(i) & Transmission::color_mask)); 156 order.append(static_cast<Color::Color>(m_updatepacket.eating_order(i) & Transmission::color_mask));
157 m_scene->setEatingOrder(order);
157 } 158 }
158 159
159 Transmission::map_t map = Util::createUninitialisedMap(); 160 Transmission::map_t map = Util::createUninitialisedMap();
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp
index feef033..03abf7f 100644
--- a/pacman-c++/sceneholder.cpp
+++ b/pacman-c++/sceneholder.cpp
@@ -72,9 +72,8 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x
72 } 72 }
73 73
74 /* an item must be removed by an actor */ 74 /* an item must be removed by an actor */
75 if (actor == NULL) { 75 if (actor == NULL)
76 Q_ASSERT(false); 76 Q_ASSERT(false);
77 }
78 oldItem->onDie(actor); 77 oldItem->onDie(actor);
79 78
80 /* register item for removal in next update */ 79 /* register item for removal in next update */
@@ -200,9 +199,8 @@ unsigned int SceneHolder::pointsLeft()
200void SceneHolder::decrementPoints() 199void SceneHolder::decrementPoints()
201{ 200{
202 --m_pointsLeft; 201 --m_pointsLeft;
203 if (m_pointsLeft == 0) { 202 if (m_pointsLeft == 0)
204 emit allPointsRemoved(); 203 emit allPointsRemoved();
205 }
206} 204}
207 205
208void SceneHolder::setEatingOrder(QList<Color::Color> &order) 206void SceneHolder::setEatingOrder(QList<Color::Color> &order)
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
493void Server::onRoundFinished() 485void 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
508void Server::initRoundMap(bool firstPacket) 498void 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
538bool Server::parseCommandline() 527bool 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 }