Author: cazfi
Date: Sat Jan  3 17:30:18 2015
New Revision: 27499

URL: http://svn.gna.org/viewcvs/freeciv?rev=27499&view=rev
Log:
Added support for barbarian types that can act as both Land and Sea barbarian

See patch #5521

Modified:
    trunk/common/fc_types.h
    trunk/fc_version
    trunk/server/barbarian.c
    trunk/server/ruleset.c

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=27499&r1=27498&r2=27499&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Sat Jan  3 17:30:18 2015
@@ -259,6 +259,8 @@
 #define SPECENUM_VALUE2NAME "Sea"
 #define SPECENUM_VALUE3 ANIMAL_BARBARIAN
 #define SPECENUM_VALUE3NAME "Animal"
+#define SPECENUM_VALUE4 LAND_AND_SEA_BARBARIAN
+#define SPECENUM_VALUE4NAME "LandAndSea"
 #include "specenum_gen.h"
 
 /*

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27499&r1=27498&r2=27499&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sat Jan  3 17:30:18 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Jan.02"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Jan.03"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/barbarian.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/barbarian.c?rev=27499&r1=27498&r2=27499&view=diff
==============================================================================
--- trunk/server/barbarian.c    (original)
+++ trunk/server/barbarian.c    Sat Jan  3 17:30:18 2015
@@ -73,7 +73,8 @@
 **************************************************************************/
 bool is_land_barbarian(struct player *pplayer)
 {
-  return (pplayer->ai_common.barbarian_type == LAND_BARBARIAN);
+  return (pplayer->ai_common.barbarian_type == LAND_BARBARIAN
+          || pplayer->ai_common.barbarian_type == LAND_AND_SEA_BARBARIAN);
 }
 
 /**************************************************************************
@@ -81,7 +82,8 @@
 **************************************************************************/
 bool is_sea_barbarian(struct player *pplayer)
 {
-  return (pplayer->ai_common.barbarian_type == SEA_BARBARIAN);
+  return (pplayer->ai_common.barbarian_type == SEA_BARBARIAN
+          || pplayer->ai_common.barbarian_type == LAND_AND_SEA_BARBARIAN);
 }
 
 /**************************************************************************
@@ -94,7 +96,7 @@
 struct player *create_barbarian_player(enum barbarian_type type)
 {
   struct player *barbarians;
-  struct nation_type *nation;
+  struct nation_type *nation = NULL;
   struct research *presearch;
 
   players_iterate(barbarians) {
@@ -129,7 +131,19 @@
   }
   server_player_init(barbarians, TRUE, TRUE);
 
-  nation = pick_a_nation(NULL, FALSE, FALSE, type);
+  if (type == LAND_BARBARIAN || type == SEA_BARBARIAN) {
+    /* Try LAND_AND_SEA *FIRST*, so that we don't end up
+     * with one of the Land/Sea barbarians created first and
+     * then LAND_AND_SEA created instead of the second. */
+    nation = pick_a_nation(NULL, FALSE, FALSE, LAND_AND_SEA_BARBARIAN);
+    if (nation != NULL) {
+      type = LAND_AND_SEA_BARBARIAN;
+    }
+  }
+
+  if (nation == NULL) {
+    nation = pick_a_nation(NULL, FALSE, FALSE, type);
+  }
 
   /* Ruleset loading time checks should guarantee that there always is
      suitable nation available */

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=27499&r1=27498&r2=27499&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Sat Jan  3 17:30:18 2015
@@ -4266,7 +4266,8 @@
     
     /* Sanity checks on all sets */
     nation_sets_iterate(pset) {
-      int num_playable = 0, barb_land_count = 0, barb_sea_count = 0;
+      int num_playable = 0, barb_land_count = 0, barb_sea_count = 0, 
barb_both_count = 0;
+
       nations_iterate(pnation) {
         if (nation_is_in_set(pnation, pset)) {
           switch (nation_barbarian_type(pnation)) {
@@ -4284,6 +4285,9 @@
           case ANIMAL_BARBARIAN:
             /* Animals are optional */
             break;
+          case LAND_AND_SEA_BARBARIAN:
+            barb_both_count++;
+            break;
           default:
             fc_assert_ret_val(FALSE, FALSE);
           }
@@ -4296,14 +4300,14 @@
         ok = FALSE;
         break;
       }
-      if (barb_land_count == 0) {
+      if (barb_land_count == 0 && barb_both_count == 0) {
         ruleset_error(LOG_ERROR,
                       "No land barbarian nation defined in set \"%s\". "
                       "At least one required!", nation_set_rule_name(pset));
         ok = FALSE;
         break;
       }
-      if (barb_sea_count == 0) {
+      if (barb_sea_count == 0 && barb_both_count == 0) {
         ruleset_error(LOG_ERROR,
                       "No sea barbarian nation defined in set \"%s\". "
                       "At least one required!", nation_set_rule_name(pset));


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to