[Freeciv-commits] r35682 - /trunk/server/srv_main.c

2017-05-21 Thread cazfi74
Author: cazfi
Date: Sun May 21 19:07:05 2017
New Revision: 35682

URL: http://svn.gna.org/viewcvs/freeciv?rev=35682=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:
trunk/server/srv_main.c

Modified: trunk/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=35682=35681=35682=diff
==
--- trunk/server/srv_main.c (original)
+++ trunk/server/srv_main.c Sun May 21 19:07:05 2017
@@ -853,33 +853,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--;

[Freeciv-commits] r35680 - in /trunk: ./ tools/ tools/shared/

2017-05-21 Thread sveinung84
Author: sveinung
Date: Sun May 21 11:32:10 2017
New Revision: 35680

URL: http://svn.gna.org/viewcvs/freeciv?rev=35680=rev
Log:
Move tools_fc_interface.[c|h] to tools/shared.

Use it to form a new library, libtoolsshared, for stuff otherwise unrelated
(by task) tools may need.

See hrm Feature #661963

Added:
trunk/tools/shared/
trunk/tools/shared/Makefile.am
trunk/tools/shared/tools_fc_interface.c
  - copied, changed from r35668, trunk/tools/tools_fc_interface.c
trunk/tools/shared/tools_fc_interface.h
  - copied, changed from r35668, trunk/tools/tools_fc_interface.h
Removed:
trunk/tools/tools_fc_interface.c
trunk/tools/tools_fc_interface.h
Modified:
trunk/configure.ac
trunk/tools/Makefile.am

Modified: trunk/configure.ac
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/configure.ac?rev=35680=35679=35680=diff
==
--- trunk/configure.ac  (original)
+++ trunk/configure.ac  Sun May 21 11:32:10 2017
@@ -1718,6 +1718,7 @@
   tools/Makefile
   tools/ruledit/Makefile
   tools/ruleutil/Makefile
+  tools/shared/Makefile
   gen_headers/Makefile
   translations/Makefile
  translations/core/Makefile.in

Modified: trunk/tools/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/Makefile.am?rev=35680=35679=35680=diff
==
--- trunk/tools/Makefile.am (original)
+++ trunk/tools/Makefile.am Sun May 21 11:32:10 2017
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = ruleutil
+SUBDIRS = shared ruleutil
 
 if RULEDIT
 SUBDIRS += ruledit
@@ -44,6 +44,7 @@
-I$(top_srcdir)/client \
-I$(top_srcdir)/client/include \
-I$(top_srcdir)/tools/ruleutil \
+   -I$(top_srcdir)/tools/shared \
-I$(top_srcdir)/dependencies/tinycthread
 
 AM_CPPFLAGS = $(common_cppflags)
@@ -84,8 +85,6 @@
 
 if FCMANUAL
 freeciv_manual_SOURCES =   \
-   tools_fc_interface.c   \
-   tools_fc_interface.h   \
civmanual.c
 
 freeciv_manual_LDFLAGS = $(GGZDMOD_LDFLAGS)
@@ -96,6 +95,7 @@
  $(top_builddir)/server/libfreeciv-srv.la \
  ../client/helpdata.lo \
  $(top_builddir)/common/libfreeciv.la \
+ $(top_builddir)/tools/shared/libtoolsshared.la \
  $(INTLLIBS) $(TINYCTHR_LIBS) $(MAPIMG_WAND_LIBS) \
  $(SERVER_LIBS) $(LIB_GGZDMOD)
 endif

Added: trunk/tools/shared/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/shared/Makefile.am?rev=35680=auto
==
--- trunk/tools/shared/Makefile.am  (added)
+++ trunk/tools/shared/Makefile.am  Sun May 21 11:32:10 2017
@@ -0,0 +1,14 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LTLIBRARIES = libtoolsshared.la
+
+AM_CPPFLAGS =  \
+-I$(top_srcdir)/utility\
+-I$(top_srcdir)/common \
+-I$(top_srcdir)/common/networking  \
+-I$(top_srcdir)/server \
+-I$(top_srcdir)/dependencies/tinycthread
+
+libtoolsshared_la_SOURCES =\
+tools_fc_interface.c   \
+tools_fc_interface.h

Copied: trunk/tools/shared/tools_fc_interface.c (from r35668, 
trunk/tools/tools_fc_interface.c)
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/shared/tools_fc_interface.c?p2=trunk/tools/shared/tools_fc_interface.c=trunk/tools/tools_fc_interface.c=35668=35680=35680=diff
==
(empty)

Copied: trunk/tools/shared/tools_fc_interface.h (from r35668, 
trunk/tools/tools_fc_interface.h)
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/shared/tools_fc_interface.h?p2=trunk/tools/shared/tools_fc_interface.h=trunk/tools/tools_fc_interface.h=35668=35680=35680=diff
==
(empty)

