QTfrontend/team.cpp
author displacer
Sun, 12 Nov 2006 20:15:58 +0000
changeset 231 c77b16e48273
parent 184 f97a7a3dc8f6
child 239 f9adf3c73bed
permissions -rw-r--r--
bots power icons added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     2
 * Hedgewars, a worms-like game
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     3
 * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     4
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
#include <QFile>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#include <QTextStream>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
#include <QApplication>
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    22
#include <QSpinBox>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    23
#include "team.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    24
#include "hwform.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include "predefteams.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    26
#include "pages.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    27
#include "hwconsts.h"
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    29
HWTeam::HWTeam(const QString & teamname) :
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    30
  difficulty(0)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    31
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    32
	TeamName = teamname;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    33
	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    34
	Grave = "Simple";
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    35
	Fort = "Barrelhouse";
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    36
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    37
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    38
		binds[i].action = cbinds[i].action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    39
		binds[i].strbind = cbinds[i].strbind;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    40
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    41
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    42
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    43
HWTeam::HWTeam(quint8 num) :
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
    44
  difficulty(0)
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    45
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    46
	num %= PREDEFTEAMS_COUNT;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    47
	TeamName = QApplication::translate("teams", pteams[num].TeamName);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    48
	HHName[0] = QApplication::translate("teams", pteams[num].hh0name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    49
	HHName[1] = QApplication::translate("teams", pteams[num].hh1name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    50
	HHName[2] = QApplication::translate("teams", pteams[num].hh2name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    51
	HHName[3] = QApplication::translate("teams", pteams[num].hh3name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    52
	HHName[4] = QApplication::translate("teams", pteams[num].hh4name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    53
	HHName[5] = QApplication::translate("teams", pteams[num].hh5name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    54
	HHName[6] = QApplication::translate("teams", pteams[num].hh6name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    55
	HHName[7] = QApplication::translate("teams", pteams[num].hh7name);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    56
	Grave = pteams[num].Grave;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    57
	Fort = pteams[num].Fort;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    58
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    59
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    60
		binds[i].action = cbinds[i].action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    61
		binds[i].strbind = cbinds[i].strbind;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    62
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    63
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    64
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    65
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    66
bool HWTeam::LoadFromFile()
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    67
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    68
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    69
	if (!cfgfile.open(QIODevice::ReadOnly)) return false;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    70
	QTextStream stream(&cfgfile);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    71
	stream.setCodec("UTF-8");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    72
	QString str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    73
	QString action;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    74
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    75
	while (!stream.atEnd())
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    76
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    77
		str = stream.readLine();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    78
		if (str.startsWith(";")) continue;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    79
		if (str.startsWith("name team "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    80
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    81
			str.remove(0, 10);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    82
			TeamName = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    83
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    84
		if (str.startsWith("name hh"))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    85
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    86
			str.remove(0, 7);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    87
			long i = str.left(1).toLong();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    88
			if ((i < 0) || (i > 7)) continue;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    89
			str.remove(0, 2);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    90
			HHName[i] = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    91
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    92
		if (str.startsWith("grave "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    93
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    94
			str.remove(0, 6);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    95
			Grave = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    96
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    97
		if (str.startsWith("fort "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    98
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    99
			str.remove(0, 5);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   100
			Fort = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   101
		} else
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   102
		if (str.startsWith("bind "))
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   103
		{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   104
			str.remove(0, 5);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   105
			action = str.section(' ', 1);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   106
			str = str.section(' ', 0, 0);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   107
			str.truncate(15);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   108
			for (int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   109
				if (action == binds[i].action)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   110
				{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   111
					binds[i].strbind = str;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   112
					break;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   113
				}
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   114
		} else 
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   115
		if (str.startsWith("difficulty "))
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   116
		{
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   117
		  str.remove(0, 11);
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   118
		  difficulty=str.toUInt();
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   119
		  if (difficulty>5) difficulty=0; // this shouldn't normally happen
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   120
		}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   121
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   122
	cfgfile.close();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   123
	return true;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   124
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   125
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
bool HWTeam::SaveToFile()
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   127
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   128
	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   129
	if (!cfgfile.open(QIODevice::WriteOnly)) return false;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   130
	QTextStream stream(&cfgfile);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   131
	stream.setCodec("UTF-8");
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   132
	stream << "; Generated by Hedgewars, do not modify" << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   133
	stream << "name team " << TeamName << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   134
	for (int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   135
		stream << "name hh" << i << " " << HHName[i] << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   136
	stream << "grave " << Grave << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   137
	stream << "fort " << Fort << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   138
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   139
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   140
		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   141
	}
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   142
	stream << "difficulty " << difficulty << endl;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   143
	cfgfile.close();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   144
	return true;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   145
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   146
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   147
void HWTeam::SetToPage(HWForm * hwform)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   148
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   149
	hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName);
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   150
	hwform->ui.pageEditTeam->difficultyBox->setValue(difficulty);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   151
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   152
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   153
		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   154
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   155
	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   156
	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   157
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   158
	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   159
	hwform->ui.pageEditTeam->CBFort_activated(Fort);
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   160
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   161
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   162
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   163
		hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findText(binds[i].strbind));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   164
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   165
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   166
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   167
void HWTeam::GetFromPage(HWForm * hwform)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   168
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   169
	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
231
c77b16e48273 bots power icons added
displacer
parents: 184
diff changeset
   170
	difficulty = hwform->ui.pageEditTeam->difficultyBox->value();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   171
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   172
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   173
		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   174
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   175
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   176
	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   177
	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   178
	for(int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   179
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   180
		binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->currentText();
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   181
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   182
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   183
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   184
QByteArray HWTeam::IPCTeamInfo() const
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   185
{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   186
	QByteArray buf;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   187
	#define ADD(a) { \
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   188
					QByteArray strmsg = a.toUtf8(); \
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   189
					quint8 sz = strmsg.size(); \
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   190
					buf.append(QByteArray((char *)&sz, 1)); \
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   191
					buf.append(strmsg); \
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   192
					}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   193
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   194
	ADD(QString("ename team " + TeamName));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   195
	for (int i = 0; i < 8; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   196
		ADD(QString("ename hh%1 ").arg(i).append(HHName[i]));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   197
	ADD(QString("egrave " + Grave));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   198
	ADD(QString("efort " + Fort));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   199
	for(int i = 0; i < BINDS_NUMBER; i++)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   200
	{
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   201
		ADD(QString("ebind " + binds[i].strbind + " " + binds[i].action));
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   202
	}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   203
	#undef ADD
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   204
	return buf;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   205
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   206
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   207
bool HWTeam::operator==(const HWTeam& t1) const {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   208
  return TeamName==t1.TeamName;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   209
}
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   210
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   211
bool HWTeam::operator<(const HWTeam& t1) const {
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   212
  return TeamName<t1.TeamName;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   213
}