Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] Re: (PR#10459) bug: pplayer_can_ally assert fail
Home

[Freeciv-Dev] Re: (PR#10459) bug: pplayer_can_ally assert fail

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bagpipe@xxxxxxxxx, bh@xxxxxxxxxxxxxxxxxxx, jorneg@xxxxxxxxxxx, marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#10459) bug: pplayer_can_ally assert fail
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Oct 2004 11:12:59 -0700
Reply-to: rt@xxxxxxxxxxx

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

I think this patch should solve the problem.

- pplayers_can_ally always returns TRUE if the players are equal (this 
has to match with the definition of pplayers_allied).  Otherwise it 
always returns FALSE if either player is dead.

- pplayers_allied, pplayers_at_war, pplayers_at_peace, 
pplayers_non_attack always return TRUE if the players are the same (this 
has always been the case).  Otherwise it always returns FALSE if either 
player is dead.

And it compiles, too (unlike the previous patch) :-).

I tested it with the -0961 savegame in the ticket.

That said, this doesn't necessarily replace Per's patch.  They may be 
orthogonal.

jason


Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.157.2.1
diff -u -r1.157.2.1 player.c
--- common/player.c     8 Oct 2004 05:11:53 -0000       1.157.2.1
+++ common/player.c     18 Oct 2004 18:09:47 -0000
@@ -44,6 +44,12 @@
 ***************************************************************/
 bool pplayer_can_ally(struct player *p1, struct player *p2)
 {
+  if (p1 == p2) {
+    return TRUE;
+  }
+  if (!p1->is_alive || !p2->is_alive) {
+    return FALSE;
+  }
   players_iterate(pplayer) {
     enum diplstate_type ds = pplayer_get_diplstate(p1, pplayer)->type;
     if (pplayer != p1
@@ -641,9 +647,13 @@
                      const struct player *pplayer2)
 {
   enum diplstate_type ds = pplayer_get_diplstate(pplayer, pplayer2)->type;
+
   if (pplayer == pplayer2) {
     return FALSE;
   }
+  if (!pplayer->is_alive || !pplayer2->is_alive) {
+    return FALSE;
+  }
   if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
     return TRUE;
   }
@@ -657,9 +667,13 @@
                      const struct player *pplayer2)
 {
   enum diplstate_type ds = pplayer_get_diplstate(pplayer, pplayer2)->type;
+
   if (pplayer == pplayer2) {
     return TRUE;
   }
+  if (!pplayer->is_alive || !pplayer2->is_alive) {
+    return FALSE;
+  }
   if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
     return FALSE;
   }
@@ -677,6 +691,9 @@
   if (pplayer == pplayer2) {
     return TRUE;
   }
+  if (!pplayer->is_alive || !pplayer2->is_alive) {
+    return FALSE;
+  }
   if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
     return FALSE;
   }
@@ -690,9 +707,13 @@
                          const struct player *pplayer2)
 {
   enum diplstate_type ds = pplayer_get_diplstate(pplayer, pplayer2)->type;
+
   if (pplayer == pplayer2) {
     return FALSE;
   }
+  if (!pplayer->is_alive || !pplayer2->is_alive) {
+    return FALSE;
+  }
   if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
     return FALSE;
   }

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