Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12372) gamelog interpreter for pubserver needed
Home

[Freeciv-Dev] (PR#12372) gamelog interpreter for pubserver needed

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12372) gamelog interpreter for pubserver needed
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 16 Apr 2005 21:08:02 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Here is the patch that allows pubserver ranking to work.

I will apply this patch to S2_0 shortly.

-jason

? gamelog.txt
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.79.2.2
diff -u -r1.79.2.2 barbarian.c
--- server/barbarian.c  9 Dec 2004 16:28:10 -0000       1.79.2.2
+++ server/barbarian.c  16 Apr 2005 21:05:25 -0000
@@ -38,7 +38,6 @@
 #include "terrain.h"
 
 #include "gamehand.h"
-#include "gamelog.h"
 #include "maphand.h"
 #include "plrhand.h"
 #include "srv_main.h"
@@ -155,7 +154,6 @@
   notify_player_ex(NULL, NULL, E_UPRISING,
                    _("Barbarians gain a leader by the name %s.  Dangerous "
                      "times may lie ahead."), barbarians->name);
-  gamelog(GAMELOG_PLAYER, barbarians);
 
   send_game_info(NULL);
   send_player_info(barbarians, NULL);
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.276.2.11
diff -u -r1.276.2.11 citytools.c
--- server/citytools.c  1 Apr 2005 00:42:29 -0000       1.276.2.11
+++ server/citytools.c  16 Apr 2005 21:05:25 -0000
@@ -931,6 +931,10 @@
 
   map_fog_pseudo_city_area(pgiver, pcity->tile);
 
+  gamelog(GAMELOG_LOSEC, _("%s lose %s (%i,%i)"),
+         get_nation_name_plural(pgiver->nation), pcity->name,
+         pcity->tile->x, pcity->tile->y);
+
   /* Build a new palace for free if the player lost her capital and
      savepalace is on. */
   if (had_palace && game.savepalace) {
@@ -952,6 +956,8 @@
   struct nation_type *nation = get_nation_by_plr(pplayer);
 
   freelog(LOG_DEBUG, "Creating city %s", name);
+  gamelog(GAMELOG_FOUNDC, _("%s (%i, %i) founded by the %s"), name,
+         ptile->x, ptile->y, nation->name_plural);
 
   if (terrain_control.may_road) {
     map_set_special(ptile, S_ROAD);
@@ -1063,8 +1069,6 @@
     }
   } unit_list_iterate_end;
   sanity_check_city(pcity);
-
-  gamelog(GAMELOG_FOUNDCITY, pcity);
 }
 
 /**************************************************************************
@@ -1078,6 +1082,10 @@
   bool had_palace = pcity->improvements[game.palace_building] != I_NONE;
   char *city_name = mystrdup(pcity->name);
 
+  gamelog(GAMELOG_LOSEC, _("%s lose %s (%i,%i)"),
+         get_nation_name_plural(pplayer->nation), pcity->name,
+         pcity->tile->x, pcity->tile->y);
+
   built_impr_iterate(pcity, i) {
     city_remove_improvement(pcity, i);
   } built_impr_iterate_end;
@@ -1246,7 +1254,10 @@
     notify_player_ex(cplayer, pcity->tile, E_CITY_LOST, 
                     _("Game: %s has been destroyed by %s."), 
                     pcity->name, pplayer->name);
-    gamelog(GAMELOG_LOSECITY, city_owner(pcity), pplayer, pcity, "destroyed");
+    gamelog(GAMELOG_LOSEC, _("%s (%s) (%i,%i) destroyed by %s"), pcity->name,
+           get_nation_name(city_owner(pcity)->nation),
+           pcity->tile->x, pcity->tile->y,
+           get_nation_name_plural(pplayer->nation));
     remove_city(pcity);
     if (do_civil_war) {
       civil_war(cplayer);
@@ -1268,7 +1279,10 @@
                     _("Game: %s conquered %s and looted %d gold"
                       " from the city."),
                     pplayer->name, pcity->name, coins);
-    gamelog(GAMELOG_LOSECITY, city_owner(pcity), pplayer, pcity, "conquered");
+    gamelog(GAMELOG_CONQ, _("%s (%s) (%i,%i) conquered by %s"), pcity->name,
+           get_nation_name(city_owner(pcity)->nation),
+           pcity->tile->x, pcity->tile->y,
+           get_nation_name_plural(pplayer->nation));
   } else {
     notify_player_ex(pplayer, pcity->tile, E_UNIT_WIN_ATT, 
                     _("Game: You have liberated %s!"
@@ -1279,8 +1293,9 @@
                     _("Game: %s liberated %s and looted %d gold"
                       " from the city."),
                     pplayer->name, pcity->name, coins);
-
-    gamelog(GAMELOG_LOSECITY, city_owner(pcity), pplayer, pcity, "liberated");
+    gamelog(GAMELOG_CONQ, _("%s (%s) (%i,%i) liberated by %s"), pcity->name,
+           get_nation_name(city_owner(pcity)->nation), pcity->tile->x,
+           pcity->tile->y, get_nation_name_plural(pplayer->nation));
   }
 
   get_a_tech(pplayer, cplayer);
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.267.2.11
diff -u -r1.267.2.11 cityturn.c
--- server/cityturn.c   1 Mar 2005 21:50:12 -0000       1.267.2.11
+++ server/cityturn.c   16 Apr 2005 21:05:25 -0000
@@ -564,14 +564,14 @@
     unit_list_iterate_safe(pcity->units_supported, punit) {
       if (unit_type(punit)->food_cost > 0 
           && !unit_flag(punit, F_UNDISBANDABLE)) {
+       const char *utname = unit_type(punit)->name;
+       wipe_unit(punit);
 
        notify_player_ex(city_owner(pcity), pcity->tile, E_UNIT_LOST,
                         _("Game: Famine feared in %s, %s lost!"), 
-                        pcity->name, unit_type(punit)->name);
- 
-        gamelog(GAMELOG_UNITLOSS, punit, NULL, "famine");
-        wipe_unit(punit);
-
+                        pcity->name, utname);
+       gamelog(GAMELOG_UNITFS, _("%s lose %s (famine)"),
+               get_nation_name_plural(city_owner(pcity)->nation), utname);
        pcity->food_stock = (city_granary_size(pcity->size)
                             * granary_savings(pcity)) / 100;
        return;
@@ -964,11 +964,16 @@
                       get_nation_name_plural(pplayer->nation),
                       get_impr_name_ex(pcity, pcity->currently_building),
                       pcity->name);
-      /* TODO: if wonders become just-another-building, remove this */
-      gamelog(GAMELOG_WONDER, pcity);
-    } else {
-      gamelog(GAMELOG_BUILD, pcity);
-    }
+      gamelog(GAMELOG_WONDER, _("%s build %s in %s"),
+             get_nation_name_plural(pplayer->nation),
+             get_impr_name_ex(pcity, pcity->currently_building),
+             pcity->name);
+
+    } else
+      gamelog(GAMELOG_IMP, _("%s build %s in %s"),
+             get_nation_name_plural(pplayer->nation),
+             get_impr_name_ex(pcity, pcity->currently_building),
+             pcity->name);
 
     notify_player_ex(pplayer, pcity->tile, E_IMP_BUILD,
                     _("Game: %s has finished building %s."), pcity->name,
@@ -1096,7 +1101,10 @@
                     pcity->name,
                     unit_types[pcity->currently_building].name);
 
-    gamelog(GAMELOG_BUILD, pcity);
+    gamelog(GAMELOG_UNIT, _("%s build %s in %s (%i,%i)"),
+           get_nation_name_plural(pplayer->nation),
+           unit_types[pcity->currently_building].name, pcity->name,
+           pcity->tile->x, pcity->tile->y);
 
     /* If there's something in the worklist, change the build
        target. If there's nothing there, worklist_change_build_target
@@ -1426,7 +1434,10 @@
                   /* TRANS: Settler production leads to disbanded city. */
                   _("Game: %s is disbanded into %s."), 
                   pcity->name, unit_types[pcity->currently_building].name);
-  gamelog(GAMELOG_DISBANDCITY, pcity);
+  gamelog(GAMELOG_UNIT, _("%s (%i, %i) disbanded into %s by the %s"),
+         pcity->name, ptile->x, ptile->y,
+         unit_types[pcity->currently_building].name,
+         get_nation_name_plural(pplayer->nation));
 
   remove_city(pcity);
   return TRUE;
