[Freeciv-Dev] Re: (NEW PATCH) settler_worker_cost patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
--- Michael Kiermaier <michael.kiermaier@xxxxxxx> wrote:
> a question:
> i fear that adding variables and flags to unit.ruleset breaks
> 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
> >parameter of the number of workers to remove, and to actually
> >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
> 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:
1) Building a "worker_cost" unit (settler, engineer)
3) Revolt caused by diplomat
4) Poison water supply (spy)
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
> 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
> that handles keyboard inputs?
You want to change can_unit_add_to_city in unit.c
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.