#ifndef SERVER_H #define SERVER_H #include "sceneholder.h" #include "actor.h" #include "pacman.pb.h" #include #include class QTcpSocket; class Server : public SceneHolder { Q_OBJECT public: Server(QWidget *parent = 0); bool parseCommandline(); bool run(); protected slots: void tick(); /* receive updates of client */ void keyPressUpdate(); protected: /* block until we have connections from all clients */ bool waitForClientConnections(); /* calculate updates of current tick for sending to client */ Transmission::map_t calculateUpdates(); /* update client maps */ void sendUpdate(Transmission::map_t map, bool firstPacket = false); QPoint addRandomPoint(Transmission::map_t map, Transmission::field_t type = Transmission::bonuspoint); void colorizeBlocks(Transmission::map_t map); void botCalculate(Actor *actor); protected slots: // TODO: call this when a pacman get's eaten void onRoundFinished(); // called when a round is finished protected: void initRoundMap(bool firstPacket = false); // creates new round map protected: QMap m_clientConnections; QList m_bots; /* current movements. required to make pacmans continue their movement */ QMap m_actorMovements; /* allocate as member variable as this packet is large and used often */ ProtoBuf::MapUpdate m_updatepacket; /* list of blocks */ QList m_blocks; /* currently colored blocks + tickcount before they will turn to non-colored back */ QMap m_coloredBlocks; QHostAddress m_bindaddress; unsigned int m_port; unsigned int m_maxplayers; unsigned int m_rounds; // number of rounds (>= 1) unsigned int m_numbots; unsigned int m_curRound; // current round starting with 0 QTimer *m_tickTimer; }; #endif // SERVER_H