QTfrontend/netserver.h
author unc0rr
Wed, 14 Feb 2007 20:05:20 +0000
changeset 442 57ed1444606e
parent 420 6cdfc07dceed
child 465 07eca0a2546c
permissions -rw-r--r--
- Fix bad fix from previous revision .) - Update translation
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
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
     3
 * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
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);
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    44
  bool haveNick(const QString& nick) const;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    45
  QString getRunningHostName() const;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    46
  quint16 getRunningPort() const;
338
d1e75dcd285f multiple teams now available per host (still alpha)
displacer
parents: 335
diff changeset
    47
  QList<QStringList> getTeamsConfig() const;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    48
  void teamChanged();
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    49
  bool shouldStart(HWConnectedClient* client);
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    50
  QString prepareConfig(QStringList lst);
388
dcf5335940bd repeated start now allowed
displacer
parents: 354
diff changeset
    51
  void resetStart();
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    52
404
64a62b679b04 final bugfixes :)
displacer
parents: 399
diff changeset
    53
  QMap<QString, QStringList> m_gameCfg; // config_param - value
399
c7da1bd32b4e more correct network hhnum
displacer
parents: 388
diff changeset
    54
  int hhnum;
c7da1bd32b4e more correct network hhnum
displacer
parents: 388
diff changeset
    55
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    56
 private:
334
85eacbd9827f protocol changes
displacer
parents: 326
diff changeset
    57
  HWConnectedClient* getChiefClient() const;
315
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    58
  static const quint16 ds_port;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    59
  QTcpServer* IPCServer;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    60
  QList<HWConnectedClient*> connclients;
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    61
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    62
 private slots:
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    63
  void NewConnection();
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    64
  void ClientDisconnect(HWConnectedClient* client);
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    65
};
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    66
73003488240b client/server net pre-alpha
displacer
parents:
diff changeset
    67
#endif // _NETSERVER_INCLUDED