Page 1 of 1

home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 12:16 am
by Wahazar
Currently you can't set home city for homeless unit - it usually make sense, to avoid accidentally making upkeep of free units,
but is completely counterproductive, if killunhomed option is set.
In such case units others than settlers are dying after at least 10 turns and you can't do anything (besides disbanding them to collect few shields).

Therefore I propose small patch in function can_unit_change_homecity_to in common/unit.c

Code: Select all

  return (punit && pcity
     && ((punit->homecity > 0) || (game.server.killunhomed >0))
     && acity
     && city_owner(acity) == unit_owner(punit)
     && punit->homecity != acity->id);


Not sure if brackets are needed, added them to enhance code.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 8:20 am
by Caedo
In the current master (3.1+), the "change home city" action is already controlled by an action enabler; I believe the requirement that a unit must already have a home has been un-hardcoded. However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 4:51 pm
by Ignatus
Caedo wrote:However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.

"ServerSetting" requirement in 3.0 supports boolean-type options.

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 8:27 pm
by Caedo
Ignatus wrote:
Caedo wrote:However, I don't believe there is currently a means of requiring a server setting to have (or not have) some value, so it is only possible to either always allow it, or never allow it (or some more fine-grained conditions based on other things in the game), regardless of the killunhomed server setting.

"ServerSetting" requirement in 3.0 supports boolean-type options.

Do you happen to know if this includes testing whether a numeric setting is non-zero?

Re: home city for homeless when killunhomed>0

Posted: Tue Feb 04, 2020 9:37 pm
by Ignatus
Caedo wrote:Do you happen to know if this includes testing whether a numeric setting is non-zero?

For non-boolean options, it yet either does not load or returns always false. The development obstacle seems to me like just it would require some a bit more sophisticated coding to fit universals with non-boolean value into 32 bytes, a bigger structure for requiremens will slow down too many things.

Re: home city for homeless when killunhomed>0

Posted: Thu Feb 06, 2020 2:29 pm
by Wahazar
By the way, this patch (for 2.6) doesn't work - seems it is hardcoded also elsewhere - gui client?