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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] Make do_unit_goto return a meaningful value (PR#985)
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Sun, 30 Sep 2001 12:28:33 -0400

-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.

Cheers,
RossW
=====

At 02:16 PM 01/09/29 -0700, Gregory Berkolaiko wrote:
>Since do_unit_goto attempts to change the location of a unit and can
>fail/succeed in a number of different ways. This information is later
>extracted indirectly and used by other code, e.g.
>  http://www.freeciv.org/lxr/source/ai/aiunit.c?v=cvs#L234
>  http://www.freeciv.org/lxr/source/ai/aiunit.c?v=cvs#L894
>
>I think it would be better to have do_unit_goto return a meaningful
>answer.
>
>Attached patch introduces 
>  enum goto_result 
>and makes do_unit_goto and goto_route_execute return a value of this
>type.
>
>So far it is not used but I really need it to improve ai_manage_explorer.
>
>The testgames are identical with/without the patch.
>
>Best,
>G.
>
>____________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
>or your free @yahoo.ie address at http://mail.yahoo.ie
>Attachment Converted: "c:\program files\eudora\attach\goto_result.diff"
>



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