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

 New unit type flag "BarbarianOnly". These units can be built only by
barbarians.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/helpdata.c freeciv/client/helpdata.c
--- freeciv/client/helpdata.c	2007-01-23 16:05:15.000000000 +0200
+++ freeciv/client/helpdata.c	2007-01-26 02:08:49.000000000 +0200
@@ -790,6 +790,10 @@
     sprintf(buf + strlen(buf),
 	    _("* May not be built in cities.\n"));
   }
+  if (unit_type_flag(utype, F_BARBARIAN_ONLY)) {
+    sprintf(buf + strlen(buf),
+	    _("* Only barbarians may build this.\n"));
+  }
   if (unit_type_flag(utype, F_NOHOME)) {
     sprintf(buf + strlen(buf), _("* Never has a home city.\n"));
   }
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c	2007-01-26 02:01:28.000000000 +0200
+++ freeciv/common/unittype.c	2007-01-26 02:04:17.000000000 +0200
@@ -52,7 +52,7 @@
   "AddToCity", "Fanatic", "GameLoss", "Unique", "Unbribable", 
   "Undisbandable", "SuperSpy", "NoHome", "NoVeteran", "Bombarder",
   "CityBuster", "NoBuild", "BadWallAttacker", "BadCityDefender",
-  "Helicopter", "AirUnit", "Fighter"
+  "Helicopter", "AirUnit", "Fighter", "BarbarianOnly"
 };
 static const char *role_names[] = {
   "FirstBuild", "Explorer", "Hut", "HutTech", "Partisan",
@@ -469,6 +469,14 @@
   if (unit_type_flag(punittype, F_NOBUILD)) {
     return FALSE;
   }
+
+  if (unit_type_flag(punittype, F_BARBARIAN_ONLY)
+      && !is_barbarian(p)) {
+    /* Unit can be built by barbarians only and this player is
+     * not barbarian */
+    return FALSE;
+  }
+
   if (punittype->gov_requirement
       && punittype->gov_requirement != p->government) {
     return FALSE;
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/common/unittype.h	2007-01-26 02:02:15.000000000 +0200
@@ -100,6 +100,7 @@
   F_HELICOPTER,       /* Defends badly against F_FIGHTER units */
   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_LAST
 };
 #define F_MAX 64
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/data/default/units.ruleset	2007-01-26 02:08:56.000000000 +0200
@@ -216,6 +216,7 @@
 ; "Helicopter"  = defends very badly against "Fighter" units
 ; "AirUnit"     = very bad at attacking "AEGIS" units
 ; "Fighter"     = good attacker against "Helicopter" units
+; "BarbarianOnly" = only barbarians can build this unit
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to