diff options
| author | manuel <manuel@mausz.at> | 2011-05-05 00:57:07 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-05-05 00:57:07 +0200 |
| commit | ce48af53646cd9e7ec762fc1ac176b3aa620b11d (patch) | |
| tree | f8fbf2cae8c7d0cbac2696a8f4cf94410bfb4928 /pacman-c++/server.h | |
| parent | e54ccad07e256ba877bd41d70bd358bd0085bd1e (diff) | |
| download | foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.gz foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.bz2 foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.zip | |
- refactorized the whole project and made a few subprojects
- replaced tcp with enet
- added connect dialog
- some smaller bugfixes
Diffstat (limited to 'pacman-c++/server.h')
| -rw-r--r-- | pacman-c++/server.h | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/pacman-c++/server.h b/pacman-c++/server.h deleted file mode 100644 index 41b800e..0000000 --- a/pacman-c++/server.h +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | #ifndef SERVER_H | ||
| 2 | #define SERVER_H | ||
| 3 | |||
| 4 | #include "sceneholder.h" | ||
| 5 | #include "actor.h" | ||
| 6 | #include "pacman.pb.h" | ||
| 7 | #include <QtGui> | ||
| 8 | #include <QHostAddress> | ||
| 9 | |||
| 10 | class QTcpSocket; | ||
| 11 | |||
| 12 | class Server | ||
| 13 | : public SceneHolder | ||
| 14 | { | ||
| 15 | Q_OBJECT | ||
| 16 | public: | ||
| 17 | Server(QWidget *parent = 0); | ||
| 18 | bool parseCommandline(); | ||
| 19 | bool run(); | ||
| 20 | |||
| 21 | protected slots: | ||
| 22 | void tick(); | ||
| 23 | |||
| 24 | /* receive updates of client */ | ||
| 25 | void keyPressUpdate(); | ||
| 26 | |||
| 27 | protected: | ||
| 28 | /* block until we have connections from all clients */ | ||
| 29 | bool waitForClientConnections(); | ||
| 30 | |||
| 31 | /* calculate updates of current tick for sending to client */ | ||
| 32 | Transmission::map_t calculateUpdates(); | ||
| 33 | |||
| 34 | /* update client maps */ | ||
| 35 | void sendUpdate(Transmission::map_t map, bool firstPacket = false); | ||
| 36 | |||
| 37 | QPoint addRandomPoint(Transmission::map_t map, Transmission::field_t type = Transmission::bonuspoint); | ||
| 38 | void colorizeBlocks(Transmission::map_t map); | ||
| 39 | void botCalculate(Actor *actor); | ||
| 40 | void initRoundMap(); | ||
| 41 | |||
| 42 | protected slots: | ||
| 43 | /* called when a round is started/finished */ | ||
| 44 | void startGame(); | ||
| 45 | void stopGame(bool delay = false); | ||
| 46 | void setFinishRound(); | ||
| 47 | |||
| 48 | protected: | ||
| 49 | QMap<Color::Color, QTcpSocket *> m_clientConnections; | ||
| 50 | QList<Color::Color> m_bots; | ||
| 51 | |||
| 52 | /* current movements. required to make pacmans continue their movement */ | ||
| 53 | QMap<Color::Color, Actor::Movement> m_actorMovements; | ||
| 54 | |||
| 55 | /* allocate as member variable as this packet is large and used often */ | ||
| 56 | ProtoBuf::MapUpdate m_updatepacket; | ||
| 57 | |||
| 58 | /* list of blocks */ | ||
| 59 | QList<QPoint> m_blocks; | ||
| 60 | /* currently colored blocks + tickcount before they will turn to non-colored back */ | ||
| 61 | QMap<QPoint, unsigned int> m_coloredBlocks; | ||
| 62 | |||
| 63 | QHostAddress m_bindaddress; | ||
| 64 | unsigned int m_port; | ||
| 65 | unsigned int m_maxplayers; | ||
| 66 | unsigned int m_numbots; | ||
| 67 | /* number of rounds (>= 1) */ | ||
| 68 | unsigned int m_rounds; | ||
| 69 | /* current round, starting at 0 */ | ||
| 70 | unsigned int m_curRound; | ||
| 71 | bool m_running; | ||
| 72 | bool m_finishRound; | ||
| 73 | |||
| 74 | QTimer *m_tickTimer; | ||
| 75 | |||
| 76 | }; | ||
| 77 | |||
| 78 | #endif // SERVER_H | ||
