Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12641) Move /score into player dialog
Home

[Freeciv-Dev] (PR#12641) Move /score into player dialog

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12641) Move /score into player dialog
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 25 Mar 2005 09:06:16 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch moves the /score info into the player dialog. You can see the
score of any player you are in contact with.

This cuts through all the arguments/difficulties associated with /score.

It may not immediately be to everyone's liking, but it has the virtue of
simplicity and user-friendliness, and I challenge anyone to come up with
something better.

What is /score used for? Mostly for ending games, I think. Players look at
a much higher score in another player and decide the game cannot be won
any longer.

(For the longest time while playtesting this, I thought something had to
be wrong. I always had such a larger score than the AI. Then I realized, I
really am better than the AI.)

  - Per

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.480
diff -u -r1.480 packhand.c
--- client/packhand.c   24 Mar 2005 16:41:41 -0000      1.480
+++ client/packhand.c   25 Mar 2005 17:00:14 -0000
@@ -1472,6 +1472,7 @@
   pplayer->nation=pinfo->nation;
   pplayer->is_male=pinfo->is_male;
   pplayer->team = pinfo->team;
+  pplayer->score.game = pinfo->score;
 
   pplayer->economic.gold=pinfo->gold;
   pplayer->economic.tax=pinfo->tax;
Index: client/plrdlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/plrdlg_common.c,v
retrieving revision 1.17
diff -u -r1.17 plrdlg_common.c
--- client/plrdlg_common.c      23 Feb 2005 03:34:05 -0000      1.17
+++ client/plrdlg_common.c      25 Mar 2005 17:00:14 -0000
@@ -227,6 +227,7 @@
   {TRUE, COL_FLAG, N_("Flag"), NULL, NULL, "flag"},
   {TRUE, COL_TEXT, N_("Nation"), col_nation, NULL, "nation"},
   {TRUE, COL_COLOR, N_("Border"), NULL, NULL, "border"},
+  {TRUE, COL_TEXT, N_("Score"), get_score_text, NULL, "score"},
   {TRUE, COL_TEXT, N_("Team"), col_team, NULL, "team"},
   {TRUE, COL_BOOLEAN, N_("AI"), NULL, col_ai, "ai"},
   {TRUE, COL_TEXT, N_("Attitude"), col_love, NULL, "attitude"},
Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.30
diff -u -r1.30 text.c
--- client/text.c       19 Mar 2005 14:41:44 -0000      1.30
+++ client/text.c       25 Mar 2005 17:00:14 -0000
@@ -718,6 +718,23 @@
 }
 
 /****************************************************************************
+  Return text giving the score of the player. This should only be used 
+  in playerdlg_common.c.
+****************************************************************************/
+const char *get_score_text(const struct player *pplayer)
+{
+  INIT;
+
+  if (pplayer->score.game > 0 || pplayer == game.player_ptr) {
+    add("%d", pplayer->score.game);
+  } else {
+    add("?");
+  }
+
+  RETURN;
+}
+
+/****************************************************************************
   Get the title for a "report".  This may include the city, economy,
   military, trade, player, etc., reports.  Some clients may generate the
   text themselves to get a better GUI layout.
Index: client/text.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.h,v
retrieving revision 1.9
diff -u -r1.9 text.h
--- client/text.h       17 Dec 2004 09:13:54 -0000      1.9
+++ client/text.h       25 Mar 2005 17:00:14 -0000
@@ -37,6 +37,7 @@
 const char *get_timeout_label_text(void);
 const char *format_duration(int duration);
 const char *get_ping_time_text(const struct player *pplayer);
+const char *get_score_text(const struct player *pplayer);
 const char *get_report_title(const char *report_name);
 const char *get_happiness_buildings(const struct city *pcity);
 const char *get_happiness_wonders(const struct city *pcity);
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.98
diff -u -r1.98 packets.def
--- common/packets.def  24 Mar 2005 16:41:41 -0000      1.98
+++ common/packets.def  25 Mar 2005 17:00:16 -0000
@@ -551,6 +551,7 @@
   STRING name[MAX_LEN_NAME];
   STRING username[MAX_LEN_NAME];
 
+  UINT32 score;
   BOOL is_observer;
   BOOL is_male;
   GOVERNMENT government;
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.142
diff -u -r1.142 player.h
--- common/player.h     18 Mar 2005 11:26:24 -0000      1.142
+++ common/player.h     25 Mar 2005 17:00:20 -0000
@@ -119,6 +119,7 @@
   int bnp;
   int mfg;
   int spaceship;
+  int game;             /* total score you get in player dialog */
 };
 
 struct player_ai {
Index: server/commands.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.c,v
retrieving revision 1.7
diff -u -r1.7 commands.c
--- server/commands.c   20 Mar 2005 09:08:48 -0000      1.7
+++ server/commands.c   25 Mar 2005 17:00:20 -0000
@@ -95,12 +95,6 @@
       "used by clients).  With an argument, show only the named option, "
       "or options with that prefix.")
   },
