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: 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: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 30 Sep 2001 19:28:22 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sat, Sep 29, 2001 at 02:16:32PM -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.

Looks ok.

> @@ -1099,7 +1104,7 @@
>        /* this is a special case for air units who do not always want to 
> move. */
>        if (same_pos(waypoint_x, waypoint_y, punit->x, punit->y)) {
>       advance_unit_focus(punit);
> -     return;
> +     return GR_ARRIVED; /* well, somewhere */

Than split GR_ARRIVED into GR_ARRIVED_AT_DEST and GR_ARRIVED_SOMEWHERE

> -     return;
> +     return GR_FAILED;  /* Isn't this line redundant? */

Either it is or it isn't.

>        /* Don't attack more than once per goto */
>        if (penemy && !pplayer->ai.control) { /* Should I cancel for ai's too? 
> */
>       punit->activity = ACTIVITY_IDLE;
>       send_unit_info(0, punit);
> -     return;
> +     return GR_FAILED; /* well, nothing better comes to mind... */

????

>       freelog(LOG_DEBUG, "stopping because we ran a round\n");
> -     return; /* don't patrol more than one round */
> +     return GR_ARRIVED; /* don't patrol more than one round */

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 checking for the vaidity of the Maxwell laws on this machine... ok
 checking if e=mc^2... ok
 checking if we can safely swap on /dev/fd0... yes
    -- kvirc 2.0.0's configure 


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