[freeciv-ai] Re: patch/rfc: wrap activity
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, 18 Nov 2002, Per I. Mathisen wrote:
> This is the essential wrapper for retaining fortification status, taken
> from massive ai patch. Shout if you think this is wrong, otherwise I will
> commit along with the necessary wrapping changes elsewhere in the code.
I like it. But that doesn't mean it's good. So I will list bad points
about it:
1. Only in 1% of the time (if that) it will be called with fortifying
task. So 99% of the time the check is a CPU waste.
2. It will not solve the fortification problem. It won't even _help_ to
solve it. The fortification problem comes from aiunit.c
2271 if (punit->activity != ACTIVITY_IDLE)
2272 handle_unit_activity_request(punit, ACTIVITY_IDLE);
and then later
2312 } else if (punit->activity == ACTIVITY_IDLE) {
2313 handle_unit_activity_request(punit, ACTIVITY_FORTIFYING);
If the first 2 lines are removed, the last two lines make perfect sense
and need no wrappers.
On the other hand, although I am against moving AI to client, there should
be good separation between AI and the game engine. This wrapper provides
another layer of this separation. But maybe handle_unit_activity_request
is enough of a separation?
G.
> - Per
>
> diff -u -r1.62 aitools.c
>
> +/**************************************************************************
> + Gate all changes to unit activities through here to enforce sanity
> +
> + FIXME: packetify request
> ++**************************************************************************/
> +void ai_unit_new_activity(struct unit *punit, enum unit_activity task)
> +{
> + if (punit->activity == task) {
> + return; /* useless */
> + }
> + if (punit->activity == ACTIVITY_FORTIFIED && task == ACTIVITY_FORTIFYING) {
> + return; /* worse than useless */
> }
> + handle_unit_activity_request(punit, task);
> }
>
>
>
>
|
|