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

 I have never liked how name of the variable government_when_anarchy
is not telling what it is used for, but instead contains typical value
for the variable.

 Attached patch renames it as government_during_revolution.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/advdiplomacy.c freeciv/ai/advdiplomacy.c
--- freeciv/ai/advdiplomacy.c   2008-06-18 18:49:36.000000000 +0300
+++ freeciv/ai/advdiplomacy.c   2008-07-01 18:53:22.000000000 +0300
@@ -1153,7 +1153,7 @@
   /* Check for Senate obstruction.  If so, dissolve it. */
   if (pplayer_can_cancel_treaty(pplayer, target) == DIPL_SENATE_BLOCKING) {
     handle_player_change_government(pplayer, 
-                                    game.info.government_when_anarchy_id);
+                                    game.info.government_during_revolution_id);
   }
 
   /* This will take us straight to war. */
diff -Nurd -X.diff_ignore freeciv/ai/aihand.c freeciv/ai/aihand.c
--- freeciv/ai/aihand.c 2008-03-08 16:32:50.000000000 +0200
+++ freeciv/ai/aihand.c 2008-07-01 18:51:48.000000000 +0300
@@ -113,7 +113,7 @@
     return; /* This ruleset does not support changing tax rates. */
   }
 
-  if (government_of_player(pplayer) == game.government_when_anarchy) {
+  if (government_of_player(pplayer) == game.government_during_revolution) {
     return; /* This government does not support changing tax rates. */
   }
 
@@ -303,7 +303,7 @@
       int val = 0;
       int dist;
 
-      if (gov == game.government_when_anarchy) {
+      if (gov == game.government_during_revolution) {
         continue; /* pointless */
       }
       if (gov->ai.better
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/menu.c 
freeciv/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c   2008-06-24 01:37:56.000000000 +0300
+++ freeciv/client/gui-gtk-2.0/menu.c   2008-07-01 19:03:01.000000000 +0300
@@ -1354,7 +1354,7 @@
 
       /* add new government entries. */
       government_iterate(g) {
-        if (g != game.government_when_anarchy) {
+        if (g != game.government_during_revolution) {
           GtkWidget *item, *image;
           struct sprite *gsprite;
          char buf[256];
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/dialogs.c 
freeciv/client/gui-sdl/dialogs.c
--- freeciv/client/gui-sdl/dialogs.c    2008-03-08 16:33:05.000000000 +0200
+++ freeciv/client/gui-sdl/dialogs.c    2008-07-01 19:17:05.000000000 +0300
@@ -1989,7 +1989,7 @@
   j = 0;
   government_iterate(pGov) {
 
-    if (pGov == game.government_when_anarchy) {
+    if (pGov == game.government_during_revolution) {
       continue;
     }
 
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/menu.c 
freeciv/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c     2008-06-16 04:26:14.000000000 +0300
+++ freeciv/client/gui-win32/menu.c     2008-07-01 20:19:58.000000000 +0300
@@ -1049,7 +1049,7 @@
     id = IDM_GOVERNMENT_CHANGE_FIRST;
 
     government_iterate(g) {
-      if (g != game.government_when_anarchy) {
+      if (g != game.government_during_revolution) {
        AppendMenu(govts, MF_STRING, id + government_number(g),
                   government_name_translation(g));
        my_enable_menu(menu, id + government_number(g),
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/menu.c 
freeciv/client/gui-xaw/menu.c
--- freeciv/client/gui-xaw/menu.c       2008-03-08 16:32:59.000000000 +0200
+++ freeciv/client/gui-xaw/menu.c       2008-07-01 19:28:25.000000000 +0300
@@ -327,7 +327,7 @@
     government_iterate(pgovernment) {
       Widget w;
 
-      if (pgovernment == game.government_when_anarchy) {
+      if (pgovernment == game.government_during_revolution) {
        continue;
       }
 
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2008-06-25 12:21:40.000000000 +0300
+++ freeciv/client/packhand.c   2008-07-01 18:51:14.000000000 +0300
@@ -1592,8 +1592,8 @@
   VALIDATE(num_teams,          MAX_NUM_TEAMS,          "teams");
 #undef VALIDATE
 
-  game.government_when_anarchy =
-    government_by_number(game.info.government_when_anarchy_id);
+  game.government_during_revolution =
+    government_by_number(game.info.government_during_revolution_id);
 
   if (C_S_PREPARING == client_state()) {
     /* FIXME: only for change in nations */
@@ -1667,7 +1667,7 @@
 void start_revolution(void)
 {
   dsend_packet_player_change_government(&client.conn,
-                                       game.info.government_when_anarchy_id);
+                                   game.info.government_during_revolution_id);
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/client/repodlgs_common.c 
freeciv/client/repodlgs_common.c
--- freeciv/client/repodlgs_common.c    2008-03-08 16:33:11.000000000 +0200
+++ freeciv/client/repodlgs_common.c    2008-07-01 19:04:50.000000000 +0300
@@ -83,7 +83,8 @@
       /* Currently there is no building expense under anarchy.  It's
        * not a good idea to hard-code this in the client, but what
        * else can we do? */
-      if (government_of_player(client.conn.playing) != 
game.government_when_anarchy) {
+      if (government_of_player(client.conn.playing) !=
+          game.government_during_revolution) {
         *total_cost += cost;
       }
     }
diff -Nurd -X.diff_ignore freeciv/common/city.c freeciv/common/city.c
--- freeciv/common/city.c       2008-06-28 17:48:44.000000000 +0300
+++ freeciv/common/city.c       2008-07-01 18:49:32.000000000 +0300
@@ -1621,7 +1621,7 @@
   }
   
   /* ANARCHY */
-  if (government_of_player(pplayer) == game.government_when_anarchy) {
+  if (government_of_player(pplayer) == game.government_during_revolution) {
     rates[SCIENCE] = 0;
     rates[LUXURY] = 100;
     rates[TAX] = 0;
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c       2008-03-08 16:32:49.000000000 +0200
+++ freeciv/common/game.c       2008-07-01 18:49:04.000000000 +0300
@@ -310,7 +310,7 @@
 #else
   game.info.save_compress_type = FZ_PLAIN;
 #endif
-  game.info.government_when_anarchy_id = G_MAGIC;   /* flag */
+  game.info.government_during_revolution_id = G_MAGIC;   /* flag */
 
   game.info.is_new_game   = TRUE;
   game.info.is_edit_mode = FALSE;
diff -Nurd -X.diff_ignore freeciv/common/game.h freeciv/common/game.h
--- freeciv/common/game.h       2008-06-19 01:24:53.000000000 +0300
+++ freeciv/common/game.h       2008-07-01 18:50:08.000000000 +0300
@@ -41,7 +41,7 @@
 
 struct civ_game {
   struct packet_game_info info;
-  struct government *government_when_anarchy;
+  struct government *government_during_revolution;
 
   struct packet_ruleset_control control;
   bool debug[DEBUG_LAST];
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2008-06-30 12:02:12.000000000 +0300
+++ freeciv/common/packets.def  2008-07-01 18:49:52.000000000 +0300
@@ -447,7 +447,7 @@
   UINT16 incite_improvement_factor;
   UINT16 incite_unit_factor;
   UINT16 incite_total_factor;
-  GOVERNMENT government_when_anarchy_id;
+  GOVERNMENT government_during_revolution_id;
   UINT8 revolution_length;
   SINT16 base_pollution;
   UINT8 happy_cost;
diff -Nurd -X.diff_ignore freeciv/data/civ1/governments.ruleset 
freeciv/data/civ1/governments.ruleset
--- freeciv/data/civ1/governments.ruleset       2008-05-07 17:44:45.000000000 
+0300
+++ freeciv/data/civ1/governments.ruleset       2008-07-01 18:59:01.000000000 
+0300
@@ -17,7 +17,7 @@
 options="1.9"
 
 [governments]
-when_anarchy="Anarchy"
+during_revolution="Anarchy"
 
 ; Below: The individual government types, one per section.
 ;
diff -Nurd -X.diff_ignore freeciv/data/civ2/governments.ruleset 
freeciv/data/civ2/governments.ruleset
--- freeciv/data/civ2/governments.ruleset       2008-05-07 17:44:46.000000000 
+0300
+++ freeciv/data/civ2/governments.ruleset       2008-07-01 18:58:47.000000000 
+0300
@@ -15,7 +15,7 @@
 options="1.9"
 
 [governments]
-when_anarchy="Anarchy"
+during_revolution="Anarchy"
 
 ; Below: The individual government types, one per section.
 ;
diff -Nurd -X.diff_ignore freeciv/data/default/governments.ruleset 
freeciv/data/default/governments.ruleset
--- freeciv/data/default/governments.ruleset    2007-09-14 14:45:42.000000000 
+0300
+++ freeciv/data/default/governments.ruleset    2008-07-01 18:58:33.000000000 
+0300
@@ -15,7 +15,7 @@
 options="1.9"
 
 [governments]
-when_anarchy="Anarchy"
+during_revolution="Anarchy"
 
 ; Below: The individual government types, one per section.
 ;
diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2008-07-01 01:07:31.000000000 +0300
+++ freeciv/server/plrhand.c    2008-07-01 18:56:34.000000000 +0300
@@ -227,10 +227,10 @@
 {
   struct government *government = pplayer->target_government;
 
-  if (pplayer->target_government == game.government_when_anarchy
+  if (pplayer->target_government == game.government_during_revolution
       || pplayer->target_government == NULL) {
     /* More descriptive assert than just assert(FALSE) */
-    assert(pplayer->target_government != game.government_when_anarchy
+    assert(pplayer->target_government != game.government_during_revolution
            && pplayer->target_government != NULL);
     return;
   }
@@ -309,7 +309,7 @@
     turns = game.info.revolution_length;
   }
 
-  pplayer->government = game.government_when_anarchy;
+  pplayer->government = game.government_during_revolution;
   pplayer->target_government = gov;
   pplayer->revolution_finishes = game.info.turn + turns;
 
@@ -322,7 +322,7 @@
 
   /* Now see if the revolution is instantaneous. */
   if (turns <= 0
-      && pplayer->target_government != game.government_when_anarchy) {
+      && pplayer->target_government != game.government_during_revolution) {
     finish_revolution(pplayer);
     return;
   } else if (turns > 0) {
@@ -340,7 +340,7 @@
                     turns,
                     government_name_translation(pplayer->target_government));
   } else {
-    assert(pplayer->target_government == game.government_when_anarchy);
+    assert(pplayer->target_government == game.government_during_revolution);
     notify_player(pplayer, NULL, E_REVOLT_START,
                     _("Revolution: returning to anarchy."));
   }
@@ -391,9 +391,9 @@
          ? government_rule_name(pplayer->target_government)
          : "(none)",
          pplayer->revolution_finishes, game.info.turn);
-  if (government_of_player(pplayer) == game.government_when_anarchy
+  if (government_of_player(pplayer) == game.government_during_revolution
       && pplayer->revolution_finishes <= game.info.turn) {
-    if (pplayer->target_government != game.government_when_anarchy) {
+    if (pplayer->target_government != game.government_during_revolution) {
       /* If the revolution is over and a target government is set, go into
        * the new government. */
       freelog(LOG_DEBUG, "Update: finishing revolution for %s.",
@@ -406,7 +406,7 @@
                       _("You should choose a new government from the "
                         "government menu."));
     }
-  } else if (government_of_player(pplayer) != game.government_when_anarchy
+  } else if (government_of_player(pplayer) != game.government_during_revolution
             && pplayer->revolution_finishes < game.info.turn) {
     /* Reset the revolution counter.  If the player has another revolution
      * they'll have to re-enter anarchy. */
@@ -1559,9 +1559,9 @@
   } advance_index_iterate_end;
   
   /* change the original player */
-  if (government_of_player(pplayer) != game.government_when_anarchy) {
+  if (government_of_player(pplayer) != game.government_during_revolution) {
     pplayer->target_government = pplayer->government;
-    pplayer->government = game.government_when_anarchy;
+    pplayer->government = game.government_during_revolution;
     pplayer->revolution_finishes = game.info.turn + 1;
   }
   get_player_research(pplayer)->bulbs_researched = 0;
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2008-06-30 12:02:12.000000000 +0300
+++ freeciv/server/ruleset.c    2008-07-01 18:58:14.000000000 +0300
@@ -2059,7 +2059,7 @@
 }
 
 /**************************************************************************
-...  
+  This loads information from given governments.ruleset
 **************************************************************************/
 static void load_ruleset_governments(struct section_file *file)
 {
@@ -2071,9 +2071,10 @@
 
   sec = secfile_get_secnames_prefix(file, GOVERNMENT_SECTION_PREFIX, &nval);
 
-  game.government_when_anarchy
-    = lookup_government(file, "governments.when_anarchy", filename);
-  game.info.government_when_anarchy_id = 
government_number(game.government_when_anarchy);
+  game.government_during_revolution
+    = lookup_government(file, "governments.during_revolution", filename);
+  game.info.government_during_revolution_id =
+    government_number(game.government_during_revolution);
 
   /* easy ones: */
   government_iterate(g) {
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2008-05-10 11:46:36.000000000 +0300
+++ freeciv/server/sanitycheck.c        2008-07-01 18:59:32.000000000 +0300
@@ -146,9 +146,9 @@
     } players_iterate_end;
   } whole_map_iterate_end;
 
-  SANITY_CHECK(game.government_when_anarchy != NULL);
-  SANITY_CHECK(game.government_when_anarchy
-              == government_by_number(game.info.government_when_anarchy_id));
+  SANITY_CHECK(game.government_during_revolution != NULL);
+  SANITY_CHECK(game.government_during_revolution
+              == 
government_by_number(game.info.government_during_revolution_id));
 }
 
 /**************************************************************************
@@ -622,13 +622,13 @@
     } players_iterate_end;
 
     if (pplayer->revolution_finishes == -1) {
-      if (government_of_player(pplayer) == game.government_when_anarchy) {
+      if (government_of_player(pplayer) == game.government_during_revolution) {
         SANITY_("%s government is anarchy, but does not finish!"),
                 nation_rule_name(nation_of_player(pplayer)));
       }
-      SANITY_CHECK(government_of_player(pplayer) != 
game.government_when_anarchy);
+      SANITY_CHECK(government_of_player(pplayer) != 
game.government_during_revolution);
     } else if (pplayer->revolution_finishes > game.info.turn) {
-      SANITY_CHECK(government_of_player(pplayer) == 
game.government_when_anarchy);
+      SANITY_CHECK(government_of_player(pplayer) == 
game.government_during_revolution);
     } else {
       /* Things may vary in this case depending on when the sanity_check
        * call is made.  No better check is possible. */
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2008-06-28 20:49:38.000000000 +0300
+++ freeciv/server/savegame.c   2008-07-01 19:00:16.000000000 +0300
@@ -2067,7 +2067,7 @@
                                                plrno);
 
     if (revolution == 0) {
-      if (government_of_player(plr) != game.government_when_anarchy) {
+      if (government_of_player(plr) != game.government_during_revolution) {
         revolution = -1;
       } else {
         /* some old savegames may be buggy */
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c   2008-06-25 12:21:39.000000000 +0300
+++ freeciv/server/srv_main.c   2008-07-01 19:00:57.000000000 +0300
@@ -2008,7 +2008,7 @@
 
     pplayer->government = pnation->init_government;
 
-    if (pnation->init_government == game.government_when_anarchy) {
+    if (pnation->init_government == game.government_during_revolution) {
       /* If we do not do this, an assert will trigger. This enables us to
        * select a valid government on game start. */
       pplayer->revolution_finishes = 0;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to