Author: jtn
Date: Fri Nov  4 00:40:17 2016
New Revision: 34368

URL: http://svn.gna.org/viewcvs/freeciv?rev=34368&view=rev
Log:
Prevent untargeted revolution for the RANDQUICK revolentype, the same as
QUICKENING.

See gna bug #25256.

Modified:
    trunk/client/gui-gtk-2.0/menu.c
    trunk/client/gui-gtk-3.0/menu.c
    trunk/client/gui-gtk-3.22/menu.c
    trunk/common/government.c
    trunk/common/government.h
    trunk/server/plrhand.c

Modified: trunk/client/gui-gtk-2.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/menu.c?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/menu.c     (original)
+++ trunk/client/gui-gtk-2.0/menu.c     Fri Nov  4 00:40:17 2016
@@ -2167,7 +2167,7 @@
       } else {
         /* Revolution without target government */
         gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
-                                 game.info.revolentype != REVOLEN_QUICKENING);
+                                 untargeted_revolution_allowed());
       }
     }
     g_list_free(list);

Modified: trunk/client/gui-gtk-3.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/menu.c?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/menu.c     (original)
+++ trunk/client/gui-gtk-3.0/menu.c     Fri Nov  4 00:40:17 2016
@@ -2183,7 +2183,7 @@
       } else {
         /* Revolution without target government */
         gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
-                                 game.info.revolentype != REVOLEN_QUICKENING);
+                                 untargeted_revolution_allowed());
       }
     }
     g_list_free(list);

Modified: trunk/client/gui-gtk-3.22/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/menu.c?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/menu.c    (original)
+++ trunk/client/gui-gtk-3.22/menu.c    Fri Nov  4 00:40:17 2016
@@ -2182,7 +2182,7 @@
       } else {
         /* Revolution without target government */
         gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
-                                 game.info.revolentype != REVOLEN_QUICKENING);
+                                 untargeted_revolution_allowed());
       }
     }
     g_list_free(list);

Modified: trunk/common/government.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/government.c?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/common/government.c   (original)
+++ trunk/common/government.c   Fri Nov  4 00:40:17 2016
@@ -547,3 +547,18 @@
   governments = NULL;
   game.control.government_count = 0;
 }
+
+/****************************************************************************
+  Is it possible to start a revolution without specifying the target
+  government in the current game?
+****************************************************************************/
+bool untargeted_revolution_allowed(void)
+{
+  if (game.info.revolentype == REVOLEN_QUICKENING
+      || game.info.revolentype == REVOLEN_RANDQUICK) {
+    /* We need to know the target government at the onset of the revolution
+     * in order to know how long anarchy will last. */
+    return FALSE;
+  }
+  return TRUE;
+}

Modified: trunk/common/government.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/government.h?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/common/government.h   (original)
+++ trunk/common/government.h   Fri Nov  4 00:40:17 2016
@@ -132,4 +132,6 @@
 }
 #endif /* __cplusplus */
 
+bool untargeted_revolution_allowed(void);
+
 #endif  /* FC__GOVERNMENT_H */

Modified: trunk/server/plrhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=34368&r1=34367&r2=34368&view=diff
==============================================================================
--- trunk/server/plrhand.c      (original)
+++ trunk/server/plrhand.c      Fri Nov  4 00:40:17 2016
@@ -394,6 +394,14 @@
 {
   int turns;
 
+  if (!untargeted_revolution_allowed()
+      && gov == game.government_during_revolution) {
+    /* Targetless revolution not acceptable */
+    notify_player(plr, NULL, E_REVOLT_DONE, ftc_server,
+                  _("You can't revolt without selecting target government."));
+    return -1;
+  }
+
   turns = GAME_DEFAULT_REVOLUTION_LENGTH; /* To avoid compiler warning */
   switch (game.info.revolentype) {
   case REVOLEN_FIXED:
@@ -404,12 +412,6 @@
     break;
   case REVOLEN_QUICKENING:
   case REVOLEN_RANDQUICK:
-    if (gov == game.government_during_revolution) {
-      /* Targetless revolution not acceptable */
-      notify_player(plr, NULL, E_REVOLT_DONE, ftc_server,
-                    _("You can't revolt without selecting target 
government."));
-      return -1;
-    }
     turns = game.server.revolution_length - gov->changed_to_times;
     turns = MAX(1, turns);
     if (game.info.revolentype == REVOLEN_RANDQUICK) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to