Complete.Org: Mailing Lists: Archives: freeciv-ai: November 2004:
[freeciv-ai] Re: (PR#8992) Patch: Building ferries

[freeciv-ai] Re: (PR#8992) Patch: Building ferries

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#8992) Patch: Building ferries
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 1 Nov 2004 11:32:19 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: >

Per I. Mathisen wrote:

> You call is_ocean_near_tile(acity->tile) a lot of times. Perhaps we should
> add a new variable bool pcity->coastal instead, since the function call
> above is comparatively expensive.

I would be extremely wary of adding new global data fields that will 
need to be kept updated.

pcity->coastal would need to be updated at least every turn.

In some cases it may even become stale during the course of a turn.  Say 
the value was calculated, then unit activities/global warming/whatever 
was done, then it were used.  The real danger is that this could cause a 
fatal error.  If the above caused a crash, for instance, it would be 
extremely difficult to track down.

This is a problem in many other places in the code.  Adding values like 
this that are assumed to be correct creates many dependencies that are 
not easy to keep track of (or even to find).  If you do use precomputed 
values, you should always treat them as approximations and assume they 
might be wrong.


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