--- a/QTfrontend/game.cpp Sun Nov 25 22:17:11 2012 +0400
+++ b/QTfrontend/game.cpp Mon Nov 26 00:06:42 2012 +0400
@@ -117,45 +117,6 @@
commonConfig();
}
-void HWGame::SendQuickConfig()
-{
- QByteArray teamscfg;
- ThemeModel * themeModel = DataManager::instance().themeModel();
-
- HWProto::addStringToBuffer(teamscfg, "TL");
- HWProto::addStringToBuffer(teamscfg, QString("etheme %1")
- .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data().toString() : "steel"));
- HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString());
-
- HWProto::addStringToBuffer(teamscfg, "e$template_filter 2");
-
- HWTeam team1;
- team1.setDifficulty(0);
- team1.setColor(0);
- team1.setNumHedgehogs(4);
- HWNamegen::teamRandomNames(team1, true);
-// HWProto::addStringListToBuffer(teamscfg,
-// team1.teamGameConfig(100));
-
- HWTeam team2;
- team2.setDifficulty(4);
- team2.setColor(1);
- team2.setNumHedgehogs(4);
- do
- HWNamegen::teamRandomNames(team2,true);
- while(!team2.name().compare(team1.name()) || !team2.hedgehogHat(0).compare(team1.hedgehogHat(0)));
-// HWProto::addStringListToBuffer(teamscfg,
-// team2.teamGameConfig(100));
-
- HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber)));
- HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber)));
- HWProto::addStringToBuffer(teamscfg, QString("eammdelay %1").arg(cDefaultAmmoStore->mid(2 * cAmmoNumber, cAmmoNumber)));
- HWProto::addStringToBuffer(teamscfg, QString("eammreinf %1").arg(cDefaultAmmoStore->mid(3 * cAmmoNumber, cAmmoNumber)));
- HWProto::addStringToBuffer(teamscfg, QString("eammstore"));
- HWProto::addStringToBuffer(teamscfg, QString("eammstore"));
- //RawSendIPC(teamscfg);
-}
-
void HWGame::SendTrainingConfig()
{
QByteArray traincfg;
@@ -181,7 +142,7 @@
{
commonConfig();
}
-
+/*
void HWGame::ParseMessage(const QByteArray & msg)
{
switch(msg.at(1))
@@ -286,7 +247,7 @@
//demo.append(msg);
}
}
-}
+}*/
void HWGame::FromNet(const QByteArray & msg)
{
@@ -377,14 +338,7 @@
{
ThemeModel * themeModel = DataManager::instance().themeModel();
gameType = gtQLocal;
-/*
-typedef struct {
- char *style; // e.g. "Capture the Flag"
- flib_scheme *gamescheme;
- flib_map *map;
- flib_teamlist *teamlist;
-} flib_gamesetup;
- */
+
flib_gamesetup gameSetup;
gameSetup.style = NULL;
gameSetup.gamescheme = flib_scheme_create("Default");
@@ -394,8 +348,31 @@
, 3);
gameSetup.teamlist = flib_teamlist_create();
+ { // add teams
+ HWTeam team1;
+ team1.setDifficulty(0);
+ team1.setColor(0);
+ team1.setNumHedgehogs(4);
+ HWNamegen::teamRandomNames(team1, true);
+
+ HWTeam team2;
+ team2.setDifficulty(4);
+ team2.setColor(1);
+ team2.setNumHedgehogs(4);
+ do
+ HWNamegen::teamRandomNames(team2,true);
+ while(!team2.name().compare(team1.name()) || !team2.hedgehogHat(0).compare(team1.hedgehogHat(0)));
+
+ flib_teamlist_insert(gameSetup.teamlist, team1.toFlibTeam(), 0);
+ flib_teamlist_insert(gameSetup.teamlist, team2.toFlibTeam(), 1);
+ }
+
m_conn = flib_gameconn_create(config->netNick().toUtf8().constData(), &gameSetup, false);
+ flib_teamlist_destroy(gameSetup.teamlist);
+ flib_map_destroy(gameSetup.map);
+ flib_scheme_destroy(gameSetup.gamescheme);
+
start(false);
SetGameState(gsStarted);
}
--- a/QTfrontend/game.h Sun Nov 25 22:17:11 2012 +0400
+++ b/QTfrontend/game.h Mon Nov 26 00:06:42 2012 +0400
@@ -109,11 +109,9 @@
void commonConfig();
void SendConfig();
- void SendQuickConfig();
void SendNetConfig();
void SendTrainingConfig();
void SendCampaignConfig();
- void ParseMessage(const QByteArray & msg);
void SetGameState(GameState state);
void sendCampaignVar(const QByteArray & varToSend);
void writeCampaignVar(const QByteArray &varVal);
--- a/QTfrontend/team.cpp Sun Nov 25 22:17:11 2012 +0400
+++ b/QTfrontend/team.cpp Mon Nov 26 00:06:42 2012 +0400
@@ -32,9 +32,12 @@
HWTeam::HWTeam(const QString & teamname, QObject *parent) :
QObject(parent)
{
+ QList<QByteArray> baList;
+
flib_team team;
bzero(&team, sizeof(team));
- team.name = teamname.toUtf8().data();
+ baList << teamname.toUtf8();
+ team.name = baList.last().data();
team.grave = "Statue";
team.fort = "Plane";
team.voicepack = "Default";
@@ -42,7 +45,8 @@
for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
{
- team.hogs[i].name = QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8().data();
+ baList << QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8();
+ team.hogs[i].name = baList.last().data();
team.hogs[i].hat = "NoHat";
}
@@ -51,43 +55,54 @@
QVector<flib_binding> binds(BINDS_NUMBER);
for(int i = 0; i < BINDS_NUMBER; i++)
{
- binds[i].action = cbinds[i].action.toUtf8().data();
- binds[i].binding = cbinds[i].strbind.toUtf8().data();
+ baList << cbinds[i].action.toUtf8();
+ binds[i].action = baList.last().data();
+ baList << cbinds[i].strbind.toUtf8();
+ binds[i].binding = baList.last().data();
}
team.bindings = binds.data();
team.bindingCount = binds.size();
- team.remoteDriven = false;
- team.hogsInGame = 4;
+ m_team = flib_team_copy(&team);
- m_team = flib_team_copy(&team);
+ m_team->remoteDriven = false;
+ m_team->hogsInGame = 4;
}
HWTeam::HWTeam(const QStringList& strLst, QObject *parent) :
QObject(parent)
{
+ QList<QByteArray> baList;
+
// net teams are configured from QStringList
if(strLst.size() != 23) throw HWTeamConstructException();
flib_team team;
bzero(&team, sizeof(team));
- team.name = strLst[0].toUtf8().data();
+
+ for(int i = 0; i < 6; ++i)
+ baList << strLst[i].toUtf8();
+ team.name = baList[0].data();
m_oldTeamName = strLst[0];
- team.grave = strLst[1].toUtf8().data();
- team.fort = strLst[2].toUtf8().data();
- team.voicepack = strLst[3].toUtf8().data();
- team.flag = strLst[4].toUtf8().data();
- team.ownerName = strLst[5].toUtf8().data();
+ team.grave = baList[1].data();
+ team.fort = baList[2].data();
+ team.voicepack = baList[3].data();
+ team.flag = baList[4].data();
+ team.ownerName = baList[5].data();
int difficulty = strLst[6].toUInt();
for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
{
- team.hogs[i].name = strLst[i * 2 + 7].toUtf8().data();
+ baList << strLst[i * 2 + 7].toUtf8();
+ team.hogs[i].name = baList.last().data();
QString hat = strLst[i * 2 + 8];
if (hat.isEmpty())
team.hogs[i].hat = "NoHat";
else
- team.hogs[i].hat = hat.toUtf8().data();
+ {
+ baList << hat.toUtf8();
+ team.hogs[i].hat = baList.last().data();
+ }
team.hogs[i].difficulty = difficulty;
}
@@ -97,16 +112,17 @@
QVector<flib_binding> binds(BINDS_NUMBER);
for(int i = 0; i < BINDS_NUMBER; i++)
{
- binds[i].action = cbinds[i].action.toUtf8().data();
- binds[i].binding = cbinds[i].strbind.toUtf8().data();
+ baList << cbinds[i].action.toUtf8();
+ binds[i].action = baList.last().data();
+ baList << cbinds[i].strbind.toUtf8();
+ binds[i].binding = baList.last().data();
}
team.bindings = binds.data();
team.bindingCount = binds.size();
- team.remoteDriven = true;
- team.hogsInGame = 4;
-
m_team = flib_team_copy(&team);
+ m_team->remoteDriven = true;
+ m_team->hogsInGame = 4;
}
@@ -115,7 +131,8 @@
, m_oldTeamName(other.m_oldTeamName)
, m_team(flib_team_copy(other.m_team))
{
-
+ m_team->hogsInGame = other.m_team->hogsInGame;
+ m_team->remoteDriven = other.m_team->remoteDriven;
}
HWTeam & HWTeam::operator = (const HWTeam & other)
@@ -124,6 +141,9 @@
{
m_oldTeamName = other.m_oldTeamName;
m_team = flib_team_copy(other.m_team);
+
+ m_team->hogsInGame = other.m_team->hogsInGame;
+ m_team->remoteDriven = other.m_team->remoteDriven;
}
return *this;
@@ -363,3 +383,8 @@
{
m_team->wins++;
}
+
+flib_team * HWTeam::toFlibTeam()
+{
+ return m_team;
+}
--- a/QTfrontend/team.h Sun Nov 25 22:17:11 2012 +0400
+++ b/QTfrontend/team.h Mon Nov 26 00:06:42 2012 +0400
@@ -42,7 +42,7 @@
public:
// constructors
- HWTeam(const QString & teamname = QString(), QObject * parent = 0);
+ HWTeam(const QString & teamname = QString("Team"), QObject * parent = 0);
HWTeam(const QStringList& strLst, QObject * parent = 0);
HWTeam(const HWTeam & other);
~HWTeam();
@@ -89,6 +89,8 @@
void incRounds();
void incWins();
+ flib_team * toFlibTeam();
+
// comparison operators
bool operator == (const HWTeam& t1) const;
bool operator < (const HWTeam& t1) const;