Flag the sharing of ammo between clan teams.
authornemo
Sun, 28 Feb 2010 15:41:42 +0000
changeset 2881 70d7976fa829
parent 2880 e95c2f489345
child 2882 b9aceb3fe3d6
Flag the sharing of ammo between clan teams.
QTfrontend/ammoSchemeModel.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/hedgewars.qrc
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/btnSharedAmmo.png
hedgewars/CCHandlers.inc
hedgewars/uConsts.pas
--- a/QTfrontend/ammoSchemeModel.cpp	Sun Feb 28 13:57:34 2010 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Sun Feb 28 15:41:42 2010 +0000
@@ -38,13 +38,14 @@
 		<< QVariant(true)          // random order   12
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
-		<< QVariant(100)           // damage modfier 15
-		<< QVariant(45)            // turn time      16
-		<< QVariant(100)           // init health    17
-		<< QVariant(15)            // sudden death   18
-		<< QVariant(5)             // case prob      19
-		<< QVariant(3)             //  mines time    20
-		<< QVariant(4)             //  landadds      21
+		<< QVariant(false)         // shared ammo    15
+		<< QVariant(100)           // damage modfier 16
+		<< QVariant(45)            // turn time      17
+		<< QVariant(100)           // init health    18
+		<< QVariant(15)            // sudden death   19
+		<< QVariant(5)             // case prob      20
+		<< QVariant(3)             //  mines time    21
+		<< QVariant(4)             //  landadds      22
 		;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -76,13 +77,14 @@
 		<< "randomorder"      // 12
 		<< "king"             // 13
 		<< "placehog"         // 14
-		<< "damagefactor"     // 15
-		<< "turntime"         // 16
-		<< "health"           // 17
-		<< "suddendeath"      // 18
-		<< "caseprobability"  // 19
-		<< "minestime"        // 20
-		<< "landadds"         // 21
+		<< "sharedammo"       // 15
+		<< "damagefactor"     // 16
+		<< "turntime"         // 17
+		<< "health"           // 18
+		<< "suddendeath"      // 19
+		<< "caseprobability"  // 20
+		<< "minestime"        // 21
+		<< "landadds"         // 22
 		;
 
 	QList<QVariant> proMode;
@@ -102,13 +104,14 @@
 		<< QVariant(true)          // random order   12
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
-		<< QVariant(100)           // damage modfier 15
-		<< QVariant(15)            // turn time      16
-		<< QVariant(100)           // init health    17
-		<< QVariant(15)            // sudden death   18
-		<< QVariant(0)             // case prob      19
-		<< QVariant(3)             //  mines time    20
-		<< QVariant(4)             //  landadds      21
+		<< QVariant(true)          // shared ammo    15
+		<< QVariant(100)           // damage modfier 16
+		<< QVariant(15)            // turn time      17
+		<< QVariant(100)           // init health    18
+		<< QVariant(15)            // sudden death   19
+		<< QVariant(0)             // case prob      20
+		<< QVariant(3)             //  mines time    21
+		<< QVariant(4)             //  landadds      22
 		;
 
 	QList<QVariant> shoppa;
@@ -128,6 +131,7 @@
 		<< QVariant(true)          // random order   12
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
+		<< QVariant(true)          // shared ammo    15
 		<< QVariant(100)           // damage modfier 15
 		<< QVariant(30)            // turn time      16
 		<< QVariant(100)           // init health    17
@@ -154,13 +158,14 @@
 		<< QVariant(true)          // random order   12
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
-		<< QVariant(100)           // damage modfier 15
-		<< QVariant(30)            // turn time      16
-		<< QVariant(100)           // init health    17
-		<< QVariant(15)            // sudden death   18
-		<< QVariant(0)             // case prob      19
-		<< QVariant(3)             //  mines time    20
-		<< QVariant(4)             //  landadds      21
+		<< QVariant(true)          // shared ammo    15
+		<< QVariant(100)           // damage modfier 16
+		<< QVariant(30)            // turn time      17
+		<< QVariant(100)           // init health    18
+		<< QVariant(15)            // sudden death   19
+		<< QVariant(0)             // case prob      20
+		<< QVariant(3)             //  mines time    21
+		<< QVariant(4)             //  landadds      22
 		;
 
 	QList<QVariant> minefield;
