diff options
| author | totycro <totycro@unknown-horizons.org> | 2011-04-11 12:37:29 +0200 |
|---|---|---|
| committer | totycro <totycro@unknown-horizons.org> | 2011-04-11 12:37:29 +0200 |
| commit | 51a3559e5df31018d7de14357f83c24e7e508d7e (patch) | |
| tree | 89db0899d182dd5b3b770b07c8646dd80c915d4e /pacman-c++/server.cpp | |
| parent | 98f4a31e1a359a69dbcc0fa4055f36cefb6d4e02 (diff) | |
| download | foop-51a3559e5df31018d7de14357f83c24e7e508d7e.tar.gz foop-51a3559e5df31018d7de14357f83c24e7e508d7e.tar.bz2 foop-51a3559e5df31018d7de14357f83c24e7e508d7e.zip | |
progress
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index b631345..4656238 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp | |||
| @@ -75,20 +75,31 @@ Transmission::map_t Server::calculateUpdates() | |||
| 75 | 75 | ||
| 76 | // <t3h g4m3 10gic> | 76 | // <t3h g4m3 10gic> |
| 77 | // TODO: support actors eating each other | 77 | // TODO: support actors eating each other |
| 78 | // old item | ||
| 79 | PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; | ||
| 80 | if (oldItem != NULL) { | ||
| 81 | if (oldItem->eaten()) { | ||
| 82 | map[mapPosition.x()][mapPosition.y()] = Transmission::empty; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | // new item | ||
| 78 | PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; | 86 | PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; |
| 79 | if (item != NULL) { | 87 | if (item != NULL && oldItem != item) { |
| 80 | if (! item->checkEnter(actor)) { // movement invalid | 88 | if (! item->checkEnter(actor)) { // movement invalid |
| 81 | newMapPosition = mapPosition; | 89 | newMapPosition = mapPosition; |
| 82 | } else { // apply actions of entering this field | 90 | } else { // apply actions of entering this field |
| 83 | item->enter(actor); | 91 | bool survive = item->enter(actor); |
| 92 | if (!survive) { | ||
| 93 | //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; | ||
| 94 | } | ||
| 84 | } | 95 | } |
| 85 | } | 96 | } |
| 86 | // </t3h g4m2 10gic> | 97 | // </t3h g4m2 10gic> |
| 87 | 98 | ||
| 88 | if (mapPosition != newMapPosition) | 99 | if (mapPosition != newMapPosition) |
| 89 | { | 100 | { |
| 90 | map[mapPosition.x()][mapPosition.y()] = Transmission::empty; | 101 | //map[mapPosition.x()][mapPosition.y()] = Transmission::empty; |
| 91 | map[newMapPosition.x()][newMapPosition.y()] = | 102 | map[newMapPosition.x()][newMapPosition.y()] |= |
| 92 | Transmission::pacman | i.key() | | 103 | Transmission::pacman | i.key() | |
| 93 | Util::actorMovementToTransmission(i.value()) ; | 104 | Util::actorMovementToTransmission(i.value()) ; |
| 94 | } | 105 | } |
