diff options
| author | manuel <manuel@mausz.at> | 2011-04-11 16:58:36 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-11 16:58:36 +0200 |
| commit | 7667effa9635b0c25088305fe89c15a9805d6dbb (patch) | |
| tree | 587cdd64e633c2940f71e269cbb119cfebf4ce48 /pacman-c++/server.cpp | |
| parent | ee094b8cd15d040cb64b2082673f7bd2a2c61f4b (diff) | |
| download | foop-7667effa9635b0c25088305fe89c15a9805d6dbb.tar.gz foop-7667effa9635b0c25088305fe89c15a9805d6dbb.tar.bz2 foop-7667effa9635b0c25088305fe89c15a9805d6dbb.zip | |
- server doesn't neet mainwidget.cpp
- removed local mode (doesn't work anyway)
- made movement more like orginal pacman
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index b054804..c33c559 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp | |||
| @@ -43,6 +43,10 @@ Transmission::map_t Server::calculateUpdates() | |||
| 43 | while (i.hasNext()) | 43 | while (i.hasNext()) |
| 44 | { | 44 | { |
| 45 | i.next(); | 45 | i.next(); |
| 46 | int turn = 0; | ||
| 47 | |||
| 48 | invalid_direction: | ||
| 49 | ++turn; | ||
| 46 | Actor *actor = m_actors.value(i.key()); | 50 | Actor *actor = m_actors.value(i.key()); |
| 47 | QPoint mapPosition = CoordToMapPosition(actor->pos().toPoint()); | 51 | QPoint mapPosition = CoordToMapPosition(actor->pos().toPoint()); |
| 48 | qDebug() << "actor " << i.key() << " is at " << mapPosition << "moving " << i.value(); | 52 | qDebug() << "actor " << i.key() << " is at " << mapPosition << "moving " << i.value(); |
| @@ -108,8 +112,21 @@ Transmission::map_t Server::calculateUpdates() | |||
| 108 | } | 112 | } |
| 109 | // </t3h g4m2 10gic> | 113 | // </t3h g4m2 10gic> |
| 110 | 114 | ||
| 115 | /* movement didn't work - e.g. was blocked */ | ||
| 111 | if (mapPosition == newMapPosition) | 116 | if (mapPosition == newMapPosition) |
| 112 | m_actorMovements[i.key()] = Actor::None; | 117 | { |
| 118 | if (turn == 1) | ||
| 119 | { | ||
| 120 | /* set direction back to last known direction and try again */ | ||
| 121 | m_actorMovements[i.key()] = actor->direction(); | ||
| 122 | goto invalid_direction; | ||
| 123 | } | ||
| 124 | else | ||
| 125 | { | ||
| 126 | /* second turn didn't work too -> stop movement */ | ||
| 127 | m_actorMovements[i.key()] = Actor::None; | ||
| 128 | } | ||
| 129 | } | ||
| 113 | 130 | ||
| 114 | map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | | 131 | map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | |
| 115 | i.key() | Util::actorMovementToTransmission(i.value()); | 132 | i.key() | Util::actorMovementToTransmission(i.value()); |
