QTfrontend/game.h
changeset 178 efdc2a63be8e
parent 177 c67c15e6fae3
child 180 ea83b9e9057f
equal deleted inserted replaced
177:c67c15e6fae3 178:efdc2a63be8e
    51 #define SENDIPC(a) SendIPC(a, sizeof(a) - 1)
    51 #define SENDIPC(a) SendIPC(a, sizeof(a) - 1)
    52 
    52 
    53 class GameUIConfig;
    53 class GameUIConfig;
    54 class GameCFGWidget;
    54 class GameCFGWidget;
    55 
    55 
    56 class HWGame : public QObject
    56 class HWGame : public TCPBase
    57 {
    57 {
    58 	Q_OBJECT
    58 	Q_OBJECT
    59 public:
    59 public:
    60 	HWGame(GameUIConfig * config, GameCFGWidget * gamecfg);
    60 	HWGame(GameUIConfig * config, GameCFGWidget * gamecfg);
    61 	void AddTeam(const QString & team, unsigned char numHedgedogs);
    61 	void AddTeam(const QString & team, unsigned char numHedgedogs);
    65 	void StartNet();
    65 	void StartNet();
    66 
    66 
    67  protected:
    67  protected:
    68 	virtual QStringList setArguments();
    68 	virtual QStringList setArguments();
    69 	virtual void onClientRead();
    69 	virtual void onClientRead();
       
    70 	virtual void onClientDisconnect();
    70 
    71 
    71 signals:
    72 signals:
    72 	void SendNet(const QByteArray & msg);
    73 	void SendNet(const QByteArray & msg);
    73 
    74 
    74 public slots:
    75 public slots:
    81         gtLocal  = 1,
    82         gtLocal  = 1,
    82         gtQLocal = 2,
    83         gtQLocal = 2,
    83         gtDemo   = 3,
    84         gtDemo   = 3,
    84         gtNet    = 4
    85         gtNet    = 4
    85     };
    86     };
    86     QTcpServer * IPCServer;
       
    87 	QTcpSocket * IPCSocket;
       
    88 	char msgbuf[MAXMSGCHARS];
    87 	char msgbuf[MAXMSGCHARS];
    89 	QByteArray readbuffer;
       
    90 	QString teams[5];
    88 	QString teams[5];
    91 	std::map<QString, unsigned char> hdNum;
    89 	std::map<QString, unsigned char> hdNum;
    92 	QString seed;
    90 	QString seed;
    93 	int TeamCount;
    91 	int TeamCount;
    94 	QByteArray * demo;
    92 	QByteArray * demo;
    95 	QByteArray toSendBuf;
    93 	QByteArray toSendBuf;
    96 	GameUIConfig * config;
    94 	GameUIConfig * config;
    97 	GameCFGWidget * gamecfg;
    95 	GameCFGWidget * gamecfg;
    98 	GameType gameType;
    96 	GameType gameType;
    99 
    97 
   100 	void Start();
       
   101 	void SendConfig();
    98 	void SendConfig();
   102 	void SendQuickConfig();
    99 	void SendQuickConfig();
   103 	void SendTeamConfig(int index);
   100 	void SendTeamConfig(int index);
   104 	void ParseMessage(const QByteArray & msg);
   101 	void ParseMessage(const QByteArray & msg);
   105 	void SendIPC(const char * msg, quint8 len);
   102 	void SendIPC(const char * msg, quint8 len);
   106 	void SendIPC(const QByteArray & buf);
   103 	void SendIPC(const QByteArray & buf);
   107 	void SendIPC(const QString & buf);
   104 	void SendIPC(const QString & buf);
   108 	void RawSendIPC(const QByteArray & buf);
   105 	void RawSendIPC(const QByteArray & buf);
   109 	void SaveDemo(const QString & filename);
   106 	void SaveDemo(const QString & filename);
   110 
       
   111 private slots:
       
   112 	void NewConnection();
       
   113 	void ClientDisconnect();
       
   114 	void ClientRead();
       
   115 	void StartProcessError(QProcess::ProcessError error);
       
   116 };
   107 };
   117 
   108 
   118 #endif
   109 #endif