[Freeciv-Dev] (PR#9314) get_num_specialists function for CM
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#9314) get_num_specialists function for CM |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Thu, 8 Jul 2004 08:57:47 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9314 >
This patch adds a new function to the internals of the CM code:
get_num_specialists. This returns the number of specialists used by the
result.
This is useful because it does not hard-code the number of specialists,
but instead uses a loop.
jason
? diff
? data/tridenthex
? data/tridenthex.tilespec
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.28
diff -u -r1.28 cm.c
--- common/aicore/cm.c 25 Jun 2004 23:35:55 -0000 1.28
+++ common/aicore/cm.c 8 Jul 2004 15:56:38 -0000
@@ -303,6 +303,20 @@
}
/****************************************************************************
+ Return the number of specialists currently allocated by the result.
+****************************************************************************/
+static int get_num_specialists(const struct cm_result *const result)
+{
+ int sp, count = 0;
+
+ for (sp = 0; sp < SP_COUNT; sp++) {
+ count += result->specialists[sp];
+ }
+
+ return count;
+}
+
+/****************************************************************************
Returns TRUE iff is the result has the required surplus and the city
isn't in disorder and the city is happy if this is required.
*****************************************************************************/
@@ -312,9 +326,8 @@
int i;
if (!parameter->allow_specialists
- && (result->specialists[SP_ELVIS] + result->specialists[SP_SCIENTIST]
- + result->specialists[SP_TAXMAN]) >
- MAX(0,cache3.pcity->size - cache3.fields_available_total)) {
+ && (get_num_specialists(result)
+ > MAX(0, cache3.pcity->size - cache3.fields_available_total))) {
return FALSE;
}
@@ -606,10 +619,7 @@
pcity->id);
/* Do checks */
- if (pcity->size !=
- (worker + result->specialists[SP_ELVIS]
- + result->specialists[SP_SCIENTIST]
- + result->specialists[SP_TAXMAN])) {
+ if (pcity->size != worker + get_num_specialists(result)) {
print_city(pcity);
print_result(pcity, result);
assert(0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9314) get_num_specialists function for CM,
Jason Short <=
|
|