QTfrontend/netserver.h
author unc0rr
Thu, 06 Sep 2007 15:31:52 +0000
changeset 585 7531ae5b146e
parent 486 7ea71cd3acd5
child 658 a7e625f5d9d0
permissions -rw-r--r--
Rename PageLocalGame -> PageSimpleGame due to future changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     1
/*
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     2
 * Hedgewars, a worms-like game
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 465
diff changeset
     3
 * Copyright (c) 2006, 2007 Igor Ulyanov <iulyanov@gmail.com>
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     4
 *
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     8
 *
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    12
 * GNU General Public License for more details.
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    13
 *
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    17
 */
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    18
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    19
#ifndef _NETSERVER_INCLUDED
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    20
#define _NETSERVER_INCLUDED
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    21
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    22
#include <QObject>
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    23
#include <QList>
335
751348947fce CONFIG_PARAM for storing config
displacer
parents: 334
diff changeset
    24
#include <QMap>
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    25
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    26
#include "team.h"
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    27
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    28
class HWNetServer;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    29
class QTcpSocket;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    30
class QTcpServer;
420
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents: 404
diff changeset
    31
class HWConnectedClient;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    32
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    33
class HWNetServer : public QObject
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    34
{
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    35
  Q_OBJECT
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    36
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    37
 public:
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    38
  void StartServer();
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    39
  void StopServer();
326
c6718bfdd642 Small fixes
unc0rr
parents: 319
diff changeset
    40
  bool isChiefClient(HWConnectedClient* cl) const;
354
60e4af0a4375 network to local teams map, addteams from server before team config bug, fixed some segfaults
displacer
parents: 352
diff changeset
    41
  QMap<QString, QStringList> getGameCfg() const;
319
7f3bd9e31f18 some changes
displacer
parents: 317
diff changeset
    42
  void sendAll(QString gameCfg);
7f3bd9e31f18 some changes
displacer
parents: 317
diff changeset
    43
  void sendOthers(HWConnectedClient* this_cl, QString gameCfg);
465
07eca0a2546c chatWidget with nicks ready
displacer
parents: 420
diff changeset
    44
  void sendNicks(HWConnectedClient* cl) const;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    45
  bool haveNick(const QString& nick) const;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    46
  QString getRunningHostName() const;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    47
  quint16 getRunningPort() const;
338
d1e75dcd285f multiple teams now available per host (still alpha)
displacer
parents: 335
diff changeset
    48
  QList<QStringList> getTeamsConfig() const;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    49
  void teamChanged();
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    50
  bool shouldStart(HWConnectedClient* client);
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    51
  QString prepareConfig(QStringList lst);
388
dcf5335940bd repeated start now allowed
displacer
parents: 354
diff changeset
    52
  void resetStart();
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    53
404
64a62b679b04 final bugfixes :)
displacer
parents: 399
diff changeset
    54
  QMap<QString, QStringList> m_gameCfg; // config_param - value
399
c7da1bd32b4e more correct network hhnum
displacer
parents: 388
diff changeset
    55
  int hhnum;
c7da1bd32b4e more correct network hhnum
displacer
parents: 388
diff changeset
    56
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    57
 private:
334
85eacbd9827f protocol changes
displacer
parents: 326
diff changeset
    58
  HWConnectedClient* getChiefClient() const;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    59
  static const quint16 ds_port;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    60
  QTcpServer* IPCServer;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    61
  QList<HWConnectedClient*> connclients;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    62
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    63
 private slots:
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    64
  void NewConnection();
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    65
  void ClientDisconnect(HWConnectedClient* client);
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    66
};
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    67
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    68
#endif // _NETSERVER_INCLUDED