Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#2521) general effects prepatch
Home

[Freeciv-Dev] (PR#2521) general effects prepatch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#2521) general effects prepatch
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Aug 2003 19:59:12 -0700
Reply-to: rt@xxxxxxxxxxxxxx

here's a patch that creates the files effects.c and effects.h and moves the
existing effects functions, prototypes, arrays, and enums from improvement.c
and improvement.h

The patch is straightforward. If no one screams, I'll commit it tomorrow.

-mike

diff -Nur -Xsnap/diff_ignore snap/common/Makefile.am 
snap-peff/common/Makefile.am
--- snap/common/Makefile.am     2003-02-22 11:43:42.000000000 -0600
+++ snap-peff/common/Makefile.am        2003-08-07 21:41:44.000000000 -0500
@@ -26,6 +26,8 @@
                dataio.h        \
                diptreaty.c     \
                diptreaty.h     \
+               effects.c       \
+               effects.h       \
                events.h        \
                fcintl.c        \
                fcintl.h        \
diff -Nur -Xsnap/diff_ignore snap/common/effects.c snap-peff/common/effects.c
--- snap/common/effects.c       1969-12-31 18:00:00.000000000 -0600
+++ snap-peff/common/effects.c  2003-08-07 21:43:56.000000000 -0500
@@ -0,0 +1,183 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <string.h>
+
+#include "effects.h"
+#include "game.h"
+#include "government.h"
+#include "improvement.h"
+#include "log.h"
+#include "map.h"
+#include "mem.h"
+#include "support.h"
+#include "tech.h"
+#include "shared.h" /* ARRAY_SIZE */
+
+
+/* Names of effect ranges.
+ * (These must correspond to enum effect_range_id in effects.h.)
+ * do not change these unless you know what you're doing! */
+static const char *effect_range_names[] = {
+  "Local",
+  "City",
+  "Island",
+  "Player",
+  "World"
+};
+
+/* Names of effect types.
+ * (These must correspond to enum effect_type_id in effects.h.) */
+static const char *effect_type_names[] = {
+  "Adv_Parasite",
+  "Airlift",
+  "Any_Government",
+  "Barb_Attack",
+  "Barb_Defend",
+  "Capital_City",
+  "Capital_Exists",
+  "Enable_Nuke",
+  "Enable_Space",
+  "Enemy_Peaceful",
+  "Food_Add_Tile",
+  "Food_Bonus",
+  "Food_Inc_Tile",
+  "Food_Per_Tile",
+  "Give_Imm_Adv",
+  "Growth_Food",
+  "Have_Embassies",
+  "Improve_Rep",
+  "Luxury_Bonus",
+  "Luxury_Pct",
+  "Make_Content",
+  "Make_Content_Mil",
+  "Make_Content_Pct",
+  "Make_Happy",
+  "May_Declare_War",
+  "No_Anarchy",
+  "No_Sink_Deep",
+  "Nuke_Proof",
+  "Pollu_Adj",
+  "Pollu_Adj_Pop",
+  "Pollu_Adj_Prod",
+  "Pollu_Set",
+  "Pollu_Set_Pop",
+  "Pollu_Set_Prod",
+  "Prod_Add_Tile",
+  "Prod_Bonus",
+  "Prod_Inc_Tile",
+  "Prod_Per_Tile",
+  "Prod_To_Gold",
+  "Reduce_Corrupt",
+  "Reduce_Waste",
+  "Reveal_Cities",
+  "Reveal_Map",
+  "Revolt_Dist",
+  "Science_Bonus",
+  "Science_Pct",
+  "Size_Unlimit",
+  "Slow_Nuke_Winter",
+  "Slow_Global_Warm",
+  "Space_Part",
+  "Spy_Resistant",
+  "Tax_Bonus",
+  "Tax_Pct",
+  "Trade_Add_Tile",
+  "Trade_Bonus",
+  "Trade_Inc_Tile",
+  "Trade_Per_Tile",
+  "Trade_Route_Pct",
+  "Unit_Defend",
+  "Unit_Move",
+  "Unit_No_Lose_Pop",
+  "Unit_Recover",
+  "Unit_Repair",
+  "Unit_Vet_Combat",
+  "Unit_Veteran",
+  "Upgrade_Units",
+  "Upgrade_One_Step",
+  "Upgrade_One_Leap",
+  "Upgrade_All_Step",
+  "Upgrade_All_Leap",
+  "Upkeep_Free"
+};
+
+/**************************************************************************
+  Convert effect range names to enum; case insensitive;
+  returns EFR_LAST if can't match.
+**************************************************************************/
+enum effect_range effect_range_from_str(const char *str)
+{
+  enum effect_range ret_id;
+
+  assert(ARRAY_SIZE(effect_range_names) == EFR_LAST);
+
+  for (ret_id = 0; ret_id < EFR_LAST; ret_id++) {
+    if (0 == mystrcasecmp(effect_range_names[ret_id], str)) {
+      return ret_id;
+    }
+  }
+
+  return EFR_LAST;
+}
+
+/**************************************************************************
+  Return effect range name; NULL if bad id.
+**************************************************************************/
+const char *effect_range_name(enum effect_range id)
+{
+  assert(ARRAY_SIZE(effect_range_names) == EFR_LAST);
+
+  if (id < EFR_LAST) {
+    return effect_range_names[id];
+  } else {
+    return NULL;
+  }
+}
+
+/**************************************************************************
+  Convert effect type names to enum; case insensitive;
+  returns EFT_LAST if can't match.
+**************************************************************************/
+enum effect_type effect_type_from_str(const char *str)
+{
+  enum effect_type ret_id;
+
+  assert(ARRAY_SIZE(effect_type_names) == EFT_LAST);
+
+  for (ret_id = 0; ret_id < EFT_LAST; ret_id++) {
+    if (0 == mystrcasecmp(effect_type_names[ret_id], str)) {
+      return ret_id;
+    }
+  }
+
+  return EFT_LAST;
+}
+
+/**************************************************************************
+  Return effect type name; NULL if bad id.
+**************************************************************************/
+const char *effect_type_name(enum effect_type id)
+{
+  assert(ARRAY_SIZE(effect_type_names) == EFT_LAST);
+
+  if (id < EFT_LAST) {
+    return effect_type_names[id];
+  } else {
+    return NULL;
+  }
+}
diff -Nur -Xsnap/diff_ignore snap/common/effects.h snap-peff/common/effects.h
--- snap/common/effects.h       1969-12-31 18:00:00.000000000 -0600
+++ snap-peff/common/effects.h  2003-08-07 21:43:16.000000000 -0500
@@ -0,0 +1,116 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__EFFECTS_H
+#define FC__EFFECTS_H
+
+
+#include "shared.h"            /* bool */
+#include "terrain.h"
+
+/* Range of effects (used in equiv_range and effect.range fields)
+ * These must correspond to effect_range_names[] in improvement.c. */
+enum effect_range {
+  EFR_LOCAL,
+  EFR_CITY,
+  EFR_ISLAND,
+  EFR_PLAYER,
+  EFR_WORLD,
+  EFR_LAST   /* keep this last */
+};
+
+/* Type of effects. (Used in effect.type field)
+ * These must correspond to effect_type_names[] in effects.c. */
+enum effect_type {
+  EFT_ADV_PARASITE,
+  EFT_AIRLIFT,
+  EFT_ANY_GOVERNMENT,
+  EFT_BARB_ATTACK,
+  EFT_BARB_DEFEND,
+  EFT_CAPITAL_CITY,
+  EFT_CAPITAL_EXISTS,
+  EFT_ENABLE_NUKE,
+  EFT_ENABLE_SPACE,
+  EFT_ENEMY_PEACEFUL,
+  EFT_FOOD_ADD_TILE,
+  EFT_FOOD_BONUS,
+  EFT_FOOD_INC_TILE,
+  EFT_FOOD_PER_TILE,
+  EFT_GIVE_IMM_ADV,
+  EFT_GROWTH_FOOD,
+  EFT_HAVE_EMBASSIES,
+  EFT_IMPROVE_REP,
+  EFT_LUXURY_BONUS,
+  EFT_LUXURY_PCT,
+  EFT_MAKE_CONTENT,
+  EFT_MAKE_CONTENT_MIL,
+  EFT_MAKE_CONTENT_PCT,
+  EFT_MAKE_HAPPY,
+  EFT_MAY_DECLARE_WAR,
+  EFT_NO_ANARCHY,
+  EFT_NO_SINK_DEEP,
+  EFT_NUKE_PROOF,
+  EFT_POLLU_ADJ,
+  EFT_POLLU_ADJ_POP,
+  EFT_POLLU_ADJ_PROD,
+  EFT_POLLU_SET,
+  EFT_POLLU_SET_POP,
+  EFT_POLLU_SET_PROD,
+  EFT_PROD_ADD_TILE,
+  EFT_PROD_BONUS,
+  EFT_PROD_INC_TILE,
+  EFT_PROD_PER_TILE,
+  EFT_PROD_TO_GOLD,
+  EFT_REDUCE_CORRUPT,
+  EFT_REDUCE_WASTE,
+  EFT_REVEAL_CITIES,
+  EFT_REVEAL_MAP,
+  EFT_REVOLT_DIST,
+  EFT_SCIENCE_BONUS,
+  EFT_SCIENCE_PCT,
+  EFT_SIZE_UNLIMIT,
+  EFT_SLOW_NUKE_WINTER,
+  EFT_SLOW_GLOBAL_WARM,
+  EFT_SPACE_PART,
+  EFT_SPY_RESISTANT,
+  EFT_TAX_BONUS,
+  EFT_TAX_PCT,
+  EFT_TRADE_ADD_TILE,
+  EFT_TRADE_BONUS,
+  EFT_TRADE_INC_TILE,
+  EFT_TRADE_PER_TILE,
+  EFT_TRADE_ROUTE_PCT,
+  EFT_UNIT_DEFEND,
+  EFT_UNIT_MOVE,
+  EFT_UNIT_NO_LOSE_POP,
+  EFT_UNIT_RECOVER,
+  EFT_UNIT_REPAIR,
+  EFT_UNIT_VET_COMBAT,
+  EFT_UNIT_VETERAN,
+  EFT_UPGRADE_UNITS,
+  EFT_UPGRADE_ONE_STEP,
+  EFT_UPGRADE_ONE_LEAP,
+  EFT_UPGRADE_ALL_STEP,
+  EFT_UPGRADE_ALL_LEAP,
+  EFT_UPKEEP_FREE,
+  EFT_LAST     /* keep this last */
+};
+
+#define EFT_ALL EFT_LAST
+
+/* lookups */
+enum effect_range effect_range_from_str(const char *str);
+const char *effect_range_name(enum effect_range id);
+enum effect_type effect_type_from_str(const char *str);
+const char *effect_type_name(enum effect_type id);
+
+#endif  /* FC__EFFECTS_H */
diff -Nur -Xsnap/diff_ignore snap/common/improvement.c 
snap-peff/common/improvement.c
--- snap/common/improvement.c   2003-04-04 15:40:27.000000000 -0600
+++ snap-peff/common/improvement.c      2003-08-07 21:49:07.000000000 -0500
@@ -48,161 +48,6 @@
 **************************************************************************/
 struct impr_type improvement_types[B_LAST];
 
-/* Names of effect ranges.
- * (These must correspond to enum effect_range_id in improvement.h.)
- */
-static const char *effect_range_names[] = {
-  "None",
-  "Local",
-  "City",
-  "Island",
-  "Player",
-  "World"
-};
-
-/* Names of effect types.
- * (These must correspond to enum effect_type_id in improvement.h.)
- */
-static const char *effect_type_names[] = {
-  "Adv_Parasite",
-  "Airlift",
-  "Any_Government",
-  "Barb_Attack",
-  "Barb_Defend",
-  "Capital_City",
-  "Capital_Exists",
-  "Enable_Nuke",
-  "Enable_Space",
-  "Enemy_Peaceful",
-  "Food_Add_Tile",
-  "Food_Bonus",
-  "Food_Inc_Tile",
-  "Food_Per_Tile",
-  "Give_Imm_Adv",
-  "Growth_Food",
-  "Have_Embassies",
-  "Improve_Rep",
-  "Luxury_Bonus",
-  "Luxury_Pct",
-  "Make_Content",
-  "Make_Content_Mil",
-  "Make_Content_Pct",
-  "Make_Happy",
-  "May_Declare_War",
-  "No_Anarchy",
-  "No_Sink_Deep",
-  "Nuke_Proof",
-  "Pollu_Adj",
-  "Pollu_Adj_Pop",
-  "Pollu_Adj_Prod",
-  "Pollu_Set",
-  "Pollu_Set_Pop",
-  "Pollu_Set_Prod",
-  "Prod_Add_Tile",
-  "Prod_Bonus",
-  "Prod_Inc_Tile",
-  "Prod_Per_Tile",
-  "Prod_To_Gold",
-  "Reduce_Corrupt",
-  "Reduce_Waste",
-  "Reveal_Cities",
-  "Reveal_Map",
-  "Revolt_Dist",
-  "Science_Bonus",
-  "Science_Pct",
-  "Size_Unlimit",
-  "Slow_Nuke_Winter",
-  "Slow_Global_Warm",
-  "Space_Part",
-  "Spy_Resistant",
-  "Tax_Bonus",
-  "Tax_Pct",
-  "Trade_Add_Tile",
-  "Trade_Bonus",
-  "Trade_Inc_Tile",
-  "Trade_Per_Tile",
-  "Trade_Route_Pct",
-  "Unit_Defend",
-  "Unit_Move",
-  "Unit_No_Lose_Pop",
-  "Unit_Recover",
-  "Unit_Repair",
-  "Unit_Vet_Combat",
-  "Unit_Veteran",
-  "Upgrade_Units",
-  "Upgrade_One_Step",
-  "Upgrade_One_Leap",
-  "Upgrade_All_Step",
-  "Upgrade_All_Leap",
-  "Upkeep_Free"
-};
-
-/**************************************************************************
-  Convert effect range names to enum; case insensitive;
-  returns EFR_LAST if can't match.
-**************************************************************************/
-enum effect_range effect_range_from_str(const char *str)
-{
-  enum effect_range ret_id;
-
-  assert(ARRAY_SIZE(effect_range_names) == EFR_LAST);
-
-  for (ret_id = 0; ret_id < EFR_LAST; ret_id++) {
-    if (0 == mystrcasecmp(effect_range_names[ret_id], str)) {
-      return ret_id;
-    }
-  }
-
-  return EFR_LAST;
-}
-
-/**************************************************************************
-  Return effect range name; NULL if bad id.
-**************************************************************************/
-const char *effect_range_name(enum effect_range id)
-{
-  assert(ARRAY_SIZE(effect_range_names) == EFR_LAST);
-
-  if (id < EFR_LAST) {
-    return effect_range_names[id];
-  } else {
-    return NULL;
-  }
-}
-
-/**************************************************************************
-  Convert effect type names to enum; case insensitive;
-  returns EFT_LAST if can't match.
-**************************************************************************/
-enum effect_type effect_type_from_str(const char *str)
-{
-  enum effect_type ret_id;
-
-  assert(ARRAY_SIZE(effect_type_names) == EFT_LAST);
-
-  for (ret_id = 0; ret_id < EFT_LAST; ret_id++) {
-    if (0 == mystrcasecmp(effect_type_names[ret_id], str)) {
-      return ret_id;
-    }
-  }
-
-  return EFT_LAST;
-}
-
-/**************************************************************************
-  Return effect type name; NULL if bad id.
-**************************************************************************/
-const char *effect_type_name(enum effect_type id)
-{
-  assert(ARRAY_SIZE(effect_type_names) == EFT_LAST);
-
-  if (id < EFT_LAST) {
-    return effect_type_names[id];
-  } else {
-    return NULL;
-  }
-}
-
 /**************************************************************************
   Convert impr range names to enum; case insensitive;
   returns IR_LAST if can't match.
diff -Nur -Xsnap/diff_ignore snap/common/improvement.h 
snap-peff/common/improvement.h
--- snap/common/improvement.h   2003-02-16 23:23:55.000000000 -0600
+++ snap-peff/common/improvement.h      2003-08-07 21:47:49.000000000 -0500
@@ -19,6 +19,7 @@
 #include "tech.h"              /* Tech_Type_id */
 #include "terrain.h"           /* enum tile_terrain_type etc */
 #include "unittype.h"          /* Unit_Class_id, Unit_Type_id */
+#include "effects.h"
 
 struct player;
 
@@ -77,95 +78,6 @@
   IR_LAST      /* keep this last */
 };
 