Removed: trunk/tools/tools_fc_interface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/tools_fc_interface.c?rev=35679=auto
==
--- trunk/tools/tools_fc_interface.c(original)
+++ trunk/tools/tools_fc_interface.c(removed)
@@ -1,78 +0,0 @@
-/***
- Freeciv - Copyright (C) 2017 - Freeciv Development Team
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General 

[Freeciv-commits] r35681 - in /branches/S3_0: ./ tools/ tools/shared/

2017-05-21 Thread sveinung84
Author: sveinung
Date: Sun May 21 11:32:52 2017
New Revision: 35681

URL: http://svn.gna.org/viewcvs/freeciv?rev=35681=rev
Log:
Move tools_fc_interface.[c|h] to tools/shared.

Use it to form a new library, libtoolsshared, for stuff otherwise unrelated
(by task) tools may need.

See hrm Feature #661963

Added:
branches/S3_0/tools/shared/
branches/S3_0/tools/shared/Makefile.am
branches/S3_0/tools/shared/tools_fc_interface.c
  - copied, changed from r35679, branches/S3_0/tools/tools_fc_interface.c
branches/S3_0/tools/shared/tools_fc_interface.h
  - copied, changed from r35679, branches/S3_0/tools/tools_fc_interface.h
Removed:
branches/S3_0/tools/tools_fc_interface.c
branches/S3_0/tools/tools_fc_interface.h
Modified:
branches/S3_0/configure.ac
branches/S3_0/tools/Makefile.am

Modified: branches/S3_0/configure.ac
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/configure.ac?rev=35681=35680=35681=diff
==
--- branches/S3_0/configure.ac  (original)
+++ branches/S3_0/configure.ac  Sun May 21 11:32:52 2017
@@ -1776,6 +1776,7 @@
   tools/Makefile
   tools/ruledit/Makefile
   tools/ruleutil/Makefile
+  tools/shared/Makefile
   gen_headers/Makefile
   translations/Makefile
  translations/core/Makefile.in

Modified: branches/S3_0/tools/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/Makefile.am?rev=35681=35680=35681=diff
==
--- branches/S3_0/tools/Makefile.am (original)
+++ branches/S3_0/tools/Makefile.am Sun May 21 11:32:52 2017
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = ruleutil
+SUBDIRS = shared ruleutil
 
 if RULEDIT
 SUBDIRS += ruledit
@@ -47,6 +47,7 @@
-I$(top_srcdir)/client \
-I$(top_srcdir)/client/include \
-I$(top_srcdir)/tools/ruleutil \
+   -I$(top_srcdir)/tools/shared \
-I$(top_srcdir)/dependencies/tinycthread
 
 AM_CPPFLAGS = $(common_cppflags)
@@ -94,8 +95,6 @@
 
 if FCMANUAL
 freeciv_manual_SOURCES =   \
-   tools_fc_interface.c   \
-   tools_fc_interface.h   \
civmanual.c
 
 freeciv_manual_LDFLAGS = $(GGZDMOD_LDFLAGS)
@@ -106,6 +105,7 @@
  $(top_builddir)/server/libfreeciv-srv.la \
  ../client/helpdata.lo \
  $(top_builddir)/common/libfreeciv.la \
+ $(top_builddir)/tools/shared/libtoolsshared.la \
  $(INTLLIBS) $(TINYCTHR_LIBS) $(MAPIMG_WAND_LIBS) \
  $(SERVER_LIBS) $(LIB_GGZDMOD)
 endif

Added: branches/S3_0/tools/shared/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/shared/Makefile.am?rev=35681=auto
==
--- branches/S3_0/tools/shared/Makefile.am  (added)
+++ branches/S3_0/tools/shared/Makefile.am  Sun May 21 11:32:52 2017
@@ -0,0 +1,14 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LTLIBRARIES = libtoolsshared.la
+
+AM_CPPFLAGS =  \
+-I$(top_srcdir)/utility\
+-I$(top_srcdir)/common \
+-I$(top_srcdir)/common/networking  \
+-I$(top_srcdir)/server \
+-I$(top_srcdir)/dependencies/tinycthread
+
+libtoolsshared_la_SOURCES =\
+tools_fc_interface.c   \
+tools_fc_interface.h

Copied: branches/S3_0/tools/shared/tools_fc_interface.c (from r35679, 
branches/S3_0/tools/tools_fc_interface.c)
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/shared/tools_fc_interface.c?p2=branches/S3_0/tools/shared/tools_fc_interface.c=branches/S3_0/tools/tools_fc_interface.c=35679=35681=35681=diff
==
(empty)

Copied: branches/S3_0/tools/shared/tools_fc_interface.h (from r35679, 
branches/S3_0/tools/tools_fc_interface.h)
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/shared/tools_fc_interface.h?p2=branches/S3_0/tools/shared/tools_fc_interface.h=branches/S3_0/tools/tools_fc_interface.h=35679=35681=35681=diff
==
(empty)

Removed: branches/S3_0/tools/tools_fc_interface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/tools/tools_fc_interface.c?rev=35680=auto
==
--- branches/S3_0/tools/tools_fc_interface.c(original)
+++ 

[Freeciv-commits] r35684 - /branches/S2_6/server/srv_main.c

2017-05-21 Thread cazfi74
Author: cazfi
Date: Sun May 21 19:07:21 2017
New Revision: 35684

URL: http://svn.gna.org/viewcvs/freeciv?rev=35684=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_6/server/srv_main.c

Modified: branches/S2_6/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/srv_main.c?rev=35684=35683=35684=diff
==
--- branches/S2_6/server/srv_main.c (original)
+++ branches/S2_6/server/srv_main.c Sun May 21 19:07:21 2017
@@ -819,33 +819,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--;

[Freeciv-commits] r35685 - /branches/S2_5/server/srv_main.c

2017-05-21 Thread cazfi74
Author: cazfi
Date: Sun May 21 19:07:28 2017
New Revision: 35685

URL: http://svn.gna.org/viewcvs/freeciv?rev=35685=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=35684=35685=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--;

[Freeciv-commits] r35683 - /branches/S3_0/server/srv_main.c

2017-05-21 Thread cazfi74
Author: cazfi
Date: Sun May 21 19:07:14 2017
New Revision: 35683

URL: http://svn.gna.org/viewcvs/freeciv?rev=35683=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/S3_0/server/srv_main.c

Modified: branches/S3_0/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/srv_main.c?rev=35683=35682=35683=diff
==
--- branches/S3_0/server/srv_main.c (original)
+++ branches/S3_0/server/srv_main.c Sun May 21 19:07:14 2017
@@ -852,33 +852,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--;