From d245543a4b1767b30166fd4392dfc0a55bbe2e3c Mon Sep 17 00:00:00 2001 From: xscreach Date: Thu, 20 Jul 2023 04:27:08 +0200 Subject: [PATCH 1/5] timestamp in link and field data --- core/code/map_data_render.js | 14 +++++++++----- core/total-conversion-build.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/code/map_data_render.js b/core/code/map_data_render.js index 048fde7e7..1a2c7e3ac 100644 --- a/core/code/map_data_render.js +++ b/core/code/map_data_render.js @@ -233,13 +233,15 @@ window.Render.prototype.deleteFieldEntity = function(guid) { } -window.Render.prototype.createPlaceholderPortalEntity = function(guid,latE6,lngE6,team) { +window.Render.prototype.createPlaceholderPortalEntity = function (guid, latE6, lngE6, team, timestamp) { // intel no longer returns portals at anything but the closest zoom // stock intel creates 'placeholder' portals from the data in links/fields - IITC needs to do the same // we only have the portal guid, lat/lng coords, and the faction - no other data // having the guid, at least, allows the portal details to be loaded once it's selected. however, // no highlighters, portal level numbers, portal names, useful counts of portals, etc are possible + // zero will mean any other source of portal data will have a higher timestamp + timestamp = timestamp || 0; var ent = [ guid, //ent[0] = guid @@ -383,6 +385,7 @@ window.Render.prototype.createFieldEntity = function(ent) { var data = { // type: ent[2][0], + timestamp: ent[1], team: ent[2][1], points: ent[2][2].map(function(arr) { return {guid: arr[0], latE6: arr[1], lngE6: arr[2] }; }) }; @@ -390,7 +393,7 @@ window.Render.prototype.createFieldEntity = function(ent) { //create placeholder portals for field corners. we already do links, but there are the odd case where this is useful for (var i=0; i<3; i++) { var p=data.points[i]; - this.createPlaceholderPortalEntity(p.guid, p.latE6, p.lngE6, data.team); + this.createPlaceholderPortalEntity(p.guid, p.latE6, p.lngE6, data.team, data.timestamp); } // check if entity already exists @@ -423,7 +426,7 @@ window.Render.prototype.createFieldEntity = function(ent) { team: team, ent: ent, // LEGACY - TO BE REMOVED AT SOME POINT! use .guid, .timestamp and .data instead guid: ent[0], - timestamp: ent[1], + timestamp: data.timestamp, data: data, }); @@ -447,6 +450,7 @@ window.Render.prototype.createLinkEntity = function (ent) { var data = { // TODO add other properties and check correction direction // type: ent[2][0], + timestamp: ent[1], team: ent[2][1], oGuid: ent[2][2], oLatE6: ent[2][3], @@ -457,8 +461,8 @@ window.Render.prototype.createLinkEntity = function (ent) { }; // create placeholder entities for link start and end points (before checking if the link itself already exists - this.createPlaceholderPortalEntity(data.oGuid, data.oLatE6, data.oLngE6, data.team); - this.createPlaceholderPortalEntity(data.dGuid, data.dLatE6, data.dLngE6, data.team); + this.createPlaceholderPortalEntity(data.oGuid, data.oLatE6, data.oLngE6, data.team, data.timestamp); + this.createPlaceholderPortalEntity(data.dGuid, data.dLatE6, data.dLngE6, data.team, data.timestamp); // check if entity already exists diff --git a/core/total-conversion-build.js b/core/total-conversion-build.js index 58989793c..3066c9f2a 100644 --- a/core/total-conversion-build.js +++ b/core/total-conversion-build.js @@ -9,7 +9,7 @@ window.script_info = plugin_info; window.script_info.changelog = [ { version: '0.36.0', - changes: ['Ability to define and display changelog', 'Improved info panel styling'], + changes: ['Ability to define and display changelog', 'Improved info panel styling', 'Timestamp added to link and field data'], }, ]; From 8ec7a13da2e8ea5c45d7d1dbfc4756c1b814fd20 Mon Sep 17 00:00:00 2001 From: xscreach Date: Thu, 20 Jul 2023 04:28:56 +0200 Subject: [PATCH 2/5] raw data with readable timestamp for links and fields --- plugins/debug-raw-portal-data.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/debug-raw-portal-data.js b/plugins/debug-raw-portal-data.js index 15fa51dfc..de3fcee10 100644 --- a/plugins/debug-raw-portal-data.js +++ b/plugins/debug-raw-portal-data.js @@ -1,9 +1,17 @@ // @author jonatkins // @name Debug: Raw portal JSON data // @category Portal Info -// @version 0.2.4 +// @version 0.2.5 // @description Developer debugging aid: Add a link to the portal details to show the raw data of a portal. +/* exported setup, changelog --eslint */ + +var changelog = [ + { + version: '0.2.5', + changes: ['Added human readable timestamp for portal links and fields'], + }, +]; // use own namespace for plugin window.plugin.rawdata = function() {}; @@ -28,10 +36,9 @@ window.plugin.rawdata.showPortalData = function(guid) { var title = 'Raw portal data: ' + (data.title || ''); - var body = - 'Portal GUID: '+guid+'
' + - 'Entity timestamp: '+ts+' - '+window.unixTimeToDateTimeString(ts,true)+'
' + - 'Portal map data:
'+JSON.stringify(data,null,2)+'
'; + var body = `Portal GUID: ${guid}
+ Entity timestamp: ${ts} - ${window.unixTimeToDateTimeString(ts, true)}
+ Portal map data:
${JSON.stringify(data, null, 2)}
`; var details = portalDetail.get(guid); if (details) { @@ -45,7 +52,9 @@ window.plugin.rawdata.showPortalData = function(guid) { $.each(linkGuids.in.concat(linkGuids.out), function(i,lguid) { var l = window.links[lguid]; var ld = l.options.data; - body += 'Link GUID: '+l.options.guid+'
'+JSON.stringify(ld,null,2)+'
'; + body += `Link GUID: ${l.options.guid}
+ Entity timestamp: ${ld.timestamp} - ${window.unixTimeToDateTimeString(ld.timestamp, true)}
+
${JSON.stringify(ld, null, 2)}
`; haslinks = true; }); @@ -57,7 +66,9 @@ window.plugin.rawdata.showPortalData = function(guid) { $.each(fieldGuids, function(i,fguid) { var f = window.fields[fguid]; var fd = f.options.data; - body += 'Field guid: '+f.options.guid+'
'+JSON.stringify(fd,null,2)+'
'; + body += `Field guid: ${f.options.guid}
+ Entity timestamp: ${fd.timestamp} - ${window.unixTimeToDateTimeString(fd.timestamp, true)}
+
${JSON.stringify(fd, null, 2)}
`; hasfields = true; }); if (!hasfields) body += '

No fields linked to this portal

'; From b18f76a71e76c2dfbe0227dd9c936631e2a07bd2 Mon Sep 17 00:00:00 2001 From: xscreach Date: Thu, 20 Jul 2023 04:30:23 +0200 Subject: [PATCH 3/5] fix jumpy portals on ghostlinks --- core/code/map_data_render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/code/map_data_render.js b/core/code/map_data_render.js index 1a2c7e3ac..72f25b303 100644 --- a/core/code/map_data_render.js +++ b/core/code/map_data_render.js @@ -261,7 +261,7 @@ window.Render.prototype.createPlaceholderPortalEntity = function (guid, latE6, l if (guid in window.portals) { var p = window.portals[guid]; portalMoved = latE6 !== p.options.data.latE6 || lngE6 !== p.options.data.lngE6; - if (team !== p.options.data.team) { + if (team !== p.options.data.team && p.options.timestamp < timestamp) { // team - delete existing portal this.deletePortalEntity(guid); } From 43ac9c8c27f6d81a55471f7b6d6c832c0e95e7e7 Mon Sep 17 00:00:00 2001 From: xscreach Date: Thu, 20 Jul 2023 04:36:15 +0200 Subject: [PATCH 4/5] eslint + indentation --- core/code/map_data_render.js | 1 - plugins/debug-raw-portal-data.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/code/map_data_render.js b/core/code/map_data_render.js index 72f25b303..e12fedf8d 100644 --- a/core/code/map_data_render.js +++ b/core/code/map_data_render.js @@ -464,7 +464,6 @@ window.Render.prototype.createLinkEntity = function (ent) { this.createPlaceholderPortalEntity(data.oGuid, data.oLatE6, data.oLngE6, data.team, data.timestamp); this.createPlaceholderPortalEntity(data.dGuid, data.dLatE6, data.dLngE6, data.team, data.timestamp); - // check if entity already exists if (ent[0] in window.links) { var l = window.links[ent[0]]; diff --git a/plugins/debug-raw-portal-data.js b/plugins/debug-raw-portal-data.js index de3fcee10..4e88487bf 100644 --- a/plugins/debug-raw-portal-data.js +++ b/plugins/debug-raw-portal-data.js @@ -37,8 +37,8 @@ window.plugin.rawdata.showPortalData = function(guid) { var title = 'Raw portal data: ' + (data.title || ''); var body = `Portal GUID: ${guid}
- Entity timestamp: ${ts} - ${window.unixTimeToDateTimeString(ts, true)}
- Portal map data:
${JSON.stringify(data, null, 2)}
`; + Entity timestamp: ${ts} - ${window.unixTimeToDateTimeString(ts, true)}
+ Portal map data:
${JSON.stringify(data, null, 2)}
`; var details = portalDetail.get(guid); if (details) { From da5811457b177773ad1d97699d74d537baec2ae5 Mon Sep 17 00:00:00 2001 From: xscreach Date: Tue, 25 Jul 2023 03:28:58 +0200 Subject: [PATCH 5/5] prevent portal data without timestamp (0) clash with placeholder timestamp (now -1) --- core/code/map_data_render.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/code/map_data_render.js b/core/code/map_data_render.js index e12fedf8d..4367a5a3c 100644 --- a/core/code/map_data_render.js +++ b/core/code/map_data_render.js @@ -244,14 +244,15 @@ window.Render.prototype.createPlaceholderPortalEntity = function (guid, latE6, l timestamp = timestamp || 0; var ent = [ - guid, //ent[0] = guid - 0, //ent[1] = timestamp - zero will mean any other source of portal data will have a higher timestamp - //ent[2] = an array with the entity data - [ 'p', //0 - a portal - team, //1 - team - latE6, //2 - lat - lngE6 //3 - lng - ] + guid, // ent[0] = guid + -1, // ent[1] = timestamp - zero will mean any other source of portal data will have a higher timestamp + // ent[2] = an array with the entity data + [ + 'p', // 0 - a portal + team, // 1 - team + latE6, // 2 - lat + lngE6, // 3 - lng + ], ]; // placeholder portals don't have a useful timestamp value - so the standard code that checks for updated