Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2001:
[Freeciv-Dev] Re: (NEW PATCH) settler_worker_cost patch
Home

[Freeciv-Dev] Re: (NEW PATCH) settler_worker_cost patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Michael Kiermaier <michael.kiermaier@xxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (NEW PATCH) settler_worker_cost patch
From: Arien Malec <arien_malec@xxxxxxxxx>
Date: Wed, 7 Mar 2001 15:35:29 -0800 (PST)

--- Michael Kiermaier <michael.kiermaier@xxxxxxx> wrote:
> a question:
> i fear that adding variables and flags to unit.ruleset breaks
> compatibility.
> is this a problem? if yes, what should be done instead?

I don't know -- can anyone else comment? I retrofitted the ruleset to
make sure that the default game play is a 0 worker cost....

> >To implement the patch, I also made city_auto_remove_worker to take
> a
> >parameter of the number of workers to remove, and to actually
> decrement
> >city size. I think this is more modular and cleaner, but is not
> >actually necessary to change the Freeciv behavior.
> 
> this is exactly what i did first. but then i realized that there are
> function calls of city_auto_remove_worker without a directly
> preceeding
> pcity->size--. i did not think too much about it, maybe these
> function can
> also be changed in a suitable way.

The one exception, so far as I know, is in unithand.c, where a unit
entering a city with size=1 destroys the city. The code to do that
deletes the city in a non-standard way. I rearranged the code to get
the intent right (check for city of size=1) and used the new function.

Just for information, the actions that reduce city size are:

in cityturn.c
1) Building a "worker_cost" unit (settler, engineer)
2) Famine
in diplomat.c
3) Revolt caused by diplomat
4) Poison water supply (spy)
in unithand.c
5) Successful attack on city
6) Entry into city (which may destroy city)

>  so i prefered not change city_auto_remove_worker, but i added
> city_auto_remove_workers with an additional parameter.

The code is IMHO better with the parameterized function. It preserves
flexibility: if one later wants to make warfare, or poisoning, or
whatever destroy more, the code is already set up to do it.

My latest patch (attached), which sounds very similar to yours, changes
the function to be city_reduce_size (I then had to change a function
already named city_reduce_size to read city_reduced_by_famine which is
what is really going on). It makes worker_cost an attribute on units
(units.ruleset) which is the right place for it, I think.

Now we just need to merge our two approaches :-)


> at the moment i have a problem:
> i changed the can_unit_add_to_city function according to my new
> F_ADD_TO_CITY flag. when i click on the menu item "add to city" or
> "build
> city" everything works fine.
> but pressing the "b" key only adds F_CITIES (or F_SETTLERS?) units to
> a city
> and not all units with the F_ADD_TO_CITY flag.
> 
> can anyone imagine a reason for this behavior? where can i find the
> code
> that handles keyboard inputs?

You want to change can_unit_add_to_city in unit.c

Arien
 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Attachment: unit_worker_cost_patch
Description: unit_worker_cost_patch


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