Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] Re: (PR#14548) New treaties rules
Home

[Freeciv-Dev] Re: (PR#14548) New treaties rules

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#14548) New treaties rules
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 19 Nov 2005 07:08:58 -0800
Reply-to: bugs@xxxxxxxxxxx

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

On Sat, 19 Nov 2005, Per I. Mathisen wrote:
> Next patch (after this is committed) will do this:
>  * When a Peace treaty kicks in, all military units belonging to
>  peace-treaty players inside your border are immediately disbanded.

Patch attached (dipldisband.diff).

>  * The AI will use Armistice to move its units out of enemy territory.

Turns out not to be such a big problem in practice, the AI keeps its units
in its cities when it is not waging war, so not a very urgent issue.

>  * A shortcut key cycles through units in enemy territory for easy mass
>  exodus.

Attached patch (diplready.diff) immediately readies (idles) all units in
the territory of a player that you accept an armistice (peace) treaty
with, so that you can make the choice to move those units out.

  - Per

Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 11249)
+++ server/srv_main.c   (working copy)
@@ -400,6 +400,37 @@
 }
 
 /**************************************************************************
+  Remove illegal units when armistice turns into peace treaty.
+**************************************************************************/
+static void remove_illegal_armistice_units(struct player *plr1,
+                                           struct player *plr2)
+{
+  /* Remove illegal units */
+  unit_list_iterate(plr1->units, punit) {
+    if (punit->tile->owner == plr2
+        && is_military_unit(punit)) {
+      notify_player(plr1, NULL, E_DIPLOMACY, _("Your %s unit %s was "
+                    "disbanded in accordance with your peace treaty with "
+                    "the %s."), punit->type->name,
+                    get_location_str_at(plr1, punit->tile),
+                    get_nation_name_plural(plr2->nation));
+      wipe_unit(punit);
+    }
+  } unit_list_iterate_end;
+  unit_list_iterate(plr2->units, punit) {
+    if (punit->tile->owner == plr1
+        && is_military_unit(punit)) {
+      notify_player(plr2, NULL, E_DIPLOMACY, _("Your %s unit %s was "
+                    "disbanded in accordance with your peace treaty with "
+                    "the %s."), punit->type->name,
+                    get_location_str_at(plr2, punit->tile),
+                    get_nation_name_plural(plr1->nation));
+      wipe_unit(punit);
+    }
+  } unit_list_iterate_end;
+}
+
+/**************************************************************************
   Check for cease-fires and armistices running out; update cancelling 
   reasons and contact information.
 **************************************************************************/
@@ -416,6 +447,7 @@
         state->turns_left--;
         if (state->turns_left <= 0) {
           state->type = DS_PEACE;
+          remove_illegal_armistice_units(plr1, plr2);
         }
       }
 
Index: client/packhand.c
===================================================================
--- client/packhand.c   (revision 11248)
+++ client/packhand.c   (working copy)
@@ -1483,6 +1483,27 @@
     pplayer->ai.love[i] = pinfo->love[i];
   }
 
+  /* Check if we detect change to armistice with us. If so,
+   * ready all units for movement out of the territory in
+   * question; otherwise they will be disbanded. */
+  if (game.player_ptr
+      && pplayer->diplstates[game.player_ptr->player_no].type
+      != DS_ARMISTICE
+      && pinfo->diplstates[game.player_ptr->player_no].type
+      == DS_ARMISTICE) {
+    unit_list_iterate(game.player_ptr->units, punit) {
+      if (!punit->tile->owner || punit->tile->owner != pplayer) {
+        continue;
+      }
+      if (punit->focus_status == FOCUS_WAIT) {
+        punit->focus_status = FOCUS_AVAIL;
+      }
+      if (punit->activity != ACTIVITY_IDLE) {
+        request_new_unit_activity(punit, ACTIVITY_IDLE);
+      }
+    } unit_list_iterate_end;
+  }
+
   for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
     pplayer->diplstates[i].type =
       pinfo->diplstates[i].type;

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