summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-05-02 15:50:23 +0200
committermanuel <manuel@mausz.at>2011-05-02 15:50:23 +0200
commitce20694e0db010b5d65bdd2ee81a410efbf99e3d (patch)
tree6063fb3b023d156374936cc6d405abf3e57532cd
parent41a31420cf091aeb4e986503387855d41e550106 (diff)
downloadfoop-ce20694e0db010b5d65bdd2ee81a410efbf99e3d.tar.gz
foop-ce20694e0db010b5d65bdd2ee81a410efbf99e3d.tar.bz2
foop-ce20694e0db010b5d65bdd2ee81a410efbf99e3d.zip
w000h00
-rw-r--r--pacman-c++/actor.cpp43
-rw-r--r--pacman-c++/actor.h9
-rw-r--r--pacman-c++/audio.h2
-rw-r--r--pacman-c++/bonuspoint.cpp1
-rw-r--r--pacman-c++/mainwidget.cpp2
-rw-r--r--pacman-c++/sceneholder.cpp100
-rw-r--r--pacman-c++/sceneholder.h1
-rw-r--r--pacman-c++/server.cpp166
-rw-r--r--pacman-c++/util.cpp6
9 files changed, 269 insertions, 61 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp
index 2dced34..9c2d2fa 100644
--- a/pacman-c++/actor.cpp
+++ b/pacman-c++/actor.cpp
@@ -10,7 +10,7 @@ static QVariant myBooleanInterpolator(const bool &start, const bool &end, qreal
10} 10}
11 11
12Actor::Actor(Color::Color color, bool local, QGraphicsItem *parent) 12Actor::Actor(Color::Color color, bool local, QGraphicsItem *parent)
13 : GameEntity(color, parent), m_direction(Actor::None), m_local(local), 13 : GameEntity(color, parent), m_direction(Actor::None), m_local(local), m_reset(true),
14 m_wakaPlayer(NULL), m_roundPoints(0), m_gamePoints(0) 14 m_wakaPlayer(NULL), m_roundPoints(0), m_gamePoints(0)
15{ 15{
16 m_type = Type; 16 m_type = Type;
@@ -62,6 +62,7 @@ Actor::Actor(Color::Color color, bool local, QGraphicsItem *parent)
62 for (int i = 0; i < 11; i++) 62 for (int i = 0; i < 11; i++)
63 { 63 {
64 PixmapItem *img = new PixmapItem(m_pix, this); 64 PixmapItem *img = new PixmapItem(m_pix, this);
65 img->setZValue(zValue() * 10);
65 m_images.append(img); 66 m_images.append(img);
66 int x = i * Constants::sprite_offset + Constants::sprite_margin; 67 int x = i * Constants::sprite_offset + Constants::sprite_margin;
67 int y = 5 * Constants::sprite_offset + Constants::sprite_margin; 68 int y = 5 * Constants::sprite_offset + Constants::sprite_margin;
@@ -130,13 +131,28 @@ Actor::Movement Actor::direction()
130 return m_direction; 131 return m_direction;
131} 132}
132 133
134
135void Actor::setDirection(Movement direction)
136{
137 m_direction = direction;
138}
139
133bool Actor::isLocal() 140bool Actor::isLocal()
134{ 141{
135 return m_local; 142 return m_local;
136} 143}
137 144
138void Actor::resetAnimation() 145bool Actor::hadReset()
139{ 146{
147 if (!m_reset)
148 return false;
149 m_reset = false;
150 return true;
151}
152
153void Actor::reset()
154{
155 m_reset = true;
140 if (Constants::server) 156 if (Constants::server)
141 return; 157 return;
142 158
@@ -154,6 +170,21 @@ void Actor::resetAnimation()
154 m_images[m_direction]->setVisible(true); 170 m_images[m_direction]->setVisible(true);
155} 171}
156 172
173void Actor::move(QPoint newpos)
174{
175 QPoint oldpos = pos().toPoint();
176 Actor::Movement direction = Actor::None;
177 if (oldpos.x() - newpos.x() < 0)
178 direction = Actor::Right;
179 else if (oldpos.x() - newpos.x() > 0)
180 direction = Actor::Left;
181 else if (oldpos.y() - newpos.y() < 0)
182 direction = Actor::Down;
183 else if (oldpos.y() - newpos.y() > 0)
184 direction = Actor::Up;
185 move(direction);
186}
187
157void Actor::move(Actor::Movement direction) 188void Actor::move(Actor::Movement direction)
158{ 189{
159 if (Constants::server) 190 if (Constants::server)
@@ -244,12 +275,18 @@ bool Actor::canEat(Actor *other, const QList<Color::Color> &order)
244 return (order.at(idx + 1) == other->color()); 275 return (order.at(idx + 1) == other->color());
245} 276}
246 277
278void Actor::onDie(Actor *other)
279{
280 other->eatingPacman();
281 die();
282}
283
247void Actor::die() 284void Actor::die()
248{ 285{
249 if (Constants::server) 286 if (Constants::server)
250 return; 287 return;
251 288
252 resetAnimation(); 289 reset();
253 m_images[m_direction]->setVisible(false); 290 m_images[m_direction]->setVisible(false);
254 m_dieing->start(); 291 m_dieing->start();
255 if (m_local) 292 if (m_local)
diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h
index eb04c71..e7d3ebc 100644
--- a/pacman-c++/actor.h
+++ b/pacman-c++/actor.h
@@ -34,9 +34,12 @@ public:
34 34
35 PixmapItem &icon(); 35 PixmapItem &icon();
36 Movement direction(); 36 Movement direction();
37 void resetAnimation(); 37 void setDirection(Movement direction);
38 void reset();
39 bool hadReset();
38 bool isLocal(); 40 bool isLocal();
39 void move(Movement direction); 41 void move(Movement direction);
42 void move(QPoint newpos);
40 bool isMoving(); 43 bool isMoving();
41 void die(); 44 void die();
42 void eatingFruit(); 45 void eatingFruit();
@@ -44,13 +47,14 @@ public:
44 void startEating(); 47 void startEating();
45 void stopEating(); 48 void stopEating();
46 bool canEat(Actor *other, const QList<Color::Color> &order); 49 bool canEat(Actor *other, const QList<Color::Color> &order);
50 virtual void onDie(Actor *);
47 51
48 unsigned int getRoundPoints(); 52 unsigned int getRoundPoints();
49 unsigned int getGamePoints(); 53 unsigned int getGamePoints();
50 void addRoundPoints(unsigned int amount); 54 void addRoundPoints(unsigned int amount);
51 void finishRound(bool died = false); 55 void finishRound(bool died = false);
52 56
53 static QPoint movementToPoint(const Actor::Movement direction); 57 static QPoint movementToPoint(const Movement direction);
54 58
55private: 59private:
56 void moveByServer(Movement direction); 60 void moveByServer(Movement direction);
@@ -61,6 +65,7 @@ private:
61 Movement m_direction; 65 Movement m_direction;
62 PixmapItem m_icon; 66 PixmapItem m_icon;
63 bool m_local; 67 bool m_local;
68 bool m_reset;
64 GaplessAudioPlayer *m_wakaPlayer; 69 GaplessAudioPlayer *m_wakaPlayer;
65 70
66 unsigned int m_roundPoints; 71 unsigned int m_roundPoints;
diff --git a/pacman-c++/audio.h b/pacman-c++/audio.h
index 9a4feec..6aec42d 100644
--- a/pacman-c++/audio.h
+++ b/pacman-c++/audio.h
@@ -25,7 +25,7 @@ namespace Sound
25 }; 25 };
26 26
27 const unsigned int length[] = { 27 const unsigned int length[] = {
28 4310, 2090, 570, 570, 1720 28 4310, 2090, 570, 570, 1720,
29 }; 29 };
30}; 30};
31 31
diff --git a/pacman-c++/bonuspoint.cpp b/pacman-c++/bonuspoint.cpp
index a6736c4..033b7c8 100644
--- a/pacman-c++/bonuspoint.cpp
+++ b/pacman-c++/bonuspoint.cpp
@@ -36,4 +36,3 @@ void BonusPoint::onDie(Actor *actor)
36{ 36{
37 actor->eatingFruit(); 37 actor->eatingFruit();
38} 38}
39
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index f164219..3c77765 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -141,7 +141,7 @@ void MainWidget::tick()
141 Q_ASSERT(worked); 141 Q_ASSERT(worked);
142 Q_UNUSED(worked); 142 Q_UNUSED(worked);
143 143
144 /* eating order data set inidicates a new round */ 144 /* eating order data set indicates a new round */
145 if (m_updatepacket.eating_order_size() > 0) 145 if (m_updatepacket.eating_order_size() > 0)
146 { 146 {
147 Q_ASSERT(m_scene != NULL); 147 Q_ASSERT(m_scene != NULL);
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp
index 1ecf31b..f6b8145 100644
--- a/pacman-c++/sceneholder.cpp
+++ b/pacman-c++/sceneholder.cpp
@@ -25,7 +25,7 @@ void SceneHolder::reset()
25 /* remove actors from scene so they don't get deleted during clear */ 25 /* remove actors from scene so they don't get deleted during clear */
26 foreach(Actor *actor, m_actors) 26 foreach(Actor *actor, m_actors)
27 { 27 {
28 actor->resetAnimation(); 28 actor->reset();
29 removeItem(actor); 29 removeItem(actor);
30 } 30 }
31 31
@@ -88,8 +88,20 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x
88 if (cur == Transmission::none) 88 if (cur == Transmission::none)
89 return; 89 return;
90 90
91 /* we may have multiple colors in one position (e.g during eating another pacman) */
91 Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask); 92 Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask);
92 GameEntity* item = NULL; 93 QList<Color::Color> colors;
94 if (color == Color::none)
95 colors.append(Color::none);
96 foreach(Color::Color col, m_eatingorder.toSet())
97 {
98 if (color & col)
99 colors.append(col);
100 }
101 Q_ASSERT(colors.count() > 0);
102
103 /* for now complain if there are more colors or it's a Transmission::death packet */
104 Q_ASSERT(colors.count() == 1 || cur & Transmission::death);
93 105
94 if (cur & Transmission::empty) 106 if (cur & Transmission::empty)
95 { 107 {
@@ -102,13 +114,13 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x
102 m_oldItems.append(oldItem); 114 m_oldItems.append(oldItem);
103 115
104 /* an item must be removed by an actor */ 116 /* an item must be removed by an actor */
105 Actor *actor = m_actors[color]; 117 Actor *actor = m_actors[colors.at(0)];
106 if (actor == NULL) 118 Q_ASSERT(actor != NULL);
107 Q_ASSERT(false);
108 oldItem->onDie(actor); 119 oldItem->onDie(actor);
109 } 120 }
110 } 121 }
111 122
123 GameEntity *item = NULL;
112 if (cur == Transmission::none) 124 if (cur == Transmission::none)
113 { 125 {
114 /* no update */ 126 /* no update */
@@ -137,7 +149,7 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x
137 /* check down side */ 149 /* check down side */
138 if (y < Constants::map_size.height && map[x][y + 1] & Transmission::block) 150 if (y < Constants::map_size.height && map[x][y + 1] & Transmission::block)
139 neighbours |= Block::Down; 151 neighbours |= Block::Down;
140 item = new Block(color, neighbours); 152 item = new Block(colors.at(0), neighbours);
141 } 153 }
142 154
143 if (cur & Transmission::bonuspoint) 155 if (cur & Transmission::bonuspoint)
@@ -152,41 +164,55 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x
152 164
153 if (cur & Transmission::pacman) 165 if (cur & Transmission::pacman)
154 { 166 {
155 /* WARNING: do NOT add actor to visualMap as visualMap-items may 167 foreach(color, colors)
156 * get deleted during update and actors are referenced in_mactors too
157 * if you REALLY need that you need to changed updateMap so that all actors
158 * will be moved before any new items get allocated (totally untested)
159 */
160 Actor *actor = m_actors.value(color, NULL);
161 if (actor == NULL)
162 {
163 actor = new Actor(color, (color == m_color));
164 m_actors[color] = actor;
165 addItem(actor);
166 actor->setPos(mapPositionToCoord(x, y));
167 }
168 else
169 { 168 {
170 Actor::Movement direction = Util::transmissionMovementToActor( 169 /* WARNING: do NOT add actor to visualMap as visualMap-items may
171 cur & Transmission::direction_mask); 170 * get deleted during update and actors are referenced in_mactors too
172 /* direction Actor::None is used on round change (i.e. new actor positions) 171 * if you REALLY need that you need to changed updateMap so that all actors
173 * it is animation-safe to use it for this direction only 172 * will be moved before any new items get allocated (totally untested)
174 */ 173 */
175 if (direction == Actor::None) 174 Actor *actor = m_actors.value(color, NULL);
175 if (actor == NULL)
176 {
177 actor = new Actor(color, (color == m_color));
178 m_actors[color] = actor;
179 addItem(actor);
176 actor->setPos(mapPositionToCoord(x, y)); 180 actor->setPos(mapPositionToCoord(x, y));
177 actor->move(direction); 181 actor->hadReset();
178 /* that's kind a hack but working right now 182 }
179 * I think that will fall on our's hat sooner or later 183 else
180 */ 184 {
181 if (!(cur & Transmission::empty)) 185 /* check for death */
182 actor->stopEating(); 186 if (cur & Transmission::death)
183 qDebug() << "[SceneUpdate] actor moves: color=" << color 187 {
184 << "direction=" << direction << "newpos=" << QPoint(x, y); 188 foreach(Color::Color col, colors)
189 {
190 if (color == col)
191 continue;
192 if (m_actors[col]->canEat(actor, m_eatingorder))
193 {
194 m_death[col] = actor;
195 break;
196 }
197 }
198 }
199
200 /* move actor */
201 if (actor->hadReset())
202 actor->setPos(mapPositionToCoord(x, y));
203 else
204 actor->move(mapPositionToCoord(x, y));
205
206 /* that's kind a hack but working right now */
207 if (!(cur & Transmission::empty))
208 actor->stopEating();
209 qDebug() << "[SceneUpdate] actor moves: color=" << color
210 << "newpos=" << QPoint(x, y);
211 }
212
213 if ((cur & Transmission::death) && visualMap[x][y] != NULL)
214 m_death[color] = visualMap[x][y];
185 } 215 }
186
187
188 if (cur & Transmission::death)
189 m_death[color] = visualMap[x][y];
190 } 216 }
191 217
192 if (cur & Transmission::empty) 218 if (cur & Transmission::empty)
diff --git a/pacman-c++/sceneholder.h b/pacman-c++/sceneholder.h
index f36c31e..dcc10bf 100644
--- a/pacman-c++/sceneholder.h
+++ b/pacman-c++/sceneholder.h
@@ -51,6 +51,7 @@ protected:
51 * must be remove one tick later 51 * must be remove one tick later
52 */ 52 */
53 QList<GameEntity *> m_oldItems; 53 QList<GameEntity *> m_oldItems;
54 /* we need to store items that killed an actor too (e.g. colored blocks) */
54 QMap<Color::Color, GameEntity *> m_death; 55 QMap<Color::Color, GameEntity *> m_death;
55 56
56 /* my local color */ 57 /* my local color */
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp
index ef271f0..2b43bb9 100644
--- a/pacman-c++/server.cpp
+++ b/pacman-c++/server.cpp
@@ -44,7 +44,7 @@ bool Server::run()
44 44
45void Server::tick() 45void Server::tick()
46{ 46{
47 qDebug() << "[Tick] Doing server update"; 47 //qDebug() << "[Tick] Doing server update";
48 if (m_finishRound) 48 if (m_finishRound)
49 stopGame(true); 49 stopGame(true);
50 if (!m_running) 50 if (!m_running)
@@ -78,6 +78,7 @@ void Server::tick()
78 78
79Transmission::map_t Server::calculateUpdates() 79Transmission::map_t Server::calculateUpdates()
80{ 80{
81 QMap<Color::Color, QPair<QPoint, QPoint> > movements;
81 Transmission::map_t map = Util::createEmptyMap(); 82 Transmission::map_t map = Util::createEmptyMap();
82 83
83 QMutableMapIterator<Color::Color, Actor::Movement> i(m_actorMovements); 84 QMutableMapIterator<Color::Color, Actor::Movement> i(m_actorMovements);
@@ -105,12 +106,9 @@ invalid_direction:
105 if (newMapPosition.y() >= visualMap[newMapPosition.x()].size()) 106 if (newMapPosition.y() >= visualMap[newMapPosition.x()].size())
106 newMapPosition.setY(visualMap[newMapPosition.x()].size() - 1); 107 newMapPosition.setY(visualMap[newMapPosition.x()].size() - 1);
107 108
108 // <t3h g4m3 10gic>
109 // TODO: support actors eating each other
110 GameEntity *oldItem = visualMap[mapPosition.x()][mapPosition.y()];
111
112 /* check if there's an item at new location of actor */ 109 /* check if there's an item at new location of actor */
113 GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()]; 110 GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()];
111 GameEntity *oldItem = visualMap[mapPosition.x()][mapPosition.y()];
114 if (item != NULL && oldItem != item) 112 if (item != NULL && oldItem != item)
115 { 113 {
116 qDebug() << "[Calc] Found item at new actor location"; 114 qDebug() << "[Calc] Found item at new actor location";
@@ -128,14 +126,13 @@ invalid_direction:
128 map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty | actor->color(); 126 map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty | actor->color();
129 else if (survive == GameEntity::DestroyedActor) 127 else if (survive == GameEntity::DestroyedActor)
130 { 128 {
129 map[newMapPosition.x()][newMapPosition.y()] = Transmission::death | actor->color();
131 m_actors[item->color()]->addRoundPoints(actor->getRoundPoints()); 130 m_actors[item->color()]->addRoundPoints(actor->getRoundPoints());
132 actor->finishRound(true); 131 actor->finishRound(true);
133 map[newMapPosition.x()][newMapPosition.y()] = Transmission::death | actor->color();
134 setFinishRound(); 132 setFinishRound();
135 } 133 }
136 } 134 }
137 } 135 }
138 // </t3h g4m2 10gic>
139 136
140 /* movement didn't work - e.g. was blocked */ 137 /* movement didn't work - e.g. was blocked */
141 if (mapPosition == newMapPosition) 138 if (mapPosition == newMapPosition)
@@ -156,19 +153,108 @@ invalid_direction:
156 } 153 }
157 } 154 }
158 155
159 map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | 156 /* store movement for collision */
160 color | Util::actorMovementToTransmission(direction); 157 movements.insert(color, QPair<QPoint, QPoint>(mapPosition, newMapPosition));
158
159 /* set direction (used for collision detection) */
160 actor->setDirection(direction);
161 161
162 /* DEBUG: uncomments to disable auto-movement */ 162 /* DEBUG: uncomments to disable auto-movement */
163 //direction = Actor::None; 163 //direction = Actor::None;
164 164
165 /* actor is not moving anymore: remove from list */
165 if (direction == Actor::None) 166 if (direction == Actor::None)
166 {
167 /* set actor to non-moving */
168 m_actorMovements[color] = Actor::None;
169 i.remove(); 167 i.remove();
168 }
169
170 /* check for actor collision */
171 QList<Actor *> blocked;
172 foreach(Color::Color color, movements.keys())
173 {
174 Actor *actor = m_actors[color];
175 QPoint oldpos = movements[color].first;
176 QPoint newpos = movements[color].second;
177 QPoint scenepos = actor->pos().toPoint();
178
179 /* first move actor to new position */
180 actor->move(actor->direction());
181
182 /* next check for collisions */
183 Actor *orderer = NULL;
184 Actor *meal = NULL;
185 foreach(Actor *other, m_actors)
186 {
187 if (actor == other)
188 continue;
189 if (!actor->collidesWithItem(other))
190 continue;
191 /* both move in the same direction */
192 if (actor->direction() == other->direction())
193 continue;
194
195 if (other->canEat(actor, m_eatingorder))
196 {
197 qDebug() << "[Collision] Actor" << actor->color() << "got EATEN by" << other->color();
198 orderer = other;
199 meal = actor;
200 break;
201 }
202 else if (actor->canEat(other, m_eatingorder))
203 {
204 qDebug() << "[Collision] Actor" << actor->color() << "EATS" << other->color();
205 orderer = actor;
206 meal = other;
207 blocked.append(other);
208 break;
209 }
210 else
211 {
212 qDebug() << "[Collision] Actor" << actor->color() << "got BLOCKED by" << other->color();
213 blocked.append(actor);
214 /* no break here */
215 }
216 }
217
218 /* update map depending on collision */
219 if (orderer != NULL && meal != NULL)
220 {
221 map[newpos.x()][newpos.y()] |= Transmission::pacman | Transmission::death
222 | orderer->color() | meal->color();
223 orderer->addRoundPoints(meal->getRoundPoints());
224 meal->finishRound(true);
225 setFinishRound();
226 }
227 else if (blocked.contains(actor))
228 {
229 /* move actor back early cause he won't move */
230 actor->setPos(scenepos);
231 map[oldpos.x()][oldpos.y()] |= Transmission::pacman | color;
232 }
233 else
234 {
235 map[newpos.x()][newpos.y()] |= Transmission::pacman | color;
170 } 236 }
171 } 237 }
238
239 /* move all actors back to their origin position */
240 foreach(Color::Color color, movements.keys())
241 m_actors[color]->setPos(mapPositionToCoord(movements[color].first));
242
243 foreach(Color::Color col, m_eatingorder.toSet())
244 {
245 QList<QPoint> found;
246 for (unsigned int x = 0; x < Constants::map_size.width; ++x)
247 {
248 for (unsigned int y = 0; y < Constants::map_size.height; ++y)
249 {
250 if ((map[x][y] & Transmission::color_mask) & col)
251 found.append(QPoint(x, y));
252 }
253 }
254 if (found.count() > 1)
255 qDebug() << "found" << found << "fields with color=" << col;
256 }
257
172 return map; 258 return map;
173} 259}
174 260
@@ -519,6 +605,60 @@ void Server::initRoundMap()
519 Util::placeActors(map, m_maxplayers, Color::order); 605 Util::placeActors(map, m_maxplayers, Color::order);
520 Util::fillPoints(map); 606 Util::fillPoints(map);
521 607
608#if 0 // actor eating actor tests
609 m_actorMovements.clear();
610#if 0
611 //works
612 map[0][0] = Color::order[0] | Transmission::pacman;
613 map[0][1] = Color::order[1] | Transmission::pacman;
614 m_actorMovements.insert(Color::order[0], Actor::Down);
615#elif 0
616 //works
617 map[0][0] = Color::order[0] | Transmission::pacman;
618 map[0][3] = Color::order[1] | Transmission::pacman;
619 m_actorMovements.insert(Color::order[0], Actor::Down);
620#elif 0
621 //works
622 map[0][0] = Color::order[0] | Transmission::pacman;
623 map[0][4] = Color::order[1] | Transmission::pacman;
624 m_actorMovements.insert(Color::order[0], Actor::Down);
625#elif 0
626 //works
627 map[0][0] = Color::order[0] | Transmission::pacman;
628 map[0][5] = Color::order[1] | Transmission::pacman;
629 m_actorMovements.insert(Color::order[0], Actor::Down);
630#elif 0
631 //works
632 map[0][0] = Color::order[1] | Transmission::pacman;
633 map[0][5] = Color::order[0] | Transmission::pacman;
634 m_actorMovements.insert(Color::order[1], Actor::Down);
635#elif 0
636 //works
637 map[0][0] = Color::order[0] | Transmission::pacman;
638 map[0][5] = Color::order[1] | Transmission::pacman;
639 m_actorMovements.insert(Color::order[0], Actor::Down);
640 m_actorMovements.insert(Color::order[1], Actor::Up);
641#elif 0
642 //works
643 map[0][0] = Color::order[0] | Transmission::pacman;
644 map[0][6] = Color::order[1] | Transmission::pacman;
645 m_actorMovements.insert(Color::order[0], Actor::Down);
646 m_actorMovements.insert(Color::order[1], Actor::Up);
647#elif 0
648 //works
649 map[0][0] = Color::order[0] | Transmission::pacman;
650 map[0][7] = Color::order[1] | Transmission::pacman;
651 m_actorMovements.insert(Color::order[0], Actor::Down);
652 m_actorMovements.insert(Color::order[1], Actor::Up);
653#elif 1
654 //works
655 map[0][0] = Color::order[0] | Transmission::pacman;
656 map[0][1] = Color::order[1] | Transmission::pacman;
657 m_actorMovements.insert(Color::order[0], Actor::Down);
658 m_actorMovements.insert(Color::order[1], Actor::Down);
659#endif
660#endif
661
522 /* save positions of blocks for later usage */ 662 /* save positions of blocks for later usage */
523 m_blocks.clear(); 663 m_blocks.clear();
524 for (unsigned int x = 0; x < Constants::map_size.width; ++x) 664 for (unsigned int x = 0; x < Constants::map_size.width; ++x)
@@ -696,7 +836,7 @@ bool Server::parseCommandline()
696 { 836 {
697 bool ok; 837 bool ok;
698 unsigned int rounds = QString(opt.getValue("rounds")).toUInt(&ok); 838 unsigned int rounds = QString(opt.getValue("rounds")).toUInt(&ok);
699 if (!ok || rounds == 0) 839 if (!ok)
700 { 840 {
701 qCritical() << "Invalid number of rounds: " << opt.getValue("rounds") << endl; 841 qCritical() << "Invalid number of rounds: " << opt.getValue("rounds") << endl;
702 return false; 842 return false;
diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp
index f8396f9..bef7f0c 100644
--- a/pacman-c++/util.cpp
+++ b/pacman-c++/util.cpp
@@ -79,7 +79,7 @@ namespace Util
79 { 79 {
80#if 0 80#if 0
81 for(unsigned int i = 0; i < players; ++i) 81 for(unsigned int i = 0; i < players; ++i)
82 map[i][0] = colors[i] | Transmission::pacman | Transmission::direction_none; 82 map[i][0] = colors[i] | Transmission::pacman;
83 return; 83 return;
84#endif 84#endif
85 85
@@ -112,8 +112,8 @@ namespace Util
112 { 112 {
113 int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0))); 113 int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0)));
114 QPoint newpos = validpos.at(rand); 114 QPoint newpos = validpos.at(rand);
115 map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman | Transmission::direction_none; 115 map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman;
116 qDebug() << "Actor" << i << "at" << newpos; 116 qDebug() << "[Place] Actor" << i << "at" << newpos;
117 actors.append(newpos); 117 actors.append(newpos);
118 validpos.removeAt(rand); 118 validpos.removeAt(rand);
119 119