Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#9817) default building specified in ruleset
Home

[Freeciv-Dev] (PR#9817) default building specified in ruleset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9817) default building specified in ruleset
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Oct 2004 18:57:37 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9817 >

Here's a patch.

- Default_building is removed.

- The AI simply does not use it.  It will skip past capitalization and
go straight to settlers (probably a good thing, although this is just a
first-pass check).

- The city.c code works around it.  Instead we just search for the first
building or unit that can be built by the city.

I tested it by removing FirstBuild from all units, changing the
resulting error to be non-fatal, and founding a city.  Voila - the city
builds barracks by default.

jason

? 1
? 2
? newtiles
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.176
diff -u -r1.176 aicity.c
--- ai/aicity.c 30 Sep 2004 12:31:26 -0000      1.176
+++ ai/aicity.c 8 Oct 2004 01:54:53 -0000
@@ -677,9 +677,6 @@
     if (best_role_unit(pcity, F_TRADE_ROUTE) != U_LAST) {
       pcity->ai.choice.choice = best_role_unit(pcity, F_TRADE_ROUTE);
       pcity->ai.choice.type = CT_NONMIL;
-    } else if (can_build_improvement(pcity, game.default_building)) {
-      pcity->ai.choice.choice = game.default_building;
-      pcity->ai.choice.type = CT_BUILDING;
     } else if (best_role_unit(pcity, F_SETTLERS) != U_LAST) {
       pcity->ai.choice.choice = best_role_unit(pcity, F_SETTLERS);
       pcity->ai.choice.type = CT_NONMIL;
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.408
diff -u -r1.408 packhand.c
--- client/packhand.c   1 Oct 2004 17:40:27 -0000       1.408
+++ client/packhand.c   8 Oct 2004 01:54:54 -0000
@@ -2120,8 +2120,6 @@
     mystrlcpy(team_get_by_id(i)->name, packet->team_name[i],
               MAX_LEN_NAME);
   }
-
-  game.default_building = packet->default_building;
 }
 
 /**************************************************************************
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.249
diff -u -r1.249 city.c
--- common/city.c       1 Oct 2004 17:53:02 -0000       1.249
+++ common/city.c       8 Oct 2004 01:54:55 -0000
@@ -2429,8 +2429,30 @@
       pcity->is_building_unit = TRUE;
       pcity->currently_building = u;
     } else {
-      pcity->is_building_unit = FALSE;
-      pcity->currently_building = game.default_building;
+      bool found = FALSE;
+
+      /* Just pick the first available item. */
+
+      impr_type_iterate(id) {
+       if (can_build_improvement_direct(pcity, id)) {
+         found = TRUE;
+         pcity->is_building_unit = FALSE;
+         pcity->currently_building = id;
+         break;
+       }
+      } impr_type_iterate_end;
+
+      if (!found) {
+       unit_type_iterate(id) {
+         if (can_build_unit_direct(pcity, id)) {
+           found = TRUE;
+           pcity->is_building_unit = TRUE;
+           pcity->currently_building = id;
+         }
+       } unit_type_iterate_end;
+      }
+
+      assert(found);
     }
   }
   pcity->turn_founded = game.turn;
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.187
diff -u -r1.187 game.c
--- common/game.c       29 Sep 2004 02:24:22 -0000      1.187
+++ common/game.c       8 Oct 2004 01:54:55 -0000
@@ -280,7 +280,6 @@
   game.government_when_anarchy = G_MAGIC;   /* flag */
   game.ai_goal_government = G_MAGIC;        /* flag */
 
-  game.default_building = B_LAST;
   game.palace_building = B_LAST;
   game.land_defend_building = B_LAST;
 
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.152
diff -u -r1.152 game.h
--- common/game.h       16 Sep 2004 04:38:24 -0000      1.152
+++ common/game.h       8 Oct 2004 01:54:55 -0000
@@ -169,7 +169,6 @@
   char rulesetdir[MAX_LEN_NAME];
   int firepower_factor;                /* See README.rulesets */
 
-  Impr_Type_id default_building;
   Impr_Type_id palace_building;
   Impr_Type_id land_defend_building;
 
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.55
diff -u -r1.55 packets.def
--- common/packets.def  25 Sep 2004 22:18:41 -0000      1.55
+++ common/packets.def  8 Oct 2004 01:54:55 -0000
@@ -1237,8 +1237,6 @@
   BOOL slow_invasions;
 
   STRING team_name[MAX_NUM_TEAMS][MAX_LEN_NAME];
-
-  IMPROVEMENT default_building;
 end
 
 
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.196
diff -u -r1.196 ruleset.c
--- server/ruleset.c    25 Sep 2004 22:18:42 -0000      1.196
+++ server/ruleset.c    8 Oct 2004 01:54:56 -0000
@@ -1464,19 +1464,6 @@
 
   game.aqueduct_size = secfile_lookup_int(file, "b_special.aqueduct_size");
 
-  item = secfile_lookup_str(file, "b_special.default");
-  if (*item != '\0') {
-    game.default_building = find_improvement_by_name(item);
-    if (game.default_building == B_LAST) {
-      freelog(LOG_ERROR,
-             /* TRANS: Obscure ruleset error */
-             _("Bad value \"%s\" for b_special.default (%s)"),
-             item, filename);
-    }
-  } else {
-    game.default_building = B_LAST;
-  }
-
   /* FIXME: remove all of the following when gen-impr implemented... */
 
   game.rtech.cathedral_plus =
@@ -2006,8 +1993,6 @@
     sz_strlcpy(packet.team_name[i], team_get_by_id(i)->name);
   }
 
-  packet.default_building = game.default_building;
-
   lsend_packet_ruleset_control(dest, &packet);
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9817) default building specified in ruleset, Jason Short <=