<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40762 >

add a flag to the units there the upkeep change shields => gold is allowed

depends on ticket 40619, 40759, 40760, 40761

compile tested and also with a short game

diff -ur freeciv-2.1.99svn15584.gold3//common/unittype.c freeciv-2.1.99svn15584.gold4//common/unittype.c
--- freeciv-2.1.99svn15584.gold3//common/unittype.c	2009-04-12 00:13:51.698127364 +0200
+++ freeciv-2.1.99svn15584.gold4//common/unittype.c	2009-04-12 00:13:38.342629029 +0200
@@ -53,7 +53,7 @@
   "AddToCity", "Fanatic", "GameLoss", "Unique", "Unbribable", 
   "Undisbandable", "SuperSpy", "NoHome", "NoVeteran", "Bombarder",
   "CityBuster", "NoBuild", "BadWallAttacker", "BadCityDefender",
-  "Helicopter", "AirUnit", "Fighter", "BarbarianOnly"
+  "Helicopter", "AirUnit", "Fighter", "BarbarianOnly", "Shield2Gold"
 };
 static const char *role_names[] = {
   "FirstBuild", "Explorer", "Hut", "HutTech", "Partisan",
@@ -154,11 +154,12 @@
 
   /* switch shild upkeep to gold upkeep if
      - the effect 'EFT_SHIELD2GOLD_FACTOR' is non-zero (it gives the
-        conversion factor in percent)
+        conversion factor in percent) and
+     - the unit has the corresponding flag set (F_SHIELD2GOLD)
      Should the ai know about this? - MaPfa */
   gold_upkeep_factor = get_player_bonus(pplayer, EFT_SHIELD2GOLD_FACTOR);
   gold_upkeep_factor = (gold_upkeep_factor > 0) ? gold_upkeep_factor : 0;
-  if (gold_upkeep_factor > 0) {
+  if (gold_upkeep_factor > 0 && utype_has_flag(ut, F_SHIELD2GOLD)) {
     switch (otype) {
       case O_GOLD:
         val = ceil((0.01 * gold_upkeep_factor) * ut->upkeep[O_SHIELD]);
diff -ur freeciv-2.1.99svn15584.gold3//common/unittype.h freeciv-2.1.99svn15584.gold4//common/unittype.h
--- freeciv-2.1.99svn15584.gold3//common/unittype.h	2009-01-05 11:54:25.000000000 +0100
+++ freeciv-2.1.99svn15584.gold4//common/unittype.h	2009-04-11 20:32:40.858127483 +0200
@@ -68,6 +68,7 @@
    which uses unit_has_type_flag() without twiddling bits is unchanged.
    (It is easier to go from i to (1<<i) than the reverse.)
    See data/default/units.ruleset for documentation of their effects.
+   Change the array *flag_names[] in unittype.c accordingly.
 */
 enum unit_flag_id { 
   F_TRADE_ROUTE=0,
@@ -112,6 +113,7 @@
   F_AIRUNIT,          /* Bad at attacking F_AEGIS units */
   F_FIGHTER,          /* Good at attacking F_HELICOPTER units */
   F_BARBARIAN_ONLY,   /* Only barbarians can build this unit */
+  F_SHIELD2GOLD,      /* upkeep can switch from shield to gold */
   F_LAST
 };
 #define F_MAX 64
diff -ur freeciv-2.1.99svn15584.gold3//data/default/units.ruleset freeciv-2.1.99svn15584.gold4//data/default/units.ruleset
--- freeciv-2.1.99svn15584.gold3//data/default/units.ruleset	2009-03-21 12:19:15.000000000 +0100
+++ freeciv-2.1.99svn15584.gold4//data/default/units.ruleset	2009-04-11 20:32:41.070129086 +0200
@@ -228,6 +228,7 @@
 ; "AirUnit"     = very bad at attacking "AEGIS" units
 ; "Fighter"     = good attacker against "Helicopter" units
 ; "BarbarianOnly" = only barbarians can build this unit
+; "Shield2Gold" = Switch from shield upkeep to gold upkeep possible
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
@@ -579,7 +580,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = ""
+flags         = "Shield2Gold"
 roles         = "DefendGood", "FirstBuild", "HutTech",
                 "BarbarianTech", "BarbarianBuildTech", "BarbarianSeaTech"
 helptext      = _("\
@@ -656,7 +657,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "IgTer"
+flags         = "IgTer", "Shield2Gold"
 roles         = "DefendGood"
 helptext      = _("\
 Alpine Troops are highly mobile units as well as\
@@ -720,7 +721,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "Marines"
+flags         = "Marines", "Shield2Gold"
 roles         = "DefendOk", "BarbarianSeaTech"
 helptext      = _("\
 Marines are infantry who are experts at marine warfare.\
@@ -751,7 +752,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "Paratroopers"
+flags         = "Paratroopers", "Shield2Gold"
 roles         = "DefendOk"
 helptext      = _("\
 Paratroopers are experts at airborne attacks.\
@@ -786,7 +787,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = ""
+flags         = "Shield2Gold"
 roles         = "DefendGood"
 helptext      = _("\
 The Mechanized Infantry has the strongest defensive strength\
@@ -979,7 +980,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = ""
+flags         = "Shield2Gold"
 roles         = "AttackFast", "Hunter"
 helptext      = _("\
 Armors are motorized war wagons that are faster,\
@@ -1079,7 +1080,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = ""
+flags         = "Shield2Gold"
 roles         = "AttackStrong"
 helptext      = _("\
 The artillery is an upgraded cannon. It is a very\
@@ -1112,7 +1113,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "IgWall"
+flags         = "IgWall", "Shield2Gold"
 roles         = "AttackStrong"
 helptext      = _("\
 Howitzers are upgraded artillery with improved\
@@ -1145,7 +1146,7 @@
 uk_food       = 0
 uk_gold       = 0
 targets       = "Air", "Missile" 
-flags         = "AirUnit", "Fighter"
+flags         = "AirUnit", "Fighter", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 Fighters are your first airborne units. They can\
@@ -1177,7 +1178,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "AirUnit"
+flags         = "FieldUnit", "OneAttack", "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 Bombers are specialized airborne units that may\
@@ -1210,7 +1211,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Helicopter", "AirUnit"
+flags         = "FieldUnit", "OneAttack", "Helicopter", "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 The Helicopter is a very powerful unit, as it can both fly and\
@@ -1245,7 +1246,7 @@
 uk_food       = 0
 uk_gold       = 0
 targets       = "Air", "Missile"
-flags         = "Partial_Invis", "AirUnit", "Fighter"
+flags         = "Partial_Invis", "AirUnit", "Fighter", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 An improved Fighter, with improved attack and a higher movement\
@@ -1277,7 +1278,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "Partial_Invis", "FieldUnit", "OneAttack", "AirUnit"
+flags         = "Partial_Invis", "FieldUnit", "OneAttack", "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 An improved Bomber, with improved attack and a higher movement\
@@ -1444,7 +1445,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "BadCityDefender"
+flags         = "BadCityDefender", "Shield2Gold"
 roles         = "Hunter"
 helptext      = _("\
 The Ironclad is an armored ship that is\
@@ -1477,7 +1478,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "BadCityDefender"
+flags         = "BadCityDefender", "Shield2Gold"
 roles         = "Hunter"
 helptext      = _("\
 An improved Ironclad, with better move rate and vision.\
@@ -1511,7 +1512,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "BadCityDefender"
+flags         = "BadCityDefender", "Shield2Gold"
 roles         = "DefendGood"
 helptext      = _("\
 The Cruiser is a strong offensive boat unit.\
@@ -1542,7 +1543,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "AEGIS", "BadCityDefender"
+flags         = "AEGIS", "BadCityDefender", "Shield2Gold"
 roles         = "DefendGood"
 helptext      = _("\
 The AEGIS Cruiser is equipped with an advanced\
@@ -1574,7 +1575,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "BadCityDefender"
+flags         = "BadCityDefender", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 The Battleship is the supreme naval unit with\
@@ -1608,7 +1609,7 @@
 uk_gold       = 0
 cargo         = "Missile"
 flags         = "Partial_Invis", "BadCityDefender",
-	        "No_Land_Attack"
+	        "No_Land_Attack", "Shield2Gold"
 roles         = "Hunter"
 helptext      = _("\
 Traveling under the surface of the ocean, Submarines have\
@@ -1642,7 +1643,7 @@
 uk_food       = 0
 uk_gold       = 0
 cargo         = "Air", "Missile", "Helicopter"
-flags         = "BadCityDefender", "No_Land_Attack"
+flags         = "BadCityDefender", "No_Land_Attack", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 The Carrier is a mobile airport and cannot attack\
@@ -1679,7 +1680,7 @@
 uk_food       = 0
 uk_gold       = 0
 cargo         = "Land"
-flags         = "BadCityDefender"
+flags         = "BadCityDefender", "Shield2Gold"
 roles         = "Ferryboat"
 helptext      = _("\
 The Transport cannot attack on its own but\
@@ -1711,7 +1712,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "AirUnit"
+flags         = "FieldUnit", "OneAttack", "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 The Cruise Missile is a long-distance missile\
@@ -1746,7 +1747,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Nuclear", "AirUnit"
+flags         = "FieldUnit", "OneAttack", "Nuclear", "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 You can build Nuclear units when you have the required advance, and\
@@ -2058,7 +2059,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "AirUnit"
+flags         = "AirUnit", "Shield2Gold"
 roles         = ""
 helptext      = _("\
 The AWACS (Airborne Warning and Control System) is an airplane with an \
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to