Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Pop cost patch (resending via bug system) (PR#897)
Home

[Freeciv-Dev] Re: Pop cost patch (resending via bug system) (PR#897)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Trent Piepho <xyzzy@xxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Pop cost patch (resending via bug system) (PR#897)
From: Arien Malec <arien_malec@xxxxxxxxx>
Date: Tue, 21 Aug 2001 16:44:19 -0700 (PDT)

Here's an add_to_city_status patch that actually compiles :-)

Arien

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.125
diff -u -r1.125 unit.c
--- common/unit.c       2001/08/13 12:25:26     1.125
+++ common/unit.c       2001/08/21 23:37:44
@@ -413,35 +413,42 @@
 /**************************************************************************
 ...
 **************************************************************************/
-int can_unit_add_to_city(struct unit *punit)
+enum add_to_city_status unit_add_to_city_status (struct unit *punit)
 {
   struct city *pcity;
 
   if(!unit_flag(punit->type, F_CITIES))
-    return 0;
+    return ADD_NOT_ADDABLE_UNIT;
   if(!punit->moves_left)
-    return 0;
+    return ADD_NO_MOVES;
 
   pcity = map_get_city(punit->x, punit->y);
 
   if(!pcity)
-    return 0;
+    return ADD_NOT_AT_CITY;
   if(pcity->size >= game.add_to_size_limit)
-    return 0;
+    return ADD_TOO_BIG;
   if(pcity->owner != punit->owner)
-    return 0;
+    return ADD_NOT_OWNER;
 
   if(improvement_exists(B_AQUEDUCT)
      && !city_got_building(pcity, B_AQUEDUCT) 
      && pcity->size >= game.aqueduct_size)
-    return 0;
+    return ADD_NO_AQUEDUCT;
   
   if(improvement_exists(B_SEWER)
      && !city_got_building(pcity, B_SEWER)
      && pcity->size >= game.sewer_size)
-    return 0;
+    return ADD_NO_SEWER;
 
-  return 1;
+  return ADD_OK;
+}
+/**************************************************************************
+...
+**************************************************************************/
+int can_unit_add_to_city(struct unit *punit)
+{
+  return (unit_add_to_city_status (punit) == ADD_OK);
 }
 
 /**************************************************************************
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.72
diff -u -r1.72 unit.h
--- common/unit.h       2001/08/13 12:25:27     1.72
+++ common/unit.h       2001/08/21 23:37:44
@@ -66,6 +66,19 @@
   MR_OTHER, MR_INVALID_TYPE_FOR_CITY_TAKE_OVER, MR_NO_WAR, MR_ZOC
 };
 
+enum add_to_city_status {
+  ADD_OK, /* Unit OK to add to city */
+  ADD_NO_MOVES, /* Unit does not have moves left */
+  ADD_NOT_AT_CITY, /* Unit is not at a city */
+  ADD_NOT_OWNER, /* Owner of unit is not owner of city */
+  ADD_NOT_ADDABLE_UNIT, /* Unit is not one that can be added to cities */
+  ADD_TOO_BIG, /* City is too big to be added to */
+  ADD_NO_AQUEDUCT, /* Adding takes city past limit for aquaduct but
+                     city has no aquaduct */
+  ADD_NO_SEWER /* Adding takes city past limit for sewer but city
+                 has no sewer */
+};
+
 struct unit_ai {
   int control; /* 0: not automated    1: automated */
   enum ai_unit_task ai_role;
@@ -186,6 +199,7 @@
 int is_heli_unit(struct unit *punit);
 int is_ground_unit(struct unit *punit);
 int can_unit_build_city(struct unit *punit);
+enum add_to_city_status unit_add_to_city_status (struct unit *punit);
 int can_unit_add_to_city(struct unit *punit);
 int kills_citizen_after_attack(struct unit *punit);
 

[Prev in Thread] Current Thread [Next in Thread]