QTfrontend/netconnectedclient.cpp
author unc0rr
Sat, 10 Feb 2007 15:07:35 +0000
changeset 425 a7e1dabc8fb7
parent 420 6cdfc07dceed
child 443 eec37eb7f5db
permissions -rw-r--r--
- Better AI thinking behavior - Fix segfaul + more messageboxes with HWForm as parent instead of parent being 0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
420
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     1
/*
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     2
 * Hedgewars, a worms-like game
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     3
 * Copyright (c) 2006 Igor Ulyanov <iulyanov@gmail.com>
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     4
 *
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     8
 *
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    12
 * GNU General Public License for more details.
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    13
 *
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    17
 */
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    18
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    19
#include "netconnectedclient.h"
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    20
#include "netserver.h"
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    21
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    22
#include <QTcpServer>
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    23
#include <QTcpSocket>
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    24
#include <QStringList>
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    25
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    26
#include <QDebug>
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    27
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    28
extern char delimeter;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    29
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    30
HWConnectedClient::HWConnectedClient(HWNetServer* hwserver, QTcpSocket* client) :
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    31
  readyToStart(false),
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    32
  m_hwserver(hwserver),
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    33
  m_client(client)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    34
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    35
  connect(client, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    36
  connect(client, SIGNAL(readyRead()), this, SLOT(ClientRead()));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    37
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    38
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    39
HWConnectedClient::~HWConnectedClient()
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    40
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    41
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    42
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    43
void HWConnectedClient::ClientDisconnect()
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    44
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    45
  emit(HWClientDisconnected(this));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    46
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    47
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    48
void HWConnectedClient::ClientRead()
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    49
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    50
  try {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    51
    while (m_client->canReadLine()) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    52
      ParseLine(m_client->readLine().trimmed());
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    53
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    54
  } catch(ShouldDisconnectException& e) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    55
    m_client->close();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    56
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    57
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    58
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    59
void HWConnectedClient::ParseLine(const QByteArray & line)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    60
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    61
  QString msg = QString::fromUtf8 (line.data(), line.size());
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    62
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    63
  QStringList lst = msg.split(delimeter);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    64
  if(!lst.size()) return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    65
  if (lst[0] == "NICK") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    66
    if(lst.size()<2) return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    67
    if(m_hwserver->haveNick(lst[1])) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    68
      RawSendNet(QString("ERRONEUSNICKNAME"));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    69
      throw ShouldDisconnectException();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    70
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    71
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    72
    client_nick=lst[1];
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    73
    qDebug() << "send connected";
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    74
    RawSendNet(QString("CONNECTED"));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    75
    if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED"));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    76
    else {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    77
      RawSendNet(QString("SLAVE"));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    78
      // send teams
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    79
      QList<QStringList> team_conf=m_hwserver->getTeamsConfig();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    80
      for(QList<QStringList>::iterator tmit=team_conf.begin(); tmit!=team_conf.end(); ++tmit) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    81
	RawSendNet(QString("ADDTEAM:")+delimeter+tmit->join(QString(delimeter)));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    82
      }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    83
      // send config
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    84
      QMap<QString, QStringList> conf=m_hwserver->getGameCfg();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    85
      qDebug() << "Config:";
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    86
      for(QMap<QString, QStringList>::iterator it=conf.begin(); it!=conf.end(); ++it) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    87
	RawSendNet(QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter)));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    88
	qDebug() << QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    89
      }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    90
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    91
    return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    92
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    93
  if(client_nick=="") return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    94
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    95
  if (lst[0]=="START:") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    96
    readyToStart=true;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    97
    if(m_hwserver->shouldStart(this)) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    98
      // start
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
    99
      m_hwserver->sendAll("RUNGAME");
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   100
      m_hwserver->resetStart();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   101
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   102
    return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   103
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   104
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   105
  if(lst[0]=="CONFIG_PARAM") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   106
    if(!m_hwserver->isChiefClient(this) || lst.size()<3) return; // error or permission denied :)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   107
    else m_hwserver->m_gameCfg[lst[1]]=lst.mid(2);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   108
    qDebug() << msg;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   109
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   110
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   111
  if(lst[0]=="ADDTEAM:") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   112
    if(lst.size()<11) return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   113
    lst.pop_front();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   114
    
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   115
    // add team ID
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   116
    static unsigned int netTeamID=0;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   117
    lst.insert(1, QString::number(++netTeamID));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   118
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   119
    // hedgehogs num count
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   120
    int maxAdd=18-m_hwserver->hhnum;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   121
    if (maxAdd<=0) return; // reject command
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   122
    int toAdd=maxAdd<4 ? maxAdd : 4;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   123
    m_hwserver->hhnum+=toAdd;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   124
    // hedgehogs num config
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   125
    QString hhnumCfg=QString("CONFIG_PARAM%1HHNUM+%2+%3%1%4").arg(delimeter).arg(lst[0])\
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   126
      .arg(netTeamID)\
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   127
      .arg(toAdd);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   128
    
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   129
    // creating color config for new team
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   130
    QString colorCfg=QString("CONFIG_PARAM%1TEAM_COLOR+%2+%3%1%4").arg(delimeter).arg(lst[0])\
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   131
      .arg(netTeamID)\
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   132
      .arg(lst.takeAt(2));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   133
    qDebug() << "color config:" << colorCfg;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   134
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   135
    m_hwserver->m_gameCfg[colorCfg.split(delimeter)[1]]=colorCfg.split(delimeter).mid(2);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   136
    m_hwserver->m_gameCfg[hhnumCfg.split(delimeter)[1]]=hhnumCfg.split(delimeter).mid(2);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   137
    m_teamsCfg.push_back(lst);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   138
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   139
    m_hwserver->sendOthers(this, QString("ADDTEAM:")+delimeter+lst.join(QString(delimeter)));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   140
    RawSendNet(QString("TEAM_ACCEPTED%1%2%1%3").arg(delimeter).arg(lst[0]).arg(lst[1]));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   141
    m_hwserver->sendAll(colorCfg);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   142
    m_hwserver->sendAll(hhnumCfg);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   143
    return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   144
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   145
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   146
  if(lst[0]=="REMOVETEAM:") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   147
    if(lst.size()<2) return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   148
    
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   149
    for(QMap<QString, QStringList>::iterator it=m_hwserver->m_gameCfg.begin(); it!=m_hwserver->m_gameCfg.end(); ++it) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   150
      QStringList hhTmpList=it.key().split('+');
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   151
      if(hhTmpList[0] == "HHNUM") {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   152
	qDebug() << "hhnum config found";
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   153
	if(hhTmpList[1]==lst[1]) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   154
	  qDebug() << "hhnum config team found with: " << lst[1] << ":" << it.value()[0].toUInt();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   155
	  m_hwserver->hhnum-=it.value()[0].toUInt();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   156
	  break;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   157
	}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   158
      }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   159
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   160
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   161
    unsigned int netID=removeTeam(lst[1]);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   162
    m_hwserver->sendOthers(this, QString("REMOVETEAM:")+delimeter+lst[1]+delimeter+QString::number(netID));
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   163
    qDebug() << QString("REMOVETEAM:")+delimeter+lst[1]+delimeter+QString::number(netID);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   164
    return;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   165
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   166
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   167
  m_hwserver->sendOthers(this, msg);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   168
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   169
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   170
unsigned int HWConnectedClient::removeTeam(const QString& tname)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   171
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   172
  unsigned int netID=0;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   173
  for(QList<QStringList>::iterator it=m_teamsCfg.begin(); it!=m_teamsCfg.end(); ++it) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   174
    if((*it)[0]==tname) {
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   175
      netID=(*it)[1].toUInt();
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   176
      m_teamsCfg.erase(it);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   177
      break;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   178
    }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   179
  }
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   180
  return netID;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   181
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   182
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   183
QList<QStringList> HWConnectedClient::getTeamNames() const
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   184
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   185
  return m_teamsCfg;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   186
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   187
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   188
void HWConnectedClient::RawSendNet(const QString & str)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   189
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   190
  RawSendNet(str.toUtf8());
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   191
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   192
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   193
void HWConnectedClient::RawSendNet(const QByteArray & buf)
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   194
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   195
  m_client->write(buf);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   196
  m_client->write("\n", 1);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   197
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   198
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   199
QString HWConnectedClient::getClientNick() const
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   200
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   201
  return client_nick;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   202
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   203
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   204
bool HWConnectedClient::isReady() const
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   205
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   206
  return readyToStart;
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   207
}
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   208
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   209
QString HWConnectedClient::getHedgehogsDescription() const
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   210
{
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   211
  return QString();//pclent_team->TeamGameConfig(65535, 4, 100, true).join((QString)delimeter);
6cdfc07dceed netserver and netonnectedclient splited to different files
displacer
parents:
diff changeset
   212
}