Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [Patch] Make do_unit_goto return a meaningful value (P
Home

[Freeciv-Dev] Re: [Patch] Make do_unit_goto return a meaningful value (P

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] Make do_unit_goto return a meaningful value (PR#985)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 30 Sep 2001 19:31:41 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Sep 30, 2001 at 12:28:33PM -0400, Ross W. Wetmore wrote:
> -enum goto_result {
> -  GR_FAILED, GR_ARRIVED, GR_OUT_OF_MOVEPOINTS, GR_DIED }
> +enum goto_result {
> +  GR_ARRIVED = 0, GR_FAILED, GR_OUT_OF_MOVEPOINTS, GR_DIED }
> 
> I would make the above change noting that "ARRIVED" is really
> "SUCCESS" and the rest are different forms of "FAILED". This
> makes the return status agree with the "shell" or "strcmp" 
> concept of true/false, i.e. zero == true and non-zero == false.
> 
> This may not be immediately useful here as (ret != GR_ARRIVED)
> works just as well for the global false case, but in different
> programming environments such as a shell scripted client AI, it
> may make things more sensible to follow some standard.

Yes and no. Yes it would my make this analog to other systems. No we
want an explicit compare against a value from "enum goto_result" and
not a "if(!do_unit_goto(...))". Sometimes I explicitly code enums such
as "enum xyz{a=1,b,c,d}" to catch such bad boolean tests.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 A life? Cool! Where can I download one?


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