From 6c44b14d2bae2120c069ab205f95b2e51de2caea Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 11 Apr 2011 13:42:28 +0200 Subject: make constants::server extern code cleanup --- pacman-c++/server.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'pacman-c++/server.cpp') 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() // TODO: support actors eating each other // old item PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; - if (oldItem != NULL) { - if (oldItem->eaten()) { + if (oldItem != NULL) + { + if (oldItem->eaten()) map[mapPosition.x()][mapPosition.y()] = Transmission::empty; - } } // new item PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; - if (item != NULL && oldItem != item) { - if (! item->checkEnter(actor)) { // movement invalid + if (item != NULL && oldItem != item) + { + if (! item->checkEnter(actor)) + { + // movement invalid newMapPosition = mapPosition; - } else { // apply actions of entering this field + } + else + { + // apply actions of entering this field bool survive = item->enter(actor); - if (!survive) { + if (!survive) + { //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; } } @@ -197,6 +204,7 @@ void Server::keyPressUpdate() } } +bool Constants::server = true; int main(int argc, char ** argv) { @@ -208,7 +216,6 @@ int main(int argc, char ** argv) qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - Constants::server = true; Server Server; return app.exec(); } -- cgit v1.2.3