diff --git a/code/artifact.js b/code/artifact.js index b15fafe4..2a6164ab 100644 --- a/code/artifact.js +++ b/code/artifact.js @@ -171,7 +171,7 @@ window.artifact.updateLayer = function() { artifact._layer.clearLayers(); $.each(artifact.portalInfo, function(guid,data) { - var latlng = L.latLng ([data._entityData.locationE6.latE6/1E6, data._entityData.locationE6.lngE6/1E6]); + var latlng = L.latLng ([data._entityData.latE6/1E6, data._entityData.lngE6/1E6]); // jarvis shard icon var iconUrl = undefined; @@ -235,7 +235,7 @@ window.artifact.showArtifactList = function() { var sortVal = 0; - var onclick = 'zoomToAndShowPortal(\''+guid+'\',['+data._entityData.locationE6.latE6/1E6+','+data._entityData.locationE6.lngE6/1E6+'])'; + var onclick = 'zoomToAndShowPortal(\''+guid+'\',['+data._entityData.latE6/1E6+','+data._entityData.lngE6/1E6+'])'; var row = ''+escapeHtmlSpecialChars(data._entityData.portalV2.descriptiveText.TITLE)+''; row += ''; diff --git a/code/chat.js b/code/chat.js index 59e398bb..822da914 100644 --- a/code/chat.js +++ b/code/chat.js @@ -127,7 +127,7 @@ window.chat.requestFaction = function(getOlderMsgs, isRetry) { var d = chat.genPostData(true, chat._faction, getOlderMsgs); var r = window.postAjax( - 'getPaginatedPlextsV2', + 'getPaginatedPlexts', d, function(data, textStatus, jqXHR) { chat.handleFaction(data, getOlderMsgs); }, isRetry @@ -178,7 +178,7 @@ window.chat.requestPublic = function(getOlderMsgs, isRetry) { var d = chat.genPostData(false, chat._public, getOlderMsgs); var r = window.postAjax( - 'getPaginatedPlextsV2', + 'getPaginatedPlexts', d, function(data, textStatus, jqXHR) { chat.handlePublic(data, getOlderMsgs); }, isRetry diff --git a/code/entity_info.js b/code/entity_info.js index 16fc06f4..ef856d3a 100644 --- a/code/entity_info.js +++ b/code/entity_info.js @@ -8,8 +8,14 @@ // given the entity detail data, returns the team the entity belongs // to. Uses TEAM_* enum values. window.getTeam = function(details) { + return teamStringToId(details.controllingTeam.team); +} + +window.teamStringToId = function(teamStr) { var team = TEAM_NONE; - if(details.controllingTeam.team === 'ALIENS' || details.controllingTeam.team === 'ENLIGHTENED') team = TEAM_ENL; - if(details.controllingTeam.team === 'RESISTANCE') team = TEAM_RES; + if(teamStr === 'ENLIGHTENED') team = TEAM_ENL; + if(teamStr === 'RESISTANCE') team = TEAM_RES; return team; } + + diff --git a/code/map_data_render.js b/code/map_data_render.js index df354c4b..2e1d43f8 100644 --- a/code/map_data_render.js +++ b/code/map_data_render.js @@ -104,7 +104,6 @@ window.Render.prototype.processDeletedGameEntityGuids = function(deleted) { } window.Render.prototype.processGameEntities = function(entities) { - var portalGuids = []; for (var i in entities) { var ent = entities[i]; @@ -112,14 +111,9 @@ window.Render.prototype.processGameEntities = function(entities) { // don't create entities in the 'deleted' list if (!(ent[0] in this.deletedGuid)) { this.createEntity(ent); - if ('portalV2' in ent[2]) portalGuids.push(ent[0]); } } - // now reconstruct links 'optimised' out of the data from the portal link data - for (var i in portalGuids) { - this.createLinksFromPortalData(portalGuids[i]); - } } @@ -130,6 +124,7 @@ window.Render.prototype.endRenderPass = function() { // check to see if there are any entities we haven't seen. if so, delete them for (var guid in window.portals) { // special case for selected portal - it's kept even if not seen + // artifact (e.g. jarvis shard) portals are also kept - but they're always 'seen' if (!(guid in this.seenPortalsGuid) && guid !== selectedPortal) { this.deletePortalEntity(guid); } @@ -214,22 +209,6 @@ window.Render.prototype.deleteFieldEntity = function(guid) { var f = window.fields[guid]; var fd = f.options.details; - var deletePortalLinkedField = function(pguid) { - if (pguid in window.portals) { - var pd = window.portals[pguid].options.details; - if (pd.portalV2.linkedFields) { - var i = pd.portalV2.linkedFields.indexOf(guid); - if (i >= 0) { - pd.portalV2.linkedFields.splice(i,1); - } - } - } - } - - deletePortalLinkedField (fd.capturedRegion.vertexA.guid); - deletePortalLinkedField (fd.capturedRegion.vertexB.guid); - deletePortalLinkedField (fd.capturedRegion.vertexC.guid); - fieldsFactionLayers[f.options.team].removeLayer(f); delete window.fields[guid]; } @@ -244,23 +223,30 @@ window.Render.prototype.createEntity = function(ent) { // logic on detecting entity type based on the stock site javascript. - if ("portalV2" in ent[2]) { - this.createPortalEntity(ent); - } else if ("capturedRegion" in ent[2]) { - this.createFieldEntity(ent); - } else if ("edge" in ent[2]) { - this.createLinkEntity(ent); - } else { - console.warn("Unknown entity found: "+JSON.stringify(ent)); - } + switch (ent[2].type) { + case 'portal': + this.createPortalEntity(ent); + break; + case 'edge': + this.createLinkEntity(ent); + break; + + case 'region': + this.createFieldEntity(ent); + break; + + default: + console.warn('unknown entity found: '+JSON.stringify(ent)); + break; + } } window.Render.prototype.createPortalEntity = function(ent) { this.seenPortalsGuid[ent[0]] = true; // flag we've seen it - var previousDetails = undefined; + var previousData = undefined; // check if entity already exists if (ent[0] in window.portals) { @@ -275,21 +261,15 @@ window.Render.prototype.createPortalEntity = function(ent) { // remember the old details, for the callback - previousDetails = p.options.details; + previousData = p.options.data; this.deletePortalEntity(ent[0]); } - var portalLevel = getPortalLevel(ent[2]); - var team = getTeam(ent[2]); + var portalLevel = parseInt(ent[2].level); + var team = teamStringToId(ent[2].team); - var latlng = L.latLng(ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6); - -//TODO: move marker creation, style setting, etc into a separate class -//(as it's called from elsewhere - e.g. selecting/deselecting portals) - -//ALSO: change API for highlighters - make them return the updated style rather than directly calling setStyle on the portal marker -//(can this be done in a backwardly-compatible way??) + var latlng = L.latLng(ent[2].latE6/1E6, ent[2].lngE6/1E6); var dataOptions = { level: portalLevel, @@ -297,32 +277,16 @@ window.Render.prototype.createPortalEntity = function(ent) { ent: ent, // LEGACY - TO BE REMOVED AT SOME POINT! use .guid, .timestamp and .details instead guid: ent[0], timestamp: ent[1], - details: ent[2] + data: { summary: ent[2] }, }; - // Javascript uses references for objects. For now, at least, we need to modify the data within - // the options.details.portalV2 (to add in linkedFields). To avoid tainting the original data (which may be cached) - // we'll shallow-copy these items - dataOptions.details = $.extend({}, dataOptions.details); - dataOptions.details.portalV2 = $.extend({}, dataOptions.details.portalV2); - - - // create a linkedFields entry and add it to details - various bits of code assumes it will exist - for (var fguid in window.fields) { - var fd = window.fields[fguid].options.details; - if ( fd.capturedRegion.vertexA.guid == ent[0] || fd.capturedRegion.vertexB.guid == ent[0] || fd.capturedRegion.vertexC.guid == ent[0]) { - if (!dataOptions.details.portalV2.linkedFields) dataOptions.details.portalV2.linkedFields = []; - dataOptions.details.portalV2.linkedFields.push(fguid); - } - } - var marker = createMarker(latlng, dataOptions); marker.on('click', function() { window.renderPortalDetails(ent[0]); }); marker.on('dblclick', function() { window.renderPortalDetails(ent[0]); window.map.setView(latlng, 17); }); - window.runHooks('portalAdded', {portal: marker, previousDetails: previousDetails}); + window.runHooks('portalAdded', {portal: marker, previousData: previousData}); window.portals[ent[0]] = marker; @@ -370,12 +334,11 @@ window.Render.prototype.createFieldEntity = function(ent) { this.deleteFieldEntity(ent[0]); // option 2, for now } - var team = getTeam(ent[2]); - var reg = ent[2].capturedRegion; + var team = teamStringToId(ent[2].team); var latlngs = [ - L.latLng(reg.vertexA.location.latE6/1E6, reg.vertexA.location.lngE6/1E6), - L.latLng(reg.vertexB.location.latE6/1E6, reg.vertexB.location.lngE6/1E6), - L.latLng(reg.vertexC.location.latE6/1E6, reg.vertexC.location.lngE6/1E6) + L.latLng(ent[2].points[0].latE6/1E6, ent[2].points[0].lngE6/1E6), + L.latLng(ent[2].points[1].latE6/1E6, ent[2].points[1].lngE6/1E6), + L.latLng(ent[2].points[2].latE6/1E6, ent[2].points[2].lngE6/1E6) ]; var poly = L.geodesicPolygon(latlngs, { @@ -387,27 +350,9 @@ window.Render.prototype.createFieldEntity = function(ent) { team: team, guid: ent[0], timestamp: ent[1], - details: ent[2], - // LEGACY FIELDS: these duplicate data available via .details, as IITC previously stored it in data and vertices data: ent[2], - vertices: ent[2].capturedRegion }); - - // now fill in any references portals linkedFields data - var addPortalLinkedField = function(pguid) { - if (pguid in window.portals) { - var pd = window.portals[pguid].options.details; - if (!pd.portalV2.linkedFields) pd.portalV2.linkedFields = []; - if (pd.portalV2.linkedFields.indexOf(pguid) <0 ) { - pd.portalV2.linkedFields.push (ent[0]); - } - } - } - addPortalLinkedField(ent[2].capturedRegion.vertexA.guid); - addPortalLinkedField(ent[2].capturedRegion.vertexB.guid); - addPortalLinkedField(ent[2].capturedRegion.vertexC.guid); - runHooks('fieldAdded',{field: poly}); window.fields[ent[0]] = poly; @@ -433,11 +378,10 @@ window.Render.prototype.createLinkEntity = function(ent,faked) { this.deleteLinkEntity(ent[0]); // option 2 - for now } - var team = getTeam(ent[2]); - var edge = ent[2].edge; + var team = teamStringToId(ent[2].team); var latlngs = [ - L.latLng(edge.originPortalLocation.latE6/1E6, edge.originPortalLocation.lngE6/1E6), - L.latLng(edge.destinationPortalLocation.latE6/1E6, edge.destinationPortalLocation.lngE6/1E6) + L.latLng(ent[2].oLatE6/1E6, ent[2].oLngE6/1E6), + L.latLng(ent[2].dLatE6/1E6, ent[2].dLngE6/1E6) ]; var poly = L.geodesicPolyline(latlngs, { color: COLORS[team], @@ -448,8 +392,6 @@ window.Render.prototype.createLinkEntity = function(ent,faked) { team: team, guid: ent[0], timestamp: ent[1], - details: ent[2], - // LEGACY FIELDS: these duplicate data available via .details, as IITC previously stored it in data and vertices data: ent[2] }); @@ -465,56 +407,6 @@ window.Render.prototype.createLinkEntity = function(ent,faked) { } -window.Render.prototype.createLinksFromPortalData = function(portalGuid) { - - var sourcePortal = portals[portalGuid]; - - for (var sourceLinkIndex in sourcePortal.options.details.portalV2.linkedEdges||[]) { - var sourcePortalLinkInfo = sourcePortal.options.details.portalV2.linkedEdges[sourceLinkIndex]; - - // portals often contain details for edges that don't exist. so only consider faking an edge if this - // is the origin portal - if (sourcePortalLinkInfo.isOrigin) { - - // ... and the other porta has matching link information. - if (sourcePortalLinkInfo.otherPortalGuid in portals) { - - var targetPortal = portals[sourcePortalLinkInfo.otherPortalGuid]; - - for (var targetLinkIndex in targetPortal.options.details.portalV2.linkedEdges||[]) { - var targetPortalLinkInfo = targetPortal.options.details.portalV2.linkedEdges[targetLinkIndex]; - - if (targetPortalLinkInfo.edgeGuid == sourcePortalLinkInfo.edgeGuid) { - // yes - edge in both portals. create it - - var fakeEnt = [ - sourcePortalLinkInfo.edgeGuid, - 0, // mtime for entity data - unknown when faking it, so zero will be the oldest possible - { - controllingTeam: sourcePortal.options.details.controllingTeam, - edge: { - originPortalGuid: portalGuid, - originPortalLocation: sourcePortal.options.details.locationE6, - destinationPortalGuid: sourcePortalLinkInfo.otherPortalGuid, - destinationPortalLocation: targetPortal.options.details.locationE6 - } - } - ]; - - this.createLinkEntity(fakeEnt,true); - - - } - - } - - } - - } - - } -} - window.Render.prototype.updateEntityVisibility = function() { if (this.entityVisibilityZoom === undefined || this.entityVisibilityZoom != map.getZoom()) { diff --git a/code/map_data_request.js b/code/map_data_request.js index 64ea0d2c..fac77036 100644 --- a/code/map_data_request.js +++ b/code/map_data_request.js @@ -391,7 +391,7 @@ window.MapDataRequest.prototype.sendTileRequest = function(tiles) { var savedThis = this; // NOTE: don't add the request with window.request.add, as we don't want the abort handling to apply to map data any more - window.postAjax('getThinnedEntitiesV4', data, + window.postAjax('getThinnedEntities', data, function(data, textStatus, jqXHR) { savedThis.handleResponse (data, tiles, true); }, // request successful callback function() { savedThis.handleResponse (undefined, tiles, false); } // request failed callback ); diff --git a/code/munge.js b/code/munge.js index cc6c0dbe..c464c6b9 100644 --- a/code/munge.js +++ b/code/munge.js @@ -14,145 +14,16 @@ var requestParameterMunges = [ // obsolete munge sets (they don't have some of the new parameters) deleted - // set 7 - 2013-11-06 - { - 'dashboard.getArtifactInfo': 'artifacts', // GET_ARTIFACT_INFO: new (and not obfuscated?!) - 'dashboard.getGameScore': 'yol4dxx5ufqolhk2', // GET_GAME_SCORE - 'dashboard.getPaginatedPlextsV2': '7b83j2z81rtk6101', // GET_PAGINATED_PLEXTS - 'dashboard.getThinnedEntitiesV4': '46su4lrisoq28gxh', // GET_THINNED_ENTITIES - 'dashboard.getPlayersByGuids': 'wsc5puahrymtf1qh', // LOOKUP_PLAYERS - 'dashboard.redeemReward': 'oo0n7pw2m0xufpzx', // REDEEM_REWARD - 'dashboard.sendInviteEmail': 'bo1bp74rz8kbdjkb', // SEND_INVITE_EMAIL - 'dashboard.sendPlext': 'q0f8o4v9t8pt91yv', // SEND_PLEXT - - // common parameters - method: 'imo60cdzkemxduub', - version: '54lh4o0q7nz7dao9', //guessed parameter name - only seen munged - version_parameter: '370c0b4e160ed26c8c4ce40f10f546545730e1ef', // passed as the value to the above parameter - - // GET_THINNED_ENTITIES - quadKeys: 'iqy8e2d3zpne0cmh', //guessed parameter name - only seen munged - - // GET_PAGINATED_PLEXTS - desiredNumItems: 'chwe3yko3xy0qlk3', - minLatE6: 'f31z3x27ua8i05cf', - minLngE6: 't0rmob7f42c0w04r', - maxLatE6: 'ebwfvri5io9q0tvu', - maxLngE6: 'lfqzvpj92dp8uxo6', - minTimestampMs: '23a6djyyieeaeduu', - maxTimestampMs: 'zhjtsm2gw7w3b7mx', - chatTab: 'tak64gipm3hhqpnh', //guessed parameter name - only seen munged - ascendingTimestampOrder: 'v5rzzxtg5rmry3dx', - - // SEND_PLEXT - message: 'onptntn3szan21lj', - latE6: '1jq9lgu3hjajrt7s', - lngE6: 'plbubiopnavbxxh6', -// chatTab: 'tak64gipm3hhqpnh', //guessed parameter name - only seen munged - - // LOOKUP_PLAYERS - guids: '919p2cfpdo2wz03n', - - // SEND_INVITE_EMAIL - inviteeEmailAddress: 'thpbnoyjx0antwm5', - }, - - // set 8 - 2013-11-07 - { - 'dashboard.getArtifactInfo': 'artifacts', // GET_ARTIFACT_INFO: new (and not obfuscated?!) - 'dashboard.getGameScore': 'lls4clhel87apzpa', // GET_GAME_SCORE - 'dashboard.getPaginatedPlextsV2': 'r6n2xgcd8wjsm4og', // GET_PAGINATED_PLEXTS - 'dashboard.getThinnedEntitiesV4': '1ybigzcf2sifu34b', // GET_THINNED_ENTITIES - 'dashboard.getPlayersByGuids': 'uig0xeb6trclqd2l', // LOOKUP_PLAYERS - 'dashboard.redeemReward': '7dd7x64cc2lbutoq', // REDEEM_REWARD - 'dashboard.sendInviteEmail': 'd8p6dvwilsr460u3', // SEND_INVITE_EMAIL - 'dashboard.sendPlext': 'repg2orpg7htkoto', // SEND_PLEXT - - // common parameters - method: '97aes4vnlvyhoxik', - version: 'an8mglz21qabq3wq', //guessed parameter name - only seen munged - version_parameter: 'b92c9d055fcdf715887b173c706e7a2c267e32c5', // passed as the value to the above parameter - - // GET_THINNED_ENTITIES - quadKeys: 'mhjknavysslwfhk6', //guessed parameter name - only seen munged - - // GET_PAGINATED_PLEXTS - desiredNumItems: 'l61g8u397alq3j1x', - minLatE6: 'wwsvpboc5bxd1s9q', - minLngE6: '48l4x7ngfsz47z3u', - maxLatE6: 'p3m1qg81uqldizu6', - maxLngE6: 'h4kv1eef878vfyk3', - minTimestampMs: 'uj1vcy9ufws24v2c', - maxTimestampMs: '8pt1x5nd9hk5vakv', - chatTab: 'zy1yc1rfczashshu', //guessed parameter name - only seen munged - ascendingTimestampOrder: 'duyuskmky68nl2ci', - - // SEND_PLEXT - message: 'xktwjguq0nohzioa', - latE6: 'm4crflfaibmg9mdf', - lngE6: 'h6jfungrw5ii830r', -// chatTab: 'zy1yc1rfczashshu', //guessed parameter name - only seen munged - - // LOOKUP_PLAYERS - guids: '3u9h9cpfh2yiy4fk', - - // SEND_INVITE_EMAIL - inviteeEmailAddress: 'jpg3y4ax7t0w356j', - }, - - // set 9 - 2013-11-1 - { - 'dashboard.getArtifactInfo': 'artifacts', // GET_ARTIFACT_INFO: new (and not obfuscated?!) - 'dashboard.getGameScore': '9w8phj2dccvns3t9', // GET_GAME_SCORE - 'dashboard.getPaginatedPlextsV2': '3b1nc3ub0sd1704x', // GET_PAGINATED_PLEXTS - 'dashboard.getThinnedEntitiesV4': '2xa55qj41qrhfhas', // GET_THINNED_ENTITIES - 'dashboard.getPlayersByGuids': '734hxjh89d53clqq', // LOOKUP_PLAYERS - 'dashboard.redeemReward': 'k3hwg41wf112gjjh', // REDEEM_REWARD - 'dashboard.sendInviteEmail': 'uwizjeb18xmcesa0', // SEND_INVITE_EMAIL - 'dashboard.sendPlext': '5au1m1hut1gyvnix', // SEND_PLEXT - - // common parameters - method: '3sld77nsm0tjmkvi', - version: 'xz7q6r3aja5ttvoo', //guessed parameter name - only seen munged - version_parameter: 'b121024077de2a0dc6b34119e4440785c9ea5e64', // passed as the value to the above parameter - - // GET_THINNED_ENTITIES - quadKeys: '0o6bkrbwevwn6bg1', //guessed parameter name - only seen munged - - // GET_PAGINATED_PLEXTS - desiredNumItems: '3fketl1tv01q7vxu', - minLatE6: '5i6jhgbv3aq3c4qz', - minLngE6: 'pe2io3r932qysg4u', - maxLatE6: 'plzyuy89bnlb3pth', - maxLngE6: 'q0qq1ooc7sxpynth', - minTimestampMs: 'nc282s8hdklv21mw', - maxTimestampMs: 'ezrljj0l71gpelpu', - chatTab: 'efaznrayv5n3jxs0', //guessed parameter name - only seen munged - ascendingTimestampOrder: 'fcmlcb8ya0oa1clk', - - // SEND_PLEXT - message: 'jg4ms2i14rgzi02n', - latE6: 'nkf3evzpkxkq8l2q', - lngE6: '7xoz0xl8se4d1j53', -// chatTab: 'efaznrayv5n3jxs0', //guessed parameter name - only seen munged - - // LOOKUP_PLAYERS - guids: 'm4dcrdltldigfo94', - - // SEND_INVITE_EMAIL - inviteeEmailAddress: 'rye9be4um2t1z5ts', - }, - // set 10 - 2013-11-27 { - 'dashboard.getArtifactInfo': 'artifacts', - 'dashboard.getGameScore': '4oid643d9zc168hs', - 'dashboard.getPaginatedPlextsV2': 's1msyywq51ntudpe', - 'dashboard.getThinnedEntitiesV4': '4467ff9bgxxe4csa', - - 'dashboard.redeemReward': '66l9ivg39ygfqqjm', - 'dashboard.sendInviteEmail': 'cgb7hi5hglv0xx8k', - 'dashboard.sendPlext': 'etn9xq7brd6947kq', + 'dashboard.getArtifactInfo': 'artifacts', // GET_ARTIFACT_INFO + 'dashboard.getGameScore': '4oid643d9zc168hs', // GET_GAME_SCORE + 'dashboard.getPaginatedPlexts': 's1msyywq51ntudpe', // GET_PAGINATED_PLEXTS + 'dashboard.getThinnedEntities': '4467ff9bgxxe4csa', // GET_THINNED_ENTITIES + 'dashboard.getPortalDetails': 'c00thnhf1yp3z6mn', // GET_PORTAL_DETAILS + 'dashboard.redeemReward': '66l9ivg39ygfqqjm', // REDEEM_REWARD + 'dashboard.sendInviteEmail': 'cgb7hi5hglv0xx8k', // SEND_INVITE_EMAIL + 'dashboard.sendPlext': 'etn9xq7brd6947kq', // SEND_PLEXT // common parameters method: 'yyngyttbmmbuvdpa', @@ -179,8 +50,8 @@ var requestParameterMunges = [ lngE6: '3dlxsqrjj2vcmhbc', // chatTab: 'efaznrayv5n3jxs0', //guessed parameter name - only seen munged - // LOOKUP_PLAYERS - guids: '', + // GET_PORTAL_DETAILS + guid: 'seg6ohxgnqf9xu9w', // SEND_INVITE_EMAIL inviteeEmailAddress: '8exta9k7y8huhqmc', @@ -203,9 +74,9 @@ function extractMungeFromStock() { // these are easy - directly available in variables foundMunges['dashboard.getArtifactInfo'] = nemesis.dashboard.requests.MethodName.GET_ARTIFACT_INFO; foundMunges['dashboard.getGameScore'] = nemesis.dashboard.requests.MethodName.GET_GAME_SCORE; - foundMunges['dashboard.getPaginatedPlextsV2'] = nemesis.dashboard.requests.MethodName.GET_PAGINATED_PLEXTS; - foundMunges['dashboard.getThinnedEntitiesV4'] = nemesis.dashboard.requests.MethodName.GET_THINNED_ENTITIES; - foundMunges['dashboard.getPlayersByGuids'] = nemesis.dashboard.requests.MethodName.LOOKUP_PLAYERS; + foundMunges['dashboard.getPaginatedPlexts'] = nemesis.dashboard.requests.MethodName.GET_PAGINATED_PLEXTS; + foundMunges['dashboard.getThinnedEntities'] = nemesis.dashboard.requests.MethodName.GET_THINNED_ENTITIES; + foundMunges['dashboard.getPortalDetails'] = nemesis.dashboard.requests.MethodName.GET_PORTAL_DETAILS; foundMunges['dashboard.redeemReward'] = nemesis.dashboard.requests.MethodName.REDEEM_REWARD; foundMunges['dashboard.sendInviteEmail'] = nemesis.dashboard.requests.MethodName.SEND_INVITE_EMAIL; foundMunges['dashboard.sendPlext'] = nemesis.dashboard.requests.MethodName.SEND_PLEXT; @@ -261,11 +132,11 @@ function extractMungeFromStock() { var chatTab = result[7] || result[8]; if (chatTab != foundMunges.chatTab) throw 'Error: inconsistent munge parsing for chatTab'; - // LOOKUP_PLAYERS - var reg = new RegExp('LOOKUP_PLAYERS, {'+mungeRegExpLit+'a}'); - var result = reg.exec(nemesis.dashboard.network.DataFetcher.prototype.lookupPlayersByGuids.toString()); + // GET_PORTAL_DETAILS + var reg = new RegExp('GET_PORTAL_DETAILS, {'+mungeRegExpLit+'a}'); + var result = reg.exec(nemesis.dashboard.network.DataFetcher.prototype.getPortalDetails.toString()); - foundMunges.guids = result[1] || result[2]; + foundMunges.guid = result[1] || result[2]; // SEND_INVITE_EMAIL var reg = new RegExp('SEND_INVITE_EMAIL, {'+mungeRegExpLit+'b}'); diff --git a/code/player_names.js b/code/player_names.js index e9475a03..7a4a6d82 100644 --- a/code/player_names.js +++ b/code/player_names.js @@ -57,62 +57,6 @@ window.playerNameToGuid = function(playerName) { return guid; } -// resolves all player GUIDs that have been added to the list. Reruns -// renderPortalDetails when finished, so that then-unresolved names -// get replaced by their correct versions. -window.resolvePlayerNames = function() { - if(window.playersToResolve.length === 0) return; - - //limit per request. stock site is never more than 13 (8 res, 4 mods, owner) - //testing shows 15 works and 20 fails - var MAX_RESOLVE_PLAYERS_PER_REQUEST = 15; - var MAX_RESOLVE_REQUESTS = 8; - - if (window.playersToResolve.length > MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS) { - console.log('Warning: player name resolve queue had '+window.playersToResolve.length+' entries. Limiting to the first '+MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS+' to prevent excessive requests'); - window.playersToResolve = playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS); - } - - var p = window.playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST); - window.playersToResolve = playersToResolve.slice(MAX_RESOLVE_PLAYERS_PER_REQUEST); - - var d = {guids: p}; - window.playersInResolving = window.playersInResolving.concat(p); - - postAjax('getPlayersByGuids', d, function(dat) { - var resolvedName = {}; - if(dat.result) { - $.each(dat.result, function(ind, player) { - window.setPlayerName(player.guid, player.nickname); - resolvedName[player.guid] = player.nickname; - // remove from array - window.playersInResolving.splice(window.playersInResolving.indexOf(player.guid), 1); - }); - } else { - //no 'result' - a successful http request, but the returned result was an error of some kind - console.warn('getplayers problem - no result in response: '+dat); - - //likely to be some kind of 'bad request' (e.g. too many names at once, or otherwise badly formatted data. - //therefore, not a good idea to automatically retry by adding back to the playersToResolve list - } - - // Run hook 'playerNameResolved' with the resolved player names - window.runHooks('playerNameResolved', {names: resolvedName}); - - //TODO: have an event triggered for this instead of hard-coded single function call - if(window.selectedPortal) - window.renderPortalDetails(window.selectedPortal); - - //if more to do, run again - if(window.playersToResolve.length>0) resolvePlayerNames(); - }, - function() { - // append failed resolves to the list again - console.warn('resolving player guids failed: ' + p.join(', ')); - window.playersToResolve.concat(p); - }); -} - window.setPlayerName = function(guid, nick, uncertain) { // the 'uncertain' flag is set when we're scrolling back through chat. it's possible in this case diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 3562844f..ef5eb31b 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -147,9 +147,6 @@ window.renderPortalDetails = function(guid) { + '' ); - // try to resolve names that were required for above functions, but - // weren't available yet. - resolvePlayerNames(); runHooks('portalDetailsUpdated', {portalDetails: d}); }