From a33bdcbf3843b49b1052c1a6dabbf1b8d50dfe62 Mon Sep 17 00:00:00 2001 From: fkloft Date: Wed, 16 Oct 2013 19:03:39 +0200 Subject: [PATCH] Show link range details for partially deployed portals. Calculates the link range for portals with <8 resonators as well, but uses a dashed circle and a striked-through range value for those. The tooltip over the range value in the details pane shows base range, link amp boost and total range. The range for portals with missing resonators can be important because links with shorter lengths might originate here. Those will collapse when the total link range drops below their length, but not as soon as a resonator is destroyed. --- code/portal_detail_display.js | 9 +++++++-- code/portal_detail_display_tools.js | 17 +++++++++++++---- code/portal_info.js | 14 ++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index b2771d3f..f2f513bd 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -145,8 +145,13 @@ window.setPortalIndicators = function(d) { var range = getPortalRange(d); var coord = [d.locationE6.latE6/1E6, d.locationE6.lngE6/1E6]; - portalRangeIndicator = (range > 0 - ? L.geodesicCircle(coord, range, { fill: false, color: RANGE_INDICATOR_COLOR, weight: 3, clickable: false }) + portalRangeIndicator = (range.range > 0 + ? L.geodesicCircle(coord, range.range, { + fill: false, + color: RANGE_INDICATOR_COLOR, + weight: 3, + dashArray: range.isLinkable ? undefined : "10,10", + clickable: false }) : L.circle(coord, range, { fill: false, stroke: false, clickable: false }) ).addTo(map); diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index a1196d60..353189d9 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -5,11 +5,20 @@ // returns displayable text+link about portal range window.getRangeText = function(d) { var range = getPortalRange(d); + + var title = 'Base range:\t' + digits(Math.floor(range.base))+'m' + + '\nLink amp boost:\t×'+range.boost + + '\nRange:\t'+digits(Math.floor(range.range))+'m'; + + if(!range.isLinkable) title += '\nPortal is missing resonators,\nno new links can be made'; + return ['range', - '' - + (range > 1000 - ? Math.floor(range/1000) + ' km' - : Math.floor(range) + ' m') + '' + + (range.range > 1000 + ? Math.floor(range.range/1000) + ' km' + : Math.floor(range.range) + ' m') + '']; } diff --git a/code/portal_info.js b/code/portal_info.js index a6a5bc01..569f8f0f 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -47,18 +47,20 @@ window.getPortalRange = function(d) { $.each(d.resonatorArray.resonators, function(ind, reso) { if(!reso) { resoMissing = true; - return false; + return; } lvl += parseInt(reso.level); }); - if(resoMissing) return 0; - var range = 160*Math.pow(getPortalLevel(d), 4); + var range = { + base: 160*Math.pow(getPortalLevel(d), 4), + boost: getLinkAmpRangeBoost(d) + }; - var boost = getLinkAmpRangeBoost(d); - - return range*boost; + range.range = range.boost * range.base; + range.isLinkable = !resoMissing; + return range; } window.getLinkAmpRangeBoost = function(d) {