Author: cazfi
Date: Thu Nov  5 20:21:20 2015
New Revision: 30422

URL: http://svn.gna.org/viewcvs/freeciv?rev=30422&view=rev
Log:
Make sure dead players do not cancel pacts.

Based on patch by Isaac O'Hern <wisoh>

See bug #23811

Modified:
    trunk/client/gui-gtk-2.0/plrdlg.c
    trunk/client/gui-gtk-3.0/plrdlg.c
    trunk/client/gui-qt/plrdlg.cpp
    trunk/client/gui-sdl2/diplodlg.c
    trunk/common/player.c

Modified: trunk/client/gui-gtk-2.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/plrdlg.c?rev=30422&r1=30421&r2=30422&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/plrdlg.c   (original)
+++ trunk/client/gui-gtk-2.0/plrdlg.c   Thu Nov  5 20:21:20 2015
@@ -151,18 +151,13 @@
     }
 
     if (NULL != client.conn.playing) {
-      switch (player_diplstate_get(client.conn.playing,
-                                   player_by_number(plrno))->type) {
-      case DS_WAR:
-      case DS_NO_CONTACT:
-       gtk_widget_set_sensitive(players_war_command, FALSE);
-       break;
-      default:
-       gtk_widget_set_sensitive(players_war_command,
-                                can_client_issue_orders()
-                                 && 
!players_on_same_team(player_by_number(plrno),
-                                                          
client.conn.playing));
-      }
+      /* We keep button sensitive in case of DIPL_SENATE_BLOCKING, so that 
player
+       * can request server side to check requirements of those effects with 
omniscience */
+      gtk_widget_set_sensitive(players_war_command,
+                               can_client_issue_orders()
+                               && pplayer_can_cancel_treaty(client_player(),
+                                                            
player_by_number(plrno))
+                               != DIPL_ERROR);
     } else {
       gtk_widget_set_sensitive(players_war_command, FALSE);
     }

Modified: trunk/client/gui-gtk-3.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/plrdlg.c?rev=30422&r1=30421&r2=30422&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/plrdlg.c   (original)
+++ trunk/client/gui-gtk-3.0/plrdlg.c   Thu Nov  5 20:21:20 2015
@@ -158,18 +158,13 @@
     }
 
     if (NULL != client.conn.playing) {
-      switch (player_diplstate_get(client.conn.playing,
-                                   player_by_number(plrno))->type) {
-      case DS_WAR:
-      case DS_NO_CONTACT:
-       gtk_widget_set_sensitive(players_war_command, FALSE);
-       break;
-      default:
-       gtk_widget_set_sensitive(players_war_command,
-                                can_client_issue_orders()
-                                 && 
!players_on_same_team(player_by_number(plrno),
-                                                          
client.conn.playing));
-      }
+      /* We keep button sensitive in case of DIPL_SENATE_BLOCKING, so that 
player
+       * can request server side to check requirements of those effects with 
omniscience */
+      gtk_widget_set_sensitive(players_war_command,
+                               can_client_issue_orders()
+                               && pplayer_can_cancel_treaty(client_player(),
+                                                            
player_by_number(plrno))
+                               != DIPL_ERROR);
     } else {
       gtk_widget_set_sensitive(players_war_command, FALSE);
     }

Modified: trunk/client/gui-qt/plrdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/plrdlg.cpp?rev=30422&r1=30421&r2=30422&view=diff
==============================================================================
--- trunk/client/gui-qt/plrdlg.cpp      (original)
+++ trunk/client/gui-qt/plrdlg.cpp      Thu Nov  5 20:21:20 2015
@@ -646,7 +646,6 @@
 **************************************************************************/
 void plr_report::update_report()
 {
-  struct player_diplstate *ds;
   meet_but->setDisabled(true);
   cancel_but->setDisabled(true);
   withdraw_but->setDisabled(true);
@@ -654,14 +653,15 @@
   ally_label->setText(plr_wdg->ally_str);
   tech_label->setText(plr_wdg->tech_str);
   other_player = plr_wdg->other_player;
-  if (other_player == NULL || can_client_issue_orders() == false) {
+  if (other_player == NULL || !can_client_issue_orders()) {
     return;
   }
   if (NULL != client.conn.playing
       && other_player != client.conn.playing) {
-    ds = player_diplstate_get(client_player(), other_player);
-    if (ds->type != DS_WAR && ds->type != DS_NO_CONTACT
-        && !players_on_same_team(client_player(), other_player)) {
+
+    // We keep button sensitive in case of DIPL_SENATE_BLOCKING, so that player
+    // can request server side to check requirements of those effects with 
omniscience
+    if (pplayer_can_cancel_treaty(client_player(), other_player) != 
DIPL_ERROR) {
       cancel_but->setEnabled(true);
     }
   }

Modified: trunk/client/gui-sdl2/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/diplodlg.c?rev=30422&r1=30421&r2=30422&view=diff
==============================================================================
--- trunk/client/gui-sdl2/diplodlg.c    (original)
+++ trunk/client/gui-sdl2/diplodlg.c    Thu Nov  5 20:21:20 2015
@@ -1542,8 +1542,8 @@
     area.w = MAX(area.w , pText->w);
     area.h += pText->h + adj_size(15);
 
-    if (type != DS_WAR && can_client_issue_orders()
-        && !players_on_same_team(client.conn.playing, pPlayer)) {
+    if (can_client_issue_orders()
+        && pplayer_can_cancel_treaty(client_player(), pPlayer)) {
       if (type == DS_ARMISTICE) {
        fc_snprintf(cBuf, sizeof(cBuf), _("Declare WAR"));
       } else {

Modified: trunk/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.c?rev=30422&r1=30421&r2=30422&view=diff
==============================================================================
--- trunk/common/player.c       (original)
+++ trunk/common/player.c       Thu Nov  5 20:21:20 2015
@@ -97,10 +97,13 @@
 {
   enum diplstate_type ds = player_diplstate_get(p1, p2)->type;
 
-  if (p1 == p2 || ds == DS_WAR) {
+  if (p1 == p2 || ds == DS_WAR || ds == DS_NO_CONTACT) {
     return DIPL_ERROR;
   }
   if (players_on_same_team(p1, p2)) {
+    return DIPL_ERROR;
+  }
+  if (!p1->is_alive || !p2->is_alive) {
     return DIPL_ERROR;
   }
   if (player_diplstate_get(p1, p2)->has_reason_to_cancel == 0


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

Reply via email to