New Feature: Remove lower level portal when portal render limit reached
This commit is contained in:
parent
4b3348e5d4
commit
17a81c09d9
@ -70,6 +70,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
// https://github.com/Leaflet/Leaflet/issues/185
|
// https://github.com/Leaflet/Leaflet/issues/185
|
||||||
var ppp = [];
|
var ppp = [];
|
||||||
var p2f = {};
|
var p2f = {};
|
||||||
|
PRL.resetOrInit();
|
||||||
$.each(m, function(qk, val) {
|
$.each(m, function(qk, val) {
|
||||||
$.each(val.deletedGameEntityGuids, function(ind, guid) {
|
$.each(val.deletedGameEntityGuids, function(ind, guid) {
|
||||||
if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) {
|
if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) {
|
||||||
@ -98,7 +99,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
) return;
|
) return;
|
||||||
|
|
||||||
|
|
||||||
|
PRL.pushPortal(ent);
|
||||||
ppp.push(ent); // delay portal render
|
ppp.push(ent); // delay portal render
|
||||||
} else if(ent[2].edge !== undefined) {
|
} else if(ent[2].edge !== undefined) {
|
||||||
renderLink(ent);
|
renderLink(ent);
|
||||||
@ -147,6 +148,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
|
|
||||||
if(portalUpdateAvailable) renderPortalDetails(selectedPortal);
|
if(portalUpdateAvailable) renderPortalDetails(selectedPortal);
|
||||||
resolvePlayerNames();
|
resolvePlayerNames();
|
||||||
|
renderUpdateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// removes entities that are still handled by Leaflet, although they
|
// removes entities that are still handled by Leaflet, although they
|
||||||
|
@ -2,6 +2,60 @@
|
|||||||
|
|
||||||
// UTILS + MISC ///////////////////////////////////////////////////////
|
// UTILS + MISC ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// PRL - Portal Render Limit
|
||||||
|
window.PRL = function() {}
|
||||||
|
|
||||||
|
window.PRL.resetOrInit = function () {
|
||||||
|
PRL.initialized = true;
|
||||||
|
PRL.minLevel = -1;
|
||||||
|
PRL.minLevelSet = false;
|
||||||
|
PRL.newPortalsPerLevel = new Array(MAX_PORTAL_LEVEL+1);
|
||||||
|
for(var i = 0; i <= MAX_PORTAL_LEVEL; i++) {
|
||||||
|
PRL.newPortalsPerLevel[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.PRL.pushPortal = function(ent) {
|
||||||
|
var portalGuid = ent[0];
|
||||||
|
var portalLevel = parseInt(getPortalLevel(ent[2]));
|
||||||
|
var layerGroup = portalsLayers[portalLevel];
|
||||||
|
|
||||||
|
if(findEntityInLeaflet(layerGroup, window.portals, ent[0])) return;
|
||||||
|
PRL.newPortalsPerLevel[portalLevel]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.PRL.getMinLevel = function() {
|
||||||
|
if(!PRL.initialized) return -1;
|
||||||
|
if(!PRL.minLevelSet) PRL.setMinLevel();
|
||||||
|
return PRL.minLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.PRL.setMinLevel = function() {
|
||||||
|
var totalPortalsCount = 0;
|
||||||
|
PRL.minLevel = MAX_PORTAL_LEVEL + 1;
|
||||||
|
|
||||||
|
// Find the min portal level under render limit
|
||||||
|
while(PRL.minLevel > 0) {
|
||||||
|
var oldPortalCount = layerGroupLength(portalsLayers[PRL.minLevel - 1]);
|
||||||
|
totalPortalsCount += oldPortalCount + PRL.newPortalsPerLevel[PRL.minLevel - 1];
|
||||||
|
if(totalPortalsCount >= MAX_DRAWN_PORTALS)
|
||||||
|
break;
|
||||||
|
PRL.minLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If render limit reached at max portal level, still let portal at max level render
|
||||||
|
if(PRL.minLevel === MAX_PORTAL_LEVEL + 1) PRL.minLevel = MAX_PORTAL_LEVEL;
|
||||||
|
PRL.minLevelSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.layerGroupLength = function(layerGroup) {
|
||||||
|
var layersCount = 0;
|
||||||
|
var layers = layerGroup._layers;
|
||||||
|
if (layers)
|
||||||
|
layersCount = Object.keys(layers).length;
|
||||||
|
return layersCount;
|
||||||
|
}
|
||||||
|
|
||||||
// retrieves parameter from the URL?query=string.
|
// retrieves parameter from the URL?query=string.
|
||||||
window.getURLParam = function(param) {
|
window.getURLParam = function(param) {
|
||||||
var v = document.URL;
|
var v = document.URL;
|
||||||
@ -152,7 +206,11 @@ window.getMinPortalLevel = function() {
|
|||||||
var z = map.getZoom();
|
var z = map.getZoom();
|
||||||
if(z >= 16) return 0;
|
if(z >= 16) return 0;
|
||||||
var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1];
|
var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1];
|
||||||
return conv[z];
|
var minLevelByRenderLimit = PRL.getMinLevel();
|
||||||
|
var result = minLevelByRenderLimit > conv[z]
|
||||||
|
? minLevelByRenderLimit
|
||||||
|
: conv[z];
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns number of pixels left to scroll down before reaching the
|
// returns number of pixels left to scroll down before reaching the
|
||||||
|
1
main.js
1
main.js
@ -186,6 +186,7 @@ window.DESTROY_FIELD = 750; //AP for destroying field
|
|||||||
window.CAPTURE_PORTAL = 500; //AP for capturing a portal
|
window.CAPTURE_PORTAL = 500; //AP for capturing a portal
|
||||||
window.DEPLOY_RESONATOR = 125; //AP for deploying a resonator
|
window.DEPLOY_RESONATOR = 125; //AP for deploying a resonator
|
||||||
window.COMPLETION_BONUS = 250; //AP for deploying all resonators on portal
|
window.COMPLETION_BONUS = 250; //AP for deploying all resonators on portal
|
||||||
|
window.MAX_PORTAL_LEVEL = 8;
|
||||||
|
|
||||||
// OTHER MORE-OR-LESS CONSTANTS //////////////////////////////////////
|
// OTHER MORE-OR-LESS CONSTANTS //////////////////////////////////////
|
||||||
window.TEAM_NONE = 0;
|
window.TEAM_NONE = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user