@@ -180,13 +185,14 @@
 		<< QVariant(true)          // random order   12
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
-		<< QVariant(150)           // damage modfier 15
-		<< QVariant(30)            // turn time      16
-		<< QVariant(50)            // init health    17
-		<< QVariant(15)            // sudden death   18
-		<< QVariant(0)             // case prob      19
-		<< QVariant(0)             //  mines time    20
-		<< QVariant(50)            //  landadds      21
+		<< QVariant(true)          // shared ammo    15
+		<< QVariant(150)           // damage modfier 16
+		<< QVariant(30)            // turn time      17
+		<< QVariant(50)            // init health    18
+		<< QVariant(15)            // sudden death   19
+		<< QVariant(0)             // case prob      20
+		<< QVariant(0)             //  mines time    21
+		<< QVariant(50)            //  landadds      22
 		;
 
 	schemes.append(defaultScheme);
--- a/QTfrontend/gamecfgwidget.cpp	Sun Feb 28 13:57:34 2010 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sun Feb 28 15:41:42 2010 +0000
@@ -126,13 +126,15 @@
 		result |= 0x4000;
 	if (schemeData(14).toBool())
 		result |= 0x8000;
+	if (schemeData(15).toBool())
+		result |= 0x10000;
 
 	return result;
 }
 
 quint32 GameCFGWidget::getInitHealth() const
 {
-	return schemeData(17).toInt();
+	return schemeData(18).toInt();
 }
 
 QStringList GameCFGWidget::getFullConfig() const
@@ -140,12 +142,12 @@
 	QStringList sl;
 	sl.append("eseed " + pMapContainer->getCurrentSeed());
 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
