QTfrontend/team.h
author sheepluva
Sat, 24 Sep 2011 22:14:10 +0200
changeset 6015 daffc14a518a
parent 4976 088d40d8aba2
child 6024 d38da7c19e43
permissions -rw-r--r--
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
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
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 3758
diff changeset
     3
 * Copyright (c) 2005-2011 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
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
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;
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    41
    int Rounds, Kills, Deaths, Suicides;
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    42
};
b18a166e6ca4 Frontend:
smxx
parents: 3236
diff changeset
    43
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
    44
// class representing a team
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    45
class HWTeam
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    46
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    47
    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
    48
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
    49
        // constructors
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    50
        HWTeam(const QString & teamname);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    51
        HWTeam(const QStringList& strLst);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
    52
        HWTeam();
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    53
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
    54
        // file operations
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
    55
        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
    56
        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
    57
        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
    58
        bool fileExists();
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
    59
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
        // attribute getters
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
         unsigned int campaignProgress() const;
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
               QColor color() const;
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
         unsigned int difficulty() const;
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
    64
              QString flag() const;
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
              QString fort() const;
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
              QString grave() const;
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
    67
        const HWHog & hedgehog(unsigned int idx) const;
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
    68
                 bool isNetTeam() const;
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
    69
              QString name() const;
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
    70
        unsigned char numHedgehogs() const;
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
    71
              QString owner() const;
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
    72
              QString voicepack() const;
352
4665bfe25470 first buggy hedgehogs num net change
displacer
parents: 348
diff changeset
    73
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
    74
        // attribute setters
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
    75
        void setColor(const QColor & color);
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
    76
        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
    77
        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
    78
        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
    79
        void setGrave(const QString & 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
    80
        void setHedgehog(unsigned int idx, const HWHog & hh);
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
        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
    82
        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
    83
        void setVoicepack(const QString & voicepack);
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
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
        // increments for statistical info
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 incRounds();
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
    87
        void incWins();
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
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
        // pages... wait... wth is THIS doing in this class? FIXME!!!!
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 SetToPage(HWForm * hwform);
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
    91
        void GetFromPage(HWForm * hwform);
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
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
    94
        QStringList teamGameConfig(quint32 InitHealth) const;
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
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
    97
        bool operator==(const HWTeam& t1) const;
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
    98
        bool operator<(const HWTeam& t1) const;
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
    99
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
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
   101
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
   102
    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
   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
        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
   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
        // 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
   107
        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
   108
        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
   109
        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
   110
        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
   111
        QString m_voicepack;
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
        HWHog m_hedgehogs[HEDGEHOGS_PER_TEAM];
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
        unsigned int m_difficulty;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2747
diff changeset
   114
        BindAction binds[BINDS_NUMBER];
341
184230eb4151 - Store more team specific values in HWTeam
unc0rr
parents: 339
diff changeset
   115
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
   116
        // class members that contain info for the current game setup
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
   117
        unsigned char m_numHedgehogs;
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
        QColor m_color;
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
   119
        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
   120
        QString m_owner;
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   121
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
   122
        // 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
   123
        unsigned int m_campaignProgress;
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
        unsigned int m_rounds;
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 m_wins;
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
   126
        unsigned int AchievementProgress[MAX_ACHIEVEMENTS];
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   127
1840
4747f0232b88 ttsmj2's random teams patch
unc0rr
parents: 1683
diff changeset
   128
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   129
};
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   130
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   131
#endif