Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2006:
[Freeciv-Dev] Re: (PR#19510) [Bug] diplstate type plr1 -> plr2 different
Home

[Freeciv-Dev] Re: (PR#19510) [Bug] diplstate type plr1 -> plr2 different

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: cazfi74@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#19510) [Bug] diplstate type plr1 -> plr2 different from plr2 -> plr1
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 15 Aug 2006 03:14:05 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=19510 >

On Mon, 14 Aug 2006, Marko Lindqvist wrote:
>  Problem is resolving love-love-hate in update_diplomatics(). Alliance
> is canceled in the middle of the player iteration. Iteration has already
> passed plr1->plr2 part, but plr2->plr1 follows. Turns_left is subtracted
> for one party, but not for the other.

Good catch. Will this (untested) patch fix the problem? It also changes 
the alliance breaking in LLH-situations, so that it does not arbitrarily 
favour one party.

  - Per
Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 12258)
+++ server/srv_main.c   (working copy)
@@ -463,6 +463,7 @@
   players_iterate(plr1) {
     players_iterate(plr2) {
       struct player_diplstate *state = &plr1->diplstates[plr2->player_no];
+      struct player_diplstate *state2 = &plr2->diplstates[plr1->player_no];
 
       state->has_reason_to_cancel = MAX(state->has_reason_to_cancel - 1, 0);
       state->contact_turns_left = MAX(state->contact_turns_left - 1, 0);
@@ -471,6 +472,9 @@
         state->turns_left--;
         if (state->turns_left <= 0) {
           state->type = DS_PEACE;
+          state2->type = DS_PEACE;
+          state->turns_left = 0;
+          state2->turns_left = 0;
           remove_illegal_armistice_units(plr1, plr2);
         }
       }
@@ -487,6 +491,8 @@
                         "%s has run out. You are now at war with the %s."),
                         plr2->name, get_nation_name_plural(plr2->nation));
           state->type = DS_WAR;
+          state2->type = DS_WAR;
+          state2->turns_left = 0;
           check_city_workers(plr1);
           check_city_workers(plr2);
 
@@ -497,10 +503,12 @@
                 && pplayers_allied(plr3, plr2)) {
               notify_player(plr3, NULL, E_TREATY_BROKEN,
                             _("Ceasefire between %s and %s has run out. "
-                              "They are at war. You cancel alliance with %s."),
-                            plr1->name, plr2->name, plr1->name);
+                              "They are at war. You cancel your alliance "
+                              "with both."), plr1->name, plr2->name);
               plr3->diplstates[plr1->player_no].has_reason_to_cancel = TRUE;
+              plr3->diplstates[plr2->player_no].has_reason_to_cancel = TRUE;
               handle_diplomacy_cancel_pact(plr3, plr1->player_no, 
CLAUSE_ALLIANCE);
+              handle_diplomacy_cancel_pact(plr3, plr2->player_no, 
CLAUSE_ALLIANCE);
             }
           } players_iterate_end;
           break;

[Prev in Thread] Current Thread [Next in Thread]