-  {"score",    ALLOW_CTRL,
-   "score",
-   N_("Show current scores."),
-   N_("For each connected client, pops up a window showing the current "
-      "player scores.")
-  },
   {"wall",     ALLOW_HACK,
    N_("wall <message>"),
    N_("Send message to all connections."),
Index: server/commands.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.h,v
retrieving revision 1.5
diff -u -r1.5 commands.h
--- server/commands.h   25 Mar 2005 11:25:09 -0000      1.5
+++ server/commands.h   25 Mar 2005 17:00:20 -0000
@@ -44,7 +44,6 @@
   /* completely non-harmful: */
   CMD_EXPLAIN,
   CMD_SHOW,
-  CMD_SCORE,
   CMD_WALL,
   CMD_VOTE,
   
Index: server/gamelog.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamelog.c,v
retrieving revision 1.44
diff -u -r1.44 gamelog.c
--- server/gamelog.c    22 Jan 2005 19:45:44 -0000      1.44
+++ server/gamelog.c    25 Mar 2005 17:00:20 -0000
@@ -620,7 +620,7 @@
 
   players_iterate(pplayer) {
     if (!is_barbarian(pplayer)) {
-      rank[count].value = get_civ_score(pplayer);
+      rank[count].value = pplayer->score.game;
       rank[count].idx = pplayer->player_no;
       size[count].value = total_player_citizens(pplayer);
       size[count].idx = pplayer->player_no;
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.361
diff -u -r1.361 plrhand.c
--- server/plrhand.c    18 Mar 2005 11:26:24 -0000      1.361
+++ server/plrhand.c    25 Mar 2005 17:00:21 -0000
@@ -1486,6 +1486,13 @@
   packet->gold            = plr->economic.gold;
   packet->government      = plr->government;
 
+  /* Only send score if we have contact */
+  if (info_level >= INFO_MEETING) {
+    packet->score = plr->score.game;
+  } else {
+    packet->score = 0;
+  }
+
   /* Send diplomatic status of the player to everyone they are in
    * contact with. */
   if (info_level >= INFO_EMBASSY
Index: server/report.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.c,v
retrieving revision 1.62
diff -u -r1.62 report.c
--- server/report.c     14 Feb 2005 18:09:33 -0000      1.62
+++ server/report.c     25 Mar 2005 17:00:21 -0000
@@ -1063,40 +1063,6 @@
 }
 
 /**************************************************************************
- Inform clients about player scores during a game.
-**************************************************************************/
-void report_progress_scores(void)
-{
-  int i, j = 0;
-  char buffer[4096];
-  struct player_score_entry size[game.nplayers];
-
-  players_iterate(pplayer) {
-    if (GOOD_PLAYER(pplayer)) {
-      size[j].value = get_civ_score(pplayer);
-      size[j].player = pplayer;
-      j++;
-    }
-  } players_iterate_end;
-
-  qsort(size, j, sizeof(struct player_score_entry), secompare);
-  buffer[0] = '\0';
-
-  for (i = 0; i < j; i++) {
-    cat_snprintf(buffer, sizeof(buffer),
-                PL_("%2d: The %s %s scored %d point\n",
-                    "%2d: The %s %s scored %d points\n",
-                    size[i].value),
-                i + 1, _(greatness[i]),
-                get_nation_name_plural(size[i].player->nation),
-                size[i].value);
-  }
-  page_conn(game.game_connections,
-           _("Progress Scores:"),
-           _("The Greatest Civilizations in the world."), buffer);
-}
-
-/**************************************************************************
   Inform clients about player scores and statistics when the game ends.
 **************************************************************************/
 void report_final_scores(void)
@@ -1107,7 +1073,7 @@
 
   players_iterate(pplayer) {
     if (GOOD_PLAYER(pplayer)) {
-      size[j].value = get_civ_score(pplayer);
+      size[j].value = pplayer->score.game;
       size[j].player = pplayer;
       j++;
     }
Index: server/report.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.h,v
retrieving revision 1.8
diff -u -r1.8 report.h
--- server/report.h     11 May 2004 17:59:34 -0000      1.8
+++ server/report.h     25 Mar 2005 17:00:21 -0000
@@ -26,7 +26,6 @@
 void report_top_five_cities(struct conn_list *dest);
 bool is_valid_demography(const char *demography, const char **error_message);
 void report_demographics(struct connection *pconn);
-void report_progress_scores(void);
 void report_final_scores(void);
 
 /* See also report_server_options() in stdinhand.h */
Index: server/score.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/score.c,v
retrieving revision 1.17
diff -u -r1.17 score.c
--- server/score.c      3 Feb 2005 09:51:51 -0000       1.17
+++ server/score.c      25 Mar 2005 17:00:21 -0000
@@ -25,6 +25,7 @@
 #include "score.h"
 #include "unit.h"
 
+static int get_civ_score(const struct player *pplayer);
 
 /**************************************************************************
   Allocates, fills and returns a land area claim map.
@@ -452,12 +453,14 @@
     pplayer->score.spaceship += (int)(100 * pplayer->spaceship.habitation
                                      * pplayer->spaceship.success_rate);
   }
+
+  pplayer->score.game = get_civ_score(pplayer);
 }
 
 /**************************************************************************
   Return the civilization score (a numerical value) for the player.
 **************************************************************************/
-int get_civ_score(const struct player *pplayer)
+static int get_civ_score(const struct player *pplayer)
 {
   /* We used to count pplayer->score.happy here too, but this is too easily
    * manipulated by players at the endyear. */
Index: server/score.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/score.h,v
retrieving revision 1.4
diff -u -r1.4 score.h
--- server/score.h      25 Nov 2004 06:29:49 -0000      1.4
+++ server/score.h      25 Mar 2005 17:00:21 -0000
@@ -17,7 +17,6 @@
 
 void calc_civ_score(struct player *pplayer);
 
-int get_civ_score(const struct player *pplayer);
 int total_player_citizens(const struct player *pplayer);
 
 #endif /* FC__SCORE_H */
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.236
diff -u -r1.236 srv_main.c
--- server/srv_main.c   22 Mar 2005 04:03:35 -0000      1.236
+++ server/srv_main.c   25 Mar 2005 17:00:21 -0000
@@ -478,8 +478,9 @@
   send_game_info(game.game_connections);
 
   if (is_new_turn) {
-    /* We build scores at the beginning and end of every turn.  We have to
-     * build them at the beginning so that the AI can use the data. */
+    /* We build scores at the beginning of every turn.  We have to
+     * build them at the beginning so that the AI can use the data,
+     * and we are sure to have it when we need it. */
     players_iterate(pplayer) {
       calc_civ_score(pplayer);
     } players_iterate_end;
@@ -657,12 +658,6 @@
     } players_iterate_end;
   }
 
-  /* We build scores at the beginning and end of every turn.  We have to
-   * build them at the end so that the history report can be built. */
-  players_iterate(pplayer) {
-    calc_civ_score(pplayer);
-  } players_iterate_end;
-
   freelog(LOG_DEBUG, "Season of native unrests");
   summon_barbarians(); /* wild guess really, no idea where to put it, but
                          I want to give them chance to move their units */
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.390
diff -u -r1.390 stdinhand.c
--- server/stdinhand.c  22 Mar 2005 04:03:35 -0000      1.390
+++ server/stdinhand.c  25 Mar 2005 17:00:22 -0000
@@ -3495,17 +3495,6 @@
     return team_command(caller, arg, check);
   case CMD_RULESETDIR:
     return set_rulesetdir(caller, arg, check);
-  case CMD_SCORE:
-    if (server_state == RUN_GAME_STATE || server_state == GAME_OVER_STATE) {
-      if (!check) {
-        report_progress_scores();
-      }
-      return TRUE;
-    } else {
-      cmd_reply(cmd, caller, C_SYNTAX,
-               _("The game must be running before you can see the score."));
-      return FALSE;
-    }
   case CMD_WALL:
     return wall(arg, check);
   case CMD_VOTE:

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12641) Move /score into player dialog, Per I. Mathisen <=