Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain pl
Home

[Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain pl

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mburda@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain place, used to place poles.
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 7 May 2004 10:06:56 -0700
Reply-to: rt@xxxxxxxxxxx

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

Marcelo Burda wrote:

>>And...
>>
>>You can't hard-code the number of tiles.  This value would change under 
>>a hex-tiled map.  Instead we need an else clause.  I guess this means 
>>you need a hard-coded iterator.  Or maybe add an "else" clause to one of 
>>the existing iterators.
>>
> 
> mmm... i need there this function. 
> In the hex-tiled map you need to patch with a else for the hard coded
> number. the concept of these patch is based in the way i need implement
> iterators, then i am no choice about the hard coded number.
> probably i go use a litle sqare today, this will change in exteded
> topologies patch.
> i need to see your hex patch to make choices but i ll am no make it
> today

With the right implementation it will work find for hex tiles too.

Something like:

   for (x_itr = -2; x_itr <= 2; x_itr++)
     for (y_itr = -2; y_itr <= 2; y_itr++)
       if (map_distance_sq(x, y, x0 + x_itr, y0 + y_itr) <= 4)
         if (!is_real_map_pos(x0 + x_itr, y0 + y_itr))
           return TRUE;
   return FALSE;

the problem is that this iteration is actually looking for the unreal 
case.  All of the iterators in map.h skip automatically past such 
positions.  So there is no way to use the current iterators to do this task.

It also may not be obvious why this works in hex tiles.  Hex tiles don't 
correspond to cartesian coordinates the way rectangular tiles do, so the 
loop may actually cover a weird shape on the map.  However 
map_distance_sq will give the correct value so things will actually work.

It would be possible to change the iterators to allow for an "else" 
case.  But it wouldn't be pretty.

jason




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