--- a/QTfrontend/game.cpp Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/game.cpp Mon Jan 08 20:51:22 2007 +0000
@@ -65,6 +65,7 @@
}
SendIPC("TL");
SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii());
+ SendIPC(QString("e$turntime %1").arg(gamecfg->getTurnTime() * 1000).toAscii());
}
void HWGame::SendConfig()
@@ -78,7 +79,9 @@
QColor clr = m_teamsParams[teams[i]].teamColor;
QByteArray buf;
- QStringList sl = team.TeamGameConfig(clr.rgb()&0xFFFFFF, m_teamsParams[teams[i]].numHedgehogs);
+ QStringList sl = team.TeamGameConfig(clr.rgb()&0xFFFFFF,
+ m_teamsParams[teams[i]].numHedgehogs,
+ gamecfg->getInitHealth());
HWProto::addStringListToBuffer(buf, sl);
RawSendIPC(buf);
}
@@ -91,11 +94,13 @@
QByteArray teamscfg;
HWTeam team1(0);
team1.difficulty = 0;
- HWProto::addStringListToBuffer(teamscfg, team1.TeamGameConfig(65535, 4));
+ HWProto::addStringListToBuffer(teamscfg,
+ team1.TeamGameConfig(65535, 4, gamecfg->getInitHealth()));
HWTeam team2(2);
team2.difficulty = 4;
- RawSendIPC(HWProto::addStringListToBuffer(teamscfg, team2.TeamGameConfig(16776960, 4)));
+ RawSendIPC(HWProto::addStringListToBuffer(teamscfg,
+ team2.TeamGameConfig(16776960, 4, gamecfg->getInitHealth())));
}
void HWGame::ParseMessage(const QByteArray & msg)
@@ -298,6 +303,7 @@
QByteArray teamcfg;
HWTeam team(teamname);
team.LoadFromFile();
- RawSendIPC(HWProto::addStringListToBuffer(teamcfg, team.TeamGameConfig(16776960, 4)));
+ RawSendIPC(HWProto::addStringListToBuffer(teamcfg,
+ team.TeamGameConfig(16776960, 4, gamecfg->getInitHealth())));
}
--- a/QTfrontend/gamecfgwidget.cpp Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/gamecfgwidget.cpp Mon Jan 08 20:51:22 2007 +0000
@@ -61,7 +61,7 @@
SB_TurnTime->setSingleStep(15);
SB_InitHealth = new QSpinBox(GBoxOptions);
SB_InitHealth->setRange(50, 200);
- SB_TurnTime->setValue(100);
+ SB_InitHealth->setValue(100);
SB_InitHealth->setSingleStep(25);
GBoxOptionsLayout->addWidget(SB_TurnTime, 1, 1);
GBoxOptionsLayout->addWidget(SB_InitHealth, 2, 1);
@@ -91,3 +91,13 @@
{
return pMapContainer->getCurrentTheme();
}
+
+quint32 GameCFGWidget::getInitHealth() const
+{
+ return SB_InitHealth->value();
+}
+
+quint32 GameCFGWidget::getTurnTime() const
+{
+ return SB_TurnTime->value();
+}
--- a/QTfrontend/gamecfgwidget.h Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/gamecfgwidget.h Mon Jan 08 20:51:22 2007 +0000
@@ -38,6 +38,8 @@
QString getCurrentSeed() const;
QString getCurrentMap() const;
QString getCurrentTheme() const;
+ quint32 getInitHealth() const;
+ quint32 getTurnTime() const;
private slots:
--- a/QTfrontend/hwform.cpp Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/hwform.cpp Mon Jan 08 20:51:22 2007 +0000
@@ -69,6 +69,7 @@
connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions()));
+ connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect()));
--- a/QTfrontend/team.cpp Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/team.cpp Mon Jan 08 20:51:22 2007 +0000
@@ -188,7 +188,7 @@
}
}
-QStringList HWTeam::TeamGameConfig(quint32 color, int hedgehogs) const
+QStringList HWTeam::TeamGameConfig(quint32 color, int hedgehogs, quint32 InitHealth) const
{
QStringList sl;
sl.push_back("eaddteam");
@@ -203,8 +203,9 @@
sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));
}
for (int t = 0; t < hedgehogs; t++)
- sl.push_back(QString("eadd hh%1 %2")
- .arg(QString::number(t), QString::number(difficulty)));
+ sl.push_back(QString("eaddhh %1 %2")
+ .arg(QString::number(difficulty),
+ QString::number(InitHealth)));
return sl;
}
--- a/QTfrontend/team.h Mon Jan 08 18:21:40 2007 +0000
+++ b/QTfrontend/team.h Mon Jan 08 20:51:22 2007 +0000
@@ -43,7 +43,7 @@
bool SaveToFile();
void SetToPage(HWForm * hwform);
void GetFromPage(HWForm * hwform);
- QStringList TeamGameConfig(quint32 color, int hedgehogs) const;
+ QStringList TeamGameConfig(quint32 color, int hedgehogs, quint32 InitHealth) const;
bool operator==(const HWTeam& t1) const;
bool operator<(const HWTeam& t1) const;
--- a/hedgewars/CCHandlers.inc Mon Jan 08 18:21:40 2007 +0000
+++ b/hedgewars/CCHandlers.inc Mon Jan 08 20:51:22 2007 +0000
@@ -102,25 +102,25 @@
AdjustColor(CurrentTeam.AdjColor)
end;
-procedure chAdd(var id: shortstring);
+procedure chAddHH(var id: shortstring);
var s: shortstring;
c: integer;
Gear: PGear;
- b: byte;
begin
if (not isDeveloperMode)or(CurrentTeam=nil) then exit;
-SplitBySpace(id, s);
-if (id[1]='h')and(id[2]='h')and(id[3]>='0')and(id[3]<='7') then
- begin
- b:= byte(id[3])-48;
- val(s, CurrentTeam.Hedgehogs[b].BotLevel, c);
- Gear:= AddGear(0, 0, gtHedgehog, 0);
- Gear.Hedgehog:= @CurrentTeam.Hedgehogs[b];
- PHedgehog(Gear.Hedgehog).Team:= CurrentTeam;
- CurrentTeam.Hedgehogs[b].AmmoStore:= 0;
- CurrentTeam.Hedgehogs[b].Gear:= Gear
- end
-else OutError(errmsgUnknownVariable + ' "' + id + '"', true)
+with CurrentTeam^ do
+ begin
+ SplitBySpace(id, s);
+ val(id, Hedgehogs[HedgehogsNumber].BotLevel, c);
+ Gear:= AddGear(0, 0, gtHedgehog, 0);
+ Gear.Hedgehog:= @Hedgehogs[HedgehogsNumber];
+ val(s, Gear.Health, c);
+ TryDo(Gear.Health > 0, 'Invalid hedgehog health', true);
+ PHedgehog(Gear.Hedgehog).Team:= CurrentTeam;
+ Hedgehogs[HedgehogsNumber].AmmoStore:= 0;
+ Hedgehogs[HedgehogsNumber].Gear:= Gear;
+ inc(HedgehogsNumber)
+ end
end;
procedure chAddAmmoStore(var descr: shortstring);
--- a/hedgewars/uConsole.pas Mon Jan 08 18:21:40 2007 +0000
+++ b/hedgewars/uConsole.pas Mon Jan 08 20:51:22 2007 +0000
@@ -276,7 +276,7 @@
RegisterVariable('fort' , vtCommand, @chFort , false);
RegisterVariable('grave' , vtCommand, @chGrave , false);
RegisterVariable('bind' , vtCommand, @chBind , true );
-RegisterVariable('add' , vtCommand, @chAdd , false);
+RegisterVariable('addhh' , vtCommand, @chAddHH , false);
RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false);
RegisterVariable('skip' , vtCommand, @chSkip , false);
RegisterVariable('say' , vtCommand, @chSay , true );
--- a/hedgewars/uTeams.pas Mon Jan 08 18:21:40 2007 +0000
+++ b/hedgewars/uTeams.pas Mon Jan 08 20:51:22 2007 +0000
@@ -54,6 +54,7 @@
TeamHealthBarWidth: integer;
DrawHealthY: integer;
AttackBar: LongWord;
+ HedgehogsNumber: byte;
end;
var CurrentTeam: PTeam = nil;
@@ -215,10 +216,7 @@
th:= 0;
for i:= 0 to cMaxHHIndex do
if p.Hedgehogs[i].Gear <> nil then
- begin
- p.Hedgehogs[i].Gear.Health:= 100;
- inc(th, 100);
- end;
+ inc(th, p.Hedgehogs[i].Gear.Health);
if th > MaxTeamHealth then MaxTeamHealth:= th;
p:= p.Next
end;