|
|
|
@ -323,68 +323,83 @@ public function UpdateFeatureArray(
|
|
|
|
|
out array<Packages.FeatureConfigPair> featuresToEnable) |
|
|
|
|
{ |
|
|
|
|
local int i; |
|
|
|
|
local Text newConfigName; |
|
|
|
|
local HashTable includedFeaturesMap; |
|
|
|
|
local Text nextKey, nextConfig; |
|
|
|
|
local string nextFeatureClassName; |
|
|
|
|
local CollectionIterator iter; |
|
|
|
|
local Packages.FeatureConfigPair newPair; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < featuresToEnable.length; i += 1) |
|
|
|
|
// Exclude features we're told to exclude |
|
|
|
|
while (i < featuresToEnable.length) |
|
|
|
|
{ |
|
|
|
|
nextFeatureClassName = string(featuresToEnable[i].featureClass); |
|
|
|
|
// `excludeFeature` |
|
|
|
|
if (FeatureExcluded(nextFeatureClassName)) |
|
|
|
|
if (IsFeatureExcluded(nextFeatureClassName)) |
|
|
|
|
{ |
|
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
|
featuresToEnable[i].configName = none; |
|
|
|
|
continue; |
|
|
|
|
featuresToEnable.Remove(i, 1); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
i += 1; |
|
|
|
|
} |
|
|
|
|
// `includeFeatureAs` |
|
|
|
|
newConfigName = TryReplacingFeatureConfig(nextFeatureClassName); |
|
|
|
|
if (newConfigName != none) |
|
|
|
|
} |
|
|
|
|
// Rewrite auto-enabled configs if different config was specified |
|
|
|
|
includedFeaturesMap = BuildIncludedFeaturesMap(); |
|
|
|
|
for (i = 0; i < featuresToEnable.length; i += 1) |
|
|
|
|
{ |
|
|
|
|
nextKey = |
|
|
|
|
_.text.FromString(Locs(string(featuresToEnable[i].featureClass))); |
|
|
|
|
nextConfig = Text(includedFeaturesMap.TakeItem(nextKey)); |
|
|
|
|
if (nextConfig != none) |
|
|
|
|
{ |
|
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
|
featuresToEnable[i].configName = newConfigName; |
|
|
|
|
featuresToEnable[i].configName = nextConfig; |
|
|
|
|
} |
|
|
|
|
// `includeFeature` |
|
|
|
|
if ( featuresToEnable[i].configName == none |
|
|
|
|
&& FeatureInIncludedArray(nextFeatureClassName)) |
|
|
|
|
{ |
|
|
|
|
featuresToEnable[i].configName = P("default").Copy(); |
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
|
} |
|
|
|
|
// Add features that are included, but weren't auto-enabled in |
|
|
|
|
// the first place |
|
|
|
|
for (iter = includedFeaturesMap.Iterate(); !iter.HasFinished(); iter.Next()) |
|
|
|
|
{ |
|
|
|
|
nextKey = Text(iter.GetKey()); |
|
|
|
|
newPair.featureClass = class<Feature>(_.memory.LoadClass(nextKey)); |
|
|
|
|
newPair.configName = Text(iter.Get()); |
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
|
featuresToEnable[featuresToEnable.length] = newPair; |
|
|
|
|
} |
|
|
|
|
includedFeaturesMap.FreeSelf(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function bool FeatureExcluded(string featureClassName) |
|
|
|
|
private function HashTable BuildIncludedFeaturesMap() |
|
|
|
|
{ |
|
|
|
|
local int i; |
|
|
|
|
local Text nextKey; |
|
|
|
|
local HashTable result; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < excludeFeature.length; i += 1) |
|
|
|
|
result = _.collections.EmptyHashTable(); |
|
|
|
|
// First fill `HashTable` with non-specified conmfigs from `includeFeature` |
|
|
|
|
for (i = 0; i < includeFeature.length; i += 1) |
|
|
|
|
{ |
|
|
|
|
if (excludeFeature[i] ~= featureClassName) { |
|
|
|
|
return true; |
|
|
|
|
nextKey = _.text.FromString(Locs(includeFeature[i])); |
|
|
|
|
result.SetItem(nextKey, none); |
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function Text TryReplacingFeatureConfig(string featureClassName) |
|
|
|
|
{ |
|
|
|
|
local int i; |
|
|
|
|
|
|
|
|
|
// Then add/rewrite configs from `includeFeatureAs` |
|
|
|
|
for (i = 0; i < includeFeatureAs.length; i += 1) |
|
|
|
|
{ |
|
|
|
|
if (includeFeatureAs[i].feature ~= featureClassName) { |
|
|
|
|
return _.text.FromString(includeFeatureAs[i].config); |
|
|
|
|
nextKey = _.text.FromString(Locs(includeFeatureAs[i].feature)); |
|
|
|
|
result.SetString(nextKey, Locs(includeFeatureAs[i].config)); |
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return none; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function bool FeatureInIncludedArray(string featureClassName) |
|
|
|
|
private function bool IsFeatureExcluded(string featureClassName) |
|
|
|
|
{ |
|
|
|
|
local int i; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < includeFeature.length; i += 1) |
|
|
|
|
for (i = 0; i < excludeFeature.length; i += 1) |
|
|
|
|
{ |
|
|
|
|
if (includeFeature[i] ~= featureClassName) { |
|
|
|
|
if (excludeFeature[i] ~= featureClassName) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|