Author: cazfi
Date: Sun May 21 19:07:28 2017
New Revision: 35685

URL: http://svn.gna.org/viewcvs/freeciv?rev=35685&view=rev
Log:
Do not try to cancel Team membership

When a player with which we are allied and another with which we
are in the same team go to war, only cancel the alliance. Do not try
to cancel pact with the team member.

Reported by David Fernandez (bard)

See hrm Bug #662059

Modified:
    branches/S2_5/server/srv_main.c

Modified: branches/S2_5/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.c?rev=35685&r1=35684&r2=35685&view=diff
==============================================================================
--- branches/S2_5/server/srv_main.c     (original)
+++ branches/S2_5/server/srv_main.c     Sun May 21 19:07:28 2017
@@ -773,33 +773,72 @@
                     = player_diplstate_get(plr3, plr2);
                 struct player_diplstate *from2
                     = player_diplstate_get(plr2, plr3);
-
-                notify_player(plr3, NULL, E_TREATY_BROKEN, ftc_server,
-                              _("The cease-fire between %s and %s has run out. 
"
-                                "They are at war. You cancel your alliance "
-                                "with both."),
-                              player_name(plr1),
-                              player_name(plr2));
-
-                /* Cancel the alliance. */
-                to1->has_reason_to_cancel = TRUE;
-                to2->has_reason_to_cancel = TRUE;
-                handle_diplomacy_cancel_pact(plr3, player_number(plr1), 
CLAUSE_ALLIANCE);
-                handle_diplomacy_cancel_pact(plr3, player_number(plr2), 
CLAUSE_ALLIANCE);
-
-                /* Avoid asymmetric turns_left for the armistice. */
-                to1->auto_cancel_turn = game.info.turn;
-                from1->auto_cancel_turn = game.info.turn;
-
-                to2->auto_cancel_turn = game.info.turn;
-                from2->auto_cancel_turn = game.info.turn;
-
-                /* Count down for this turn. */
-                to1->turns_left--;
-                from1->turns_left--;
-
-                to2->turns_left--;
-                from2->turns_left--;
+                const char *plr1name = player_name(plr1);
+                const char *plr2name = player_name(plr2);
+                bool cancel1;
+                bool cancel2;
+
+                if (players_on_same_team(plr3, plr1)) {
+                  fc_assert(!players_on_same_team(plr3, plr2));
+
+                  cancel1 = FALSE;
+                  cancel2 = TRUE;
+
+                  notify_player(plr3, NULL, E_TREATY_BROKEN, ftc_server,
+                                _("The cease-fire between %s and %s has run 
out. "
+                                  "They are at war. You cancel your alliance "
+                                  "with %s."),
+                                plr1name, plr2name, plr2name);
+                } else if (players_on_same_team(plr3, plr2)) {
+
+                  cancel1 = TRUE;
+                  cancel2 = FALSE;
+
+                  notify_player(plr3, NULL, E_TREATY_BROKEN, ftc_server,
+                                _("The cease-fire between %s and %s has run 
out. "
+                                  "They are at war. You cancel your alliance "
+                                  "with %s."),
+                                plr1name, plr2name, plr1name);
+                } else {
+
+                  cancel1 = TRUE;
+                  cancel2 = TRUE;
+
+                  notify_player(plr3, NULL, E_TREATY_BROKEN, ftc_server,
+                                _("The cease-fire between %s and %s has run 
out. "
+                                  "They are at war. You cancel your alliance "
+                                  "with both."),
+                                player_name(plr1),
+                                player_name(plr2));
+                }
+
+                if (cancel1) {
+                  /* Cancel the alliance. */
+                  to1->has_reason_to_cancel = TRUE;
+                  handle_diplomacy_cancel_pact(plr3, player_number(plr1), 
CLAUSE_ALLIANCE);
+
+                  /* Avoid asymmetric turns_left for the armistice. */
+                  to1->auto_cancel_turn = game.info.turn;
+                  from1->auto_cancel_turn = game.info.turn;
+
+                  /* Count down for this turn. */
+                  to1->turns_left--;
+                  from1->turns_left--;
+                }
+
+                if (cancel2) {
+                  /* Cancel the alliance. */
+                  to2->has_reason_to_cancel = TRUE;
+                  handle_diplomacy_cancel_pact(plr3, player_number(plr2), 
CLAUSE_ALLIANCE);
+
+                  /* Avoid asymmetric turns_left for the armistice. */
+                  to2->auto_cancel_turn = game.info.turn;
+                  from2->auto_cancel_turn = game.info.turn;
+
+                  /* Count down for this turn. */
+                  to2->turns_left--;
+                  from2->turns_left--;
+                }
               }
             } players_iterate_alive_end;
             break;


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

Reply via email to