Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9892) space part effects
Home

[Freeciv-Dev] (PR#9892) space part effects

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9892) space part effects
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 31 Aug 2004 21:23:43 -0700
Reply-to: rt@xxxxxxxxxxx

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

In Vasco's effects patch the Space_Part effect is replaced with 
SS_Component, SS_Structural, and SS_Module effects.  The only real 
advantage of this is that building_has_effect can be used directly 
(since that function returns a boolean rather than an integer).

This patch makes that change, and removes most references to the space 
part enum values.  Unlike the effects patch, Space_Part is removed and 
all rulesets are updated.

Note that if a space part has any other effects, bad things may happen. 
  Surely this should be documented, and possibly checked in the ruleset 
loading code.

jason

Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.7
diff -u -r1.7 effects.c
--- common/effects.c    1 Sep 2004 03:16:47 -0000       1.7
+++ common/effects.c    1 Sep 2004 04:16:22 -0000
@@ -98,7 +98,9 @@
   "Size_Unlimit",
   "Slow_Nuke_Winter",
   "Slow_Global_Warm",
-  "Space_Part",
+  "SS_Structural",
+  "SS_Component",
+  "SS_Module",
   "Spy_Resistant",
   "Tax_Bonus",
   "Tax_Pct",
@@ -253,10 +255,24 @@
 int get_current_construction_bonus(const struct city *pcity,
                                   enum effect_type effect)
 {
-  if (effect == EFT_PROD_TO_GOLD) {
-    return (!pcity->is_building_unit 
-           && pcity->currently_building == B_CAPITAL) ? 1 : 0;
+  if (pcity->is_building_unit) {
+    return 0; /* No effects for units. */
   }
+
+  switch (effect) {
+  case EFT_PROD_TO_GOLD:
+    return (pcity->currently_building == B_CAPITAL) ? 1 : 0;
+  case EFT_SS_STRUCTURAL:
+    return (pcity->currently_building == B_SSTRUCTURAL) ? 1 : 0;
+  case EFT_SS_COMPONENT:
+    return (pcity->currently_building == B_SCOMP) ? 1 : 0;
+  case EFT_SS_MODULE:
+    return (pcity->currently_building == B_SMODULE) ? 1 : 0;
+  default:
+    /* All others unsupported. */
+    break;
+  }
+
   assert(0);
   return 0;
 }
Index: common/effects.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.h,v
retrieving revision 1.5
diff -u -r1.5 effects.h
--- common/effects.h    1 Sep 2004 03:16:47 -0000       1.5
+++ common/effects.h    1 Sep 2004 04:16:22 -0000
@@ -91,7 +91,9 @@
   EFT_SIZE_UNLIMIT,
   EFT_SLOW_NUKE_WINTER,
   EFT_SLOW_GLOBAL_WARM,
-  EFT_SPACE_PART,
+  EFT_SS_STRUCTURAL,
+  EFT_SS_COMPONENT,
+  EFT_SS_MODULE,
   EFT_SPY_RESISTANT,
   EFT_TAX_BONUS,
   EFT_TAX_PCT,
Index: common/improvement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v
retrieving revision 1.44
diff -u -r1.44 improvement.c
--- common/improvement.c        1 Sep 2004 03:16:47 -0000       1.44
+++ common/improvement.c        1 Sep 2004 04:16:22 -0000
@@ -130,9 +130,13 @@
   if (id<0 || id>=B_LAST || id>=game.num_impr_types)
     return FALSE;
 
-  if ((id==B_SCOMP || id==B_SMODULE || id==B_SSTRUCTURAL)
-      && !game.spacerace)
+  if (!game.spacerace
+      && (building_has_effect(id, EFT_SS_STRUCTURAL)
+         || building_has_effect(id, EFT_SS_COMPONENT)
+         || building_has_effect(id, EFT_SS_MODULE))) {
+    /* This assumes that space parts don't have any other effects. */
     return FALSE;
+  }
 
   return (improvement_types[id].tech_req!=A_LAST);
 }
