[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]
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?
|
|