Index: server/connecthand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/connecthand.c,v
retrieving revision 1.34.2.5
diff -u -r1.34.2.5 connecthand.c
--- server/connecthand.c        31 Mar 2005 17:48:36 -0000      1.34.2.5
+++ server/connecthand.c        16 Apr 2005 21:05:26 -0000
@@ -31,7 +31,6 @@
 #include "user_db.h"
 #include "diplhand.h"
 #include "gamehand.h"
-#include "gamelog.h"
 #include "maphand.h"
 #include "meta.h"
 #include "plrhand.h"
@@ -135,9 +134,6 @@
     if (game.auto_ai_toggle && pplayer->ai.control) {
       toggle_ai_player_direct(NULL, pplayer);
     }
-
-    gamelog(GAMELOG_PLAYER, pplayer);
-
   } else if (server_state == PRE_GAME_STATE && game.is_new_game) {
     if (!attach_connection_to_player(pconn, NULL)) {
       notify_conn(dest, _("Couldn't attach your connection to new player."));
@@ -587,9 +583,6 @@
         && !pplayer->is_connected /* eg multiple controllers */) {
       toggle_ai_player_direct(NULL, pplayer);
     }
-
-    gamelog(GAMELOG_PLAYER, pplayer);
-
     check_for_full_turn_done();
   }
 
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.87.2.4
diff -u -r1.87.2.4 diplhand.c
--- server/diplhand.c   9 Feb 2005 15:57:36 -0000       1.87.2.4
+++ server/diplhand.c   16 Apr 2005 21:05:26 -0000
@@ -236,6 +236,9 @@
                      "Game: A treaty containing %d clauses was agreed upon.",
                      nclauses),
                  nclauses);
+    gamelog(GAMELOG_TREATY, _("%s and %s agree to a treaty"),
+           get_nation_name_plural(pplayer->nation),
+           get_nation_name_plural(pother->nation));
 
     /* Check that one who accepted treaty earlier still have everything
        (s)he promised to give. */
@@ -332,7 +335,6 @@
         notify_player_ex(pdest, NULL, E_TREATY_SHARED_VISION,
                          _("Game: %s allowed you to create an embassy!"),
                          pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_EMBASSY, pgiver, pdest);
         break;
       case CLAUSE_ADVANCE:
         /* It is possible that two players open the diplomacy dialog
@@ -356,8 +358,11 @@
                         get_tech_name(pdest, pclause->value),
                         get_nation_name_plural(pgiver->nation));
 
-        gamelog(GAMELOG_TECH, pdest, pgiver, pclause->value, "acquire");
-        gamelog(GAMELOG_TREATY, GL_TECH, pgiver, pdest);
+       gamelog(GAMELOG_TECH, _("%s acquire %s (Treaty) from %s"),
+               get_nation_name_plural(pdest->nation),
+               get_tech_name(pdest, pclause->value),
+               get_nation_name_plural(pgiver->nation));
+
        do_dipl_cost(pdest);
 
        found_new_tech(pdest, pclause->value, FALSE, TRUE, A_NONE);
@@ -366,19 +371,19 @@
        notify_player(pdest, _("Game: You get %d gold."), pclause->value);
        pgiver->economic.gold -= pclause->value;
        pdest->economic.gold += pclause->value;
-        gamelog(GAMELOG_TREATY, GL_GOLD, pgiver, pdest);
+       gamelog(GAMELOG_TECH, _("%s acquire %d gold from %s"),
+               get_nation_name_plural(pdest->nation), pclause->value, 
+               get_nation_name_plural(pgiver->nation));
        break;
       case CLAUSE_MAP:
        give_map_from_player_to_player(pgiver, pdest);
        notify_player(pdest, _("Game: You receive %s's worldmap."),
                      pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_MAP, pgiver, pdest);
        break;
       case CLAUSE_SEAMAP:
        give_seamap_from_player_to_player(pgiver, pdest);
        notify_player(pdest, _("Game: You receive %s's seamap."),
                      pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_SEAMAP, pgiver, pdest);
        break;
       case CLAUSE_CITY:
        {
@@ -399,8 +404,9 @@
                           _("Game: You give city of %s to %s."),
                           pcity->name, pdest->name);
 
-          gamelog(GAMELOG_LOSECITY, pgiver, pdest, pcity, "acquired");
-          gamelog(GAMELOG_TREATY, GL_CITY, pgiver, pdest, pcity);
+          gamelog(GAMELOG_TECH, _("%s acquire the city %s from %s"),
+                 get_nation_name_plural(pdest->nation), pcity->name, 
+                 get_nation_name_plural(pgiver->nation));
          transfer_city(pdest, pcity, -1, TRUE, TRUE, FALSE);
          break;
        }
@@ -415,7 +421,6 @@
        notify_player_ex(pdest, NULL, E_TREATY_CEASEFIRE,
                         _("Game: You agree on a cease-fire with %s."),
                         pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_CEASEFIRE, pgiver, pdest);
        check_city_workers(pplayer);
        check_city_workers(pother);
        break;
@@ -428,7 +433,6 @@
        notify_player_ex(pdest, NULL, E_TREATY_PEACE,
                         _("Game: You agree on a peace treaty with %s."),
                         pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_PEACE, pgiver, pdest);
        check_city_workers(pplayer);
        check_city_workers(pother);
        break;
@@ -441,8 +445,9 @@
        notify_player_ex(pdest, NULL, E_TREATY_ALLIANCE,
                         _("Game: You agree on an alliance with %s."),
                         pgiver->name);
-
-        gamelog(GAMELOG_TREATY, GL_ALLIANCE, pgiver, pdest);
+       gamelog(GAMELOG_TECH, _("%s agree on an alliance with %s"),
+               get_nation_name_plural(pdest->nation), 
+               get_nation_name_plural(pgiver->nation));
        check_city_workers(pplayer);
        check_city_workers(pother);
        break;
@@ -454,7 +459,9 @@
        notify_player_ex(pdest, NULL, E_TREATY_SHARED_VISION,
                         _("Game: %s gives you shared vision."),
                         pgiver->name);
-        gamelog(GAMELOG_TREATY, GL_VISION, pgiver, pdest);
+       gamelog(GAMELOG_TECH, _("%s share vision with %s"),
+               get_nation_name_plural(pdest->nation), 
+               get_nation_name_plural(pgiver->nation));
        break;
       case CLAUSE_LAST:
       case CLAUSE_UNUSED:
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.61.2.6
diff -u -r1.61.2.6 diplomats.c
--- server/diplomats.c  21 Mar 2005 12:22:06 -0000      1.61.2.6
+++ server/diplomats.c  16 Apr 2005 21:05:26 -0000
@@ -289,7 +289,9 @@
   notify_player_ex(cplayer, pcity->tile, E_ENEMY_DIPLOMAT_EMBASSY,
                   _("Game: The %s have established an embassy in %s."),
                   get_nation_name_plural(pplayer->nation), pcity->name);
-  gamelog(GAMELOG_EMBASSY, pplayer, pcity);
+  gamelog(GAMELOG_EMBASSY, _("%s establish an embassy in %s (%s) (%i,%i)"),
+         get_nation_name_plural(pplayer->nation), pcity->name,
+         get_nation_name(cplayer->nation), pcity->tile->x, pcity->tile->y);
 
   /* Charge a nominal amount of movement for this. */
   (pdiplomat->moves_left)--;
@@ -669,6 +671,9 @@
                     _("Game: Future Tech. %d stolen by %s %s from %s."),
                     pplayer->future_tech, get_nation_name(pplayer->nation),
                     unit_name(pdiplomat->type), pcity->name);
+    gamelog(GAMELOG_TECH, _("%s steals Future Tech. %d from the %s"),
+           get_nation_name_plural(pplayer->nation), pplayer->future_tech,
+           get_nation_name_plural(cplayer->nation));
     freelog (LOG_DEBUG, "steal-tech: stole future-tech %d",
             pplayer->future_tech);
   } else {
@@ -691,12 +696,14 @@
                     get_nation_name_plural(pplayer->nation),
                     get_tech_name(cplayer, target),
                     get_nation_name_plural(cplayer->nation));
+    gamelog(GAMELOG_TECH, _("%s steals %s from the %s"),
+           get_nation_name_plural(pplayer->nation),
+           get_tech_name(cplayer, target),
+           get_nation_name_plural(cplayer->nation));
     freelog(LOG_DEBUG, "steal-tech: stole %s",
            get_tech_name(cplayer, target));
   }
 
