Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] (PR#13413) Treaty reduction
Home

[Freeciv-Dev] (PR#13413) Treaty reduction

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13413) Treaty reduction
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Tue, 5 Jul 2005 11:48:21 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The diplomatic pact can be reduced be a treaty, however alliance breakup
isn't handled properly like in handle_cancel_pact().

This may be the cause of latest pubserver crash.
http://pubserver.freeciv.org/games/446100

Patch for 2.0 attached
--
mateusz
Index: diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.87.2.4
diff -u -r1.87.2.4 diplhand.c
--- diplhand.c  9 Feb 2005 15:57:36 -0000       1.87.2.4
+++ diplhand.c  5 Jul 2005 18:45:03 -0000
@@ -322,6 +322,8 @@
     clause_list_iterate(ptreaty->clauses, pclause) {
       struct player *pgiver = pclause->from;
       struct player *pdest = (pplayer == pgiver) ? pother : pplayer;
+      enum diplstate_type old_diplstate = 
+        pgiver->diplstates[pdest->player_no].type;
 
       switch (pclause->type) {
       case CLAUSE_EMBASSY:
@@ -416,6 +418,9 @@
                         _("Game: You agree on a cease-fire with %s."),
                         pgiver->name);
         gamelog(GAMELOG_TREATY, GL_CEASEFIRE, pgiver, pdest);
+       if (old_diplstate == DS_ALLIANCE) {
+         update_players_after_alliance_breakup(pgiver, pdest);
+       }
        check_city_workers(pplayer);
        check_city_workers(pother);
        break;
@@ -429,6 +434,9 @@
                         _("Game: You agree on a peace treaty with %s."),
                         pgiver->name);
         gamelog(GAMELOG_TREATY, GL_PEACE, pgiver, pdest);
+       if (old_diplstate == DS_ALLIANCE) {
+         update_players_after_alliance_breakup(pgiver, pdest);
+       }
        check_city_workers(pplayer);
        check_city_workers(pother);
        break;
Index: plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.330.2.30
diff -u -r1.330.2.30 plrhand.c
--- plrhand.c   2 Jul 2005 07:33:05 -0000       1.330.2.30
+++ plrhand.c   5 Jul 2005 18:45:09 -0000
@@ -1102,6 +1102,25 @@
 }
 
 /**************************************************************************
+  After the alliance is breaken, we need to do two things:
+  - Inform clients that they cannot see units inside the former's ally
+    cities
+  - Remove units stacked together
+**************************************************************************/
+void update_players_after_alliance_breakup(struct player* pplayer,
+                                          struct player* pplayer2)
+{
+  /* The client needs updated diplomatic state, because it is used
+   * during calculation of new states of occupied flags in cities */
+   send_player_info(pplayer, NULL);
+   send_player_info(pplayer2, NULL);
+   remove_allied_visibility(pplayer, pplayer2);
+   remove_allied_visibility(pplayer2, pplayer);    
+   resolve_unit_stacks(pplayer, pplayer2, TRUE);
+}
+
+
+/**************************************************************************
   Handles a player cancelling a "pact" with another player.
 
   packet.id is id of player we want to cancel a pact with
@@ -1189,13 +1208,7 @@
   /* 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) {
-    /* The client needs updated diplomatic state, because it is used
-     * during calculation of new states of occupied flags in cities */
-    send_player_info(pplayer, NULL);
-    send_player_info(pplayer2, NULL);
-    remove_allied_visibility(pplayer, pplayer2);
-    remove_allied_visibility(pplayer2, pplayer);    
-    resolve_unit_stacks(pplayer, pplayer2, TRUE);
+    update_players_after_alliance_breakup(pplayer, pplayer2);
   }
 
   /* We want to go all the way to war, whatever the cost! 
Index: plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.69
diff -u -r1.69 plrhand.h
--- plrhand.h   29 Sep 2004 02:24:24 -0000      1.69
+++ plrhand.h   5 Jul 2005 18:45:09 -0000
@@ -98,4 +98,6 @@
 bool civil_war_triggered(struct player *pplayer);
 void civil_war(struct player *pplayer);
 
+void update_players_after_alliance_breakup(struct player* pplayer,
+                                          struct player* pplayer2);
 #endif  /* FC__PLRHAND_H */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13413) Treaty reduction, Mateusz Stefek <=