Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12668) Changes in how to win the game...
Home

[Freeciv-Dev] (PR#12668) Changes in how to win the game...

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12668) Changes in how to win the game...
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 26 Mar 2005 14:27:07 -0800
Reply-to: bugs@xxxxxxxxxxx

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

...so read carefully.

CHANGES:
 1) Allied victory removed.
 2) /endgame only ends the game, it no longer allows you to specify
    winners.
 3) endyear gives victory to whoever has the higher score.

The reason for 1) is that this concept was a bad one. It encourages
ganging up the best player. Instead, there should only be one winner, and
he should be punished for the number of alliances and tech exchanges he
has been involved in.

The /endgame command can now be used to select winners, who gain an allied
victory. Due to 1) above, this is no longer possible. Also, being able to
simply vote a winner by majority seems... a bit much. Hence 2).

The reason for 3) is obvious, but this was actually not how it was
implemented. Right now, if you do "set endyear" to end the game, it will
end in a draw!

Untested as of yet.

  - Per

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   26 Mar 2005 22:06:35 -0000
@@ -312,10 +312,9 @@
   },
   {"endgame",  ALLOW_CTRL,
    /* TRANS: translate text between <> only */
-   N_("endgame <player1 player2 player3 ...>"),
-   N_("End the game.  If players are listed, these win the game."),
-   N_("This command ends the game immediately and credits the given players, "
-      "if any, with winning it.")
+   N_("endgame"),
+   N_("End the game."),
+   N_("This command ends the game immediately.")
   },
   {"remove",   ALLOW_CTRL,
    /* TRANS: translate text between <> only */
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    26 Mar 2005 22:06:35 -0000
@@ -533,15 +533,6 @@
                   : "Game ended in victory for the %s",
                   get_nation_name_plural(pplayer->nation));
       break;
-    case GL_ALLIEDWIN:
-      my_snprintf(buf, sizeof(buf), "<type>%s</type>", endgame_strings[num]);
-      players_iterate(aplayer) {
-        if (aplayer->is_alive) {
-          cat_snprintf(buf, sizeof(buf), "<n>%d</n>", aplayer->player_no);
-        }
-      } players_iterate_end;
-      my_snprintf(msg, sizeof(msg), "Game ended in allied victory");
-      break;
     case GL_TEAMWIN:
       pteam = va_arg(args, struct team *);
       my_snprintf(buf, sizeof(buf), "<type>%s</type>", endgame_strings[num]);
@@ -612,8 +603,8 @@
   Every time we save the game, we also output to the gamelog the score
   and status info.
 **************************************************************************/
-static void gamelog_status(char *buffer, int len) {
-
+static void gamelog_status(char *buffer, int len) 
+{
   int i, count = 0, highest = -1;
   struct player *highest_plr = NULL;
   struct player_score_entry size[game.nplayers], rank[game.nplayers];
@@ -632,20 +623,6 @@
     }
   } players_iterate_end;
 
-  /* Draws and team victories */
-  count = 0;
-  players_iterate(pplayer) {
-    if (!is_barbarian(pplayer)) {
-      if ((BV_ISSET_ANY(srvarg.draw)
-           && BV_ISSET(srvarg.draw, pplayer->player_no))
-          || players_on_same_team(pplayer, highest_plr)) {
-        /* We win a shared victory, so equal the score. */
-        rank[count].value = highest;
-      }
-      count++;
-    }
-  } players_iterate_end;
-
   buffer[0] = '\0';
   qsort(rank, count, sizeof(struct player_score_entry), secompare1);
 
Index: server/gamelog.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamelog.h,v
retrieving revision 1.10
diff -u -r1.10 gamelog.h
--- server/gamelog.h    9 Dec 2004 16:38:35 -0000       1.10
+++ server/gamelog.h    26 Mar 2005 22:06:35 -0000
@@ -50,8 +50,7 @@
   GL_NONE,
   GL_DRAW,
   GL_LONEWIN,
-  GL_TEAMWIN,
-  GL_ALLIEDWIN
+  GL_TEAMWIN
 };
 
 /* treaty clause types */
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   26 Mar 2005 22:06:37 -0000
@@ -186,7 +186,6 @@
   srvarg.saves_pathname = "";
 
   srvarg.quitidle = 0;
-  BV_CLR_ALL(srvarg.draw);
 
   srvarg.auth_enabled = FALSE;
   srvarg.auth_allow_guests = FALSE;
@@ -216,17 +215,15 @@
 static bool is_game_over(void)
 {
   int barbs = 0, alive = 0, observers = 0;
-  bool all_allied;
   struct player *victor = NULL;
 
-  /* quit if we are past the year limit */
-  if (game.year > game.end_year) {
-    notify_conn_ex(game.est_connections, NULL, E_GAME_END, 
-                  _("Game ended in a draw as end year exceeded"));
-    gamelog(GAMELOG_JUDGE, GL_DRAW, 
-            "Game ended in a draw as end year exceeded");
-    return TRUE;
-  }
+  /* count the living */
+  players_iterate(pplayer) {
+    if (pplayer->is_alive && !is_barbarian(pplayer)) {
+      alive++;
+      victor = pplayer;
+    }
+  } players_iterate_end;
 
   /* count barbarians and observers */
   players_iterate(pplayer) {
@@ -238,18 +235,13 @@
     }
   } players_iterate_end;
 