-  gamelog(GAMELOG_TECH, pplayer, cplayer, target, "steal");
-
   /* Update stealing player's science progress and research fields */
   send_player_info(pplayer, pplayer);
 
@@ -807,8 +814,6 @@
   pplayer->economic.gold -= revolt_cost;
 
   /* Notify everybody involved. */
-  gamelog(GAMELOG_LOSECITY, cplayer, pplayer, pcity, "incited to revolt");
-
   notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_INCITE,
                   _("Game: Revolt incited in %s, you now rule the city!"),
                   pcity->name);
Index: server/gamelog.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamelog.c,v
retrieving revision 1.38.2.4
diff -u -r1.38.2.4 gamelog.c
--- server/gamelog.c    16 Jan 2005 02:36:35 -0000      1.38.2.4
+++ server/gamelog.c    16 Apr 2005 21:05:26 -0000
@@ -21,7 +21,6 @@
 #include <string.h>
 
 #include "fcintl.h"
-#include "government.h"
 #include "log.h"
 #include "map.h"
 #include "mem.h"
@@ -30,43 +29,16 @@
 #include "support.h"
 
 #include "gamelog.h"
-#include "stdinhand.h"
 
 int gamelog_level;             /* also accessed from stdinhand.c */
 static char *gamelog_filename;
 
-/* Stuff for gamelog_status() */
+/* Stuff for gamelog_save() */
 struct player_score_entry {
   int idx;
   int value;
 };
 
-static void gamelog_status(char *buffer, int len);
-
-/* must match the enum in gamelog.h */
-const char *treaty_clause_strings[] = {
-  "Embassy",
-  "Tech",
-  "Gold",
-  "Map",
-  "Seamap",
-  "City",
-  "Ceasefire",
-  "Peace",
-  "Alliance",
-  "Team",
-  "Shared Vision"
-};
-
-/* must match the enum in gamelog.h */
-const char *endgame_strings[] = {
-  "None",
-  "Draw",
-  "Lone Win",
-  "Team Win",
-  "Allied Win"
-};
-
 /**************************************************************************
   Filename can be NULL, which means no logging.
 **************************************************************************/
@@ -89,105 +61,12 @@
 }
 
 /**************************************************************************
- Place the toplevel xml tags for each line. Also add the year and turn 
- attributes to the tag. "element" is the name of the tag.
-**************************************************************************/
-static void gamelog_put_prefix(char *buf, int len, const char *element)
-{
-  char buf2[5000];
-
-  my_snprintf(buf2, sizeof(buf2), "<%s y=\"%d\" t=\"%d\">%s</%s>", element,
-              game.year, game.turn, buf, element);
-  
-  mystrlcpy(buf, buf2, len);
-}
-
-/**************************************************************************
- Does the heavy lifing. Note that this function takes variable arguments.
- This means that you'd better know what you're doing when altering a gamelog
- call.
-
- Following are the parameters to be passed given "level".
- See the case statement for more information on what the parameters are for:
-
-  GAMELOG_BEGIN
-    none.
-  GAMELOG_END
-    none.
-  GAMELOG_JUDGE
-    int
-  GAMELOG_MAP
-    none
-  GAMELOG_PLAYER
-    struct player *
-  GAMELOG_TEAM
-    struct team *
-  GAMELOG_WONDER
-    struct city *
-  GAMELOG_FOUNDCITY
-    struct city *
-  GAMELOG_LOSECITY
-    struct player *
-    struct player *
-    struct city *
-    char *
-  GAMELOG_DISBANDCITY
-    struct city *
-  GAMELOG_TECH
-    struct player *
-    struct player * (can be NULL)
-    int
-    char * (only present if second player is not NULL)
-  GAMELOG_EMBASSY
-    struct player *
-    struct city *
-  GAMELOG_GOVERNMENT
-    struct player *
-  GAMELOG_REVOLT
-    struct player *
-  GAMELOG_GENO
-    struct player *
-  GAMELOG_TREATY
-    int
-    struct player *
-    struct player *
-    struct city *   (can be NULL, present only if int is GL_CITY)
-  GAMELOG_DIPLSTATE
-    struct player *
-    struct player *
-    int
-  GAMELOG_STATUS
-    none
-  GAMELOG_FULL
-    do not call this.
-  GAMELOG_INFO
-    struct player *
-  GAMELOG_UNITLOSS
-    struct unit *
-    struct player * (can be NULL)
-    char * (only present if player is NULL)
-  GAMELOG_UNITGAMELOSS
-    struct unit *
-  GAMELOG_BUILD
-    struct city *
-  GAMELOG_RATECHANGE
-    struct player *
-  GAMELOG_EVERYTHING
-     do not call this
-  GAMELOG_DEBUG
-     do not call this
-
+  ...
 **************************************************************************/
