Project

General

Profile

Feature #369 ยป 0039-Add-support-for-UnitFlag-requirements-on-Tile-Adjace.patch

Marko Lindqvist, 03/29/2024 09:52 AM

View differences:

common/requirements.c
&& req.range != REQ_RANGE_ALLIANCE
&& req.range != REQ_RANGE_WORLD);
break;
case VUT_UTFLAG:
case VUT_UCLASS:
case VUT_UCFLAG:
case VUT_MINVETERAN:
......
invalid = (req.range != REQ_RANGE_LOCAL);
break;
case VUT_UTYPE:
case VUT_UTFLAG:
invalid = (req.range != REQ_RANGE_LOCAL
&& req.range != REQ_RANGE_TILE
&& req.range != REQ_RANGE_CADJACENT
......
unitflag = req->source.value.unitflag;
if (req->range != REQ_RANGE_LOCAL) {
return TRI_NO;
}
if (!context->unittype) {
return TRI_MAYBE;
switch (req->range) {
case REQ_RANGE_LOCAL:
if (!context->unittype) {
return TRI_MAYBE;
}
return BOOL_TO_TRISTATE(utype_has_flag(context->unittype, unitflag));
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_type_flag(punit, unitflag)) {
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_type_flag(punit, unitflag)) {
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_type_flag(punit, unitflag)) {
return TRI_YES;
}
} unit_list_iterate_end;
} adjc_iterate_end;
}
return TRI_NO;
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(utype_has_flag(context->unittype, unitflag));
return TRI_NO;
}
/**********************************************************************//**
doc/README.effects
Terrain: Tile, Adjacent, CAdjacent, Traderoute, City
Good: City
UnitType: Local, Tile, CAdjacent, Adjacent
UnitFlag: Local
UnitFlag: Local, Tile, CAdjacent, Adjacent
UnitClass: Local
UnitClassFlag: Local
Nation: World, Alliance, Team, Player
    (1-1/1)