diff options
Diffstat (limited to 'pacman-c++/server.cpp')
| -rw-r--r-- | pacman-c++/server.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index 7e467e5..0a84561 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp | |||
| @@ -52,8 +52,11 @@ Transmission::map_t Server::calculateUpdates() | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | // <t3h g4m3 10gic> | 54 | // <t3h g4m3 10gic> |
| 55 | if(dynamic_cast<Block*>(visualMap[newMapPosition.x()][newMapPosition.y()]) != 0) { | 55 | if (0 <= newMapPosition.x() && newMapPosition.x() < visualMap.size() && |
| 56 | continue; | 56 | 0 <= newMapPosition.y() && newMapPosition.y() < visualMap[newMapPosition.x()].size()) { |
| 57 | if(dynamic_cast<Block*>(visualMap[newMapPosition.x()][newMapPosition.y()]) != 0) { | ||
| 58 | continue; | ||
| 59 | } | ||
| 57 | } | 60 | } |
| 58 | // </t3h g4m2 10gic> | 61 | // </t3h g4m2 10gic> |
| 59 | 62 | ||
| @@ -75,6 +78,12 @@ QSharedPointer< ProtoBuf::MapUpdate > Server::createUpdatePacket(Transmission::m | |||
| 75 | updatePacket->add_field(map[x][y]); | 78 | updatePacket->add_field(map[x][y]); |
| 76 | } | 79 | } |
| 77 | } | 80 | } |
| 81 | updatePacket->set_round_points_red(m_actors.value(Color::red)->getRoundPoints()); | ||
| 82 | updatePacket->set_game_points_red(m_actors.value(Color::red)->getGamePoints()); | ||
| 83 | updatePacket->set_round_points_green(m_actors.value(Color::green)->getRoundPoints()); | ||
| 84 | updatePacket->set_game_points_green(m_actors.value(Color::green)->getGamePoints()); | ||
| 85 | updatePacket->set_round_points_blue(m_actors.value(Color::blue)->getRoundPoints()); | ||
| 86 | updatePacket->set_game_points_blue(m_actors.value(Color::blue)->getGamePoints()); | ||
| 78 | //qDebug() << "field sz "<< updatePacket->field_size(); | 87 | //qDebug() << "field sz "<< updatePacket->field_size(); |
| 79 | return updatePacket; | 88 | return updatePacket; |
| 80 | } | 89 | } |
| @@ -85,9 +94,14 @@ void Server::waitForClientConnections() | |||
| 85 | // server must stay alive as long as sockets (qt parent mem mechanism) | 94 | // server must stay alive as long as sockets (qt parent mem mechanism) |
| 86 | tcpSrv->listen(QHostAddress::Any, Constants::port); | 95 | tcpSrv->listen(QHostAddress::Any, Constants::port); |
| 87 | 96 | ||
| 97 | #define SINGLE | ||
| 98 | |||
| 88 | Color::Color playerColors[3] = { Color::red, Color::blue, Color::green }; | 99 | Color::Color playerColors[3] = { Color::red, Color::blue, Color::green }; |
| 89 | //for (unsigned int i=0; i<Color::max; ++i) { | 100 | #ifdef SINGLE |
| 90 | for (unsigned int i=0; i<1; ++i) { | 101 | for (unsigned int i=0; i<1; ++i) { |
| 102 | #else | ||
| 103 | for (unsigned int i=0; i<Color::max; ++i) { | ||
| 104 | #endif | ||
| 91 | bool connectionAvailable = tcpSrv->waitForNewConnection(-1); | 105 | bool connectionAvailable = tcpSrv->waitForNewConnection(-1); |
| 92 | Q_ASSERT(connectionAvailable); | 106 | Q_ASSERT(connectionAvailable); |
| 93 | QTcpSocket *socket = tcpSrv->nextPendingConnection(); | 107 | QTcpSocket *socket = tcpSrv->nextPendingConnection(); |
