summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pacman-c++/point.cpp1
-rw-r--r--pacman-c++/server.cpp14
2 files changed, 8 insertions, 7 deletions
diff --git a/pacman-c++/point.cpp b/pacman-c++/point.cpp
index 1943756..755871d 100644
--- a/pacman-c++/point.cpp
+++ b/pacman-c++/point.cpp
@@ -29,7 +29,6 @@ bool Point::enter(Actor *actor)
29void Point::onDie(Actor *actor) 29void Point::onDie(Actor *actor)
30{ 30{
31 AudioPlayer *player = actor->wakaPlayer(); 31 AudioPlayer *player = actor->wakaPlayer();
32 qDebug() << "onDie" << player;
33 if (player == NULL) 32 if (player == NULL)
34 return; 33 return;
35 if (player->state() != Phonon::PlayingState) 34 if (player->state() != Phonon::PlayingState)
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp
index dd15934..b7cd1a0 100644
--- a/pacman-c++/server.cpp
+++ b/pacman-c++/server.cpp
@@ -83,6 +83,9 @@ invalid_direction:
83 83
84 // <t3h g4m3 10gic> 84 // <t3h g4m3 10gic>
85 // TODO: support actors eating each other 85 // TODO: support actors eating each other
86 // TODO: old item - REMOVE THAT?
87 GameEntity *oldItem = visualMap[mapPosition.x()][mapPosition.y()];
88
86 /* check if there's an item at new location of actor */ 89 /* check if there's an item at new location of actor */
87 GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()]; 90 GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()];
88 if (item != NULL && oldItem != item) 91 if (item != NULL && oldItem != item)
@@ -108,9 +111,11 @@ invalid_direction:
108 /* movement didn't work - e.g. was blocked */ 111 /* movement didn't work - e.g. was blocked */
109 if (mapPosition == newMapPosition) 112 if (mapPosition == newMapPosition)
110 { 113 {
111 if (turn == 1) 114 /* */
115 if (turn == 1 && i.value() != actor->direction())
112 { 116 {
113 /* set direction back to last known direction and try again */ 117 /* set direction back to last known direction and try again */
118 qDebug() << "Movement was blocked. Try last known direction";
114 m_actorMovements[i.key()] = actor->direction(); 119 m_actorMovements[i.key()] = actor->direction();
115 goto invalid_direction; 120 goto invalid_direction;
116 } 121 }
@@ -200,24 +205,21 @@ void Server::sendUpdate(QSharedPointer< ProtoBuf::MapUpdate > packet)
200 205
201void Server::keyPressUpdate() 206void Server::keyPressUpdate()
202{ 207{
203 qDebug() << "kpress"; 208 QMapIterator<Color::Color, QTcpSocket *> i(m_clientConnections);
204 QMapIterator<Color::Color, QTcpSocket*> i(m_clientConnections);
205 while (i.hasNext()) 209 while (i.hasNext())
206 { 210 {
207 i.next(); 211 i.next();
208 Color::Color color = i.key(); 212 Color::Color color = i.key();
209 QTcpSocket *socket = i.value(); 213 QTcpSocket *socket = i.value();
210 qDebug() << "data?";
211 if (socket->bytesAvailable() > 0) 214 if (socket->bytesAvailable() > 0)
212 { 215 {
213 qDebug() << "data!";
214 std::string dataStr; 216 std::string dataStr;
215 Util::QByteArrayToStdString(socket->readAll(), dataStr); 217 Util::QByteArrayToStdString(socket->readAll(), dataStr);
216 ProtoBuf::KeyPressUpdate packet; 218 ProtoBuf::KeyPressUpdate packet;
217 bool worked = packet.ParseFromString(dataStr); 219 bool worked = packet.ParseFromString(dataStr);
218 Q_ASSERT(worked); 220 Q_ASSERT(worked);
219 Transmission::field_t direction = packet.newkey(); 221 Transmission::field_t direction = packet.newkey();
220 qDebug() << "data:" << direction; 222 qDebug() << "[keypress] actor=" << color << ", direction=" << direction;
221 m_actorMovements[color] = Util::transmissionMovementToActor(direction); 223 m_actorMovements[color] = Util::transmissionMovementToActor(direction);
222 } 224 }
223 } 225 }