Skip to content

Commit

Permalink
Make the NoHome utype flag mean "built homeless".
Browse files Browse the repository at this point in the history
Limit the meaning of the NoHome unit type flag to "built without a home
city". Make it up to the ruleset author if the action "Home City"
(sometimes) should be permitted for units with the NoHome utype flag.

See osdn #41621
  • Loading branch information
kvilhaugsvik committed Feb 22, 2021
1 parent acbd1b6 commit 83ab99c
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 29 deletions.
6 changes: 5 additions & 1 deletion client/helpdata.c
Expand Up @@ -1954,7 +1954,11 @@ char *helptext_unit(char *buf, size_t bufsz, struct player *pplayer,
}
}
if (utype_has_flag(utype, UTYF_NOHOME)) {
CATLSTR(buf, bufsz, _("* Never has a home city.\n"));
if (utype_can_do_action_result(utype, ACTRES_HOME_CITY)) {
CATLSTR(buf, bufsz, _("* Built without a home city.\n"));
} else {
CATLSTR(buf, bufsz, _("* Never has a home city.\n"));
}
}
if (utype_has_flag(utype, UTYF_GAMELOSS)) {
CATLSTR(buf, bufsz, _("* Losing this unit will lose you the game!\n"));
Expand Down
11 changes: 0 additions & 11 deletions common/actions.c
Expand Up @@ -486,17 +486,6 @@ static void hard_code_oblig_hard_reqs(void)
ACTRES_MARKETPLACE,
ACTRES_NONE);

/* Why this is a hard requirement: Preserve semantics of NoHome
* flag. Need to replace other uses in game engine before this can
* be demoted to a regular unit flag. */
oblig_hard_req_register(req_from_values(VUT_UTFLAG, REQ_RANGE_LOCAL,
FALSE, TRUE, TRUE, UTYF_NOHOME),
FALSE,
N_("All action enablers for %s must require"
" that the actor doesn't have"
" the NoHome utype flag."),
ACTRES_HOME_CITY, ACTRES_NONE);

/* Why this is a hard requirement:
* - preserve the semantics of the NonMil unit type flag. */
oblig_hard_req_reg(req_contradiction_or(
Expand Down
2 changes: 1 addition & 1 deletion data/alien/units.ruleset
Expand Up @@ -337,7 +337,7 @@ flags = "Missile", "DoesntOccupyTile"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/civ2civ3/units.ruleset
Expand Up @@ -368,7 +368,7 @@ flags = "Unreachable", "DoesntOccupyTile", "CanPillage", "Airliftable"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/classic/units.ruleset
Expand Up @@ -344,7 +344,7 @@ flags = "Unreachable", "DoesntOccupyTile"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/experimental/units.ruleset
Expand Up @@ -356,7 +356,7 @@ flags = "Unreachable", "DoesntOccupyTile"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/granularity/units.ruleset
Expand Up @@ -281,7 +281,7 @@ flags = "TerrainSpeed"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/multiplayer/units.ruleset
Expand Up @@ -344,7 +344,7 @@ flags = "Unreachable", "DoesntOccupyTile"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/ruledit/comments-3.2.txt
Expand Up @@ -458,7 +458,7 @@ utypes = "\
; it encounters another SuperSpy, in which case defender wins;\n\
; can also be used on non-diplomat units, in which case it can\n\
; protect cities from diplomats; also 100% spy survival chance\n\
; \"NoHome\" = this unit has no homecity and will be free of all upkeep, and\n\
; \"NoHome\" = this unit is built with no homecity, free of all upkeep, and\n\
; therefore will not revolt along with its city of origin should\n\
; it be incited\n\
; \"NoVeteran\" = this unit cannot gain veteran levels through experience\n\
Expand Down
2 changes: 1 addition & 1 deletion data/sandbox/units.ruleset
Expand Up @@ -380,7 +380,7 @@ flags = "Unreachable", "DoesntOccupyTile", "CanPillage", "MediumWeight"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/stub/units.ruleset
Expand Up @@ -265,7 +265,7 @@ flags = ""
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
2 changes: 1 addition & 1 deletion data/webperimental/units.ruleset
Expand Up @@ -349,7 +349,7 @@ flags = "Unreachable", "DoesntOccupyTile"
; it encounters another SuperSpy, in which case defender wins;
; can also be used on non-diplomat units, in which case it can
; protect cities from diplomats; also 100% spy survival chance
; "NoHome" = this unit has no homecity and will be free of all upkeep, and
; "NoHome" = this unit is built with no homecity, free of all upkeep, and
; therefore will not revolt along with its city of origin should
; it be incited
; "NoVeteran" = this unit cannot gain veteran levels through experience
Expand Down
1 change: 0 additions & 1 deletion doc/README.actions
Expand Up @@ -478,7 +478,6 @@ Actions done by a unit against a city
* UI name can be set using ui_name_home_city
* actor must be aware that the target exists
* actor must be on the same tile as the target
* actor must not have the "NoHome" unit type flag. (!)
* can't set existing home city as new home city
* target city has enough unused unit maintenance slots to support the actor
unit. (No problem if the actor unit spends 0 city slots)
Expand Down
7 changes: 1 addition & 6 deletions server/unithand.c
Expand Up @@ -3589,12 +3589,7 @@ void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity,
}

if (rehome) {
fc_assert(!unit_has_type_flag(punit, UTYF_NOHOME));

/* Remove from old city first and add to new city only after that.
* This is more robust in case old_city == new_city (currently
* prohibited by fc_assert in the beginning of the function).
*/
/* Remove from old city first and add to new city only after that. */
if (old_pcity) {
/* Even if unit is dead, we have to unlink unit pointer (punit). */
unit_list_remove(old_pcity->units_supported, punit);
Expand Down

0 comments on commit 83ab99c

Please sign in to comment.