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

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

Based on patch by Isaac O'Hern <wisoh>

See bug #23811

Modified:
    branches/S2_5/client/gui-gtk-2.0/plrdlg.c
    branches/S2_5/client/gui-gtk-3.0/plrdlg.c
    branches/S2_5/client/gui-qt/plrdlg.cpp
    branches/S2_5/client/gui-sdl/diplodlg.c
    branches/S2_5/common/player.c

Modified: branches/S2_5/client/gui-gtk-2.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/plrdlg.c?rev=30424&r1=30423&r2=30424&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/plrdlg.c   (original)
+++ branches/S2_5/client/gui-gtk-2.0/plrdlg.c   Thu Nov  5 20:21:36 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: branches/S2_5/client/gui-gtk-3.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/plrdlg.c?rev=30424&r1=30423&r2=30424&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/plrdlg.c   (original)
+++ branches/S2_5/client/gui-gtk-3.0/plrdlg.c   Thu Nov  5 20:21:36 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: branches/S2_5/client/gui-qt/plrdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/plrdlg.cpp?rev=30424&r1=30423&r2=30424&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/plrdlg.cpp      (original)
+++ branches/S2_5/client/gui-qt/plrdlg.cpp      Thu Nov  5 20:21:36 2015
@@ -638,7 +638,6 @@
 **************************************************************************/
 void plr_report::update_report()
 {
-  struct player_diplstate *ds;
   meet_but->setDisabled(true);
   cancel_but->setDisabled(true);
   withdraw_but->setDisabled(true);
@@ -646,14 +645,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: branches/S2_5/client/gui-sdl/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-sdl/diplodlg.c?rev=30424&r1=30423&r2=30424&view=diff
==============================================================================
--- branches/S2_5/client/gui-sdl/diplodlg.c     (original)
+++ branches/S2_5/client/gui-sdl/diplodlg.c     Thu Nov  5 20:21:36 2015
@@ -1525,8 +1525,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: branches/S2_5/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/player.c?rev=30424&r1=30423&r2=30424&view=diff
==============================================================================
--- branches/S2_5/common/player.c       (original)
+++ branches/S2_5/common/player.c       Thu Nov  5 20:21:36 2015
@@ -104,10 +104,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