placeholder portals created from link ends

surprisingly few issues, but i'm sure quite a few plugins break badly
This commit is contained in:
Jon Atkins
2015-06-28 19:14:17 +01:00
parent 701f09db58
commit 00b546cb98
4 changed files with 60 additions and 44 deletions

View File

@ -268,7 +268,7 @@ window.Render.prototype.createPlaceholderPortalEntity = function(guid,latE6,lngE
]
];
// this.createPortalEntity(ent);
this.createPortalEntity(ent);
}
@ -296,7 +296,7 @@ window.Render.prototype.createPortalEntity = function(ent) {
this.deletePortalEntity(ent[0]);
}
var portalLevel = parseInt(ent[2][4]);
var portalLevel = parseInt(ent[2][4])||0;
var team = teamStringToId(ent[2][1]);
// the data returns unclaimed portals as level 1 - but IITC wants them treated as level 0
if (team == TEAM_NONE) portalLevel = 0;
@ -409,6 +409,22 @@ window.Render.prototype.createFieldEntity = function(ent) {
window.Render.prototype.createLinkEntity = function(ent,faked) {
this.seenLinksGuid[ent[0]] = true; // flag we've seen it
var data = { // TODO add other properties and check correction direction
// type: ent[2][0],
team: ent[2][1],
oGuid: ent[2][2],
oLatE6: ent[2][3],
oLngE6: ent[2][4],
dGuid: ent[2][5],
dLatE6: ent[2][6],
dLngE6: ent[2][7]
};
// 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);
// check if entity already exists
if (ent[0] in window.links) {
// yes. now, as sometimes links are 'faked', they have incomplete data. if the data we have is better, replace the data
@ -423,17 +439,6 @@ window.Render.prototype.createLinkEntity = function(ent,faked) {
this.deleteLinkEntity(ent[0]); // option 2 - for now
}
var data = { // TODO add other properties and check correction direction
// type: ent[2][0],
team: ent[2][1],
oGuid: ent[2][2],
oLatE6: ent[2][3],
oLngE6: ent[2][4],
dGuid: ent[2][5],
dLatE6: ent[2][6],
dLngE6: ent[2][7]
};
var team = teamStringToId(ent[2][1]);
var latlngs = [
L.latLng(data.oLatE6/1E6, data.oLngE6/1E6),
@ -457,14 +462,6 @@ window.Render.prototype.createLinkEntity = function(ent,faked) {
window.links[ent[0]] = poly;
linksFactionLayers[poly.options.team].addLayer(poly);
// create placeholder entities for link start and end points
this.createPlaceholderPortalEntity(data.oGuid, data.oLatE6, data.oLngE6, data.team);
this.createPlaceholderPortalEntity(data.dGuid, data.dLatE6, data.dLngE6, data.team);
}
@ -485,12 +482,12 @@ window.Render.prototype.rescalePortalMarkers = function() {
// add the portal to the visible map layer
window.Render.prototype.addPortalToMapLayer = function(portal) {
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].addLayer(portal);
portalsFactionLayers[parseInt(portal.options.level)||0][portal.options.team].addLayer(portal);
}
window.Render.prototype.removePortalFromMapLayer = function(portal) {
//remove it from the portalsLevels layer
portalsFactionLayers[parseInt(portal.options.level)][portal.options.team].removeLayer(portal);
portalsFactionLayers[parseInt(portal.options.level)||0][portal.options.team].removeLayer(portal);
}