Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6402) AI focus woes.
Home

[Freeciv-Dev] Re: (PR#6402) AI focus woes.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6402) AI focus woes.
From: "Arnstein Lindgard" <a-l@xxxxxxx>
Date: Sat, 8 Nov 2003 10:27:34 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6402 >

"Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx> wrote:

> When a sentried unit wakes up in the server, the client gets an info 
> packet and focuses on that unit.
> 
> Sometimes, set_unit_focus would slightly alter the state of the unit and 
> send a corresponding packet to the server.
> 
> All is fine unless the unit is AI controlled.  When it is in a boat, it is 
> sentried, then it wakes up (the packet is sent to client, client react 
> with another packet), moves ashore, does it's nasty business there etc 
> etc.  When the AI is finished, server starts sniffing for packets, gets 
> the now stale packet from client (unit is no longer on the boat, where it 
> lost its sentriness, but to the server it looks as if the unit wants to 
> move back to the boat!), tries to react on it.  In the best case the unit 
> has no movepoints and you get a corresponding message.  I guess sometimes 
> the server will actually move the unit back.
> 
> There are two ways to fix it:
> 
> 1. the packet should not be sent back from the client.  it only happens 
> because punit->ai.control is TRUE, why I don't know [1].

The entire [ packhand.c:handle_unit_packet_common() / control.c /
server ] complex is tricky. It also used to be more messy and
unspecific, causing focus to jump imperceptibly back and forth.
(Maybe it stil does, but in different circumstances).

1. You click an automated unit, client must inform server of idle status.
(Client does not inform server anymore, when you click idle units.)

http://www.freeciv.org/lxr/source/client/packhand.c#L917

2. Server informs client of new idle status, but we do NOT want to
advance focus; Since the fast-focus patch, client already focused on
the unit when you clicked it.

3. However, when client is informed of new automated status (because
you pressed "A"), you want to advance focus, less you're stuck with
focus on an exhausted unit.

http://www.freeciv.org/lxr/source/client/control.c#L124

Client sets the activity of the unit that we are about to focus to
idle, before instructing server to idle it, in order to avoid Wakeup
Focus when the respose comes. The function name
    request_new_unit_activity(punit, ACTIVITY_IDLE)
may be inappropriate in this case. ("request").

> 2. the client observing AI should not focus on unsentried units [2].  It
> is highly annoying, I switch off all the auto-center options to observe
> one particular part of the map and the client still jumps back and forth
> when some units decide to go ashore.

Makes much sense to me. That code (packhand.c) expects feedback from
you giving orders manually; there never was separate code for orders
that were initiated from the server (AI). This is a bit dodgy, but I
think your solution could eliminate the problems in this particular
area for now. However, see #3390; I think the whole complex needs
structuring too.

Prior to fast-focus, the focusing network-packet carried a bit called
"select it", which I should have thought about at the time with
regard to AI orders.

Come to think of it, maybe the client should never _focus_ a unit
when the player is AI'd, except when you mouseclick. That should
resolve your issue #1. You could still have the map recentering.


Arnstein




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