wanted.addAll(p1.getWanted());
}
Comparator itemLineCompare = new Comparator() {
public int compare(Object o1, Object o2) {
ItemLine i1 = (ItemLine) o1;
ItemLine i2 = (ItemLine) o2;
return i1.getItem().getName().compareTo(i2.getItem().getName());
}
};
Collections.sort(forSale, itemLineCompare);
Collections.sort(wanted, itemLineCompare);
int iwbb = 0; // item wanted begin bracket.
ItemLine iw;
int iwndx;
for (ItemLine ifs : forSale) {
if (item != null && !itemP.matcher(ifs.getItem().getName()).find()) {
continue;
}
if (fromSys != null && !fromSysP.matcher(ifs.getLocation().getSystem().name()).find()) {
continue;
}
if (fromLoc != null && !fromLocP.matcher(ifs.getLocation().getName()).find()) {
continue;
}
LocationProperty lpfs = locationsProperties.get(ifs.getLocation().getName());
if (lpfs != null && lpfs.isIgnore()) {
continue;
}
for (iwndx = iwbb; iwndx < wanted.size(); iwndx++) {
iw = wanted.get(iwndx);
if (ifs.getItem().getName().compareTo(iw.getItem().getName()) > 0) {
iwbb++;
continue;
}
if (ifs.getItem().getName().compareTo(iw.getItem().getName()) < 0) {
break;
}
if (item != null && !itemP.matcher(iw.getItem().getName()).find()) {
continue;
}
if (toSys != null && !toSysP.matcher(iw.getLocation().getSystem().name()).find()) {
continue;
}
if (toLoc != null && !toLocP.matcher(iw.getLocation().getName()).find()) {
continue;
}
LocationProperty lpw = locationsProperties.get(iw.getLocation().getName());
if (lpw != null && lpw.isIgnore()) {
continue;
}
if (ifs.getItem().getName().equals(iw.getItem().getName())) {
Route r = new Route(ifs, iw, weightLimit, credits);
if ((minimumAbsoluteProfit != null) &&
(r.getAbsoluteProfit() < minimumAbsoluteProfit)) {
continue;
}
if ((minimumRelativeProfit != null) &&
(r.getRelativeProfit() < minimumRelativeProfit)) {
continue;
}
if ((minimumTotalProfit != null) &&
(r.getTotalProfit() < minimumTotalProfit)) {
continue;
}
long turns = PricelistsTools.getRouteTurns(r, currentLocation, sector, grid, hop);
if ((turnLimit != null) && (turns > turnLimit)) {
continue;
}
long tptc = r.getTotalProfit() / turns;
if ((minimumTPTC != null) && (tptc < minimumTPTC)) {
continue;
}
ifs.getConnectedItemLines().add(iw);
iw.getConnectedItemLines().add(ifs);
routes.add(new Route(ifs, iw, weightLimit, credits));
}
}
}
// here goes nothing.