Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9510) is_coast_seen is wrong
Home

[Freeciv-Dev] (PR#9510) is_coast_seen is wrong

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9510) is_coast_seen is wrong
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Jul 2004 09:52:38 -0700
Reply-to: rt@xxxxxxxxxxx

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

Is_coast_seen is logically wrong.  It tries to be clever, but this 
cleverness is based on something that isn't true in the development 
version anymore.  And the cleverness is logically wrong anyway.

/***************************************************************
Can pplayer conclude (at least by circumstantial evidence) that
(x,y) is on coastline?  Remember, coastline ocean tiles have a
small stripe of land in them, even if the actual continent is
not seen.
***************************************************************/
bool is_coast_seen(int x, int y, struct player *pplayer)
{
   bool ai_always_see_map = !ai_handicap(pplayer, H_MAP);

   square_iterate(x, y, 1, x1, y1) {
     if (is_ocean(map_get_terrain(x1, y1))) {
       continue;
     }
     /* Found land next to (x,y).  Can we see it? */
     if (ai_always_see_map || map_is_known(x1, y1, pplayer)) {
       /* Yes, we can see it */
       return TRUE;
     }
     /* No, we cannot see it, but maybe we can see the strip of land
      * on a tile next to it? */
     adjc_cardinal_dir_iterate(x1, y1, x2, y2, dir) {
       if (map_is_known(x2, y2, pplayer)) {
         /* Yes, we can see (x2, y2) and it will display
          * the strip of land.  We can conclude that (x1, y1) is land
          * and therefore (x,y) is right next to (or on) the land */
         return TRUE;
       }
     } adjc_cardinal_dir_iterate_end; /* around x1,y1 */
   } square_iterate_end; /* around x,y */

   return FALSE;
}

Coastline ocean tiles do _not_ have a strip of land in them.  That's 
just the way the client displays things.  It used to be that the client 
would show that even if you didn't know the land was there, but this is 
no longer true.  Regardless, this isn't logically correct since we don't 
care if (x1,y1) is on the coastline, we need to know if (x,y) is on the 
coastline.  This error will probably result in AI tririemes sinking a lot.

Also this function should assert(is_ocean(map_get_terrain(x, y)), and it 
should use adjc_iterate not square_iterate.

jason




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9510) is_coast_seen is wrong, Jason Short <=