Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] [PATCH] Improvement effects speedup (PR#1094)
Home

[Freeciv-Dev] [PATCH] Improvement effects speedup (PR#1094)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] Improvement effects speedup (PR#1094)
From: "ben@xxxxxxxxxxxxxxxxxxxxxx" <dbsmith@xxxxxxxxxxx>
Date: Wednesday, 05 Dec 2001 20:19:18 -500

Originally to: David Bryan Smith

  by provide.net (CommuniGate Pro SMTP 3.5b5)
  with ESMTP id 6262564 for 
dbsmith@xxxxxxxxxxx; Wed, 05 Dec 2001 
15:23:51 -0500
Received: from pi (localhost [127.0.0.1])
        by pi.glockenspiel.complete.org (Postfix) 
with ESMTP
        id EA3F13B9F2; Wed,  5 Dec 2001 15:17:07 
-0500 (EST)
Received: with LISTAR (v1.0.0; list 
freeciv-dev); Wed, 05 Dec 2001 15:17:07 -0500 
(EST)
Delivered-To: 
virtual-freeciv.org-freeciv-dev@xxxxxxxxxxxx
Received: from freeciv.freeciv.org 
(www.freeciv.org [64.37.156.68])
        by pi.glockenspiel.complete.org (Postfix) 
with ESMTP id 4E64D3B853
        for <freeciv-dev@xxxxxxxxxxx>; Wed,  5 Dec 
2001 15:17:07 -0500 (EST)
Received: from localhost (localhost 
[127.0.0.1])
        by freeciv.freeciv.org (8.9.3+Sun/8.9.1) 
with ESMTP id MAA09738
        for <freeciv-dev@xxxxxxxxxxx>; Wed, 5 Dec 
2001 12:17:05 -0800 (PST)
Date: Wed, 5 Dec 2001 12:17:05 -0800 (PST)
Message-Id: 
<200112052017.MAA09738@xxxxxxxxxxxxxxxxxxx>
From: Ben Webb <ben@xxxxxxxxxxxxxxxxxxxxxx>
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] Improvement 
effects speedup (PR#1094)
Cc: bugs@xxxxxxxxxxxxxxxxxxx
X-Loop: bugs@xxxxxxxxxxxxxxxxxxx
MIME-Version: 1.0
Content-Transfer-Encoding: BASE64
Content-Type: MULTIPART/MIXED; 

OUNDARY="27493923-423773660-1007583417=:7596"
X-archive-position: 5099
X-listar-version: Listar v1.0.0
Sender: freeciv-dev-bounce@xxxxxxxxxxx
Errors-To: freeciv-dev-bounce@xxxxxxxxxxx
X-original-sender: ben@xxxxxxxxxxxxxxxxxxxxxx
Precedence: bulk
X-list: freeciv-dev

  This message is in MIME format.  The first 
part should be readable text,
  while the remaining parts are likely 
unreadable without MIME-aware tools.
  Send mail to 
mime@xxxxxxxxxxxxxxxxxxxxxxxxxxxx for more 
info.

--27493923-423773660-1007583417=:7596
Content-Type: TEXT/PLAIN; charset=US-ASCII

The situation:
        Current Freeciv CVS contains part of the 
impr-gen patch from the 
FreecivAC project (http://freecivac.sf.net/). 
This attempts to implement 
the behaviour defined in buildings.ruleset, 
for the "effects" of city 
improvements (e.g. boosting science, making 
citizens happy, etc.) so that 
modpacks and support for other games like Sid 
Meier's Alpha Centauri 
(SMAC) can modify the (presently hard-coded) 
behaviour of improvements.

The problem:
        Improvement effects are calculated both on 
the server and the 
client (to reduce network traffic, and allow 
for clientside AI). At 
present, the client calls 
"update_all_effects" every time a new 
city_info/short_city (for improvements) or 
game_info (for Wonders) packet 
is received, and this is particularly 
wasteful since update_all_effects() 
is a CPU-intensive function.

The fix:
        See attached patch. Effects are now updated 
only if a city_info or 
game_info packet actually adds or removes an 
improvement. Furthermore, 
updates as a result of packets received 
before the first turn starts (e.g. 
from the server sending savegame information) 
or between turns, are 
deferred until the start of the turn (this 
may cause update problems on 
particularly slow network connections, but I 
believe this to be 
negligible, and other information will also 
be out of date in such a 
situation anyway). This cuts the number of 
calls of update_all_effects() 
down to one per turn, plus any caused by the 
player building cities or 
selling improvements during the turn, which 
is a significant saving.

        Touches little code, but does add a global 
variable to 
client/packhand.c (there seemed to be no 
other way of detecting whether we 
were "between" turns or not).

Review and commit, please...

        Ben
-- 
ben@xxxxxxxxxxxxxxxxxxxxxx           
http://bellatrix.pcl.ox.ac.uk/~ben/
"The Right Hon was a tubby little chap who 
looked as if he had been
poured into his clothes and had forgotten to 
say When!"
        - 'Jeeves and the Impending Doom', P. G. 
Wodehouse

--27493923-423773660-1007583417=:7596
Content-Type: TEXT/PLAIN; charset=US-ASCII; 
name="effect-update-opt.patch"
Content-Transfer-Encoding: BASE64
Content-ID: 












33.0112052016570.7596@xxxxxxxxxxxxxxxxxxxxxx>
Content-Description: 
Content-Disposition: attachment; 
filename="effect-update-opt.patch"

Attached file: effect-update-opt.patch



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