Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] Cascading war changes (PR#5103)
Home

[Freeciv-Dev] Cascading war changes (PR#5103)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] Cascading war changes (PR#5103)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 8 Mar 2004 09:04:47 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=5103 >

The attached patch should remove some excess server messages when doing
cascading declarations of war due to alliances, and it should also remove
reputation loss from such cascades. Since it would be quite hard to get
such cascades right if it was implemented so that allies declared war on
the aggressor, instead of the aggressor declaring war on a victim's
allies, due to the complicated use of recursion, I let it stand as it is
in this respect.

The patch is untested, please comment on the policy changes.

  - Per

Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.304
diff -u -r1.304 plrhand.c
--- server/plrhand.c    19 Feb 2004 21:06:42 -0000      1.304
+++ server/plrhand.c    6 Mar 2004 12:43:12 -0000
@@ -991,29 +991,50 @@
   case DS_NO_CONTACT: /* possible if someone declares war on our ally */
   case DS_NEUTRAL:
     new_type = DS_WAR;
-    reppenalty = 0;
     break;
   case DS_CEASEFIRE:
     new_type = DS_NEUTRAL;
-    reppenalty = GAME_MAX_REPUTATION/6;
+    reppenalty += GAME_MAX_REPUTATION/6;
     break;
   case DS_PEACE:
     new_type = DS_NEUTRAL;
-    reppenalty = GAME_MAX_REPUTATION/5;
+    reppenalty += GAME_MAX_REPUTATION/5;
     break;
   case DS_ALLIANCE:
     new_type = DS_PEACE;
-    reppenalty = GAME_MAX_REPUTATION/4;
+    reppenalty += GAME_MAX_REPUTATION/4;
     break;
   case DS_TEAM:
     new_type = DS_ALLIANCE;
-    reppenalty = 0;
     break;
   default:
-    freelog(LOG_VERBOSE, "non-pact diplstate in handle_player_cancel_pact");
+    freelog(LOG_ERROR, "non-pact diplstate in handle_player_cancel_pact");
     return;
   }
 
+  /* do the change */
+  pplayer->diplstates[pplayer2->player_no].type =
+    pplayer2->diplstates[pplayer->player_no].type =
+    new_type;
+  pplayer->diplstates[pplayer2->player_no].turns_left =
+    pplayer2->diplstates[pplayer->player_no].turns_left =
+    16;
+
+  /* If the old state was alliance, the players' units can share tiles
+     illegally, and we need to call resolve_unit_stacks() */
+  if (old_type == DS_ALLIANCE) {
+    resolve_unit_stacks(pplayer, pplayer2, TRUE);
+  }
+
+  /* We want to go all the way to war, whatever the cost! 
+   * This is only used when declaring war against an alliance 
+   * and by the AI. */
+  if (clause == CLAUSE_LAST && new_type != DS_WAR) {
+    repeat = TRUE;
+    old_type = new_type;
+    goto repeat_break_treaty;
+  }
+
   /* if there's a reason to cancel the pact, do it without penalty */
   if (pplayer->diplstates[pplayer2->player_no].has_reason_to_cancel > 0) {
     pplayer->diplstates[pplayer2->player_no].has_reason_to_cancel = 0;
@@ -1043,29 +1064,6 @@
     }
   }
 
-  /* do the change */
-  pplayer->diplstates[pplayer2->player_no].type =
-    pplayer2->diplstates[pplayer->player_no].type =
-    new_type;
-  pplayer->diplstates[pplayer2->player_no].turns_left =
-    pplayer2->diplstates[pplayer->player_no].turns_left =
-    16;
-
-  /* If the old state was alliance, the players' units can share tiles
-     illegally, and we need to call resolve_unit_stacks() */
-  if (old_type == DS_ALLIANCE) {
-    resolve_unit_stacks(pplayer, pplayer2, TRUE);
-  }
-
-  /* We want to go all the way to war, whatever the cost! 
-   * This is only used when declaring war against an alliance 
-   * and by the AI. */
-  if (clause == CLAUSE_LAST && new_type != DS_WAR) {
-    repeat = TRUE;
-    old_type = new_type;
-    goto repeat_break_treaty;
-  }
-
   send_player_info(pplayer, NULL);
   send_player_info(pplayer2, NULL);
 
@@ -1097,11 +1095,12 @@
         && new_type == DS_WAR && pplayers_allied(pplayer2, other)
         && !pplayers_at_war(pplayer, other)) {
       /* A declaration of war by A against B also means A declares
-       * war against all of B's allies. Yes, A gets the blame. */
+       * war against all of B's allies. */
       notify_player_ex(other, -1, -1, E_TREATY_BROKEN,
                       _("Game: %s has attacked one of your allies! "
                          "The alliance brings you into the war as well."),
                        pplayer->name);
+      pplayer->diplstates[other->player_no].has_reason_to_cancel = 3;
       handle_diplomacy_cancel_pact(pplayer, other->player_no, CLAUSE_LAST);
     }
   } players_iterate_end;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Cascading war changes (PR#5103), Per I. Mathisen <=