Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] (PR#14652) Patch proposal: resources cleanup
Home

[Freeciv-Dev] (PR#14652) Patch proposal: resources cleanup

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14652) Patch proposal: resources cleanup
From: "Jerome Plut" <Jerome.Plut@xxxxxx>
Date: Sun, 20 Nov 2005 09:40:02 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14652 >

Joined is a patch (against SVN trunk as of Nov. 15th) that changes
resource handling. What this does is separate completely the
"specials" field of tiles in two parts:
 - resources (that is, the natural resources on this terrain, such as
   buffalo, silk or iron),
 - modifications (all that remains).

(I dropped entirely the name "specials", as I don't feel like it has a
lot of sense, but maybe I'm wrong -- I'm not a native English speaker,
so feel free to s/modification/special/g if needed).

Resources are stored in a separate table, and each terrain type has a
list of possible resources on this terrain, that the generator uses.
There are almost (*) no gameplay changes, but the ruleset for terrain
is changed (file attached): the [terrain] section now only has a list
of available resources, which are defined in [resource_*] sections.

That means, it is no longer written
[terrain_ocean]
special_1_name = "Whales"
special_1_food = 2 ...

but
[terrain_ocean]
resources = "Whales", "Fish"

[resource_whales]
name = "Whales"
food = 2

Note that the outputs in the resource_* sections are actually *added*
to the base terrain output. This means that if, for example, you allow
Wheat to be found in Plains and Grassland, it will increase the amount
of food on both terrains by the same value. And this explains the only
change perceivable in gameplay: glacier + oil now only gives 3 shields
(oil gives 3 bonus, so that desert + oil is still at 4). Well, if you
don't like this, you still can add "Petroleum" with 4 shields and same
graphics, and make it appear on glacier instead of oil.

Advantages: this allows to have more than two different resources for
a given terrain. The MAX_NUM_SPECIALS mechanism introduced was far
from complete, as you still needed to change *a lot* of code if you
wanted to set it, say, to three, and I'm not saying anything about the
compatibility problems it would introduce. This could also possibly
allow to easily define relative probabilities for resources at ruleset
level (say, Iron more frequent than Silver, itself more so than Gold),
I'll code this if you think it adds interest.

It, of course, breaks network compatibility (this would have been VERY
awkward to avoid) and savegame compatibility (resources are now saved by
identifier, as are terrains). But since this system is far more
supple, it will probably easier not to break compatiblity again once
it is in place.

Still to do: decide what to do with resources when terrain is changed
(through terraformation). I think that what was previously done was
that special_i stayed special_i (for i = 1, 2); this doesn't make
sense. Now resource_i remains resource_i (you keep the Oil when
terraforming a desert), which is only slightly more consistent. I
guess the right thing to do would be to remove any present resource,
and then re-draw a random number and decide whether to make a resource
appear. Any opinions about this?

Attachment: resources.diff.gz
Description: application/gunzip


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