-	sl.append(QString("e$damagepct %1").arg(schemeData(15).toInt()));
-	sl.append(QString("e$turntime %1").arg(schemeData(16).toInt() * 1000));
-	sl.append(QString("e$minestime %1").arg(schemeData(20).toInt() * 1000));
-	sl.append(QString("e$landadds %1").arg(schemeData(21).toInt()));
-	sl.append(QString("e$sd_turns %1").arg(schemeData(18).toInt()));
-	sl.append(QString("e$casefreq %1").arg(schemeData(19).toInt()));
+	sl.append(QString("e$damagepct %1").arg(schemeData(16).toInt()));
+	sl.append(QString("e$turntime %1").arg(schemeData(17).toInt() * 1000));
+	sl.append(QString("e$minestime %1").arg(schemeData(21).toInt() * 1000));
+	sl.append(QString("e$landadds %1").arg(schemeData(22).toInt()));
+	sl.append(QString("e$sd_turns %1").arg(schemeData(19).toInt()));
+	sl.append(QString("e$casefreq %1").arg(schemeData(20).toInt()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
 
 	QString currentMap = pMapContainer->getCurrentMap();
--- a/QTfrontend/hedgewars.qrc	Sun Feb 28 13:57:34 2010 +0000
+++ b/QTfrontend/hedgewars.qrc	Sun Feb 28 15:41:42 2010 +0000
@@ -60,6 +60,7 @@
     <file>res/btnRandomOrder.png</file>
     <file>res/btnKing.png</file>
     <file>res/btnPlaceHog.png</file>
+    <file>res/btnSharedAmmo.png</file>
     <file>res/iconBox.png</file>
     <file>res/iconHealth.png</file>
     <file>res/iconSuddenDeath.png</file>
--- a/QTfrontend/pages.cpp	Sun Feb 28 13:57:34 2010 +0000
+++ b/QTfrontend/pages.cpp	Sun Feb 28 15:41:42 2010 +0000
@@ -1102,6 +1102,11 @@
     TBW_placehog->setToolTip(tr("Take turns placing your hedgehogs before the start of play."));
 	glGMLayout->addWidget(TBW_placehog,3,1,1,1);
 
+	TBW_sharedammo = new ToggleButtonWidget(gbGameModes, ":/res/btnSharedAmmo.png");
+	TBW_sharedammo->setText(ToggleButtonWidget::tr("Clan Shares Ammo"));
+    TBW_sharedammo->setToolTip(tr("Ammo is shared between all teams that share a colour."));
+	glGMLayout->addWidget(TBW_sharedammo,3,2,1,1);
+
 	// Right
 	QLabel * l;
 
@@ -1252,13 +1257,14 @@
 	mapper->addMapping(TBW_randomorder->button(), 12);
 	mapper->addMapping(TBW_king->button(), 13);
 	mapper->addMapping(TBW_placehog->button(), 14);
-	mapper->addMapping(SB_DamageModifier, 15);
-	mapper->addMapping(SB_TurnTime, 16);
-	mapper->addMapping(SB_InitHealth, 17);
-	mapper->addMapping(SB_SuddenDeath, 18);
-	mapper->addMapping(SB_CaseProb, 19);
-	mapper->addMapping(SB_MinesTime, 20);
-	mapper->addMapping(SB_Mines, 21);
+	mapper->addMapping(TBW_sharedammo->button(), 15);
+	mapper->addMapping(SB_DamageModifier, 16);
+	mapper->addMapping(SB_TurnTime, 17);
+	mapper->addMapping(SB_InitHealth, 18);
+	mapper->addMapping(SB_SuddenDeath, 19);
+	mapper->addMapping(SB_CaseProb, 20);
+	mapper->addMapping(SB_MinesTime, 21);
+	mapper->addMapping(SB_Mines, 22);
 
 	mapper->toFirst();
 }
--- a/QTfrontend/pages.h	Sun Feb 28 13:57:34 2010 +0000
+++ b/QTfrontend/pages.h	Sun Feb 28 15:41:42 2010 +0000
@@ -441,6 +441,7 @@
 	ToggleButtonWidget * TBW_randomorder;
 	ToggleButtonWidget * TBW_king;
 	ToggleButtonWidget * TBW_placehog;
+	ToggleButtonWidget * TBW_sharedammo;
 
 	QSpinBox * SB_DamageModifier;
 	QSpinBox * SB_TurnTime;
Binary file QTfrontend/res/btnSharedAmmo.png has changed
--- a/hedgewars/CCHandlers.inc	Sun Feb 28 13:57:34 2010 +0000
+++ b/hedgewars/CCHandlers.inc	Sun Feb 28 15:41:42 2010 +0000
@@ -155,9 +155,8 @@
 	val(s, Gear^.Health);
 	TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
 	PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
-// Needs shared clan ammo game flag
-	CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex; // FIXME HACK to get ammostores work
-	//CurrentHedgehog^.AmmoStore:= TeamsCount - 1; // FIXME HACK to get ammostores work
+    if (GameFlags and gfSharedAmmo) <> 0 then CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
+    else CurrentHedgehog^.AmmoStore:= TeamsCount - 1;
 	CurrentHedgehog^.Gear:= Gear;
 	CurrentHedgehog^.Name:= id;
     CurrHedgehog:= HedgehogsNumber;
--- a/hedgewars/uConsts.pas	Sun Feb 28 13:57:34 2010 +0000
+++ b/hedgewars/uConsts.pas	Sun Feb 28 15:41:42 2010 +0000
@@ -306,6 +306,7 @@
 	gfRandomOrder  = $00002000;
 	gfKing         = $00004000;
 	gfPlaceHog     = $00008000;
+	gfSharedAmmo   = $00010000;
 
 	gstDrowning       = $00000001;
 	gstHHDriven       = $00000002;