QTfrontend/team.cpp
branchflibqtfrontend
changeset 8103 c247346d296f
parent 8100 0e6fadf81a2c
child 8106 861d145b270e
equal deleted inserted replaced
8100:0e6fadf81a2c 8103:c247346d296f
    27 
    27 
    28 #include "team.h"
    28 #include "team.h"
    29 #include "hwform.h"
    29 #include "hwform.h"
    30 #include "DataManager.h"
    30 #include "DataManager.h"
    31 
    31 
    32 HWTeam::HWTeam(const QString & teamname) :
    32 HWTeam::HWTeam(const QString & teamname, QObject *parent) :
    33     QObject(0)
    33     QObject(parent)
    34     , m_difficulty(0)
    34 {
    35     , m_numHedgehogs(4)
    35     flib_team team;
    36     , m_isNetTeam(false)
    36     bzero(&team, sizeof(team));
    37     , m_team(NULL)
    37     team.name = teamname.toUtf8().data();
    38 {
    38     team.grave = "Statue";
    39     m_name = teamname;
    39     team.fort = "Plane";
    40     OldTeamName = m_name;
    40     team.voicepack = "Default";
       
    41     team.flag = "hedgewars";
       
    42 
    41     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    43     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    42     {
    44     {
    43         m_hedgehogs.append(HWHog());
    45         team.hogs[i].name = QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8().data();
    44         m_hedgehogs[i].Name = (QLineEdit::tr("hedgehog %1").arg(i+1));
    46         team.hogs[i].hat = "NoHat";
    45         m_hedgehogs[i].Hat = "NoHat";
    47     }
    46     }
    48 
    47     m_grave = "Statue";
    49     m_oldTeamName = teamname;
    48     m_fort = "Plane";
    50 
    49     m_voicepack = "Default";
    51     QVector<flib_binding> binds(BINDS_NUMBER);
    50     m_flag = "hedgewars";
       
    51     for(int i = 0; i < BINDS_NUMBER; i++)
    52     for(int i = 0; i < BINDS_NUMBER; i++)
    52     {
    53     {
    53         m_binds.append(BindAction());
    54         binds[i].action = cbinds[i].action.toUtf8().data();
    54         m_binds[i].action = cbinds[i].action;
    55         binds[i].binding = cbinds[i].strbind.toUtf8().data();
    55         m_binds[i].strbind = cbinds[i].strbind;
    56     }
    56     }
    57     team.bindings = binds.data();
    57     m_rounds = 0;
    58     team.bindingCount = binds.size();
    58     m_wins = 0;
    59 
    59     m_campaignProgress = 0;
    60     team.remoteDriven = false;
    60     m_color = 0;
    61     team.hogsInGame = 4;
    61 }
    62 
    62 
    63     m_team = flib_team_copy(&team);
    63 HWTeam::HWTeam(const QStringList& strLst) :
    64 }
    64     QObject(0)
    65 
    65     , m_numHedgehogs(4)
    66 HWTeam::HWTeam(const QStringList& strLst, QObject *parent) :
    66     , m_isNetTeam(true)
    67     QObject(parent)
    67     , m_team(NULL)
       
    68 {
    68 {
    69     // net teams are configured from QStringList
    69     // net teams are configured from QStringList
    70     if(strLst.size() != 23) throw HWTeamConstructException();
    70     if(strLst.size() != 23) throw HWTeamConstructException();
    71     m_name = strLst[0];
    71     flib_team team;
    72     m_grave = strLst[1];
    72     bzero(&team, sizeof(team));
    73     m_fort = strLst[2];
    73     team.name = strLst[0].toUtf8().data();
    74     m_voicepack = strLst[3];
    74     m_oldTeamName = strLst[0];
    75     m_flag = strLst[4];
    75     team.grave = strLst[1].toUtf8().data();
    76     m_owner = strLst[5];
    76     team.fort = strLst[2].toUtf8().data();
    77     m_difficulty = strLst[6].toUInt();
    77     team.voicepack = strLst[3].toUtf8().data();
    78     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    78     team.flag = strLst[4].toUtf8().data();
    79     {
    79     team.ownerName = strLst[5].toUtf8().data();
    80         m_hedgehogs.append(HWHog());
    80     int difficulty = strLst[6].toUInt();
    81         m_hedgehogs[i].Name=strLst[i * 2 + 7];
    81 
    82         m_hedgehogs[i].Hat=strLst[i * 2 + 8];
       
    83 // Somehow claymore managed an empty hat.  Until we figure out how, this should avoid a repeat
       
    84 // Checking net teams is probably pointless, but can't hurt.
       
    85         if (m_hedgehogs[i].Hat.isEmpty()) m_hedgehogs[i].Hat = "NoHat";
       
    86     }
       
    87     m_rounds = 0;
       
    88     m_wins = 0;
       
    89     m_campaignProgress = 0;
       
    90     m_color = 0;
       
    91 }
       
    92 
       
    93 HWTeam::HWTeam() :
       
    94     QObject(0)
       
    95     , m_difficulty(0)
       
    96     , m_numHedgehogs(4)
       
    97     , m_isNetTeam(false)
       
    98     , m_team(NULL)
       
    99 {
       
   100     m_name = QString("Team");
       
   101     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    82     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   102     {
    83     {
   103         m_hedgehogs.append(HWHog());
    84         team.hogs[i].name = strLst[i * 2 + 7].toUtf8().data();
   104         m_hedgehogs[i].Name.sprintf("hedgehog %d", i);
    85 
   105         m_hedgehogs[i].Hat = "NoHat";
    86         QString hat = strLst[i * 2 + 8];
   106     }
    87         if (hat.isEmpty())
   107 
    88             team.hogs[i].hat = "NoHat";
   108     m_grave = QString("Simple"); // default
    89         else
   109     m_fort = QString("Island"); // default
    90             team.hogs[i].hat = hat.toUtf8().data();
   110     m_voicepack = "Default";
    91 
   111     m_flag = "hedgewars";
    92         team.hogs[i].difficulty = difficulty;
   112 
    93     }
       
    94 
       
    95     m_oldTeamName = strLst[0];
       
    96 
       
    97     QVector<flib_binding> binds(BINDS_NUMBER);
   113     for(int i = 0; i < BINDS_NUMBER; i++)
    98     for(int i = 0; i < BINDS_NUMBER; i++)
   114     {
    99     {
   115         m_binds.append(BindAction());
   100         binds[i].action = cbinds[i].action.toUtf8().data();
   116         m_binds[i].action = cbinds[i].action;
   101         binds[i].binding = cbinds[i].strbind.toUtf8().data();
   117         m_binds[i].strbind = cbinds[i].strbind;
   102     }
   118     }
   103     team.bindings = binds.data();
   119     m_rounds = 0;
   104     team.bindingCount = binds.size();
   120     m_wins = 0;
   105 
   121     m_campaignProgress = 0;
   106     team.remoteDriven = true;
   122     m_color = 0;
   107     team.hogsInGame = 4;
   123 }
   108 
       
   109     m_team = flib_team_copy(&team);
       
   110 }
       
   111 
   124 
   112 
   125 HWTeam::HWTeam(const HWTeam & other) :
   113 HWTeam::HWTeam(const HWTeam & other) :
   126     QObject(0)
   114     QObject(other.parent())
   127     , OldTeamName(other.OldTeamName)
   115     , m_oldTeamName(other.m_oldTeamName)
   128     , m_name(other.m_name)
       
   129     , m_grave(other.m_grave)
       
   130     , m_fort(other.m_fort)
       
   131     , m_flag(other.m_flag)
       
   132     , m_voicepack(other.m_voicepack)
       
   133     , m_hedgehogs(other.m_hedgehogs)
       
   134     , m_difficulty(other.m_difficulty)
       
   135     , m_binds(other.m_binds)
       
   136     , m_team(flib_team_copy(other.m_team))
   116     , m_team(flib_team_copy(other.m_team))
   137     , m_numHedgehogs(other.m_numHedgehogs)
       
   138     , m_color(other.m_color)
       
   139     , m_isNetTeam(other.m_isNetTeam)
       
   140     , m_owner(other.m_owner)
       
   141     , m_campaignProgress(other.m_campaignProgress)
       
   142     , m_rounds(other.m_rounds)
       
   143     , m_wins(other.m_wins)
       
   144 //      , AchievementProgress(other.AchievementProgress)
       
   145 {
   117 {
   146 
   118 
   147 }
   119 }
   148 
   120 
   149 HWTeam & HWTeam::operator = (const HWTeam & other)
   121 HWTeam & HWTeam::operator = (const HWTeam & other)
   150 {
   122 {
   151     if(this != &other)
   123     if(this != &other)
   152     {
   124     {
   153         OldTeamName = other.OldTeamName;
   125         m_oldTeamName = other.m_oldTeamName;
   154         m_name = other.m_name;
   126         m_team = flib_team_copy(other.m_team);
   155         m_grave = other.m_grave;
       
   156         m_fort = other.m_fort;
       
   157         m_flag = other.m_flag;
       
   158         m_voicepack = other.m_voicepack;
       
   159         m_hedgehogs = other.m_hedgehogs;
       
   160         m_difficulty = other.m_difficulty;
       
   161         m_binds = other.m_binds;
       
   162         m_numHedgehogs = other.m_numHedgehogs;
       
   163         m_color = other.m_color;
       
   164         m_isNetTeam = other.m_isNetTeam;
       
   165         m_owner = other.m_owner;
       
   166         m_campaignProgress = other.m_campaignProgress;
       
   167         m_rounds = other.m_rounds;
       
   168         m_wins = other.m_wins;
       
   169         m_color = other.m_color;
       
   170     }
   127     }
   171 
   128 
   172     return *this;
   129     return *this;
   173 }
   130 }
   174 
   131 
   178         flib_team_destroy(m_team);
   135         flib_team_destroy(m_team);
   179 }
   136 }
   180 
   137 
   181 bool HWTeam::loadFromFile()
   138 bool HWTeam::loadFromFile()
   182 {
   139 {
       
   140     QString name = QString::fromUtf8(m_team->name);
       
   141 
   183     if(m_team)
   142     if(m_team)
   184         flib_team_destroy(m_team);
   143         flib_team_destroy(m_team);
   185 
   144 
   186     m_team = flib_team_from_ini(QString("/config/Teams/%1.hwt").arg(m_name).toUtf8().constData());
   145     m_team = flib_team_from_ini(QString("/config/Teams/%1.hwt").arg(name).toUtf8().data());
   187 
   146 
   188     /*
       
   189     QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0);
       
   190     teamfile.setIniCodec("UTF-8");
       
   191     m_name = teamfile.value("Team/Name", m_name).toString();
       
   192     m_grave = teamfile.value("Team/Grave", "Statue").toString();
       
   193     m_fort = teamfile.value("Team/Fort", "Plane").toString();
       
   194     m_voicepack = teamfile.value("Team/Voicepack", "Default").toString();
       
   195     m_flag = teamfile.value("Team/Flag", "hedgewars").toString();
       
   196     m_difficulty = teamfile.value("Team/Difficulty", 0).toInt();
       
   197     m_rounds = teamfile.value("Team/Rounds", 0).toInt();
       
   198     m_wins = teamfile.value("Team/Wins", 0).toInt();
       
   199     m_campaignProgress = teamfile.value("Team/CampaignProgress", 0).toInt();
       
   200     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
       
   201     {
       
   202         QString hh = QString("Hedgehog%1/").arg(i);
       
   203         m_hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i+1)).toString();
       
   204         m_hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString();
       
   205         m_hedgehogs[i].Rounds = teamfile.value(hh + "Rounds", 0).toInt();
       
   206         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
       
   207         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
       
   208         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
       
   209     }
       
   210     for(int i = 0; i < BINDS_NUMBER; i++)
       
   211         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
       
   212     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
       
   213         if(achievements[i][0][0])
       
   214             AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt();
       
   215         else
       
   216             break;*/
       
   217     return m_team != NULL;
   147     return m_team != NULL;
   218 }
   148 }
   219 
   149 
   220 bool HWTeam::fileExists()
   150 bool HWTeam::fileExists()
   221 {
   151 {
   222     QFile f(QString("physfs://config/Teams/%1.hwt").arg(m_name));
   152     QFile f(QString("physfs://config/Teams/%1.hwt").arg(name()));
   223     return f.exists();
   153     return f.exists();
   224 }
   154 }
   225 
   155 
   226 bool HWTeam::deleteFile()
   156 bool HWTeam::deleteFile()
   227 {
   157 {
   228     if(m_isNetTeam)
   158     if(m_team->remoteDriven)
   229         return false;
   159         return false;
   230     QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(m_name));
   160 
       
   161     QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(name()));
   231     cfgfile.remove();
   162     cfgfile.remove();
   232     return true;
   163     return true;
   233 }
   164 }
   234 
   165 
   235 bool HWTeam::saveToFile()
   166 bool HWTeam::saveToFile()
   236 {
   167 {
   237     if (OldTeamName != m_name)
   168     if (m_oldTeamName != name())
   238     {
   169     {
   239         QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(OldTeamName));
   170         QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(m_oldTeamName));
   240         cfgfile.remove();
   171         cfgfile.remove();
   241         OldTeamName = m_name;
   172         m_oldTeamName = name();
   242     }
   173     }
   243     QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0);
   174 
   244     teamfile.setIniCodec("UTF-8");
   175     return flib_team_to_ini(QString("physfs://config/Teams/%1.hwt").arg(name()).toUtf8(), m_team) == 0;
   245     teamfile.setValue("Team/Name", m_name);
   176 }
   246     teamfile.setValue("Team/Grave", m_grave);
   177 
   247     teamfile.setValue("Team/Fort", m_fort);
       
   248     teamfile.setValue("Team/Voicepack", m_voicepack);
       
   249     teamfile.setValue("Team/Flag", m_flag);
       
   250     teamfile.setValue("Team/Difficulty", m_difficulty);
       
   251     teamfile.setValue("Team/Rounds", m_rounds);
       
   252     teamfile.setValue("Team/Wins", m_wins);
       
   253     teamfile.setValue("Team/CampaignProgress", m_campaignProgress);
       
   254     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
       
   255     {
       
   256         QString hh = QString("Hedgehog%1/").arg(i);
       
   257         teamfile.setValue(hh + "Name", m_hedgehogs[i].Name);
       
   258         teamfile.setValue(hh + "Hat", m_hedgehogs[i].Hat);
       
   259         teamfile.setValue(hh + "Rounds", m_hedgehogs[i].Rounds);
       
   260         teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills);
       
   261         teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths);
       
   262         teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides);
       
   263     }
       
   264     for(int i = 0; i < BINDS_NUMBER; i++)
       
   265         teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind);
       
   266     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
       
   267         if(achievements[i][0][0])
       
   268             teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]);
       
   269         else
       
   270             break;
       
   271     return true;
       
   272 }
       
   273 
       
   274 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const
       
   275 {
       
   276     QStringList sl;
       
   277     if (m_isNetTeam)
       
   278     {
       
   279         sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toUtf8(), QCryptographicHash::Md5).toHex())));
       
   280         sl.push_back("erdriven");
       
   281     }
       
   282     else sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(playerHash));
       
   283 
       
   284     sl.push_back(QString("egrave " + m_grave));
       
   285     sl.push_back(QString("efort " + m_fort));
       
   286     sl.push_back(QString("evoicepack " + m_voicepack));
       
   287     sl.push_back(QString("eflag " + m_flag));
       
   288 
       
   289     if (!m_isNetTeam)
       
   290         for(int i = 0; i < BINDS_NUMBER; i++)
       
   291             if(!m_binds[i].strbind.isEmpty())
       
   292                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
       
   293 
       
   294     for (int t = 0; t < m_numHedgehogs; t++)
       
   295     {
       
   296         sl.push_back(QString("eaddhh %1 %2 %3")
       
   297                      .arg(QString::number(m_difficulty),
       
   298                           QString::number(InitHealth),
       
   299                           m_hedgehogs[t].Name));
       
   300         sl.push_back(QString("ehat %1")
       
   301                      .arg(m_hedgehogs[t].Hat));
       
   302     }
       
   303     return sl;
       
   304 }
       
   305 
   178 
   306 bool HWTeam::isNetTeam() const
   179 bool HWTeam::isNetTeam() const
   307 {
   180 {
   308     return m_isNetTeam;
   181     return m_team->remoteDriven;
   309 }
   182 }
   310 
   183 
   311 
   184 
   312 bool HWTeam::operator==(const HWTeam& t1) const
   185 bool HWTeam::operator==(const HWTeam& t1) const
   313 {
   186 {
   314     return m_name==t1.m_name;
   187     return qstrcmp(m_team->name, t1.m_team->name) == 0;
   315 }
   188 }
   316 
   189 
   317 bool HWTeam::operator<(const HWTeam& t1) const
   190 bool HWTeam::operator<(const HWTeam& t1) const
   318 {
   191 {
   319     return m_name<t1.m_name; // if names are equal - test if it is net team
   192     return qstrcmp(m_team->name, t1.m_team->name) < 0; // if names are equal - test if it is net team
   320 }
   193 }
   321 
   194 
   322 
   195 
   323 //// Methods for member inspection+modification ////
   196 //// Methods for member inspection+modification ////
   324 
   197 
   325 
   198 
   326 // name
   199 // name
   327 QString HWTeam::name() const
   200 QString HWTeam::name() const
   328 {
   201 {
   329     return m_name;
   202     return QString::fromUtf8(m_team->name);
   330 }
   203 }
       
   204 
   331 void HWTeam::setName(const QString & name)
   205 void HWTeam::setName(const QString & name)
   332 {
   206 {
   333     m_name = name;
   207     free(m_team->name);
   334 }
   208 
   335 
   209     m_team->name = qstrdup(name.toUtf8().constData());
   336 // single hedgehog
   210 }
   337 const HWHog & HWTeam::hedgehog(unsigned int idx) const
   211 
   338 {
   212 QString HWTeam::hedgehogName(int index) const
   339     return m_hedgehogs[idx];
   213 {
   340 }
   214     return QString::fromUtf8(m_team->hogs[index].name);
   341 void HWTeam::setHedgehog(unsigned int idx, HWHog hh)
   215 }
   342 {
   216 
   343     m_hedgehogs[idx] = hh;
   217 QString HWTeam::hedgehogHat(int index) const
   344 }
   218 {
       
   219     return QString::fromUtf8(m_team->hogs[index].hat);
       
   220 }
       
   221 
       
   222 void HWTeam::setHedgehogName(int index, const QString & name)
       
   223 {
       
   224     free(m_team->hogs[index].name);
       
   225 
       
   226     m_team->hogs[index].name = qstrdup(name.toUtf8().constData());
       
   227 }
       
   228 
       
   229 void HWTeam::setHedgehogHat(int index, const QString & hat)
       
   230 {
       
   231     free(m_team->hogs[index].hat);
       
   232 
       
   233     m_team->hogs[index].hat = qstrdup(hat.toUtf8().constData());
       
   234 }
       
   235 
   345 
   236 
   346 // owner
   237 // owner
   347 QString HWTeam::owner() const
   238 QString HWTeam::owner() const
   348 {
   239 {
   349     return m_owner;
   240     return QString::fromUtf8(m_team->ownerName);
   350 }
   241 }
   351 
   242 
   352 
   243 
   353 
   244 
   354 // difficulty
   245 // difficulty
   355 unsigned int HWTeam::difficulty() const
   246 unsigned int HWTeam::difficulty() const
   356 {
   247 {
   357     return m_difficulty;
   248     return m_team->hogs[0].difficulty;
   358 }
   249 }
       
   250 
   359 void HWTeam::setDifficulty(unsigned int level)
   251 void HWTeam::setDifficulty(unsigned int level)
   360 {
   252 {
   361     m_difficulty = level;
   253     for(int i = 0; i < HEDGEHOGS_PER_TEAM; ++i)
       
   254         m_team->hogs[i].difficulty = level;
   362 }
   255 }
   363 
   256 
   364 // color
   257 // color
   365 int HWTeam::color() const
   258 int HWTeam::color() const
   366 {
   259 {
   367     return m_color;
   260     return m_team->colorIndex;
   368 }
   261 }
   369 
   262 
   370 QColor HWTeam::qcolor() const
   263 QColor HWTeam::qcolor() const
   371 {
   264 {
   372     return DataManager::instance().colorsModel()->item(m_color)->data().value<QColor>();
   265     return DataManager::instance().colorsModel()->item(m_team->colorIndex)->data().value<QColor>();
   373 }
   266 }
   374 
   267 
   375 void HWTeam::setColor(int color)
   268 void HWTeam::setColor(int color)
   376 {
   269 {
   377     m_color = color % DataManager::instance().colorsModel()->rowCount();
   270     m_team->colorIndex = color % DataManager::instance().colorsModel()->rowCount();
   378 }
   271 }
   379 
   272 
   380 
   273 
   381 // binds
   274 // binds
   382 QString HWTeam::keyBind(unsigned int idx) const
   275 QString HWTeam::keyBind(unsigned int idx) const
   383 {
   276 {
   384     return m_binds[idx].strbind;
   277     return QString::fromUtf8(m_team->bindings[idx].binding);
   385 }
   278 }
       
   279 
   386 void HWTeam::bindKey(unsigned int idx, const QString & key)
   280 void HWTeam::bindKey(unsigned int idx, const QString & key)
   387 {
   281 {
   388     m_binds[idx].strbind = key;
   282     free(m_team->bindings[idx].binding);
       
   283 
       
   284     m_team->bindings[idx].binding = qstrdup(key.toUtf8().constData());
   389 }
   285 }
   390 
   286 
   391 // flag
   287 // flag
   392 void    HWTeam::setFlag(const QString & flag)
   288 void HWTeam::setFlag(const QString & flag)
   393 {
   289 {
   394     m_flag = flag;
   290     free(m_team->flag);
   395 }
   291 
       
   292     m_team->flag = strdup(flag.toUtf8().constData());
       
   293 }
       
   294 
   396 QString HWTeam::flag() const
   295 QString HWTeam::flag() const
   397 {
   296 {
   398     return m_flag;
   297     return QString::fromUtf8(m_team->flag);
   399 }
   298 }
   400 
   299 
   401 // fort
   300 // fort
   402 void    HWTeam::setFort(const QString & fort)
   301 void HWTeam::setFort(const QString & fort)
   403 {
   302 {
   404     m_fort = fort;
   303     free(m_team->fort);
   405 }
   304 
       
   305     m_team->fort = strdup(fort.toUtf8().constData());
       
   306 }
       
   307 
   406 QString HWTeam::fort() const
   308 QString HWTeam::fort() const
   407 {
   309 {
   408     return m_fort;
   310     return QString::fromUtf8(m_team->fort);
   409 }
   311 }
   410 
   312 
   411 // grave
   313 // grave
   412 void HWTeam::setGrave(const QString & grave)
   314 void HWTeam::setGrave(const QString & grave)
   413 {
   315 {
   414     m_grave = grave;
   316     free(m_team->grave);
   415 }
   317 
       
   318     m_team->grave = strdup(grave.toUtf8().constData());
       
   319 }
       
   320 
   416 QString HWTeam::grave() const
   321 QString HWTeam::grave() const
   417 {
   322 {
   418     return m_grave;
   323     return QString::fromUtf8(m_team->grave);
   419 }
   324 }
   420 
   325 
   421 // voicepack - getter/setter
   326 // voicepack - getter/setter
   422 void HWTeam::setVoicepack(const QString & voicepack)
   327 void HWTeam::setVoicepack(const QString & voicepack)
   423 {
   328 {
   424     m_voicepack = voicepack;
   329     free(m_team->voicepack);
   425 }
   330 
       
   331     m_team->voicepack = strdup(voicepack.toUtf8().constData());
       
   332 }
       
   333 
   426 QString HWTeam::voicepack() const
   334 QString HWTeam::voicepack() const
   427 {
   335 {
   428     return m_voicepack;
   336     return QString::fromUtf8(m_team->voicepack);
   429 }
   337 }
   430 
   338 
   431 
   339 
   432 // campaignProgress - getter
   340 // campaignProgress - getter
   433 unsigned int HWTeam::campaignProgress() const
   341 unsigned int HWTeam::campaignProgress() const
   434 {
   342 {
   435     return m_campaignProgress;
   343     return m_team->campaignProgress;
   436 };
   344 }
   437 
   345 
   438 // amount of hedgehogs
   346 // amount of hedgehogs
   439 unsigned char HWTeam::numHedgehogs() const
   347 unsigned char HWTeam::numHedgehogs() const
   440 {
   348 {
   441     return m_numHedgehogs;
   349     return m_team->hogsInGame;
   442 }
   350 }
       
   351 
   443 void HWTeam::setNumHedgehogs(unsigned char num)
   352 void HWTeam::setNumHedgehogs(unsigned char num)
   444 {
   353 {
   445     m_numHedgehogs = num;
   354     m_team->hogsInGame = num;
   446 }
   355 }
   447 
       
   448 
       
   449 
   356 
   450 // rounds+wins - incrementors
   357 // rounds+wins - incrementors
   451 void HWTeam::incRounds()
   358 void HWTeam::incRounds()
   452 {
   359 {
   453     m_rounds++;
   360     m_team->rounds++;
   454 }
   361 }
   455 void HWTeam::incWins()
   362 void HWTeam::incWins()
   456 {
   363 {
   457     m_wins++;
   364     m_team->wins++;
   458 }
   365 }