hacky workaround for request munging issues - check for issues in the updateGameStatus function

This commit is contained in:
Jon Atkins 2013-08-31 17:44:16 +01:00
parent 61177c4cda
commit 8448b71fae

View File

@ -1,12 +1,35 @@
// GAME STATUS /////////////////////////////////////////////////////// // GAME STATUS ///////////////////////////////////////////////////////
// MindUnit display // MindUnit display
window.window.updateGameScoreFailCount = 0;
window.updateGameScore = function(data) { window.updateGameScore = function(data) {
if(!data) { if(!data) {
window.postAjax('getGameScore', {}, window.updateGameScore); window.postAjax('getGameScore', {}, window.updateGameScore);
return; return;
} }
// hacky - but here is as good as any for a location
// the niantic servers have attempted to obsfucate the client/server protocol, by munging the request parameters
// detecting which munge set should be used is tricky - even the stock site gets it wrong sometimes
// to detect the problem and try a different set is easiest in a place where there's only a single request of that type
// sent at once, and it has no extra parameters. this method matches those requirements
if (data == '{"error": "invalid method params"}' || data.error) {
window.window.updateGameScoreFailCount++;
if (window.window.updateGameScoreFailCount < 5) {
window.activeRequestMungeSet = (window.activeRequestMungeSet+1) % window.requestParameterMunges.length;
console.warn('IITC munge issue - cycling to set '+window.activeRequestMungeSet);
updateGameScore();
return;
} else {
console.error('IITC munge issue - and retry limit reached. IITC will likely fail');
}
}
window.window.updateGameScoreFailCount = 0;
var r = parseInt(data.result.resistanceScore), e = parseInt(data.result.enlightenedScore); var r = parseInt(data.result.resistanceScore), e = parseInt(data.result.enlightenedScore);
var s = r+e; var s = r+e;
var rp = r/s*100, ep = e/s*100; var rp = r/s*100, ep = e/s*100;