Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2003:
[Freeciv-Dev] Re: (PR#4107) Client crash on start.
Home

[Freeciv-Dev] Re: (PR#4107) Client crash on start.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxx, ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4107) Client crash on start.
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 2 May 2003 08:55:07 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Thu, 1 May 2003, Gregory Berkolaiko wrote:
> Believe it or not, the cause of this bug is the resent change to AI
> government evaluation.
...
> #0 send_unit_info (dest=0x813608c, punit=0x82e52e8) at unittools.c:2005
> #10x080970a2 in city_support (pcity=0x833e668) at city.c:2070
> #20x08097113 in generic_city_refresh (pcity=0x833e668,
>   refresh_trade_route_cities=true) at city.c:2091
> #30x080bc9ee in ai_best_government (pplayer=0x813608c) at aihand.c:360
> #40x080bb955 in ai_data_turn_init (pplayer=0x813608c) at aidata.c:256
...
> I think the best solution is to remove (or at least move) the
> assess_danger_player from srv_loop. The comment says it will confuse the
> AI, but I don't see why, as it will not _do_ anything, just do some
> advisory stuff.

Right. This is the simplest solution. I couldn't find any problems with
it, so I'll commit that so that cvs will be fine.

However, there are more problems here. What happened above shouldn't be a
problem, but it is because generic_city_refresh() sends packets.

Why is a function (or set of functions) in common/ when they send packets
to the client? These should either be generalised or moved to server/. One
way to generalising them, and presumably save some network traffic, would
be to instead mark units as "dirty" when they need updating on the client,
and then actually only do the send_unit_infos later.

Also, we should start to discuss the way the AI is structured. At present
we invoke it once for data initialization and units except settlers in the
beginning of the turn, and then once at the end of the turn for units
(again) and everything else.

This means we can't use static data buffers initialized in the
initialization step for use in the end-of-turn AI step, since other AIs
may have been controlled meanwhile and the world has changed. So we need
to either save the data per player, even though we only need it for one
turn, or we recalculate it twice per turn.

Instead we should, I think, do all AI stuff at the same time, and while
the human players move their mouses and click their keyboards on their
clients and the server is otherwise idle - ie right after turn start. On
turn end the server will be busy processing end of turn stuff and human
players will be waiting for the server to react, so that is a bad time to
do AI processing.

The best would be to do one AI at a time completely in the beginning of
the turn, then empty the network queue for packets from players, before
handling the next AI player. This should give maximum performance, even if
it imposes some limitations on the AI. It would also remove the frequently
complained about "AI double move".

Uhm, this post got way too long.

  - Per




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