Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] Re: (PR#2521) general effects framework
Home

[Freeciv-Dev] Re: (PR#2521) general effects framework

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kaufman@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2521) general effects framework
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 9 Dec 2002 13:05:34 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Mon, 9 Dec 2002, Mike Kaufman via RT wrote:
> I'm curious as to why the auto_arrange_workers has anything to do with
> general effects? Or is this simply another aspect of your patch?

Add a temple to a city. The most important effect of that is that now you
can reassign an elvis to a whale. Add an Offshore Platform to a city - you
may use more ocean tiles - if you don't use any it is worthless. Etc.

The fundamental problem is that we call generic_city_refresh() in total
four times for each applicable building for each city that is changed for
each city to be evaluated. That's a lot of refreshes. Also the refresh
code isn't very fast. auto_arrange_workers()  affects this in a big way
since we must call a refresh after rearranging as well as before.

In pseudocode, what I do is roughly this:

for each non-obsolete building you have the teq reqs for {
  for each city that can build it {
    add improvement
    update all effects
    refresh all affected cities  /* so that we can rearranged based on
                                    correct info */
    rearrange workers in all affected cities
    refresh all affected cities  /* the rearranged workers cause changes
                                    that must be recalculated */
    compare all affected cities as they are now with how they were before
    remove improvement
    update all effects
    refresh all affected cities
    rearrange workers in all affected cities
    refresh all affected cities
  }
}

  - Per




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