[Freeciv-Dev] (PR#11212) specialists in the score
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11212 >
This patch removes hard-coding of specialists in the score code.
Instead specialist_type_iterate is used with an array.
jason
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.169
diff -u -r1.169 city.h
--- common/city.h 26 Nov 2004 09:49:12 -0000 1.169
+++ common/city.h 26 Nov 2004 23:48:10 -0000
@@ -23,8 +23,10 @@
};
enum specialist_type {
- SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_COUNT
+ SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
};
+#define SP_COUNT SP_LAST
+#define SP_MAX SP_LAST
enum city_tile_type {
C_TILE_EMPTY, C_TILE_WORKER, C_TILE_UNAVAILABLE
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.132
diff -u -r1.132 player.h
--- common/player.h 17 Nov 2004 16:59:07 -0000 1.132
+++ common/player.h 26 Nov 2004 23:48:10 -0000
@@ -104,9 +104,7 @@
int content;
int unhappy;
int angry;
- int taxmen;
- int scientists;
- int elvis;
+ int specialists[SP_MAX];
int wonders;
int techs;
int techout;
Index: server/score.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/score.c,v
retrieving revision 1.10
diff -u -r1.10 score.c
--- server/score.c 25 Nov 2004 06:29:49 -0000 1.10
+++ server/score.c 26 Nov 2004 23:48:11 -0000
@@ -373,9 +373,9 @@
pplayer->score.content = 0;
pplayer->score.unhappy = 0;
pplayer->score.angry = 0;
- pplayer->score.taxmen = 0;
- pplayer->score.scientists = 0;
- pplayer->score.elvis = 0;
+ specialist_type_iterate(sp) {
+ pplayer->score.specialists[sp] = 0;
+ } specialist_type_iterate_end;
pplayer->score.wonders = 0;
pplayer->score.techs = 0;
pplayer->score.techout = 0;
@@ -404,9 +404,9 @@
pplayer->score.content += pcity->ppl_content[4];
pplayer->score.unhappy += pcity->ppl_unhappy[4];
pplayer->score.angry += pcity->ppl_angry[4];
- pplayer->score.taxmen += pcity->specialists[SP_TAXMAN];
- pplayer->score.scientists += pcity->specialists[SP_SCIENTIST];
- pplayer->score.elvis += pcity->specialists[SP_ELVIS];
+ specialist_type_iterate(sp) {
+ pplayer->score.specialists[sp] += pcity->specialists[sp];
+ } specialist_type_iterate_end;
pplayer->score.population += city_population(pcity);
pplayer->score.cities++;
pplayer->score.pollution += pcity->pollution;
@@ -476,11 +476,14 @@
**************************************************************************/
int total_player_citizens(const struct player *pplayer)
{
- return (pplayer->score.happy
- + pplayer->score.content
- + pplayer->score.unhappy
- + pplayer->score.angry
- + pplayer->score.scientists
- + pplayer->score.elvis
- + pplayer->score.taxmen);
+ int count = (pplayer->score.happy
+ + pplayer->score.content
+ + pplayer->score.unhappy
+ + pplayer->score.angry);
+
+ specialist_type_iterate(sp) {
+ count += pplayer->score.specialists[sp];
+ } specialist_type_iterate_end;
+
+ return count;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11212) specialists in the score,
Jason Short <=
|
|