Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] (PR#6519) self-referential alliances?
Home

[Freeciv-Dev] (PR#6519) self-referential alliances?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#6519) self-referential alliances?
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 1 Nov 2003 04:17:54 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Tue Oct 14 16:11:32 2003]:

> Playing against the AI, I initiated a ceasefire:
> 
> *Wilhelmina (AI)* Wilhelmina recommended that I give you a ceasefire.
> This is your lucky day.
> 
> Reproducable from this savegame (which uses the topology_id patch).
> 
> jason

Well, duh, that's because you already have a ceasefire with Wilhelmina!

The attached patch should solve this entire class of problems. Clients 
should gray out any pact choices that are already taken.

  - Per

Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.18
diff -u -r1.18 diptreaty.c
--- common/diptreaty.c  9 Sep 2003 15:49:06 -0000       1.18
+++ common/diptreaty.c  1 Nov 2003 12:16:43 -0000
@@ -119,12 +119,25 @@
                enum clause_type type, int val)
 {
   struct Clause *pclause;
+  enum diplstate_type ds = 
+                     pplayer_get_diplstate(ptreaty->plr0, ptreaty->plr1)->type;
 
   if (type == CLAUSE_ADVANCE && !tech_exists(val)) {
     freelog(LOG_ERROR, "Illegal tech value %i in clause.", val);
     return FALSE;
   }
   
+  if (is_pact_clause(type)
+      && ((ds == DS_PEACE && type == CLAUSE_PEACE)
+          || (ds == DS_ALLIANCE && type == CLAUSE_ALLIANCE)
+          || (ds == DS_CEASEFIRE && type == CLAUSE_CEASEFIRE))) {
+    /* we already have this diplomatic state */
+    freelog(LOG_ERROR, "Illegal treaty suggested between %s and %s - they "
+                       "already have this treaty level.", ptreaty->plr0->name, 
+                       ptreaty->plr1->name);
+    return FALSE;
+  }
+
   clause_list_iterate(ptreaty->clauses, pclause) {
     if(pclause->type==type
        && pclause->from==pfrom

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6519) self-referential alliances?, Per I. Mathisen <=