Project

General

Profile

Feature #401 ยป 0053-Add-support-for-UnitClassFlag-requirements-on-Tile-A.patch

Marko Lindqvist, 04/08/2024 07:49 PM

View differences:

common/requirements.c
if (invalid) {
error = "bad type or name";
} else {
/* Scan the range string to find the range. If no range is given a
/* Scan the range string to find the range. If no range is given a
* default fallback is used rather than giving an error. */
if (range != NULL) {
req.range = req_range_by_name(range, fc_strcasecmp);
......
&& req.range != REQ_RANGE_ALLIANCE
&& req.range != REQ_RANGE_WORLD);
break;
case VUT_UCFLAG:
case VUT_MINVETERAN:
case VUT_UNITSTATE:
case VUT_ACTIVITY:
......
case VUT_UTYPE:
case VUT_UTFLAG:
case VUT_UCLASS:
case VUT_UCFLAG:
invalid = (req.range != REQ_RANGE_LOCAL
&& req.range != REQ_RANGE_TILE
&& req.range != REQ_RANGE_CADJACENT
......
ucflag = req->source.value.unitclassflag;
if (req->range != REQ_RANGE_LOCAL) {
switch (req->range) {
case REQ_RANGE_LOCAL:
if (!context->unittype) {
return TRI_MAYBE;
}
return BOOL_TO_TRISTATE(uclass_has_flag(utype_class(context->unittype), ucflag));
case REQ_RANGE_TILE:
case REQ_RANGE_CADJACENT:
case REQ_RANGE_ADJACENT:
if (context->tile == nullptr) {
return TRI_MAYBE;
}
unit_list_iterate(context->tile->units, punit) {
if (unit_has_class_flag(punit, ucflag)) {
return TRI_YES;
}
} unit_list_iterate_end;
if (req->range == REQ_RANGE_TILE) {
return TRI_NO;
}
if (req->range == REQ_RANGE_CADJACENT) {
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
unit_list_iterate(adjc_tile->units, punit) {
if (unit_has_class_flag(punit, ucflag)) {
return TRI_YES;
}
} unit_list_iterate_end;
} cardinal_adjc_iterate_end;
} else {
fc_assert(req->range == REQ_RANGE_ADJACENT);
adjc_iterate(nmap, context->tile, adjc_tile) {
unit_list_iterate(adjc_tile->units, punit) {
if (unit_has_class_flag(punit, ucflag)) {
return TRI_YES;
}
} unit_list_iterate_end;
} adjc_iterate_end;
}
return TRI_NO;
}
if (!context->unittype) {
return TRI_MAYBE;
case REQ_RANGE_CITY:
case REQ_RANGE_TRADE_ROUTE:
case REQ_RANGE_CONTINENT:
case REQ_RANGE_PLAYER:
case REQ_RANGE_TEAM:
case REQ_RANGE_ALLIANCE:
case REQ_RANGE_WORLD:
case REQ_RANGE_COUNT:
fc_assert(FALSE);
break;
}
return BOOL_TO_TRISTATE(uclass_has_flag(utype_class(context->unittype), ucflag));
return TRI_NO;
}
/**********************************************************************//**
doc/README.effects
UnitType: Local, Tile, CAdjacent, Adjacent
UnitFlag: Local, Tile, CAdjacent, Adjacent
UnitClass: Local, Tile, CAdjacent, Adjacent
UnitClassFlag: Local
UnitClassFlag: Local, Tile, CAdjacent, Adjacent
Nation: World, Alliance, Team, Player
NationGroup: World, Alliance, Team, Player
Nationality: Traderoute, City
    (1-1/1)