Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: map iteration (PR#1018)
Home

[Freeciv-Dev] Re: PATCH: map iteration (PR#1018)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: PATCH: map iteration (PR#1018)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Oct 2001 09:51:37 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Oct 19, 2001 at 09:15:46PM -0400, Ross W. Wetmore wrote:
> The is_normal_map_pos() solution is really just a bad hack because you 
> aren't willing to think about the case and fix it right at the moment :-).
> 
> But in most cases, the right fix it is far easier than what you are 
> proposing.
> 
> The examples below should use whole_map_iterate(). When you get weird
> maps, then whole_map_iterate() will become weird, but until then it will
> remain as is, i.e. efficient iteration over the whole map. The change
> when needed is to 1 line of code in a header.

Yes whole_map_iterate should be prefered. However whole_map_iterate
doesn't allow an action if the map position is unreal or an extra
action for every new line.

What about a new macro:

#define whole_map_iterate(x_itr, y_itr,new_line_code,real_code, unreal_code)
{
  int x_itr, y_itr;
  for (y_itr = 0; y_itr < map.ysize; y_itr++){
        new_line_code;
    for (x_itr = 0; x_itr < map.xsize; x_itr++)
    {
        if(is_normal_map_pos(...))
        {
                real_code;
        }
        else
        {
                unreal_code;
        }
    }

???

> You want to use square_iterate() or block_iterate() in most of the 
> other cases. These functions do the right thing by definition. They
> will also not change until they need to.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
    1) Customers cause problems.
    2) Marketing is trying to create more customers.
  Therefore:
    3) Marketing is evil.


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