-void gamelog(int level, ...)
+void gamelog(int level, const char *message, ...)
 {
   va_list args;
-  char buf[4096] = "", msg[512] = "";
-  char *word = NULL;
-  struct player *pplayer = NULL, *pplayer2 = NULL;
-  struct city *pcity = NULL;
-  struct unit *punit = NULL;
-  struct team *pteam = NULL;
-  int num;
+  char buf[512];
   FILE *fs;
 
   if (!gamelog_filename) {
@@ -204,399 +83,47 @@
     exit(EXIT_FAILURE);
   }
 
-  va_start(args, level);
-
-  switch (level) {
-  case GAMELOG_GOVERNMENT:
-    pplayer = va_arg(args, struct player *);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n>%d</n><name>%s</name><m>%s form a %s</m>",
-                pplayer->player_no, get_government_name(pplayer->government),
-                get_nation_name_plural(pplayer->nation),
-                get_government_name(pplayer->government));
-    gamelog_put_prefix(buf, sizeof(buf), "gov");
-    break;
-  case GAMELOG_REVOLT:
-    pplayer = va_arg(args, struct player *);
-
-    my_snprintf(buf, sizeof(buf), "<n>%d</n><m>%s</m>",
-                pplayer->player_no, get_nation_name_plural(pplayer->nation));
-    gamelog_put_prefix(buf, sizeof(buf), "rev");
-    break;
-  case GAMELOG_FOUNDCITY:
-    pcity = va_arg(args, struct city *);
-
-    my_snprintf(buf, sizeof(buf), "<n>%d</n><name>%s</name>"
-                "<x>%d</x><y>%d</y><m>%s (%d,%d) founded by the %s</m>",
-                city_owner(pcity)->player_no,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                get_nation_name_plural(city_owner(pcity)->nation));
-    gamelog_put_prefix(buf, sizeof(buf), "cityf");
-    break;
-  case GAMELOG_LOSECITY:
-    pplayer = va_arg(args, struct player *);
-    pplayer2 = va_arg(args, struct player *);
-    pcity = va_arg(args, struct city *);
-    word = va_arg(args, char *);
-
-    my_snprintf(buf, sizeof(buf), "<n1>%d</n1><n2>%d</n2>"
-                "<name>%s</name><x>%d</x><y>%d</y>"
-                "<m>%s (%s) (%d,%d) %s by %s</m>", 
-                pplayer->player_no, pplayer2->player_no,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                pcity->name, get_nation_name_plural(pplayer->nation),
-                pcity->tile->x, pcity->tile->y, word,
-                get_nation_name_plural(pplayer2->nation));
-    gamelog_put_prefix(buf, sizeof(buf), "cityl");
-    break;
-  case GAMELOG_DISBANDCITY:
-    pcity = va_arg(args, struct city *);
-
-    my_snprintf(buf, sizeof(buf), "<n>%d</n><name>%s</name>"
-                "<x>%d</x><y>%d</y><m>%s (%d, %d) disbanded by the %s</m>",
-                city_owner(pcity)->player_no,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                get_nation_name_plural(city_owner(pcity)->nation));
-    gamelog_put_prefix(buf, sizeof(buf), "cityd");
-    break;
-  case GAMELOG_TREATY:
-    num = va_arg(args, int);
-    pplayer = va_arg(args, struct player *);
-    pplayer2 = va_arg(args, struct player *);
-
-    switch(num) {
-    case GL_EMBASSY:
-      sz_strlcpy(msg, "<m>Treaty - Embassy between the %s and the %s</m>");
-      break;
-    case GL_TECH:
-      sz_strlcpy(msg, "<m>Treaty - Tech given to the %s from the %s</m>");
-      break;
-    case GL_GOLD:
-      sz_strlcpy(msg, "<m>Treaty - Gold given to the %s from the %s</m>");
-      break;
-    case GL_MAP:
-      sz_strlcpy(msg, "<m>Treaty - Map given to the %s from the %s</m>");
-      break;
-    case GL_SEAMAP:
-      sz_strlcpy(msg, "<m>Treaty - Seamap given to the %s from the %s</m>");
-      break;
-    case GL_CITY:
-      pcity = va_arg(args, struct city *);
-      sz_strlcpy(msg,
-                 "<m>Treaty - City (%s) given to the %s from the %s</m>");
-      break;
-    case GL_CEASEFIRE:
-      sz_strlcpy(msg, "<m>Treaty - Ceasefire between the %s and the %s</m>");
-      break;
-    case GL_PEACE:
-      sz_strlcpy(msg, "<m>Treaty - Peace between the %s and the %s</m>");
-      break;
-    case GL_ALLIANCE:
-      sz_strlcpy(msg, "<m>Treaty - Alliance between the %s and the %s</m>");
-      break;
-    case GL_TEAM:
-      sz_strlcpy(msg, "<m>Treaty - Team between the %s and the %s</m>");
-      break;
-    case GL_VISION:
-      sz_strlcpy(msg,
-                 "<m>Treaty - Shared Vision between the %s and the %s</m>");
-      break;
-    default:
-      break;
-    }
-
-    if (pcity) {
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><n2>%d</n2><city>%s</city><type>%s</type>",
-                  pplayer->player_no, pplayer2->player_no, pcity->name,
-                  treaty_clause_strings[num]);
-      cat_snprintf(buf, sizeof(buf), msg, 
-                  pcity->name, get_nation_name_plural(pplayer2->nation),
-                  get_nation_name_plural(pplayer->nation));
-    } else {
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><n2>%d</n2><type>%s</type>",
-                  pplayer->player_no, pplayer2->player_no, 
-                  treaty_clause_strings[num]);
-      cat_snprintf(buf, sizeof(buf), msg,
-                  get_nation_name_plural(pplayer->nation),
-                  get_nation_name_plural(pplayer2->nation));
-    }
-    gamelog_put_prefix(buf, sizeof(buf), "treaty");
-    break;
-  case GAMELOG_DIPLSTATE:
-    pplayer = va_arg(args, struct player *);
-    pplayer2 = va_arg(args, struct player *);
-    num = va_arg(args, int);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n1>%d</n1><n2>%d</n2><type>%s</type>",
-                pplayer->player_no, pplayer2->player_no,  diplstate_text(num));
-    cat_snprintf(buf, sizeof(buf),
-                "<m>The diplomatic state between the %s and the %s is %s</m>",
-                get_nation_name_plural(pplayer->nation),
-                get_nation_name_plural(pplayer2->nation), diplstate_text(num));
-    gamelog_put_prefix(buf, sizeof(buf), "dipl");
-    break;
-  case GAMELOG_TECH:
-    pplayer = va_arg(args, struct player *);
-    pplayer2 = va_arg(args, struct player *);
-    num = va_arg(args, int);
-
-    if (pplayer2) {
-      word = va_arg(args, char *);
-
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><n2>%d</n2><name>%s</name>"
-                  "<m>%s %s %s from the %s</m>",
-                  pplayer->player_no, pplayer2->player_no,
-                  get_tech_name(pplayer, (Tech_Type_id) num),
-                  get_nation_name_plural(pplayer->nation), word,
-                  get_tech_name(pplayer, (Tech_Type_id) num),
-                  get_nation_name_plural(pplayer2->nation));
-    } else {
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><name>%s</name>"
-                  "<m>%s discover %s</m>",
-                  pplayer->player_no,
-                  get_tech_name(pplayer, (Tech_Type_id) num),
-                  get_nation_name_plural(pplayer->nation),
-                  get_tech_name(pplayer, (Tech_Type_id) num));
-    }
-    gamelog_put_prefix(buf, sizeof(buf), "tech");
-    break;
-  case GAMELOG_UNITLOSS:
-    punit = va_arg(args, struct unit *);
-    pplayer = va_arg(args, struct player *);
-
-    if (pplayer) {
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><n2>%d</n2><name>%s</name>"
-                  "<m>%s lose %s to the %s</m>",
-                  unit_owner(punit)->player_no, pplayer->player_no,
-                  unit_name(punit->type),
-                  get_nation_name_plural(unit_owner(punit)->nation),
-                  unit_name(punit->type),
-                  get_nation_name_plural(pplayer->nation));
+  va_start(args, message);
+  my_vsnprintf(buf, sizeof(buf), message, args);
+  if (level == GAMELOG_MAP) {
+    if (buf[0] == '(') {
+      /* KLUGE!! FIXME: remove when we fix the gamelog format --jjm */
+      fprintf(fs, "%i %s\n", game.year, buf);
     } else {
-      word = va_arg(args, char *);
-      my_snprintf(buf, sizeof(buf),
-                  "<n1>%d</n1><name>%s</name><m>%s lose %s (%s)</m>",
-                  unit_owner(punit)->player_no, unit_name(punit->type),
-                  get_nation_name_plural(unit_owner(punit)->nation),
-                  unit_name(punit->type), word);
+      fprintf(fs,"%s\n", buf);
     }
-    gamelog_put_prefix(buf, sizeof(buf), "unitl");
-    break;
-  case GAMELOG_UNITGAMELOSS:
-    punit = va_arg(args, struct unit *);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n>%d</n><name>%s</name>"
-                "<m>%s lost a game loss unit and died</m>",
-                unit_owner(punit)->player_no, unit_name(punit->type),
-                get_nation_name_plural(unit_owner(punit)->nation));
-    gamelog_put_prefix(buf, sizeof(buf), "gamel");
-    break;
-  case GAMELOG_EMBASSY:
-    pplayer = va_arg(args, struct player *);
-    pcity = va_arg(args, struct city *);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n1>%d</n1><n2>%d</n2><name>%s</name><x>%d</x><y>%d</y>"
-                "<m>%s establish an embassy in %s (%s) (%d,%d)</m>",
-                pplayer->player_no, city_owner(pcity)->player_no,
-                pcity->name, pcity->tile->x, pcity->tile->y,
-                get_nation_name_plural(pplayer->nation),
-                pcity->name,
-                get_nation_name_plural(city_owner(pcity)->nation),
-                pcity->tile->x, pcity->tile->y);
-    gamelog_put_prefix(buf, sizeof(buf), "embassy");
-    break;
-  case GAMELOG_BUILD:
-  case GAMELOG_WONDER:
-    pcity = va_arg(args, struct city *);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n>%d</n><city>%s</city><u>%d</u>"
-                "<w>%d</w><name>%s</name><m>%s build %s in %s</m>",
-                city_owner(pcity)->player_no, pcity->name,
-                pcity->is_building_unit ? 1 : 0,
-                (!pcity->is_building_unit 
-                 && is_wonder(pcity->currently_building)) ? 1 : 0,
-                pcity->is_building_unit ? 
-                  unit_types[pcity->currently_building].name :
-                  get_impr_name_ex(pcity, pcity->currently_building),
-                get_nation_name_plural(city_owner(pcity)->nation),
-                pcity->is_building_unit ? 
-                  unit_types[pcity->currently_building].name :
-                  get_impr_name_ex(pcity, pcity->currently_building),
-                pcity->name);
-    gamelog_put_prefix(buf, sizeof(buf), "build");
-    break;
-  case GAMELOG_GENO:
-    pplayer = va_arg(args, struct player *);
-
-    my_snprintf(buf, sizeof(buf),
-                "<n>%d</n><b>%d</b><m>%s civilization destroyed</m>",
-                pplayer->player_no, is_barbarian(pplayer) ? 1 : 0,
-                is_barbarian(pplayer) ? get_nation_name(pplayer->nation)
-                                      : pplayer->name);
-    gamelog_put_prefix(buf, sizeof(buf), "geno");
-    break;
-  case GAMELOG_RATECHANGE:
-    pplayer = va_arg(args, struct player *);
-
-    my_snprintf(buf, sizeof(buf), 
-                "<n>%d</n><tax>%d</tax><lux>%d</lux><sci>%d</sci>",
-                pplayer->player_no, pplayer->economic.tax, 
-                pplayer->economic.luxury, pplayer->economic.science);
-    gamelog_put_prefix(buf, sizeof(buf), "rates");
-    break;
-  case GAMELOG_INFO:
-    pplayer = va_arg(args, struct player *);
-    {
-      int food = 0, shields = 0, trade = 0, settlers = 0;
-
-      unit_list_iterate(pplayer->units, punit) {
-        if (unit_flag(punit, F_CITIES)) {
-          settlers++;
-        }
-      } unit_list_iterate_end;
-      city_list_iterate(pplayer->cities, pcity) {
-        shields += pcity->shield_prod;
-        food += pcity->food_prod;
-        trade += pcity->trade_prod;
-      } city_list_iterate_end;
-
-      my_snprintf(buf, sizeof(buf), "<n>%d</n><cities>%d</cities>"
-                  "<pop>%d</pop><food>%d</food><prod>%d</prod>"
-                  "<trade>%d</trade><settlers>%d</settlers><units>%d</units>",
-                  pplayer->player_no, city_list_size(&pplayer->cities),
-                  total_player_citizens(pplayer), food, shields, trade, 
-                  settlers, unit_list_size(&pplayer->units));
-    }
-    gamelog_put_prefix(buf, sizeof(buf), "info");
-    break;
-  case GAMELOG_PLAYER:
-    pplayer = va_arg(args, struct player *);
-
-    my_snprintf(buf, sizeof(buf), "<n>%d</n><u>%s</u><c>%d</c>"
-                "<ai>%s</ai><nat>%s</nat><l>%s</l>",
-                pplayer->player_no, pplayer->username,
-                pplayer->is_connected ? 1 : 0,
-                pplayer->ai.control ? 
-                  name_of_skill_level(pplayer->ai.skill_level) : "",
-                get_nation_name_plural(pplayer->nation), pplayer->name);
-    gamelog_put_prefix(buf, sizeof(buf), "player");
-    break;
-  case GAMELOG_TEAM:
-    pteam = va_arg(args, struct team *);
-
-    my_snprintf(buf, sizeof(buf), "<id>%d</id><name>%s</name>",
-                                  pteam->id, pteam->name);
-    players_iterate(aplayer) {
-      if (aplayer->team == pteam->id) {
-        cat_snprintf(buf, sizeof(buf), "<n>%d</n>", aplayer->player_no);
-      }
-    } players_iterate_end;
-    gamelog_put_prefix(buf, sizeof(buf), "team");
-    break;
-  case GAMELOG_BEGIN:
-    my_snprintf(buf, sizeof(buf),
-                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-                "<gamelog version=\"2.0\">");
-    break; 
-  case GAMELOG_END:
-    my_snprintf(buf, sizeof(buf), "</gamelog>");
-    break;
-  case GAMELOG_JUDGE:
-    num = va_arg(args, int);
-
-    switch(num) {
-    case GL_NONE:
-    case GL_DRAW:
-      my_snprintf(buf, sizeof(buf), "<type>%s</type>", endgame_strings[num]);
-      msg[0] = '\0';
-      break;
-    case GL_LONEWIN:
-      pplayer = va_arg(args, struct player *);
-
-      my_snprintf(buf, sizeof(buf), "<type>%s</type><n>%d</n>",
-                  endgame_strings[num], pplayer->player_no);
-      my_snprintf(msg, sizeof(msg),
-                  (pplayer->spaceship.state == SSHIP_ARRIVED)
-                  ? "The %s spaceship has arrived at Alpha Centauri."
-                  : "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]);
-      players_iterate(aplayer) {
-        if (aplayer->team == pteam->id) {
-          cat_snprintf(buf, sizeof(buf), "<n>%d</n>", aplayer->player_no);
-        }
-      } players_iterate_end;
-      my_snprintf(msg, sizeof(msg), "Team victory to %s", pteam->name);
-      break;
-    default:
-      break;
-    }
-    cat_snprintf(buf, sizeof(buf), "<m>%s</m>", msg);
-    gamelog_put_prefix(buf, sizeof(buf), "judge");
-    break;
-  case GAMELOG_MAP:
-    /* this is big, so it's special */
-    {
-      int nat_x, nat_y, i = 0;
-      char *mapline = fc_malloc(((map.xsize + 1) * map.ysize) + 1);
-
-      for (nat_y = 0; nat_y < map.ysize; nat_y++) {
-        for (nat_x = 0; nat_x < map.xsize; nat_x++) {
-          struct tile *ptile = native_pos_to_tile(nat_x, nat_y);
-
-          mapline[i++] = is_ocean(map_get_terrain(ptile)) ? ' ' : '.';
-        }
-        mapline[i++] = '\n';
-      }
-      mapline[i] = '\0';
+  } else if (level == GAMELOG_EOT) {
+    fprintf(fs,"*** %s\n", buf);
+  } else if (level == GAMELOG_RANK) {
+    fprintf(fs,"RANK %s\n", buf);
+  } else if (level == GAMELOG_TEAM) {
+    fprintf(fs,"%s\n", buf);
+  } else if (level == GAMELOG_STATUS) {
+    fprintf(fs, "STATUS %s\n", buf);
+  } else {
+    fprintf(fs, "%i %s\n", game.year,buf);
+  }
+  fflush(fs);
+  fclose(fs);
+}
 
