Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#10
Home

[Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#10

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Remove map_adjust_[xy] invocations from server (PR#1003)
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Mon, 22 Oct 2001 02:47:49 +0100

On Sat, 13 Oct 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:

> But in the long term we want normalized map positions and the code
> IS ready to 99%. So we should go IMHO the full way and just say that
> function arguements have to be normalized and deal with rest (~1%)
> in the next weeks and be done with it.

Now, that's the most sensible thing that anyone has said on this
subject in the last week or so.

Before one falls over one self trying to work out clever ways to come
up with functions/macros/spells that catch dodgy coordinates and then
either abort or try to fix the situation, it is worth remembering that
pretty much the only way that you will ever see one of these is if
you manually do what one of the _iterate macros do, not use MAPSTEP
where you should or if you do something like

   map_get_tile(pcity->x +cx-2, pcity->y + cy-2).

We have removed pretty much all such constructs from the code base,
and unless someone does something really stupid we are unlikely to see
much more of them.

This is why I think the best thing would be to add this sort of check
to map_inx().  That way, we:

  * Get an easy way to turn on comprehensive checking for unnormalised
    coordinates if you are working on changes to that part of the
    code.

  * Avoid splattering explicit checks all over the code.

  * Avoid the need to explicitly add a check in every single place we
    use a coordinate pair, or pass it to another function.

The flip side is that you have to add an explicit check to places
where you do more complicated stuff, e.g. same_pos().  Off course, if
you wanted an explicit test everywhere then you would have to add one
there anyway.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
It's so OBVIOUS!!


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