Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Bug #700906

2.6: can never get Settler-type units from huts

Added by frank e almost 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Scripting API
Sprint/Milestone:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

For comparison, found in...
2.6.0-beta1/data/default/default.lua:
  local settlers = find.role_unit_type('Cities', owner)
2.5.9/data/default/default.lua:
  local settlers = find.role_unit_type('Cities', owner)
~/.freeciv/2.x/radius/script.lua:
   if radius_vers < 260
      then  type = radius_hut_type( owner, tile, "Cities" )
      else  type = radius_hut_type( owner, tile, "CitiesStartUnit" )
   end

m-lua-unit-by-flag-1.patch (1.95 KB) m-lua-unit-by-flag-1.patch option 1: extend find.role_unit_type semantics (master) Jacob Nevins, 2018-07-08 12:16 PM
30-26-lua-unit-by-flag-1.patch (1.95 KB) 30-26-lua-unit-by-flag-1.patch option 1: extend find.role_unit_type semantics (S3_0, S2_6) Jacob Nevins, 2018-07-08 12:16 PM
m-lua-unit-by-flag-2.patch (3.62 KB) m-lua-unit-by-flag-2.patch option 2: add new find.flag_unit_type (master) Jacob Nevins, 2018-07-08 12:16 PM
30-26-lua-unit-by-flag-2.patch (3.62 KB) 30-26-lua-unit-by-flag-2.patch option 2: add new find.flag_unit_type (S3_0, S2_6) Jacob Nevins, 2018-07-08 12:16 PM

Related issues

Related to Freeciv - Bug #763890: Hut on NoCities flag terrain wouldn't turns to settlers in civ2civ3Rejected

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by Marko Lindqvist almost 4 years ago

If this is a suggestion that default.lua should give CitiesStartUnit from huts instead of Cities, I disagree. The CitiesStartUnit flag should not be used for anything else than start unit selection. The ruleset may rely on the unit not being available otherwise (e.g. to give more powerful city founder unit initially to boost the game start)

#2 Updated by frank e almost 4 years ago

Marko Lindqvist wrote:

If this is a suggestion that default.lua should give CitiesStartUnit from huts instead of Cities, I disagree.

Actually I think that role Cities does not more exist, it was renamed. But I'm not sure what find.role_unit_type( role, owner ) does.

#3 Updated by Marko Lindqvist almost 4 years ago

frank e wrote:

Marko Lindqvist wrote:

If this is a suggestion that default.lua should give CitiesStartUnit from huts instead of Cities, I disagree.

Actually I think that role Cities does not more exist, it was renamed.

Flags count as roles too.

#4 Updated by frank e almost 4 years ago

Marko Lindqvist wrote:

Flags count as roles too.

Nice, reverted in my radius/script.lua, if it's documented somewhere close this issue, please.

#5 Updated by Jacob Nevins over 3 years ago

  • Sprint/Milestone deleted (2.6.0-beta2)

#6 Updated by Marko Lindqvist over 3 years ago

  • Tracker changed from Task to Feature
  • Category changed from Rulesets to Documentation

frank e wrote:

Marko Lindqvist wrote:

Flags count as roles too.

... if it's documented somewhere close this issue, please.

So this ticket has turned to a documentation feature.

#7 Updated by Marko Lindqvist over 3 years ago

#8 Updated by Jacob Nevins about 3 years ago

  • Related to Bug #763890: Hut on NoCities flag terrain wouldn't turns to settlers in civ2civ3 added

#9 Updated by Jacob Nevins about 3 years ago

  • Tracker changed from Feature to Bug

(Coming back to this because of Akechi's report #763890, which makes a testable prediction about it.)

Flags count as roles too.

Unfortunately, for the purpose of Lua find.role_unit_type(), they do not.
While best_role_unit_for_player() and get_role_unit() would happily work for flags, the unit_role_id_by_name() that is called previously genuinely only works for roles, not flags.

#10 Updated by Jacob Nevins about 3 years ago

What would be the impact on common rulesets of changing from "Cities" to "CitiesStartUnit", as suggested here, apart from fixing the bug that you can never get Settler-type units from huts on 2.6+ currently?
  • civ1, civ2, civ2civ3, classic, experimental, multiplayer, sandbox, variant2: none (set of Cities unit types == CitiesStartUnit)
  • alien: none, as there as no NoCities terrains on which you can find a Space Capsule. (If that weren't the case: Native Settlers and Water Engineer are Cities but not CitiesStartUnit, so you'd no longer get them from from a Space Capsule.)

(Also, on S3_0+, "Cities" is now a conventional name for a ruleset-defined flag, not a built-in flag.)

#11 Updated by Jacob Nevins about 3 years ago

  • Subject changed from 260b1 _deflua_hut_get_city to 2.6: can never get Settler-type units from huts
  • Category deleted (Documentation)

But, as cazfi says, we split out the *StartUnit for a reason, so piling extra semantics on them doesn't seem like a good idea.

Alternatively, could we get away with making Lua find.role_unit_type() also look at flags in 2.6.0, by adding a call to unit_type_flag_id_by_name()? This is a behavioural change, but only one that makes code that could never have worked start working. Otherwise we have to leave this mess unresolved until 3.0.

#12 Updated by Jacob Nevins about 3 years ago

Here are two options for patching.
I'm inclined to commit one of these for 2.6.0, and probably declare an RC2 before 2.6.0-final.
  1. Extend find.role_unit_type() semantics to also cover flags. Small patch, no change to scripts.
  2. Keep find.role_unit_type() unchanged, but add find.flag_unit_type(), and call that from the default hut code. Bigger patch, but has the advantage over 1 that anyone taking a custom ruleset back to RCs/betas at least has a hard failure rather than a silent one. Ruleset authors who've replaced the hut functionality will need to change their rulesets.

I favour option 2, unless someone finds some reason to object. I'll commit within a few days, unless someone objects.

(Neither of them gives access to the internal "action_roles" added by gna patch #5554 -- utype_can_do_action_role(), etc.)

#13 Updated by Jacob Nevins about 3 years ago

#14 Updated by Marko Lindqvist about 3 years ago

I think I would prefer 1. That would make my earlier assumption true; flags to count as roles in this respect too (consistency, would be what I expect knowing behavior of the other functions).

But I might be the only one who ever has expected that behavior, or would expect it simply after reading best_role_unit_for_player() and get_role_unit() documentation (currently code comments). Tricky.

#15 Updated by Jacob Nevins about 3 years ago

  • Sprint/Milestone changed from 2.6.0 to 2.6.0-RC2

#16 Updated by Jacob Nevins about 3 years ago

OK, let's go for option 1 (*-1.patch). Will commit (and document at http://www.freeciv.org/wiki/Lua_reference_manual) soon.

#17 Updated by Jacob Nevins about 3 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF