Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9613) aisettler failed assertion
Home

[Freeciv-Dev] (PR#9613) aisettler failed assertion

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9613) aisettler failed assertion
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 19:19:21 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Thu Aug 05 19:24:52 2004]:
> 
> I started a single-player game with no AIs to test some autosettlers. 
> Immediately after putting a settler on auto:
> 
> civserver: aisettler.c:545: find_best_city_placement: Assertion `pplayer 
> && pplayer->ai.control' failed.
> 
> I assume it is the latter that is failing.

This patch should fix it.

I changed the assertion for two reasons:

(1) It's not necessary, since if pplayer is NULL we'll get better crash
than the assertion will give.

(2) On some platforms you can't assert(pplayer), you have to
assert(pplayer!=NULL).  This may not be an issue here because of the &&,
I dunno.

jason

Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.1
diff -u -r1.1 aisettler.c
--- ai/aisettler.c      5 Aug 2004 11:34:18 -0000       1.1
+++ ai/aisettler.c      6 Aug 2004 02:17:31 -0000
@@ -542,7 +542,7 @@
   struct pf_parameter parameter;
   struct unit *ferry = NULL;
 
-  assert(pplayer && pplayer->ai.control);
+  assert(pplayer->ai.control);
 
   best->x = -1;
   best->y = -1;
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.189
diff -u -r1.189 settlers.c
--- server/settlers.c   5 Aug 2004 11:34:18 -0000       1.189
+++ server/settlers.c   6 Aug 2004 02:17:32 -0000
@@ -1031,7 +1031,7 @@
     best_impr = evaluate_improvements(punit, &best_act, &gx, &gy);
   }
 
-  if (unit_flag(punit, F_CITIES)) {
+  if (unit_flag(punit, F_CITIES) && pplayer->ai.control) {
     find_best_city_placement(punit, &result, TRUE, FALSE);
     UNIT_LOG(LOG_SETTLER, punit, "city want %d (impr want %d)", result.result,
              best_impr);

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