-      va_end(args);
+/**************************************************************************
+  ...
+**************************************************************************/
+void gamelog_map(void)
+{
+  int nat_x, nat_y;
+  char *hline = fc_calloc(map.xsize + 1, sizeof(char));
 
-      fprintf(fs, "<map>\n%s</map>\n", mapline);
-      fflush(fs);
-      fclose(fs);
-      free(mapline);
-      return;
+  for (nat_y = 0; nat_y < map.ysize; nat_y++) {
+    for (nat_x = 0; nat_x < map.xsize; nat_x++) {
+      struct tile *ptile = native_pos_to_tile(nat_x, nat_y);
+
+      hline[nat_x] = is_ocean(map_get_terrain(ptile)) ? ' ' : '.';
     }
-    break;
-  case GAMELOG_STATUS:
-    gamelog_status(buf, sizeof(buf));
-    gamelog_put_prefix(buf, sizeof(buf), "status");
-    break;
-  default:
-    assert(0);
-    break;
+    gamelog(GAMELOG_MAP, "%s", hline);
   }
-
-  va_end(args);
-
-  fprintf(fs, "%s\n", buf);
-  fflush(fs);
-  fclose(fs);
+  free(hline);
 }
 
 /**************************************************************************
@@ -612,10 +139,10 @@
   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) {
-
+void gamelog_save(void) {
   int i, count = 0, highest = -1;
   struct player *highest_plr = NULL;
+  char buffer[4096];
   struct player_score_entry size[game.nplayers], rank[game.nplayers];
 
   players_iterate(pplayer) {
@@ -646,12 +173,54 @@
     }
   } players_iterate_end;
 
-  buffer[0] = '\0';
+  qsort(size, count, sizeof(struct player_score_entry), secompare1);
+  buffer[0] = 0;
+  for (i = 0; i < count; i++) {
+    cat_snprintf(buffer, sizeof(buffer),
+                "%2d: %s(%i)  ",
+                i+1,
+                get_nation_name_plural(game.players[size[i].idx].nation),
+                size[i].value);
+  }
+  gamelog(GAMELOG_EOT, "%s", buffer);
   qsort(rank, count, sizeof(struct player_score_entry), secompare1);
-
+  buffer[0] = 0;
   for (i = 0; i < count; i++) {
-    cat_snprintf(buffer, len, "<plr><no>%d</no><r>%d</r><s>%d</s></plr>",
-                game.players[rank[i].idx].player_no,
-                 rank[i].value, size[rank[i].idx].value);
+    cat_snprintf(buffer, sizeof(buffer),
+                "%s,%i|",
+                gamelog_playername(&game.players[rank[i].idx]),
+                rank[i].value);
+  }
+  gamelog(GAMELOG_RANK, "%s", buffer);
+  buffer[0] = 0;
+  for (i = 0; i < count; i++) {
+    cat_snprintf(buffer, sizeof(buffer),
+                "%s,%i,%i,%i|",
+                gamelog_playername(&game.players[rank[i].idx]),
+                game.players[rank[i].idx].ai.control ? 1 : 0 *
+                game.players[rank[i].idx].ai.skill_level,
+                game.players[rank[i].idx].is_connected, rank[i].value);
+  }
+  gamelog(GAMELOG_STATUS, "%s", buffer);
+}
+
+/**************************************************************************
+  Return the name to be used for the player in the gamelog.
+
+  For human players this is the username.  For unassigned players a
+  name is assembled.
+**************************************************************************/
+const char *gamelog_playername(const struct player *pplayer)
+{
+  if (strcmp(pplayer->username, ANON_USER_NAME) == 0) {
+    /* FIXME: there's no way to include the difficulty level here since
+     * it may change during the game. */
+    static char names[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS][MAX_LEN_NAME];
+
+    my_snprintf(names[pplayer->player_no], sizeof(names[pplayer->player_no]),
+               "%%AI%d%%", pplayer->player_no);
+    return names[pplayer->player_no];
+  } else {
+    return pplayer->username;
   }
 }
