Author: cazfi
Date: Sun Mar 29 20:58:39 2015
New Revision: 28651

URL: http://svn.gna.org/viewcvs/freeciv?rev=28651&view=rev
Log:
Made it impossible to accept pacts (cease-fire, peace, alliance) between members
of the same team.

See bug #23421

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

Modified: branches/S2_6/client/gui-gtk-2.0/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/diplodlg.c?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/diplodlg.c (original)
+++ branches/S2_6/client/gui-gtk-2.0/diplodlg.c Sun Mar 29 20:58:39 2015
@@ -425,19 +425,19 @@
     gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE);
+    gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Peace"));
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_PEACE);
+    gtk_widget_set_sensitive(item, ds != DS_PEACE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Alliance"));
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_ALLIANCE);
+    gtk_widget_set_sensitive(item, ds != DS_ALLIANCE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(_("_Pacts"));
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);

Modified: branches/S2_6/client/gui-gtk-3.0/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/diplodlg.c?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/diplodlg.c (original)
+++ branches/S2_6/client/gui-gtk-3.0/diplodlg.c Sun Mar 29 20:58:39 2015
@@ -425,19 +425,19 @@
     gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE);
+    gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Peace"));
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_PEACE);
+    gtk_widget_set_sensitive(item, ds != DS_PEACE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Alliance"));
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
     g_signal_connect(item, "activate",
                     G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
-    gtk_widget_set_sensitive(item, ds != DS_ALLIANCE);
+    gtk_widget_set_sensitive(item, ds != DS_ALLIANCE && ds != DS_TEAM);
 
     item = gtk_menu_item_new_with_mnemonic(_("_Pacts"));
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);

Modified: branches/S2_6/client/gui-qt/diplodlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/diplodlg.cpp?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/diplodlg.cpp    (original)
+++ branches/S2_6/client/gui-qt/diplodlg.cpp    Sun Mar 29 20:58:39 2015
@@ -352,19 +352,19 @@
     some_action = new QAction(Q_("?diplomatic_state:Cease-fire"), this);
     connect(some_action, SIGNAL(triggered()), this, SLOT(pact_ceasfire()));
     pacts_menu->addAction(some_action);
-    if (ds == DS_CEASEFIRE) {
+    if (ds == DS_CEASEFIRE || ds == DS_TEAM) {
       some_action->setDisabled(true);
     }
     some_action = new QAction(Q_("?diplomatic_state:Peace"), this);
     connect(some_action, SIGNAL(triggered()), this, SLOT(pact_peace()));
     pacts_menu->addAction(some_action);
-    if (ds == DS_PEACE) {
+    if (ds == DS_PEACE || ds == DS_TEAM) {
       some_action->setDisabled(true);
     }
     some_action = new QAction(Q_("?diplomatic_state:Alliance"), this);
     connect(some_action, SIGNAL(triggered()), this, SLOT(pact_allianze()));
     pacts_menu->addAction(some_action);
-    if (ds == DS_ALLIANCE) {
+    if (ds == DS_ALLIANCE || ds == DS_TEAM) {
       some_action->setDisabled(true);
     }
   }

Modified: branches/S2_6/client/gui-sdl/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/diplodlg.c?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/diplodlg.c     (original)
+++ branches/S2_6/client/gui-sdl/diplodlg.c     Sun Mar 29 20:58:39 2015
@@ -494,9 +494,8 @@
     height = pBuf->size.h;
     add_to_gui_list(ID_LABEL, pBuf);
     count++;
-    
-    /*if(type == DS_WAR || type == DS_NEUTRAL) {*/
-    if(type != DS_CEASEFIRE) {
+
+    if (type != DS_CEASEFIRE && type != DS_TEAM) {
       fc_snprintf(cBuf, sizeof(cBuf), "  %s", 
Q_("?diplomatic_state:Cease-fire"));
       pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
        cBuf, adj_font(12), 
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
@@ -509,10 +508,10 @@
       add_to_gui_list(MAX_ID - 2, pBuf);
       count++;
     }
-    
-    if(type != DS_PEACE) {
+
+    if (type != DS_PEACE && type != DS_TEAM) {
       fc_snprintf(cBuf, sizeof(cBuf), "  %s", Q_("?diplomatic_state:Peace"));
-  
+
       pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
        cBuf, adj_font(12), 
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
       pBuf->string16->fgcol = 
*get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
@@ -524,8 +523,8 @@
       add_to_gui_list(MAX_ID - 1, pBuf);
       count++;
     }
-    
-    if(pplayer_can_make_treaty(pPlayer0, pPlayer1, DS_ALLIANCE)) {
+
+    if (pplayer_can_make_treaty(pPlayer0, pPlayer1, DS_ALLIANCE)) {
       fc_snprintf(cBuf, sizeof(cBuf), "  %s", 
Q_("?diplomatic_state:Alliance"));
       
       pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,

Modified: branches/S2_6/client/gui-sdl2/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/diplodlg.c?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/diplodlg.c    (original)
+++ branches/S2_6/client/gui-sdl2/diplodlg.c    Sun Mar 29 20:58:39 2015
@@ -499,7 +499,7 @@
     add_to_gui_list(ID_LABEL, pBuf);
     count++;
 
-    if (type != DS_CEASEFIRE) {
+    if (type != DS_CEASEFIRE && type != DS_TEAM) {
       fc_snprintf(cBuf, sizeof(cBuf), "  %s", 
Q_("?diplomatic_state:Cease-fire"));
       pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
        cBuf, adj_font(12), 
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
@@ -513,7 +513,7 @@
       count++;
     }
 
-    if (type != DS_PEACE) {
+    if (type != DS_PEACE && type != DS_TEAM) {
       fc_snprintf(cBuf, sizeof(cBuf), "  %s", Q_("?diplomatic_state:Peace"));
 
       pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,

Modified: branches/S2_6/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/player.c?rev=28651&r1=28650&r2=28651&view=diff
==============================================================================
--- branches/S2_6/common/player.c       (original)
+++ branches/S2_6/common/player.c       Sun Mar 29 20:58:39 2015
@@ -131,8 +131,9 @@
 {
   enum diplstate_type existing = player_diplstate_get(p1, p2)->type;
 
-  if (p1 == p2) {
-    return DIPL_ERROR; /* duh! */
+  if (players_on_same_team(p1, p2)) {
+    /* This includes the case p1 == p2 */
+    return DIPL_ERROR;
   }
   if (get_player_bonus(p1, EFT_NO_DIPLOMACY) > 0
       || get_player_bonus(p2, EFT_NO_DIPLOMACY) > 0) {


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

Reply via email to