[Freeciv-Dev] (PR#9382) city_can_grow_to() to replace wants_to_be_bigger
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#9382) city_can_grow_to() to replace wants_to_be_bigger() |
From: |
"Jason Dorje Short" <jdorje@xxxxxxxxxxx> |
Date: |
Tue, 13 Jul 2004 22:43:38 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9382 >
This patch does two things, both small:
- A new patch city_can_grow_to(pcity, pop_size) is added. This function
checks if the city is able to grow to the current size. However since
it only returns a boolean there are some places where it is hard to use,
since the caller wants to give a useful message like "build an aqueduct"
[1]. I simply didn't use the function in those places (yet).
- wants_to_be_bigger() is removed. This function is unused, and
performs the exact same function (though with a different name) as
can_city_grow_to(). [2]
[1] The effects patch solves this by making these messages more generic
("build a building"). This is probably not even generic enough, since
the effect could come from another source instead (in SMAC this effect
is native to certain civilizations).
[2] For some reason the effects patch removes this function.
jason
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.90
diff -u -r1.90 aihand.c
--- ai/aihand.c 12 Jul 2004 20:56:07 -0000 1.90
+++ ai/aihand.c 14 Jul 2004 05:43:30 -0000
@@ -170,10 +170,7 @@
if (cmr.found_a_valid
&& pcity->food_surplus > 0
&& pcity->size >= g->rapture_size
- && (pcity->size < game.aqueduct_size
- || city_got_building(pcity, B_AQUEDUCT))
- && (pcity->size < game.sewer_size
- || city_got_building(pcity, B_SEWER))) {
+ && city_can_grow_to(pcity, pcity->size + 1)) {
pcity->ai.celebrate = TRUE;
can_celebrate++;
} else {
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.229
diff -u -r1.229 city.c
--- common/city.c 13 Jul 2004 21:54:17 -0000 1.229
+++ common/city.c 14 Jul 2004 05:43:31 -0000
@@ -1581,6 +1581,17 @@
}
}
+/****************************************************************************
+ Return TRUE iff the city can grow to the given size.
+****************************************************************************/
+bool city_can_grow_to(const struct city *pcity, int pop_size)
+{
+ return (pop_size <= game.aqueduct_size
+ || (pop_size <= game.sewer_size
+ && city_got_building(pcity, B_AQUEDUCT))
+ || city_got_building(pcity, B_SEWER));
+}
+
/**************************************************************************
is there an enemy city on this tile?
**************************************************************************/
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.152
diff -u -r1.152 city.h
--- common/city.h 13 Jul 2004 21:54:17 -0000 1.152
+++ common/city.h 14 Jul 2004 05:43:31 -0000
@@ -376,6 +376,7 @@
int city_turns_to_build(const struct city *pcity, int id, bool id_is_unit,
bool include_shield_stock );
int city_turns_to_grow(const struct city *pcity);
+bool city_can_grow_to(const struct city *pcity, int pop_size);
/* textual representation of buildings */
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.262
diff -u -r1.262 citytools.c
--- server/citytools.c 13 Jul 2004 21:54:17 -0000 1.262
+++ server/citytools.c 14 Jul 2004 05:43:32 -0000
@@ -640,22 +640,6 @@
return pcity->science_bonus;
}
-/**************************************************************************
-...
-**************************************************************************/
-bool wants_to_be_bigger(struct city *pcity)
-{
- if (pcity->size < game.aqueduct_size) return TRUE;
- if (city_got_building(pcity, B_SEWER)) return TRUE;
- if (city_got_building(pcity, B_AQUEDUCT)
- && pcity->size < game.sewer_size) return TRUE;
- if (!pcity->is_building_unit) {
- if (pcity->currently_building == B_SEWER && pcity->did_buy) return TRUE;
- if (pcity->currently_building == B_AQUEDUCT && pcity->did_buy) return TRUE;
- } /* saves a lot of stupid flipflops -- Syela */
- return FALSE;
-}
-
/*********************************************************************
Note: the old unit is not wiped here.
***********************************************************************/
Index: server/citytools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.h,v
retrieving revision 1.51
diff -u -r1.51 citytools.h
--- server/citytools.h 14 Feb 2004 02:21:26 -0000 1.51
+++ server/citytools.h 14 Jul 2004 05:43:32 -0000
@@ -45,7 +45,6 @@
int city_science_bonus(struct city *pcity);
int city_tax_bonus(struct city *pcity);
-bool wants_to_be_bigger(struct city *pcity);
int worst_worker_tile_value(struct city *pcity);
int best_worker_tile_value(struct city *pcity);
void transfer_city_units(struct player *pplayer, struct player *pvictim,
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.253
diff -u -r1.253 cityturn.c
--- server/cityturn.c 13 Jul 2004 18:16:54 -0000 1.253
+++ server/cityturn.c 14 Jul 2004 05:43:32 -0000
@@ -339,10 +339,7 @@
}
}
- can_grow = (city_got_building(pcity, B_AQUEDUCT)
- || pcity->size < game.aqueduct_size)
- && (city_got_building(pcity, B_SEWER)
- || pcity->size < game.sewer_size);
+ can_grow = city_can_grow_to(pcity, pcity->size + 1);
if ((turns_growth <= 0) && !city_celebrating(pcity) && can_grow) {
notify_conn_ex(dest, pcity->x, pcity->y,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9382) city_can_grow_to() to replace wants_to_be_bigger(),
Jason Dorje Short <=
|
|