Skip to content

Commit

Permalink
timestamp in link and field data
Browse files Browse the repository at this point in the history
  • Loading branch information
xscreach committed Jul 20, 2023
1 parent 3134b59 commit 33c2883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions core/code/map_data_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -383,14 +385,15 @@ 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] }; })
};

//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
Expand Down Expand Up @@ -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,
});

Expand All @@ -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],
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/total-conversion-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.script_info = plugin_info;
window.script_info.changelog = [
{
version: '0.36.0',
changes: ['Ability to define and display changelog'],
changes: ['Ability to define and display changelog', 'Timestamp added to link and field data'],
},
];

Expand Down

0 comments on commit 33c2883

Please sign in to comment.