Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11841) Fix historian report & observer
Home

[Freeciv-Dev] (PR#11841) Fix historian report & observer

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11841) Fix historian report & observer
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 7 Jan 2005 11:17:47 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11841 >

This patch should remove observer from the historian report. I also think
it should be be more accurate than it used to be, since we now (correctly,
I hope) count the same number of players everywhere.

  - Per

Index: server/report.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.c,v
retrieving revision 1.54.2.1
diff -u -r1.54.2.1 report.c
--- server/report.c     25 Nov 2004 23:22:34 -0000      1.54.2.1
+++ server/report.c     7 Jan 2005 19:14:34 -0000
@@ -96,6 +96,8 @@
 static const char *mil_service_to_text(int value);
 static const char *pollution_to_text(int value);
 
+#define GOOD_PLAYER(p) ((p)->is_alive && !is_barbarian(p) && !(p)->is_observer)
+
 /*
  * Describes a row.
  */
@@ -165,7 +167,7 @@
   struct player_score_entry size[game.nplayers];
 
   players_iterate(pplayer) {
-    if (pplayer->is_alive && !is_barbarian(pplayer)) {
+    if (GOOD_PLAYER(pplayer)) {
       switch(which_news) {
       case HISTORIAN_RICHEST:
        size[j].value = pplayer->economic.gold;
@@ -187,7 +189,7 @@
       }
       size[j].player = pplayer;
       j++;
-    } /* else the player is dead or barbarian */
+    } /* else the player is dead or barbarian or observer */
   } players_iterate_end;
 
   qsort(size, j, sizeof(struct player_score_entry), secompare);
@@ -611,11 +613,11 @@
     int place = 1;
 
     players_iterate(other) {
-      if (other->is_alive && !is_barbarian(other) &&
-         ((prow->greater_values_are_better
-           && prow->get_value(other) > basis)
-          || (!prow->greater_values_are_better
-              && prow->get_value(other) < basis))) {
+      if (GOOD_PLAYER(other)
+         && ((prow->greater_values_are_better
+              && prow->get_value(other) > basis)
+             || (!prow->greater_values_are_better
+                 && prow->get_value(other) < basis))) {
        place++;
       }
     } players_iterate_end;
@@ -628,7 +630,7 @@
     int best_value = prow->get_value(pplayer);
 
     players_iterate(other) {
-      if (other->is_alive && !is_barbarian(other)) {
+      if (GOOD_PLAYER(other)) {
        int value = prow->get_value(other);
 
        if ((prow->greater_values_are_better && value > best_value)
@@ -975,8 +977,6 @@
     }
   }
 
-#define GOOD_PLAYER(p) ((p)->is_alive)
-
   if (game.turn > last_turn) {
     fprintf(fp, "turn %d %d %s\n", game.turn, game.year, textyear(game.year));
     last_turn = game.turn;
@@ -1035,8 +1035,6 @@
   disabled = TRUE;
 }
 
-#undef GOOD_PLAYER
-
 /**************************************************************************
   ...
 **************************************************************************/
@@ -1079,7 +1077,7 @@
   struct player_score_entry size[game.nplayers];
 
   players_iterate(pplayer) {
-    if (!is_barbarian(pplayer)) {
+    if (GOOD_PLAYER(pplayer)) {
       size[j].value = get_civ_score(pplayer);
       size[j].player = pplayer;
       j++;
@@ -1113,7 +1111,7 @@
   struct packet_endgame_report packet;
 
   players_iterate(pplayer) {
-    if (!is_barbarian(pplayer)) {
+    if (GOOD_PLAYER(pplayer)) {
       size[j].value = get_civ_score(pplayer);
       size[j].player = pplayer;
       j++;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11841) Fix historian report & observer, Per I. Mathisen <=