[Freeciv-Dev] (PR#11877)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11877 >
While looking at Per's AI tech patch, I had to consult common/tech.[ch]
I discovered that (1) enum tech_state can use a comment and (2)
get_next_tech simply calls another function but not before doing some
checks which are then duplicated in that function. So I added the
comments and removed get_next_tech.
Glip
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.81
diff -u -r1.81 tech.c
--- common/tech.c 5 Jan 2005 23:07:40 -0000 1.81
+++ common/tech.c 9 Jan 2005 23:13:44 -0000
@@ -224,10 +224,10 @@
}
/**************************************************************************
-...don't use this function directly, call get_next_tech instead.
+ Return the next tech we should research to advance towards our goal.
+ Returns A_UNSET if nothing is available or the goal is already known.
**************************************************************************/
-static Tech_Type_id get_next_tech_rec(const struct player *pplayer,
- Tech_Type_id goal)
+Tech_Type_id get_next_tech(const struct player *pplayer, Tech_Type_id goal)
{
Tech_Type_id sub_goal;
@@ -238,27 +238,12 @@
if (get_invention(pplayer, goal) == TECH_REACHABLE) {
return goal;
}
- sub_goal = get_next_tech_rec(pplayer, advances[goal].req[0]);
+ sub_goal = get_next_tech(pplayer, advances[goal].req[0]);
if (sub_goal != A_UNSET) {
return sub_goal;
} else {
- return get_next_tech_rec(pplayer, advances[goal].req[1]);
- }
-}
-
-/**************************************************************************
-... this could be simpler, but we might have or get loops in the tech tree
- so i try to avoid endless loops.
- if return value > A_LAST then we have a bug
- caller should do something in that case.
-**************************************************************************/
-Tech_Type_id get_next_tech(const struct player *pplayer, Tech_Type_id goal)
-{
- if (!tech_is_available(pplayer, goal)
- || get_invention(pplayer, goal) == TECH_KNOWN) {
- return A_UNSET;
+ return get_next_tech(pplayer, advances[goal].req[1]);
}
- return (get_next_tech_rec(pplayer, goal));
}
/**************************************************************************
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.49
diff -u -r1.49 tech.h
--- common/tech.h 17 Nov 2004 16:59:07 -0000 1.49
+++ common/tech.h 9 Jan 2005 23:13:44 -0000
@@ -69,6 +69,9 @@
TF_LAST
};
+/* TECH_KNOWN is self-explanatory, TECH_REACHABLE are those for which all
+ * requirements are fulfilled; all others (including those which can never
+ * be reached) are TECH_UNKNOWN */
enum tech_state {
TECH_UNKNOWN = 0,
TECH_KNOWN = 1,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11877),
Gregory Berkolaiko <=
|
|