Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8811) use equiv_range for wonder range
Home

[Freeciv-Dev] (PR#8811) use equiv_range for wonder range

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8811) use equiv_range for wonder range
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 May 2004 03:36:55 -0700
Reply-to: rt@xxxxxxxxxxx

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

This is an extension of Vasco's wonder.diff patch.  I added support for 
IR_WORLD, and rewrote some comments.

jason

? convert.sh
? eff
? flags
? spec.diff
? data/flags
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.211
diff -u -r1.211 city.c
--- common/city.c       21 May 2004 19:03:43 -0000      1.211
+++ common/city.c       22 May 2004 10:26:08 -0000
@@ -1090,62 +1090,35 @@
     return FALSE;
   if (city_got_building(pcity, id))
     return TRUE;
-  
-  /* For Manhatten it can be owned by anyone, and it doesn't matter
-   * whether it is destroyed or not.
-   *
-   * (The same goes for Apollo, with respect to building spaceship parts,
-   * but not for getting the map effect.  This function only returns true
-   * for Apollo for the owner of a non-destroyed Apollo; for building
-   * spaceship parts just check (game.global_wonders[id] != 0).
-   * (Actually, this function is not currently used for either Manhatten
-   * or Apollo.))
-   *
-   * Otherwise the player who owns the city needs to have it to
-   * get the effect.
-   */
-  if (id==B_MANHATTEN) 
-    return (game.global_wonders[id] != 0);
-  
-  tmp = player_find_city_by_id(city_owner(pcity), game.global_wonders[id]);
+
+  /* Check the equiv_range of the wonder.  This is a hack because
+   * it assumes all effects of the wonder have the same range, which may
+   * not be true.  However for the current wonders it works.  Note that
+   * all of the effects are special-cased elsewhere, and sometimes the
+   * ranges are too (this is true for B_MANHATTEN and B_APOLLO). */
+  tmp = find_city_by_id(game.global_wonders[id]);
   if (!tmp)
     return FALSE;
-  switch (id) {
-  case B_ASMITHS:
-  case B_APOLLO:
-  case B_CURE:
-  case B_GREAT:
-  case B_WALL:
-  case B_HANGING:
-  case B_ORACLE:
-  case B_UNITED:
-  case B_WOMENS:
-  case B_DARWIN:
-  case B_LIGHTHOUSE:
-  case B_MAGELLAN:
-  case B_MICHELANGELO:
-  case B_SETI:
-  case B_PYRAMIDS:
-  case B_LIBERTY:
-  case B_SUNTZU:
+
+  switch (get_improvement_type(id)->equiv_range) {
+  case IR_PLAYER:
+    return tmp->owner == pcity->owner;
+  case IR_ISLAND:
+    return (tmp->owner == pcity->owner
+           && (map_get_continent(tmp->x, tmp->y)
+               == map_get_continent(pcity->x, pcity->y)));
+  case IR_WORLD:
     return TRUE;
-  case B_ISAAC:
-  case B_COPERNICUS:
-  case B_SHAKESPEARE:
-  case B_COLLOSSUS:
-  case B_RICHARDS:
-    return FALSE;
-  case B_HOOVER:
-  case B_BACH:
-    if (improvement_variant(id)==1) {
-      return (map_get_continent(tmp->x, tmp->y) ==
-             map_get_continent(pcity->x, pcity->y));
-    } else {
-      return TRUE;
-    }
-  default:
+  case IR_CITY:
+    return pcity == tmp;
+  case IR_NONE:
     return FALSE;
+  case IR_LAST:
+    break;
   }
+
+  assert(0);
+  return FALSE;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8811) use equiv_range for wonder range, Jason Short <=