diff options
| author | manuel <manuel@mausz.at> | 2011-04-11 13:42:28 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-11 13:42:28 +0200 |
| commit | 6c44b14d2bae2120c069ab205f95b2e51de2caea (patch) | |
| tree | 9fd910c27cb23d22db1cf1681e6791fb0fa0efea /pacman-c++/server.cpp | |
| parent | 3b8237b434c9a094dafebbf364b89ab2f4cbd460 (diff) | |
| download | foop-6c44b14d2bae2120c069ab205f95b2e51de2caea.tar.gz foop-6c44b14d2bae2120c069ab205f95b2e51de2caea.tar.bz2 foop-6c44b14d2bae2120c069ab205f95b2e51de2caea.zip | |
make constants::server extern
code cleanup
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 | } |