-  /* the game does not quit if we are playing solo */
-  if (game.nplayers == (observers + barbs + 1)) {
-    return FALSE;
-  } 
-
-  /* count the living */
-  players_iterate(pplayer) {
-    if (pplayer->is_alive && !is_barbarian(pplayer)) {
-      alive++;
-      victor = pplayer;
-    }
-  } players_iterate_end;
+  /* Ooops... */
+  if (alive == 0) {
+    notify_conn_ex(game.est_connections, NULL, E_GAME_END, 
+                  _("Game ended in a draw"));
+    gamelog(GAMELOG_JUDGE, GL_DRAW);
+    return TRUE;
+  }
 
   /* quit if we have team victory */
   team_iterate(pteam) {
@@ -261,39 +253,36 @@
     }
   } team_iterate_end;
 
+  /* the game does not quit if we are playing solo (ie literally alone) */
+  if (game.nplayers == (observers + barbs + 1)
+      && game.year <= game.end_year) {
+    return FALSE;
+  }
+
   /* quit if only one player is left alive */
   if (alive == 1) {
     notify_conn_ex(game.est_connections, NULL, E_GAME_END,
                   _("Game ended in victory for %s"), victor->name);
     gamelog(GAMELOG_JUDGE, GL_LONEWIN, victor);
     return TRUE;
-  } else if (alive == 0) {
-    notify_conn_ex(game.est_connections, NULL, E_GAME_END, 
-                  _("Game ended in a draw"));
-    gamelog(GAMELOG_JUDGE, GL_DRAW);
-    return TRUE;
   }
 
-  /* quit if all remaining players are allied to each other */
-  all_allied = TRUE;
-  players_iterate(pplayer) {
-    if (!pplayer->is_alive) {
-      continue;
-    }
-    players_iterate(aplayer) {
-      if (!pplayers_allied(pplayer, aplayer) && aplayer->is_alive) {
-        all_allied = FALSE;
-        break;
+  /* quit if we are past the year limit */
+  if (game.year > game.end_year) {
+    int best = -1;
+
+    /* Find the winner */
+    players_iterate(pplayer) {
+      int n = get_civ_score(pplayer);
+
+      if (n > best && pplayer->is_alive) {
+        victor = pplayer;
+        best = n;
       }
     } players_iterate_end;
-    if (!all_allied) {
-      break;
-    }
-  } players_iterate_end;
-  if (all_allied) {
     notify_conn_ex(game.est_connections, NULL, E_GAME_END, 
-                  _("Game ended in allied victory"));
-    gamelog(GAMELOG_JUDGE, GL_ALLIEDWIN);
+                  _("Game ended in victory for %s"), victor->name);
+    gamelog(GAMELOG_JUDGE, GL_LONEWIN, victor);
     return TRUE;
   }
 
@@ -1954,6 +1943,5 @@
   } players_iterate_end;
   game_free();
   ruleset_cache_free();
-  BV_CLR_ALL(srvarg.draw);
   clean_players_research();
 }
Index: server/srv_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.h,v
retrieving revision 1.28
diff -u -r1.28 srv_main.h
--- server/srv_main.h   22 Mar 2005 04:03:35 -0000      1.28
+++ server/srv_main.h   26 Mar 2005 22:06:37 -0000
@@ -19,8 +19,6 @@
 
 struct connection;
 
-BV_DEFINE(bv_draw, MAX_NUM_PLAYERS);
-
 struct server_arguments {
   /* metaserver information */
   bool metaserver_no_send;
@@ -43,8 +41,6 @@
   int quitidle;
   /* exit the server on game ending */
   bool exit_on_end;
-  /* what kind of end game we should use */
-  bv_draw draw;
   /* authentication options */
   bool auth_enabled;            /* defaults to FALSE */
   bool auth_allow_guests;       /* defaults to TRUE */
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  26 Mar 2005 22:06:37 -0000
@@ -3540,56 +3540,19 @@
 }
 
 /**************************************************************************
-  End the game and accord victory to the listed players, if any.
+  End the game.
 **************************************************************************/
 static bool end_command(struct connection *caller, char *str, bool check)
 {
   if (server_state == RUN_GAME_STATE) {
-    char *arg[MAX_NUM_PLAYERS];
-    int ntokens = 0, i;
-    enum m_pre_result plr_result;
-    bool result = TRUE;
-    char buf[MAX_LEN_CONSOLE_LINE];
-
-    if (str != NULL || strlen(str) > 0) {
-      sz_strlcpy(buf, str);
-      ntokens = get_tokens(buf, arg, MAX_NUM_PLAYERS, TOKEN_DELIMITERS);
-    }
-    /* Ensure players exist */
-    for (i = 0; i < ntokens; i++) {
-      struct player *pplayer = find_player_by_name_prefix(arg[i], &plr_result);
-
-      if (!pplayer) {
-        cmd_reply_no_such_player(CMD_TEAM, caller, arg[i], plr_result);
-        result = FALSE;
-        goto cleanup;
-      } else if (pplayer->is_alive == FALSE) {
-        cmd_reply(CMD_END_GAME, caller, C_FAIL, _("But %s is dead!"),
-                  pplayer->name);
-        result = FALSE;
-        goto cleanup;
-      }
-    }
     if (check) {
-      goto cleanup;
-    }
-    if (ntokens > 0) {
-      /* Mark players for victory. */
-      for (i = 0; i < ntokens; i++) {
-        BV_SET(srvarg.draw, 
-               find_player_by_name_prefix(arg[i], &plr_result)->player_no);
-      }
+      return TRUE;
     }
     server_state = GAME_OVER_STATE;
     force_end_of_sniff = TRUE;
     cmd_reply(CMD_END_GAME, caller, C_OK,
               _("Ending the game. The server will restart once all clients "
               "have disconnected."));
-
-    cleanup:
-    for (i = 0; i < ntokens; i++) {
-      free(arg[i]);
-    }
     return TRUE;
   } else {
     cmd_reply(CMD_END_GAME, caller, C_FAIL, 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12668) Changes in how to win the game..., Per I. Mathisen <=