Sources Cache

From Freeciv

Jump to: navigation, search

Currently we cannot have small wonders or improvements with effects having larger than city range. This is because our sources caches for buildings are in game.global_wonders[] and pcity->improvements[].

The improvements with larger than city range we are interested in having are limited to one per player or per game (i.e. world/player unique wonders).

The main culprit is global.global_wonders[]. It can only store one city id per building type, so it cannot possibly work for Palace (multiple players in a game have their own) or small wonders.

The way we fixed this was by adding a new player wide pplayer->small_wonders[] array, akin to the one for great wonders.

I've considered several other possible alternatives, which would provide more generic traits (more than one improvement of a type with larger than city range effects per player, etc). They are all hard to cache. City ids are nice and safe because if a city switches players, it still has the same id. If a continent splits, the city id is still the same. If the client doesn't know the city yet, it won't crash. If a city is destroyed, looking up that city id won't find anything (and it won't crash either). The people who created this code were ingenious to make it so in the first place.

Make the common case fast, and the uncommon case possible.

Personal tools
.