[Freeciv-Dev] (PR#9549) remove could_build_improvement
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9549 >
In city.c are lots of functions. can_build_improvement,
could_build_improvement, could_eventually_build_improvement,
can_build_improvement_direct (actually this one doesn't exist yet).
I think could_build_improvement exists only to confuse people. It's
only called from can_build_improvement to do part of the work. This
patch removes it.
I think we can justify three types of functions:
- can_build
- can_eventually_build
- can_build_direct (or can_build_forced)
for improvements and units, along with maybe some player functions too.
jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.233
diff -u -r1.233 city.c
--- common/city.c 20 Jul 2004 09:55:43 -0000 1.233
+++ common/city.c 29 Jul 2004 20:08:49 -0000
@@ -427,24 +427,27 @@
}
/**************************************************************************
- Could this improvment be built in the city, without checking if the
- owner has the required tech, but if all other pre reqs are fulfiled?
- modularized so the AI can choose the tech it wants -- Syela
+ Can this improvement get built in this city by the player who owns it?
**************************************************************************/
-static bool could_build_improvement(const struct city *pcity,
- Impr_Type_id id)
+bool can_build_improvement(const struct city *pcity, Impr_Type_id id)
{
- struct impr_type *impr;
+ struct player *p = city_owner(pcity);
+ struct impr_type *impr = get_improvement_type(id);
- if (!can_eventually_build_improvement(pcity, id)) {
+ if (!improvement_exists(id)) {
+ return FALSE;
+ }
+ if (!player_knows_improvement_tech(p, id)) {
return FALSE;
}
- impr = get_improvement_type(id);
+ if (!can_eventually_build_improvement(pcity, id)) {
+ return FALSE;
+ }
/* The building pre req */
if (impr->bldg_req != B_LAST) {
- if (!city_got_building(pcity,impr->bldg_req)) {
+ if (!city_got_building(pcity, impr->bldg_req)) {
return FALSE;
}
}
@@ -453,22 +456,6 @@
}
/**************************************************************************
- Can this improvement get built in this city by the player who owns it?
-**************************************************************************/
-bool can_build_improvement(const struct city *pcity, Impr_Type_id id)
-{
- struct player *p = city_owner(pcity);
-
- if (!improvement_exists(id)) {
- return FALSE;
- }
- if (!player_knows_improvement_tech(p, id)) {
- return FALSE;
- }
- return could_build_improvement(pcity, id);
-}
-
-/**************************************************************************
Return whether given city can build given unit, ignoring whether unit
is obsolete.
**************************************************************************/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9549) remove could_build_improvement,
Jason Short <=
|
|