Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3798) Change canvas_to_map_pos() from void to bool
Home

[Freeciv-Dev] Re: (PR#3798) Change canvas_to_map_pos() from void to bool

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3798) Change canvas_to_map_pos() from void to bool
From: "rwetmore@xxxxxxxxxxxx" <rwetmore@xxxxxxxxxxxx>
Date: Sun, 6 Apr 2003 12:53:31 -0700
Reply-to: rt@xxxxxxxxxxxxxx

a-l@xxxxxxx wrote:
>>Now, the longstanding question: what should normalize_map_pos do in the
>>unreal case?  Obviously they return FALSE, but what should happen to the
>>coordinates?  There are three choices:
>>
>>1.  They are left unchanged.
>>2.  They are wrapped - so they will be "canonical" but not "real".
>>3.  They are made normal using nearest_real_pos.
> 
> For the purpose of drawing a truly rectangular, topology independent
> selection rectangle with a visible part that extends into unreal
> tiles; #1 and #2 are fine. Only #3 (the old way) would require
> writing a special version of canvas_to_map_pos().

1 is the best solution. 2 and 3 convert unreal coordinates into real ones
which is a completely invalid transformation and thus leads to all sorts
of hard to track down bugs if they are actually used.

The only valid rule is that unreal coordinates are illegal (period).

The code that generates unreal coords should deal with the case, as only
at this point can you actually decide what to do and carry it out safely.

Any other code that finds them should throw an assert in debug mode and
try to do something user friendly like ignoring them and cleanly aborting
or dropping the current operation in a release version.

>>For testing, you should compile with debugging enabled (--enable-debug).
>>This enables CHECK_MAP_POS, which will catch some mistakes (real and
>>imagined).

CHECK_MAP_POS only catches unnormalized coordinates, which it has made
into religious mistakes. It doesn't understand the difference between
unreal and real-but-unnormalized. The latter are perfectly valid and
usable since normalization will always be the successful fix.

So CHECK_MAP_POS is useless for your purposes involving unrealness.

> This always gives me "treating warnings as errors" and refusing to
> compile because of control reaching end of some non-void function or
> another. Is that a problem with my compiler flags setup?
> 
> Arnstein

Cheers,
RossW
=====




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