Index: server/gamelog.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamelog.h,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 gamelog.h
--- server/gamelog.h    9 Dec 2004 16:28:10 -0000       1.9.2.1
+++ server/gamelog.h    16 Apr 2005 21:05:26 -0000
@@ -16,63 +16,52 @@
 
 #include "shared.h"            /* fc__attribute */
 
-enum {
-  GAMELOG_BEGIN,
-  GAMELOG_END,
-  GAMELOG_JUDGE,
-  GAMELOG_MAP,
-  GAMELOG_PLAYER,
-  GAMELOG_TEAM,
-  GAMELOG_WONDER,
-  GAMELOG_FOUNDCITY,
-  GAMELOG_LOSECITY,
-  GAMELOG_DISBANDCITY,
-  GAMELOG_TECH,
-  GAMELOG_EMBASSY,
-  GAMELOG_GOVERNMENT,
-  GAMELOG_REVOLT,
-  GAMELOG_GENO,
-  GAMELOG_TREATY,
-  GAMELOG_DIPLSTATE,
-  GAMELOG_STATUS,
-  GAMELOG_FULL,                /* placeholder */
-  GAMELOG_INFO,
-  GAMELOG_UNITLOSS,
-  GAMELOG_UNITGAMELOSS,
-  GAMELOG_BUILD,
-  GAMELOG_RATECHANGE,
-  GAMELOG_EVERYTHING,
-  GAMELOG_DEBUG
-};
-
-/* end game states */
-enum {
-  GL_NONE,
-  GL_DRAW,
-  GL_LONEWIN,
-  GL_TEAMWIN,
-  GL_ALLIEDWIN
-};
-
-/* treaty clause types */
-enum {
-  GL_EMBASSY,
-  GL_TECH,
-  GL_GOLD,
-  GL_MAP,
-  GL_SEAMAP,
-  GL_CITY,
-  GL_CEASEFIRE,
-  GL_PEACE,
-  GL_ALLIANCE,
-  GL_TEAM,
-  GL_VISION
-};
+#define GAMELOG_FATAL  0
+#define GAMELOG_NORMAL 1
+#define GAMELOG_INIT  2
+#define GAMELOG_MAP 3
+#define GAMELOG_WONDER 4
+#define GAMELOG_FOUNDC 5 
+#define GAMELOG_LOSEC 6
+#define GAMELOG_TECH 7
+#define GAMELOG_EMBASSY 8
+#define GAMELOG_GOVERNMENT 9
+#define GAMELOG_CONQ 10
+#define GAMELOG_REVOLT 11
+#define GAMELOG_GENO 12
+#define GAMELOG_TREATY 13
+#define GAMELOG_TEAM 15
+#define GAMELOG_STATUS 16
+#define GAMELOG_RANK 17
+#define GAMELOG_LAST 18
+#define GAMELOG_EOT 19
+#define GAMELOG_FULL 20
+/*Unit created*/
+#define GAMELOG_UNIT 21
+/*Unit destroyed*/
+#define GAMELOG_UNITL 22
+/*Unit  lost due to fuel*/
+#define GAMELOG_UNITF 23
+/*Trireme lost at sea*/
+#define GAMELOG_UNITTRI 24
+/*Settlers lost to famine*/
+#define GAMELOG_UNITFS 25
+/*Improvements*/
+#define GAMELOG_IMP 28
+/*Taxation rate change*/
+#define GAMELOG_RATE 29
+#define GAMELOG_EVERYTHING 30
+#define GAMELOG_DEBUG 40
 
 void gamelog_init(char *filename);
 void gamelog_set_level(int level);
-void gamelog(int level, ...);
+void gamelog(int level, const char *message, ...)
+             fc__attribute((format (printf, 2, 3)));
+void gamelog_map(void);
+void gamelog_save(void);
 
 extern int gamelog_level;
 
+const char *gamelog_playername(const struct player *pplayer);
+
 #endif  /* FC__GAMELOG_H */
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.149.2.3
diff -u -r1.149.2.3 maphand.c
--- server/maphand.c    15 Feb 2005 17:41:58 -0000      1.149.2.3
+++ server/maphand.c    16 Apr 2005 21:05:26 -0000
@@ -31,6 +31,7 @@
 
 #include "citytools.h"
 #include "cityturn.h"
+#include "gamelog.h"
 #include "plrhand.h"           /* notify_player */
 #include "sernet.h"
 #include "srv_main.h"
@@ -1491,9 +1492,14 @@
     ocean_to_land_fix_rivers(ptile);
     city_landlocked_sell_coastal_improvements(ptile);
 
+    gamelog(GAMELOG_MAP, _("(%d,%d) land created from ocean"),
+           TILE_XY(ptile));
     change_type = OLC_OCEAN_TO_LAND;
   } else if (!is_ocean(oldter) && is_ocean(newter)) {
     /* land to ocean ... */
+
+    gamelog(GAMELOG_MAP, _("(%d,%d) ocean created from land"),
+           TILE_XY(ptile));
     change_type = OLC_LAND_TO_OCEAN;
   }
 
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.330.2.20
diff -u -r1.330.2.20 plrhand.c
--- server/plrhand.c    10 Apr 2005 17:30:17 -0000      1.330.2.20
+++ server/plrhand.c    16 Apr 2005 21:05:27 -0000
@@ -156,7 +156,9 @@
        notify_player_ex(pplayer, NULL, E_TECH_GAIN,
                         _("Game: %s acquired from %s!"),
                         get_tech_name(pplayer, i), buf);
-        gamelog(GAMELOG_TECH, pplayer, NULL, i, "steal");
+       gamelog(GAMELOG_TECH, _("%s discover %s (%s)"),
+               get_nation_name_plural(pplayer->nation),
+               get_tech_name(pplayer, i), buf);
        notify_embassies(pplayer, NULL,
                         _("Game: The %s have acquired %s from %s."),
                         get_nation_name_plural(pplayer->nation),
@@ -217,13 +219,14 @@
   }
 
   if (is_barbarian(pplayer)) {
-    gamelog(GAMELOG_GENO, pplayer, 
-                          "The feared barbarian leader %s is no more");
+    gamelog(GAMELOG_GENO, _("The feared barbarian leader %s is no more"),
+           gamelog_playername(pplayer));
     return;
   } else {
     notify_player_ex(NULL, NULL, E_DESTROYED, _("Game: The %s are no more!"),
                      get_nation_name_plural(pplayer->nation));
-    gamelog(GAMELOG_GENO, pplayer, "%s civilization destroyed");
+    gamelog(GAMELOG_GENO, _("%s civilization destroyed"),
+            get_nation_name(pplayer->nation));
   }
 
   /* Transfer back all cities not originally owned by player to their
@@ -501,14 +504,18 @@
                     get_nation_name_plural(plr->nation),
                     get_tech_name(plr, plr->research.researching));
 
+    gamelog(GAMELOG_TECH, _("%s discover %s"),
+           get_nation_name_plural(plr->nation),
+           get_tech_name(plr, plr->research.researching));
   } else {
     notify_embassies(plr, NULL,
                     _("Game: The %s have researched Future Tech. %d."), 
                     get_nation_name_plural(plr->nation),
                     plr->future_tech);
   
+    gamelog(GAMELOG_TECH, _("%s discover Future Tech %d"),
+           get_nation_name_plural(plr->nation), plr->future_tech);
   }
-  gamelog(GAMELOG_TECH, plr, NULL, plr->research.researching);
 
   /* Deduct tech cost */
   plr->research.bulbs_researched = 
@@ -736,7 +743,10 @@
     } tech_type_iterate_end;
     assert(stolen_tech != A_NONE);
   }
