From 86327fa5785f22267eace7d94d8e1688642c195c Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sat, 17 May 2014 00:27:15 +0100 Subject: [PATCH] niantic removed controllingTeam from the portal details - we have to use the team from the summary data --- code/entity_info.js | 2 +- code/portal_detail_display.js | 4 +++- code/portal_detail_display_tools.js | 2 +- code/portal_info.js | 10 ++++++---- plugins/show-linked-portals.user.js | 6 +++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/code/entity_info.js b/code/entity_info.js index ef856d3a..2d340976 100644 --- a/code/entity_info.js +++ b/code/entity_info.js @@ -8,7 +8,7 @@ // given the entity detail data, returns the team the entity belongs // to. Uses TEAM_* enum values. window.getTeam = function(details) { - return teamStringToId(details.controllingTeam.team); + return teamStringToId(details.controllingTeam && details.controllingTeam.team); } window.teamStringToId = function(teamStr) { diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 0e7db7c3..92389ae3 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -28,7 +28,9 @@ window.renderPortalDetails = function(guid) { // details and data can get out of sync. if we have details, construct a matching 'data' if (details) { - data = getPortalSummaryData(details); + // the details had the team removed(!) - so we have to use the team in the summary data + // however - this can easily be out of date in areas of heavy activity - so could be just plain wrong! + data = getPortalSummaryData(details, data && data.team); } diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index e6ad01d8..e9bc3e7a 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -231,7 +231,7 @@ window.getAttackApGainText = function(d,fieldCount) { function tt(text) { var t = ''; - if (PLAYER.team == d.controllingTeam.team) { + if (d.controllingTeam && PLAYER.team == d.controllingTeam.team) { totalGain = breakdown.friendlyAp; t += 'Friendly AP:\t' + breakdown.friendlyAp + '\n'; t += ' Deploy ' + breakdown.deployCount + ', '; diff --git a/code/portal_info.js b/code/portal_info.js index 93434d8f..3db0288a 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -162,7 +162,7 @@ window.potentialPortalLevel = function(d) { var current_level = getPortalLevel(d); var potential_level = current_level; - if(PLAYER.team === d.controllingTeam.team) { + if(d.controllingTeam && PLAYER.team === d.controllingTeam.team) { var resonators_on_portal = d.resonatorArray.resonators; var resonator_levels = new Array(); // figure out how many of each of these resonators can be placed by the player @@ -311,10 +311,12 @@ window.getPortalHackDetails = function(d) { } // given a detailed portal structure, return summary portal data, as seen in the map tile data -window.getPortalSummaryData = function(d) { +window.getPortalSummaryData = function(d,probableTeamStr) { // NOTE: the summary data reports unclaimed portals as level 1 - not zero as elsewhere in IITC - var level = d.controllingTeam.team == "NEUTRAL" ? 1 : parseInt(getPortalLevel(d)); + var level = parseInt(getPortalLevel(d)); + if (level == 0) level = 1; //niantic returns neutral portals as level 1, not 0 as used throughout IITC elsewhere + var resCount = 0; if (d.resonatorArray && d.resonatorArray.resonators) { for (var x in d.resonatorArray.resonators) { @@ -332,7 +334,7 @@ window.getPortalSummaryData = function(d) { resCount: resCount, latE6: d.locationE6.latE6, health: health, - team: d.controllingTeam.team, + team: d.controllingTeam ? d.controllingTeam.team : probableTeamStr, lngE6: d.locationE6.lngE6, type: 'portal' }; diff --git a/plugins/show-linked-portals.user.js b/plugins/show-linked-portals.user.js index b8427d1f..1ad92500 100644 --- a/plugins/show-linked-portals.user.js +++ b/plugins/show-linked-portals.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-show-linked-portals@fstopienski // @name IITC plugin: Show linked portals // @category Portal Info -// @version 0.1.1.@@DATETIMEVERSION@@ +// @version 0.1.2.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -38,8 +38,8 @@ window.plugin.showLinkedPortal.portalDetail = function (data) { // don't render linked portal data if portal is neutral. // (the data can remain sometimes - when a portal decays?) - if (data.portalDetails.controllingTeam.team == 'NEUTRAL') - return; +// if (data.portalDetails.controllingTeam.team == 'NEUTRAL') +// return; var d = data.portalDetails.portalV2, c = 1;