fix warning/debug break on details passed to summary decode
This commit is contained in:
parent
2886e0be07
commit
282e184f56
@ -37,10 +37,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var summaryArrayLength = 14;
|
|
||||||
|
|
||||||
//there's also a 'placeholder' portal - generated from the data in links/fields. only has team/lat/lng
|
//there's also a 'placeholder' portal - generated from the data in links/fields. only has team/lat/lng
|
||||||
|
|
||||||
|
var CORE_PORTA_DATA_LENGTH = 4;
|
||||||
function corePortalData(a) {
|
function corePortalData(a) {
|
||||||
return {
|
return {
|
||||||
// a[0] == type (always 'p')
|
// a[0] == type (always 'p')
|
||||||
@ -50,6 +49,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var SUMMARY_PORTAL_DATA_LENGTH = 14;
|
||||||
function summaryPortalData(a) {
|
function summaryPortalData(a) {
|
||||||
return {
|
return {
|
||||||
level: a[4],
|
level: a[4],
|
||||||
@ -65,16 +65,21 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var DETAILED_PORTAL_DATA_LENGTH = SUMMARY_PORTAL_DATA_LENGTH+4;
|
||||||
|
|
||||||
|
|
||||||
window.decodeArray.portalSummary = function(a) {
|
window.decodeArray.portalSummary = function(a) {
|
||||||
if (!a) return undefined;
|
if (!a) return undefined;
|
||||||
|
|
||||||
if (a[0] != 'p') throw 'Error: decodeArray.portalSUmmary - not a portal';
|
if (a[0] != 'p') throw 'Error: decodeArray.portalSUmmary - not a portal';
|
||||||
|
|
||||||
if (a.length == 4) {
|
if (a.length == CORE_PORTA_DATA_LENGTH) {
|
||||||
return corePortalData(a);
|
return corePortalData(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.length != summaryArrayLength) {
|
// NOTE: allow for either summary or detailed portal data to be passed in here, as details are sometimes
|
||||||
|
// passed into code only expecting summaries
|
||||||
|
if (a.length != SUMMARY_PORTAL_DATA_LENGTH && a.length != DETAILED_PORTAL_DATA_LENGTH) {
|
||||||
console.warn('Portal summary length changed - portal details likely broken!');
|
console.warn('Portal summary length changed - portal details likely broken!');
|
||||||
debugger;
|
debugger;
|
||||||
}
|
}
|
||||||
@ -87,18 +92,22 @@
|
|||||||
|
|
||||||
if (a[0] != 'p') throw 'Error: decodeArray.portalDetail - not a portal';
|
if (a[0] != 'p') throw 'Error: decodeArray.portalDetail - not a portal';
|
||||||
|
|
||||||
|
if (a.length != DETAILED_PORTAL_DATA_LENGTH) {
|
||||||
|
console.warn('Portal detail length changed - portal details may be wrong');
|
||||||
|
debugger;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO look at the array values, make a better guess as to which index the mods start at, rather than using the hard-coded summaryArrayLength constant
|
//TODO look at the array values, make a better guess as to which index the mods start at, rather than using the hard-coded SUMMARY_PORTAL_DATA_LENGTH constant
|
||||||
|
|
||||||
|
|
||||||
// the portal details array is just an extension of the portal summary array
|
// the portal details array is just an extension of the portal summary array
|
||||||
// to allow for niantic adding new items into the array before the extended details start,
|
// to allow for niantic adding new items into the array before the extended details start,
|
||||||
// use the length of the summary array
|
// use the length of the summary array
|
||||||
return $.extend(corePortalData(a), summaryPortalData(a),{
|
return $.extend(corePortalData(a), summaryPortalData(a),{
|
||||||
mods: a[summaryArrayLength+0].map(parseMod),
|
mods: a[SUMMARY_PORTAL_DATA_LENGTH+0].map(parseMod),
|
||||||
resonators:a[summaryArrayLength+1].map(parseResonator),
|
resonators:a[SUMMARY_PORTAL_DATA_LENGTH+1].map(parseResonator),
|
||||||
owner: a[summaryArrayLength+2],
|
owner: a[SUMMARY_PORTAL_DATA_LENGTH+2],
|
||||||
artifact: parseArtifact(a[summaryArrayLength+3]),
|
artifact: parseArtifact(a[SUMMARY_PORTAL_DATA_LENGTH+3]),
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user