@@ -383,6 +387,7 @@
                                              Impr_Type_id id)
 {
   struct impr_type *impr;
+  bool space_part = FALSE;
 
   /* This also checks if tech req is Never */
   if (!improvement_exists(id))
@@ -390,28 +395,31 @@
 
   impr = get_improvement_type(id);
 
-  if (impr->effect) {
-    struct impr_effect *peffect = impr->effect;
-    enum effect_type type;
-
-    /* This if for a spaceship component is asked */
-    while ((type = peffect->type) != EFT_LAST) {
-      if (type == EFT_SPACE_PART) {
-       /* TODO: remove this */
-       if (game.global_wonders[B_APOLLO] == 0)
-         return FALSE;
-        if (p->spaceship.state >= SSHIP_LAUNCHED)
-         return FALSE;
-       if (peffect->amount == 1 && p->spaceship.structurals >= 
NUM_SS_STRUCTURALS)
-         return FALSE;
-       if (peffect->amount == 2 && p->spaceship.components >= 
NUM_SS_COMPONENTS)
-         return FALSE;
-       if (peffect->amount == 3 && p->spaceship.modules >= NUM_SS_MODULES)
-         return FALSE;
-      }
-      peffect++;
+  /* Check for space part construction.  This assumes that space parts have
+   * no other effects. */
+  if (building_has_effect(id, EFT_SS_STRUCTURAL)) {
+    space_part = TRUE;
+    if (p->spaceship.structurals >= NUM_SS_STRUCTURALS) {
+      return FALSE;
     }
   }
+  if (building_has_effect(id, EFT_SS_COMPONENT)) {
+    space_part = TRUE;
+    if (p->spaceship.components >= NUM_SS_COMPONENTS) {
+      return FALSE;
+    }
+  }
+  if (building_has_effect(id, EFT_SS_MODULE)) {
+    space_part = TRUE;
+    if (p->spaceship.modules >= NUM_SS_MODULES) {
+      return FALSE;
+    }
+  }
+  if (space_part && (game.global_wonders[B_APOLLO] == 0
+                    || p->spaceship.state >= SSHIP_LAUNCHED)) {
+    return FALSE;
+  }
+
   if (is_wonder(id)) {
     /* Can't build wonder if already built */
     if (game.global_wonders[id] != 0) return FALSE;
Index: data/civ1/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/buildings.ruleset,v
retrieving revision 1.35
diff -u -r1.35 buildings.ruleset
--- data/civ1/buildings.ruleset 27 Aug 2004 17:14:42 -0000      1.35
+++ data/civ1/buildings.ruleset 1 Sep 2004 04:16:22 -0000
@@ -1000,8 +1000,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 2
+    { "type", "range"
+       "SS_Component", "Local"
     }
 sound          = "b_space_component"
 sound_alt      = "b_generic"
@@ -1031,8 +1031,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 3
+    { "type", "range"
+       "SS_Module", "Local"
     }
 sound          = "b_space_module"
 sound_alt      = "b_generic"
@@ -1071,8 +1071,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 1
+    { "type", "range"
+       "SS_Structural", "Local"
     }
 sound          = "b_space_structural"
 sound_alt      = "b_generic"
Index: data/civ2/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/buildings.ruleset,v
retrieving revision 1.38
diff -u -r1.38 buildings.ruleset
--- data/civ2/buildings.ruleset 27 Aug 2004 17:14:42 -0000      1.38
+++ data/civ2/buildings.ruleset 1 Sep 2004 04:16:23 -0000
@@ -991,8 +991,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 2
+    { "type", "range"
+       "SS_Component", "Local"
     }
 sound          = "b_space_component"
 sound_alt      = "b_generic"
@@ -1022,8 +1022,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 3
+    { "type", "range"
+       "SS_Module", "Local"
     }
 sound          = "b_space_module"
 sound_alt      = "b_generic"
@@ -1062,8 +1062,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 1
+    { "type", "range"
+       "SS_Structural", "Local"
     }
 sound          = "b_space_structural"
 sound_alt      = "b_generic"
Index: data/default/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/buildings.ruleset,v
retrieving revision 1.50
diff -u -r1.50 buildings.ruleset
--- data/default/buildings.ruleset      27 Aug 2004 17:14:42 -0000      1.50
+++ data/default/buildings.ruleset      1 Sep 2004 04:16:23 -0000
@@ -1058,8 +1058,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 2
+    { "type", "range"
+       "SS_Component", "Local"
     }
 sound          = "b_space_component"
 sound_alt      = "b_generic"
@@ -1089,8 +1089,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 3
+    { "type", "range"
+       "SS_Module", "Local"
     }
 sound          = "b_space_module"
 sound_alt      = "b_generic"
@@ -1129,8 +1129,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 1
+    { "type", "range"
+       "SS_Structural", "Local"
     }
 sound          = "b_space_structural"
 sound_alt      = "b_generic"
Index: data/history/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/buildings.ruleset,v
retrieving revision 1.10
diff -u -r1.10 buildings.ruleset
--- data/history/buildings.ruleset      27 Aug 2004 17:14:42 -0000      1.10
+++ data/history/buildings.ruleset      1 Sep 2004 04:16:23 -0000
@@ -1011,8 +1011,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 2
+    { "type", "range"
+       "SS_Component", "Local"
     }
 sound          = "b_space_component"
 sound_alt      = "b_generic"
@@ -1042,8 +1042,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 3
+    { "type", "range"
+       "SS_Module", "Local"
     }
 sound          = "b_space_module"
 sound_alt      = "b_generic"
@@ -1082,8 +1082,8 @@
 upkeep         = 0
 sabotage       = 100
 effect         =
-    { "type", "range", "amount"
-       "Space_Part", "Local", 1
+    { "type", "range"
+       "SS_Structural", "Local"
     }
 sound          = "b_space_structural"
 sound_alt      = "b_generic"
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.258
diff -u -r1.258 cityturn.c
--- server/cityturn.c   28 Aug 2004 19:15:39 -0000      1.258
+++ server/cityturn.c   1 Sep 2004 04:16:24 -0000
@@ -934,11 +934,11 @@
     }
 
     space_part = TRUE;
-    if (pcity->currently_building == B_SSTRUCTURAL) {
+    if (get_current_construction_bonus(pcity, EFT_SS_STRUCTURAL) > 0) {
       pplayer->spaceship.structurals++;
-    } else if (pcity->currently_building == B_SCOMP) {
+    } else if (get_current_construction_bonus(pcity, EFT_SS_COMPONENT) > 0) {
       pplayer->spaceship.components++;
-    } else if (pcity->currently_building == B_SMODULE) {
+    } else if (get_current_construction_bonus(pcity, EFT_SS_MODULE) > 0) {
       pplayer->spaceship.modules++;
     } else {
       space_part = FALSE;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9892) space part effects, Jason Short <=