Skip to content

Commit

Permalink
Update iitc_plugin_fanfields2.user.js
Browse files Browse the repository at this point in the history
Addressing issue #56
  • Loading branch information
Heistergand authored Jun 30, 2024
1 parent 84c181e commit 6987991
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions iitc_plugin_fanfields2.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ function wrapper(plugin_info) {
for (i in plugin.drawTools.drawnItems._layers) {
var layer = plugin.drawTools.drawnItems._layers[i];
if (layer instanceof L.Marker) {

console.log("Marker found")
// Todo: make this an array by color
thisplugin.startingMarker = map.project(layer.getLatLng(), thisplugin.PROJECT_ZOOM);
Expand Down Expand Up @@ -1770,29 +1770,31 @@ function wrapper(plugin_info) {
const distance = thisplugin.distanceTo(a, b);

if (pb===0) {
var maxLinks = 8 + thisplugin.availableSBUL * 8
var maxLinks = 8 + thisplugin.availableSBUL * 8;
if (thisplugin.stardirection == thisplugin.starDirENUM.RADIATING && centerOutgoings < maxLinks ) {
outbound = 1;
}
else {
thisplugin.centerKeys++;
}

if (outbound == 1) {
a = this.sortedFanpoints[pb].point;
b = this.sortedFanpoints[pa].point;
console.log("outbound");
centerOutgoings++;
if (centerOutgoings > 8) {
// count sbul
centerSbul = Math.ceil(((centerOutgoings-8) / 8));
}
outbound = 1;
}
else thisplugin.centerKeys++;
}

possibleline = {a: a,
b: b,
bearing: bearing,
isJetLink: false,
isFanLink: (pb===0),
counts: true,
distance: distance
};
possibleline = {
a: a,
b: b,
bearing: bearing,
isJetLink: false,
isFanLink: (pb===0),
counts: true,
distance: distance
};
intersection = 0;
maplinks = [];

Expand All @@ -1804,28 +1806,37 @@ function wrapper(plugin_info) {
for (i in maplinks) {
if (this.intersects(possibleline,maplinks[i]) ) {
intersection++;
if (possibleline.isFanLink && outbound == 1) centerOutgoings--;
//console.log("FANPOINTS: " + pa + " - "+pb+" bearing: " + bearing + " " + this.bearingWord(bearing) + "(crosslink)");
break;
}
}
if (this.linkExists(maplinks, possibleline)) {
possibleline.counts = false;
if (possibleline.isFanLink && outbound == 1) centerOutgoings--;
}
}

for (i in donelinks) {
if (this.intersects(possibleline,donelinks[i])) {
intersection++;
if (possibleline.isFanLink && outbound == 1) centerOutgoings--;
break;
}
}
for (i in fanlinks) {
if (this.intersects(possibleline,fanlinks[i])) {
intersection++;
if (possibleline.isFanLink && outbound == 1) centerOutgoings--;
break;
}
}

if (centerOutgoings > 8 && centerOutgoings < maxLinks) {
// count sbul
centerSbul = Math.ceil((centerOutgoings - 8) / 8);
}

if (intersection === 0) {
//console.log("FANPOINTS: " + pa + " - "+pb+" bearing: " + bearing + "° " + this.bearingWord(bearing));
// Check if Link is a jetlink and add second field
Expand Down

0 comments on commit 6987991

Please sign in to comment.