-/* Range of effects (used in equiv_range and effect.range fields)
- * These must correspond to effect_range_names[] in improvement.c. */
-enum effect_range {
-  EFR_NONE,
-  EFR_BUILDING,
-  EFR_CITY,
-  EFR_ISLAND,
-  EFR_PLAYER,
-  EFR_WORLD,
-  EFR_LAST     /* keep this last */
-};
-
-/* Type of effects. (Used in effect.type field)
- * These must correspond to effect_type_names[] in improvement.c. */
-enum effect_type {
-  EFT_ADV_PARASITE,
-  EFT_AIRLIFT,
-  EFT_ANY_GOVERNMENT,
-  EFT_BARB_ATTACK,
-  EFT_BARB_DEFEND,
-  EFT_CAPITAL_CITY,
-  EFT_CAPITAL_EXISTS,
-  EFT_ENABLE_NUKE,
-  EFT_ENABLE_SPACE,
-  EFT_ENEMY_PEACEFUL,
-  EFT_FOOD_ADD_TILE,
-  EFT_FOOD_BONUS,
-  EFT_FOOD_INC_TILE,
-  EFT_FOOD_PER_TILE,
-  EFT_GIVE_IMM_ADV,
-  EFT_GROWTH_FOOD,
-  EFT_HAVE_EMBASSIES,
-  EFT_IMPROVE_REP,
-  EFT_LUXURY_BONUS,
-  EFT_LUXURY_PCT,
-  EFT_MAKE_CONTENT,
-  EFT_MAKE_CONTENT_MIL,
-  EFT_MAKE_CONTENT_PCT,
-  EFT_MAKE_HAPPY,
-  EFT_MAY_DECLARE_WAR,
-  EFT_NO_ANARCHY,
-  EFT_NO_SINK_DEEP,
-  EFT_NUKE_PROOF,
-  EFT_POLLU_ADJ,
-  EFT_POLLU_ADJ_POP,
-  EFT_POLLU_ADJ_PROD,
-  EFT_POLLU_SET,
-  EFT_POLLU_SET_POP,
-  EFT_POLLU_SET_PROD,
-  EFT_PROD_ADD_TILE,
-  EFT_PROD_BONUS,
-  EFT_PROD_INC_TILE,
-  EFT_PROD_PER_TILE,
-  EFT_PROD_TO_GOLD,
-  EFT_REDUCE_CORRUPT,
-  EFT_REDUCE_WASTE,
-  EFT_REVEAL_CITIES,
-  EFT_REVEAL_MAP,
-  EFT_REVOLT_DIST,
-  EFT_SCIENCE_BONUS,
-  EFT_SCIENCE_PCT,
-  EFT_SIZE_UNLIMIT,
-  EFT_SLOW_NUKE_WINTER,
-  EFT_SLOW_GLOBAL_WARM,
-  EFT_SPACE_PART,
-  EFT_SPY_RESISTANT,
-  EFT_TAX_BONUS,
-  EFT_TAX_PCT,
-  EFT_TRADE_ADD_TILE,
-  EFT_TRADE_BONUS,
-  EFT_TRADE_INC_TILE,
-  EFT_TRADE_PER_TILE,
-  EFT_TRADE_ROUTE_PCT,
-  EFT_UNIT_DEFEND,
-  EFT_UNIT_MOVE,
-  EFT_UNIT_NO_LOSE_POP,
-  EFT_UNIT_RECOVER,
-  EFT_UNIT_REPAIR,
-  EFT_UNIT_VET_COMBAT,
-  EFT_UNIT_VETERAN,
-  EFT_UPGRADE_UNITS,
-  EFT_UPGRADE_ONE_STEP,
-  EFT_UPGRADE_ONE_LEAP,
-  EFT_UPGRADE_ALL_STEP,
-  EFT_UPGRADE_ALL_LEAP,
-  EFT_UPKEEP_FREE,
-  EFT_LAST     /* keep this last */
-};
-
 /* An effect conferred by an improvement. */
 struct impr_effect {
   enum effect_type type;
@@ -184,7 +96,7 @@
 /* Maximum number of effects per improvement 
  * (this should not be more than the number of bits in the Eff_Status type) */
 #define MAX_EFFECTS 16
-
+  
 /* Type of improvement. (Read from buildings.ruleset file.) */
 struct impr_type {
   char name[MAX_LEN_NAME];
@@ -218,12 +130,6 @@
 enum impr_range impr_range_from_str(const char *str);
 const char *impr_range_name(enum impr_range id);
 
-/* improvement effect functions */
-enum effect_range effect_range_from_str(const char *str);
-const char *effect_range_name(enum effect_range id);
-enum effect_type effect_type_from_str(const char *str);
-const char *effect_type_name(enum effect_type id);
-
 /* improvement functions */
 void improvements_free(void);
 struct impr_type *get_improvement_type(Impr_Type_id id);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2521) general effects prepatch, Mike Kaufman <=