QTfrontend/team.h
author Grigory Ustinov <grenka@altlinux.org>
Fri, 02 Nov 2018 16:59:55 +0100
changeset 14089 78bf5eecfe6a
parent 13713 3264a26bbf8b
child 14482 4b678aad50e9
permissions -rw-r--r--
Update Russian frontend translation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 486
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10400
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
486
7ea71cd3acd5 - Change proto version to 4
unc0rr
parents: 352
diff changeset
     4
 * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#ifndef TEAM_H
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
#define TEAM_H
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    22
207
287077789132 coosing colors added
displacer
parents: 184
diff changeset
    23
#include <QColor>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    24
#include <QString>
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    25
#include "binds.h"
3344
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    26
#include "achievements.h"
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    27
#include "hwconsts.h"
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    29
class HWForm;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    30
class GameUIConfig;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    31
314
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    32
class HWTeamConstructException
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    33
{
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    34
};
83773ccf4f09 client/server net pre-alpha
displacer
parents: 312
diff changeset
    35
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    36
// structure for customization and statistics of a single hedgehog
3344
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    37
struct HWHog
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    38
{
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    39
    QString Name;
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    40
    QString Hat;
10248
7b9b44a051f8 Fix some of issues found by coverity
unc0rr
parents: 10108
diff changeset
    41
13713
3264a26bbf8b Remove frontend code dealing with unused team variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12675
diff changeset
    42
    HWHog(){}
3344
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    43
};
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    44
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    45
// class representing a team
6223
cc3eb9b7230f It doesn't make much sense to make checks like 'if(game)' if you never set game to 0. Using smart pointers instead. Does it fix segfaults? Probably.
unc0rr
parents: 6024
diff changeset
    46
class HWTeam : public QObject
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    47
{
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    48
        Q_OBJECT
6223
cc3eb9b7230f It doesn't make much sense to make checks like 'if(game)' if you never set game to 0. Using smart pointers instead. Does it fix segfaults? Probably.
unc0rr
parents: 6024
diff changeset
    49
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    50
    public:
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    51
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    52
        // constructors
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    53
        HWTeam(const QString & teamname);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    54
        HWTeam(const QStringList& strLst);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    55
        HWTeam();
6225
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
    56
        HWTeam(const HWTeam & other);
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    57
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    58
        // file operations
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 6015
diff changeset
    59
        static HWTeam loadFromFile(const QString & teamName);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    60
        bool loadFromFile();
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    61
        bool deleteFile();
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    62
        bool saveToFile();
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    63
        bool fileExists();
12675
967990d958bc Fix possibility to accidentally destroy team by entering an already existing team name
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    64
        bool wouldOverwriteOtherFile();
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    65
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    66
        // attribute getters
7130
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 6952
diff changeset
    67
        int color() const;
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 6952
diff changeset
    68
        QColor qcolor() const;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    69
        unsigned int difficulty() const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    70
        QString flag() const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    71
        QString fort() const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    72
        QString grave() const;
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    73
        const HWHog & hedgehog(unsigned int idx) const;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    74
        bool isNetTeam() const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    75
        QString keyBind(unsigned int idx) const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    76
        QString name() const;
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    77
        unsigned char numHedgehogs() const;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    78
        QString owner() const;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6225
diff changeset
    79
        QString voicepack() const;
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    80
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    81
        // attribute setters
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 6015
diff changeset
    82
        void bindKey(unsigned int idx, const QString & key);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    83
        void setDifficulty(unsigned int level);
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    84
        void setFlag(const QString & flag);
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    85
        void setFort(const QString & fort);
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    86
        void setGrave(const QString & grave);
6024
d38da7c19e43 some more cleanups and refactoring.
sheepluva
parents: 6015
diff changeset
    87
        void setHedgehog(unsigned int idx, HWHog hh);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    88
        void setName(const QString & name);
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    89
        void setNumHedgehogs(unsigned char num);
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    90
        void setVoicepack(const QString & voicepack);
10400
47e2189eae44 This should make frontend aware of your own teams in game on rejoin
unc0rr
parents: 10248
diff changeset
    91
        void setNetTeam(bool isNetTeam);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    92
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    93
        // convert team info into strings for further computation
9466
8b48c27201af - Load default binds from settings.ini
unc0rr
parents: 9080
diff changeset
    94
        QStringList teamGameConfig(quint32 InitHealth) const;
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    95
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
    96
        // comparison operators
6225
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
    97
        bool operator == (const HWTeam& t1) const;
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
    98
        bool operator < (const HWTeam& t1) const;
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
    99
        HWTeam & operator = (const HWTeam & other);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   100
7130
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 6952
diff changeset
   101
public slots:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 6952
diff changeset
   102
        void setColor(int color);
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   103
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   104
    private:
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   105
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   106
        QString OldTeamName;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   107
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   108
        // class members that contain the general team info and settings
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   109
        QString m_name;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   110
        QString m_grave;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   111
        QString m_fort;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   112
        QString m_flag;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   113
        QString m_voicepack;
7131
c0c787eb526e Make frontend compile with clang
unc0rr
parents: 7130
diff changeset
   114
        QList<HWHog> m_hedgehogs;
6225
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
   115
        quint8 m_difficulty;
7131
c0c787eb526e Make frontend compile with clang
unc0rr
parents: 7130
diff changeset
   116
        QList<BindAction> m_binds;
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   117
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   118
        // class members that contain info for the current game setup
6225
505643d4c23d disconnect when going back from lobby page (regression fix)
sheepluva
parents: 6223
diff changeset
   119
        quint8 m_numHedgehogs;
7130
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents: 6952
diff changeset
   120
        int m_color;
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   121
        bool m_isNetTeam;
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   122
        QString m_owner;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   123
6015
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   124
        // class members that contain statistics, etc.
daffc14a518a cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents: 4976
diff changeset
   125
        unsigned int AchievementProgress[MAX_ACHIEVEMENTS];
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
};
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   127
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   128
#endif