-  gamelog(GAMELOG_TECH, pplayer, target, stolen_tech, "steal");
+  gamelog(GAMELOG_TECH, _("%s steal %s from %s"),
+         get_nation_name_plural(pplayer->nation),
+         get_tech_name(pplayer, stolen_tech),
+         get_nation_name_plural(target->nation));
 
   notify_player_ex(pplayer, NULL, E_TECH_GAIN,
                   _("Game: You steal %s from the %s."),
@@ -800,7 +810,8 @@
     pplayer->economic.tax = tax;
     pplayer->economic.luxury = luxury;
     pplayer->economic.science = science;
-    gamelog(GAMELOG_RATECHANGE, pplayer);
+    gamelog(GAMELOG_EVERYTHING, _("RATE CHANGE: %s %i %i %i"),
+           get_nation_name_plural(pplayer->nation), tax, luxury, science);
     conn_list_do_buffer(&pplayer->connections);
     global_city_refresh(pplayer);
     send_player_info(pplayer, pplayer);
@@ -881,9 +892,10 @@
                   _("Game: %s now governs the %s as a %s."), 
                   pplayer->name, 
                   get_nation_name_plural(pplayer->nation),
-                  get_government_name(government));
-
-  gamelog(GAMELOG_GOVERNMENT, pplayer);
+                  get_government_name(government));  
+  gamelog(GAMELOG_GOVERNMENT, _("%s form a %s"),
+         get_nation_name_plural(pplayer->nation),
+         get_government_name(government));
 
   if (!pplayer->ai.control) {
     /* Keep luxuries if we have any.  Try to max out science. -GJW */
@@ -931,7 +943,8 @@
   notify_player_ex(pplayer, NULL, E_REVOLT_START,
                   _("Game: The %s have incited a revolt!"),
                   get_nation_name_plural(pplayer->nation));
-  gamelog(GAMELOG_REVOLT, pplayer);
+  gamelog(GAMELOG_REVOLT, _("The %s revolt!"),
+         get_nation_name_plural(pplayer->nation));
 
   /* Now see if the revolution is instantaneous. */
   if (pplayer->revolution_finishes <= game.turn
@@ -1074,7 +1087,9 @@
   }
 
   if (changed) {
-    gamelog(GAMELOG_RATECHANGE, pplayer);
+    gamelog(GAMELOG_EVERYTHING, _("RATE CHANGE: %s %i %i %i"),
+           get_nation_name_plural(pplayer->nation), pplayer->economic.tax,
+           pplayer->economic.luxury, pplayer->economic.science);
   }
 }
 
@@ -1161,8 +1176,6 @@
     pplayer2->diplstates[pplayer->player_no].turns_left =
     16;
 
-  gamelog(GAMELOG_DIPLSTATE, pplayer, pplayer2, new_type);
-
   /* If the old state was alliance, the players' units can share tiles
      illegally, and we need to call resolve_unit_stacks() */
   if (old_type == DS_ALLIANCE) {
@@ -2023,9 +2036,7 @@
   if (pplayer->ai.control) {
     assess_danger_player(pplayer);
   }
-
-  gamelog(GAMELOG_PLAYER, cplayer);
-  
+                   
   return cplayer;
 }
 
Index: server/spacerace.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/spacerace.c,v
retrieving revision 1.37.2.1
diff -u -r1.37.2.1 spacerace.c
--- server/spacerace.c  9 Dec 2004 16:28:11 -0000       1.37.2.1
+++ server/spacerace.c  16 Apr 2005 21:05:27 -0000
@@ -367,6 +367,10 @@
                     _("Game: The %s spaceship has arrived "
                       "at Alpha Centauri."),
                     get_nation_name(best_pplayer->nation));
-    gamelog(GAMELOG_JUDGE, GL_LONEWIN, best_pplayer);
+    gamelog(GAMELOG_NORMAL, _("The %s spaceship has arrived at "
+                             "Alpha Centauri."),
+            get_nation_name(best_pplayer->nation));
+    gamelog(GAMELOG_TEAM, "SINGLEWINNER %s",
+           gamelog_playername(best_pplayer));
   }
 }
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.201.2.10
diff -u -r1.201.2.10 srv_main.c
--- server/srv_main.c   16 Jan 2005 02:36:35 -0000      1.201.2.10
+++ server/srv_main.c   16 Apr 2005 21:05:27 -0000
@@ -221,8 +221,7 @@
   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");
+    gamelog(GAMELOG_NORMAL, _("Game ended in a draw as end year exceeded"));
     return TRUE;
   }
 
@@ -254,7 +253,8 @@
     if (team_count_members_alive(pteam->id) == alive) {
       notify_conn_ex(&game.est_connections, NULL, E_GAME_END,
                     _("Team victory to %s"), pteam->name);
-      gamelog(GAMELOG_JUDGE, GL_TEAMWIN, pteam);
+      gamelog(GAMELOG_NORMAL, _("Team victory to %s"), pteam->name);
+      gamelog(GAMELOG_TEAM, "TEAMVICTORY %s", pteam->name);
       return TRUE;
     }
   } team_iterate_end;
@@ -263,12 +263,15 @@
   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);
+    gamelog(GAMELOG_NORMAL, _("Game ended in victory for %s"), 
+           gamelog_playername(victor));
+    gamelog(GAMELOG_TEAM, "SINGLEWINNER %s", gamelog_playername(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);
+    gamelog(GAMELOG_NORMAL, _("Game ended in a draw"));
+    gamelog(GAMELOG_TEAM, "NOWINNER");
     return TRUE;
   }
 
@@ -291,7 +294,8 @@
   if (all_allied) {
     notify_conn_ex(&game.est_connections, NULL, E_GAME_END, 
                   _("Game ended in allied victory"));
-    gamelog(GAMELOG_JUDGE, GL_ALLIEDWIN);
+    gamelog(GAMELOG_NORMAL, _("Game ended in allied victory"));
+    gamelog(GAMELOG_TEAM, "ALLIEDVICTORY");
     return TRUE;
   }
 
@@ -620,7 +624,25 @@
   /* Output some ranking and AI debugging info here. */
   if (game.turn % 10 == 0) {
     players_iterate(pplayer) {
-      gamelog(GAMELOG_INFO, pplayer);
+      int workers = 0, food = 0, shields = 0, trade = 0, settlers = 0;
+
+      /* Compile statistics */
+      unit_list_iterate(pplayer->units, punit) {
+        if (unit_flag(punit, F_CITIES)) {
+          settlers++; 
+        }
+      } unit_list_iterate_end;
+      city_list_iterate(pplayer->cities, pcity) {
+        workers += pcity->size;
+        shields += pcity->shield_prod;
+        food += pcity->food_prod;
+        trade += pcity->trade_prod;
+      } city_list_iterate_end;
+      gamelog(GAMELOG_NORMAL, "INFO %s cities %d, pop %d "
+              "food %d, prod %d, trade %d, settlers %d, units %d",
+              gamelog_playername(pplayer),
+             city_list_size(&pplayer->cities), workers, food,
+              shields, trade, settlers, unit_list_size(&pplayer->units));
     } players_iterate_end;
   }
 
@@ -763,7 +785,7 @@
   my_snprintf(filename, sizeof(filename),
              "%s%+05d.sav", game.save_name, game.year);
   save_game(filename);
-  gamelog(GAMELOG_STATUS);
+  gamelog_save();              /* should this be in save_game()? --dwp */
 }
 
 /**************************************************************************
@@ -1603,7 +1625,7 @@
   con_log_init(srvarg.log_filename, srvarg.loglevel);
   gamelog_init(srvarg.gamelog_filename);
   gamelog_set_level(GAMELOG_FULL);
-  gamelog(GAMELOG_BEGIN);
+  gamelog(GAMELOG_NORMAL, _("Starting new log"));
   
 #if IS_BETA_VERSION
   con_puts(C_COMMENT, "");
@@ -1651,12 +1673,11 @@
     report_final_scores();
     show_map_to_all();
     notify_player(NULL, _("Game: The game is over..."));
-    gamelog(GAMELOG_JUDGE, GL_NONE);
+    gamelog(GAMELOG_NORMAL, _("The game is over!"));
     send_server_info_to_metaserver(META_INFO);
     if (game.save_nturns > 0) {
       save_game_auto();
     }
-    gamelog(GAMELOG_END);
 
     /* Remain in GAME_OVER_STATE until players log out */
     while (conn_list_size(&game.est_connections) > 0) {
@@ -1802,7 +1823,7 @@
     map_fractal_generate(TRUE);
   }
 
-  gamelog(GAMELOG_MAP);
+  gamelog_map();
   /* start the game */
 
   server_state = RUN_GAME_STATE;
@@ -1842,16 +1863,6 @@
    } players_iterate_end;
   }
 
