diff options
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 43aa6ff..965517e 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp | |||
| @@ -81,19 +81,26 @@ Transmission::map_t Server::calculateUpdates() | |||
| 81 | // TODO: support actors eating each other | 81 | // TODO: support actors eating each other |
| 82 | // old item | 82 | // old item |
| 83 | PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; | 83 | PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; |
| 84 | if (oldItem != NULL) { | 84 | if (oldItem != NULL) |
| 85 | if (oldItem->eaten()) { | 85 | { |
| 86 | if (oldItem->eaten()) | ||
| 86 | map[mapPosition.x()][mapPosition.y()] = Transmission::empty; | 87 | map[mapPosition.x()][mapPosition.y()] = Transmission::empty; |
| 87 | } | ||
| 88 | } | 88 | } |
| 89 | // new item | 89 | // new item |
| 90 | PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; | 90 | PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; |
| 91 | if (item != NULL && oldItem != item) { | 91 | if (item != NULL && oldItem != item) |
| 92 | if (! item->checkEnter(actor)) { // movement invalid | 92 | { |
| 93 | if (! item->checkEnter(actor)) | ||
| 94 | { | ||
| 95 | // movement invalid | ||
| 93 | newMapPosition = mapPosition; | 96 | newMapPosition = mapPosition; |
| 94 | } else { // apply actions of entering this field | 97 | } |
| 98 | else | ||
| 99 | { | ||
| 100 | // apply actions of entering this field | ||
| 95 | bool survive = item->enter(actor); | 101 | bool survive = item->enter(actor); |
| 96 | if (!survive) { | 102 | if (!survive) |
| 103 | { | ||
| 97 | //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; | 104 | //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; |
| 98 | } | 105 | } |
| 99 | } | 106 | } |
| @@ -197,6 +204,7 @@ void Server::keyPressUpdate() | |||
| 197 | } | 204 | } |
| 198 | } | 205 | } |
| 199 | 206 | ||
| 207 | bool Constants::server = true; | ||
| 200 | 208 | ||
| 201 | int main(int argc, char ** argv) | 209 | int main(int argc, char ** argv) |
| 202 | { | 210 | { |
| @@ -208,7 +216,6 @@ int main(int argc, char ** argv) | |||
| 208 | 216 | ||
| 209 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); | 217 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); |
| 210 | 218 | ||
| 211 | Constants::server = true; | ||
| 212 | Server Server; | 219 | Server Server; |
| 213 | return app.exec(); | 220 | return app.exec(); |
| 214 | } | 221 | } |
