Fix a typo in ApplicableRegionSet and improve docs.

This commit is contained in:
sk89q 2014-08-15 12:31:20 -07:00
parent 1d24be8c34
commit 8a11752253

View File

@ -208,19 +208,20 @@ private State calculateState(StateFlag flag, @Nullable LocalPlayer player, @Null
// regions, there are two scenarios that we may encounter: // regions, there are two scenarios that we may encounter:
// //
// 1) PARENT first, CHILD later: // 1) PARENT first, CHILD later:
// PARENT and its parents are added to needsClear. // a) When the loop reaches PARENT, PARENT is added to needsClear.
// When the loop reaches CHILD, all parents of CHILD (including // b) When the loop reaches CHILD, parents of CHILD (which includes
// PARENT) are removed from needsClear. (Any parents not in // PARENT) are removed from needsClear.
// needsClear are added to hasCleared for the 2nd scenario.) // c) needsClear is empty again.
// //
// 2) CHILD first, PARENT later: // 2) CHILD first, PARENT later:
// CHILD's parents are added to hasCleared. // a) When the loop reaches CHILD, CHILD's parents (i.e. PARENT) are
// When the loop reaches PARENT, since PARENT is already in // added to hasCleared.
// hasCleared, it doe not add PARENT to needsClear. // b) When the loop reaches PARENT, since PARENT is already in
// hasCleared, it does not add PARENT to needsClear.
// c) needsClear stays empty.
// //
// If there are any regions left over in needsClear, that means that // As long as the process ends with needsClear being empty, then
// there was at least one region that the player is not a member of // we have satisfied all membership requirements.
// (any of its children) and thus we can deny building.
Set<ProtectedRegion> needsClear = new HashSet<ProtectedRegion>(); Set<ProtectedRegion> needsClear = new HashSet<ProtectedRegion>();
Set<ProtectedRegion> hasCleared = new HashSet<ProtectedRegion>(); Set<ProtectedRegion> hasCleared = new HashSet<ProtectedRegion>();
@ -229,7 +230,7 @@ private State calculateState(StateFlag flag, @Nullable LocalPlayer player, @Null
// Don't consider lower priorities below minimumPriority // Don't consider lower priorities below minimumPriority
// (which starts at Integer.MIN_VALUE). A region that "counts" // (which starts at Integer.MIN_VALUE). A region that "counts"
// (has the flag set OR has members) will raise minimumPriority // (has the flag set OR has members) will raise minimumPriority
// its own priority. // to its own priority.
if (region.getPriority() < minimumPriority) { if (region.getPriority() < minimumPriority) {
break; break;
} }