-  /* tell the gamelog about the players */
-  players_iterate(pplayer) {
-    gamelog(GAMELOG_PLAYER, pplayer);
-  } players_iterate_end;
-
-  /* tell the gamelog who is whose team */
-  team_iterate(pteam) {
-    gamelog(GAMELOG_TEAM, pteam);
-  } team_iterate_end;
-
   initialize_move_costs(); /* this may be the wrong place to do this */
   init_settlers(); /* create minimap and other settlers.c data */
 
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.354.2.30
diff -u -r1.354.2.30 stdinhand.c
--- server/stdinhand.c  13 Apr 2005 03:48:32 -0000      1.354.2.30
+++ server/stdinhand.c  16 Apr 2005 21:05:28 -0000
@@ -682,7 +682,7 @@
  This could be in common/player if the client ever gets
  told the ai player skill levels.
 ***************************************************************/
-const char *name_of_skill_level(int level)
+static const char *name_of_skill_level(int level)
 {
   const char *nm[11] = { "UNUSED", "away", "novice", "easy",
                         "UNKNOWN", "normal", "UNKNOWN", "hard",
@@ -820,7 +820,6 @@
 
   if (server_state == RUN_GAME_STATE) {
     send_player_info(pplayer, NULL);
-    gamelog(GAMELOG_PLAYER, pplayer);
   }
 }
 
@@ -2949,11 +2948,6 @@
     toggle_ai_player_direct(NULL, pplayer);
   }
 
-  /* yes this has to go after the toggle check */
-  if (server_state == RUN_GAME_STATE) {
-    gamelog(GAMELOG_PLAYER, pplayer);
-  }
-
   cmd_reply(CMD_TAKE, caller, C_OK, _("%s now controls %s (%s, %s)"), 
             pconn->username, pplayer->name, 
             is_barbarian(pplayer) ? _("Barbarian") : pplayer->ai.control ?
@@ -3077,10 +3071,6 @@
     }
   }
 
-  if (server_state == RUN_GAME_STATE) {
-    gamelog(GAMELOG_PLAYER, pplayer);
-  }
-
   end:;
   /* free our args */
   for (i = 0; i < ntokens; i++) {
@@ -3272,8 +3262,6 @@
 {
   if (!check) {
     cmd_reply(CMD_QUIT, caller, C_OK, _("Goodbye."));
-    gamelog(GAMELOG_JUDGE, GL_NONE);
-    gamelog(GAMELOG_END);
     server_quit();
   }
   return TRUE;
Index: server/stdinhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.h,v
retrieving revision 1.29.2.1
diff -u -r1.29.2.1 stdinhand.h
--- server/stdinhand.h  9 Dec 2004 16:28:11 -0000       1.29.2.1
+++ server/stdinhand.h  16 Apr 2005 21:05:28 -0000
@@ -37,8 +37,6 @@
 void toggle_ai_player_direct(struct connection *caller,
                             struct player *pplayer);
 
-const char *name_of_skill_level(int level);
-
 /* for sernet.c in initing a new connection */
 enum cmdlevel_id access_level_for_next_connection(void);
 
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.306.2.11
diff -u -r1.306.2.11 unittools.c
--- server/unittools.c  1 Apr 2005 00:42:29 -0000       1.306.2.11
+++ server/unittools.c  16 Apr 2005 21:05:29 -0000
@@ -311,7 +311,9 @@
       notify_player_ex(pplayer, punit->tile, E_UNIT_LOST, 
           _("Game: Your %s has run out of hit points."), 
           unit_name(punit->type));
-      gamelog(GAMELOG_UNITLOSS, punit, NULL, "out of hp");
+      gamelog(GAMELOG_UNITF, _("%s lose a %s (out of hp)"),
+             get_nation_name_plural(pplayer->nation),
+             unit_name(punit->type));
       wipe_unit(punit);
       continue; /* Continue iterating... */
     }
@@ -328,7 +330,9 @@
         notify_player_ex(pplayer, punit->tile, E_UNIT_LOST, 
                          _("Game: Your %s has been lost on the high seas."),
                          unit_name(punit->type));
-        gamelog(GAMELOG_UNITLOSS, punit, NULL, "lost at sea");
+        gamelog(GAMELOG_UNITTRI, _("%s's %s lost at sea"),
+               get_nation_name_plural(pplayer->nation), 
+                unit_name(punit->type));
         wipe_unit(punit);
         continue; /* Continue iterating... */
       } else if (loss_chance > 0) {
@@ -347,7 +351,8 @@
       notify_player_ex(pplayer, punit->tile, E_UNIT_LOST,
                       _("Game: Your %s has been lost on unsafe terrain."),
                       unit_name(punit->type));
-      gamelog(GAMELOG_UNITLOSS, punit, NULL, "unsafe terrain");
+      gamelog(GAMELOG_UNITTRI, _("%s unit lost on unsafe terrain"),
+             get_nation_name_plural(pplayer->nation));
       wipe_unit(punit);
       continue;                        /* Continue iterating... */
     }
@@ -399,7 +404,9 @@
       notify_player_ex(pplayer, punit->tile, E_UNIT_LOST, 
                       _("Game: Your %s has run out of fuel."),
                       unit_name(punit->type));
-      gamelog(GAMELOG_UNITLOSS, punit, NULL, "fuel");
+      gamelog(GAMELOG_UNITF, _("%s lose a %s (fuel)"),
+             get_nation_name_plural(pplayer->nation),
+             unit_name(punit->type));
       wipe_unit(punit);
     } 
   } unit_list_iterate_safe_end;
@@ -1559,7 +1566,8 @@
                    unit_name(punit->type), unit_owner(punit)->name);
     notify_player(unit_owner(punit), _("Losing %s meant losing the game! "
                   "Be more careful next time!"), unit_name(punit->type));
-    gamelog(GAMELOG_UNITGAMELOSS, punit);
+    gamelog(GAMELOG_NORMAL, _("Player %s lost a game loss unit and died"),
+            gamelog_playername(unit_owner(punit)));
     unit_owner(punit)->is_dying = TRUE;
   }
 
@@ -1668,7 +1676,9 @@
                             _("Game: %s lost when %s was lost."),
                             unit_type(pcargo)->name,
                             ptype->name);
-           gamelog(GAMELOG_UNITLOSS, pcargo, NULL, "transport lost");
+           gamelog(GAMELOG_UNITL, _("%s lose %s when %s lost"),
+                   get_nation_name_plural(pplayer->nation),
+                   unit_type(pcargo)->name, ptype->name);
            server_remove_unit(pcargo);
          }
          if (++capacity >= 0) {
@@ -1744,8 +1754,10 @@
                     _("Game: %s lost to an attack by %s's %s%s."),
                     unit_type(punit)->name, destroyer->name,
                     unit_name(pkiller->type), loc_str);
+    gamelog(GAMELOG_UNITL, _("%s lose %s to the %s"),
+           get_nation_name_plural(pplayer->nation), unit_type(punit)->name,
+           get_nation_name_plural(destroyer->nation));
 
-    gamelog(GAMELOG_UNITLOSS, punit, destroyer);
     wipe_unit(punit);
   } else { /* unitcount > 1 */
     int i;
@@ -1786,8 +1798,10 @@
                           " from %s's %s."),
                         unit_type(punit2)->name, destroyer->name,
                         unit_name(pkiller->type));
-
-        gamelog(GAMELOG_UNITLOSS, punit2, destroyer);
+       gamelog(GAMELOG_UNITL, _("%s lose %s to the %s"),
+               get_nation_name_plural(unit_owner(punit2)->nation),
+               unit_type(punit2)->name,
+               get_nation_name_plural(destroyer->nation));
        wipe_unit_spec_safe(punit2, FALSE);
       }
     }
@@ -2282,7 +2296,8 @@
   notify_player_ex(pplayer, punit->tile, E_HUT_TECH,
                   _("Game: You found %s in ancient scrolls of wisdom."),
                   tech_name);
-  gamelog(GAMELOG_TECH, pplayer, NULL, new_tech);
+  gamelog(GAMELOG_TECH, _("%s discover %s (Hut)"),
+         get_nation_name_plural(pplayer->nation), tech_name);
   notify_embassies(pplayer, NULL, _("Game: The %s have acquired %s"
                                    " from ancient scrolls of wisdom."),
                   get_nation_name_plural(pplayer->nation), tech_name);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12372) gamelog interpreter for pubserver needed, Jason Short <=