blob: 826c70129f0ce8c41bda356e5e0c0df1f41283a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef SERVER_H
#define SERVER_H
#include "sceneholder.h"
#include "actor.h"
#include "pacman.pb.h"
#include <QtGui>
#include <QHostAddress>
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:
QMap<Color::Color, QTcpSocket *> m_clientConnections;
QList<Color::Color> m_bots;
/* current movements. required to make pacmans continue their movement */
QMap<Color::Color, Actor::Movement> m_actorMovements;
/* allocate as member variable as this packet is large and used often */
ProtoBuf::MapUpdate m_updatepacket;
/* list of blocks */
QList<QPoint> m_blocks;
/* currently colored blocks + tickcount before they will turn to non-colored back */
QMap<QPoint, unsigned int> m_coloredBlocks;
QHostAddress m_bindaddress;
unsigned int m_port;
unsigned int m_maxplayers;
unsigned int m_numbots;
};
#endif // SERVER_H
|