misc fixes - some untested
- no GUIDs in chat for players or portal details - so remove player GUID related functions - remove player guid code from COMM - update portal_info functions to compare to player name rather than guid
This commit is contained in:
parent
d647e8786f
commit
e935902c49
@ -338,7 +338,6 @@ window.setMapBaseLayer = function() {
|
||||
// included as inline script in the original site, the data is static
|
||||
// and cannot be updated.
|
||||
window.setupPlayerStat = function() {
|
||||
PLAYER.guid = playerNameToGuid(PLAYER.nickname);
|
||||
var level;
|
||||
var ap = parseInt(PLAYER.ap);
|
||||
for(level = 0; level < MIN_AP_FOR_LEVEL.length; level++) {
|
||||
@ -531,7 +530,6 @@ function boot() {
|
||||
window.setupTaphold();
|
||||
window.setupStyles();
|
||||
window.setupDialogs();
|
||||
window.setupPlayerNameCache();
|
||||
window.setupMap();
|
||||
window.setupGeosearch();
|
||||
window.setupRedeem();
|
||||
|
10
code/chat.js
10
code/chat.js
@ -284,11 +284,9 @@ window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel, is
|
||||
switch(markup[0]) {
|
||||
case 'SENDER': // user generated messages
|
||||
nick = markup[1].plain.slice(0, -2); // cut “: ” at end
|
||||
pguid = markup[1].guid;
|
||||
break;
|
||||
|
||||
case 'PLAYER': // automatically generated messages
|
||||
pguid = markup[1].guid;
|
||||
nick = markup[1].plain;
|
||||
team = markup[1].team === 'RESISTANCE' ? TEAM_RES : TEAM_ENL;
|
||||
if(ind > 0) msg += nick; // don’t repeat nick directly
|
||||
@ -351,13 +349,9 @@ window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel, is
|
||||
if ((!isPublicChannel) && (!isSecureMessage)) msg = '<span style="color: #ff6">[public]</span> ' + msg;
|
||||
|
||||
|
||||
// format: timestamp, autogenerated, HTML message, player guid
|
||||
storageHash.data[json[0]] = [json[1], auto, chat.renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast), pguid];
|
||||
// format: timestamp, autogenerated, HTML message
|
||||
storageHash.data[json[0]] = [json[1], auto, chat.renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast)];
|
||||
|
||||
// if we're processing older messages, we could be looking at pre-name change mentions or similar
|
||||
// so in that case, flag it so we don't overwrite existing name cache entries.
|
||||
// (it's not perfect - the initial request has the wrong value here)
|
||||
window.setPlayerName(pguid, nick, isOlderMsgs); // free nick name resolves.
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,96 +1,18 @@
|
||||
// PLAYER NAMES //////////////////////////////////////////////////////
|
||||
// Player names are cached in sessionStorage. There is no GUI
|
||||
// element from within the total conversion to clean them, but you
|
||||
// can run sessionStorage.clean() to reset it.
|
||||
|
||||
|
||||
window.setupPlayerNameCache = function() {
|
||||
// IITC used to store player names in localStorage rather than sessionStorage. lets clear out any cached
|
||||
// names from session storage
|
||||
var matchPlayerGuid = new RegExp ('^[0-9a-f]{32}\\.c$');
|
||||
|
||||
$.each(Object.keys(localStorage), function(ind,key) {
|
||||
if ( matchPlayerGuid.test(key) ) {
|
||||
// copy from localStorage to sessionStorage if not already there
|
||||
if (!sessionStorage[key]) sessionStorage[key] = localStorage[key];
|
||||
// then clear from localStorage
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// retrieves player name by GUID. If the name is not yet available, it
|
||||
// will be added to a global list of GUIDs that need to be resolved.
|
||||
// The resolve method is not called automatically.
|
||||
window.getPlayerName = function(guid) {
|
||||
if(sessionStorage[guid]) return sessionStorage[guid];
|
||||
// only add to queue if it isn’t already
|
||||
if(playersToResolve.indexOf(guid) === -1 && playersInResolving.indexOf(guid) === -1) {
|
||||
playersToResolve.push(guid);
|
||||
}
|
||||
return '{'+guid.slice(0, 12)+'}';
|
||||
}
|
||||
|
||||
window._playerNameToGuidCache = {};
|
||||
|
||||
window.playerNameToGuid = function(playerName) {
|
||||
var cachedGuid = window._playerNameToGuidCache[playerName];
|
||||
if (cachedGuid !== undefined) return cachedGuid;
|
||||
|
||||
// IITC needs our own player GUID, from a lookup by name. so we retrieve this from localstorage (if available)
|
||||
if (playerName == PLAYER.nickname) {
|
||||
cachedGuid = localStorage['PLAYER-'+PLAYER.nickname];
|
||||
if (cachedGuid !== undefined) return cachedGuid;
|
||||
}
|
||||
|
||||
var guid = null;
|
||||
$.each(Object.keys(sessionStorage), function(ind,key) {
|
||||
if(playerName === sessionStorage[key]) {
|
||||
guid = key;
|
||||
window._playerNameToGuidCache[playerName] = guid;
|
||||
return false; //break from $.each
|
||||
}
|
||||
});
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
window.setPlayerName = function(guid, nick, uncertain) {
|
||||
// the 'uncertain' flag is set when we're scrolling back through chat. it's possible in this case
|
||||
// to come across a message from before a name change. these should be ignored if existing cache entries exist
|
||||
if(uncertain && guid in sessionStorage) return;
|
||||
|
||||
if($.trim(('' + nick)).slice(0, 5) === '{"L":' && !window.alertFor37WasShown) {
|
||||
window.alertFor37WasShown = true;
|
||||
alert('You have run into bug #37. Please help me solve it!\nCopy and paste this text and post it here:\nhttps://github.com/breunigs/ingress-intel-total-conversion/issues/37\nIf copy & pasting doesn’t work, make a screenshot instead.\n\n\n' + window.debug.printStackTrace() + '\n\n\n' + JSON.stringify(nick));
|
||||
}
|
||||
sessionStorage[guid] = nick;
|
||||
|
||||
// IITC needs our own player ID early on in startup. the only way we can find this is by something else
|
||||
// doing a guid->name lookup for our own name. as this doesn't always happen - and likely won't happen when needed
|
||||
// we'll store our own name->guid lookup in localStorage
|
||||
if (nick == PLAYER.nickname) {
|
||||
localStorage['PLAYER-'+PLAYER.nickname] = guid;
|
||||
PLAYER.guid = guid; // set it in PLAYER in case it wasn't already done
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// test to see if a specific player GUID is a special system account (e.g. __JARVIS__, __ADA__) that shouldn't
|
||||
// be listed as a player
|
||||
window.isSystemPlayer = function(guid) {
|
||||
window.isSystemPlayer = function(name) {
|
||||
|
||||
switch (guid) {
|
||||
case '00000000000000000000000000000001.c':
|
||||
case '00000000000000000000000000000002.c':
|
||||
switch (name) {
|
||||
case '__ADA__':
|
||||
case '__JARVIS__':
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ window.renderPortalDetails = function(guid) {
|
||||
var randDetails = details ? getPortalRandDetails(details) : '';
|
||||
var resoDetails = details ? getResonatorDetails(details) : '';
|
||||
|
||||
|
||||
|
||||
//TODO? other status details...
|
||||
var statusDetails = details ? '' : '<div id="portalStatus">Loading details...</div>';
|
||||
|
||||
|
||||
var img = fixPortalImageUrl(details ? details.imageByUrl && details.imageByUrl.imageUrl : data.image);
|
||||
var title = details ? details.portalV2.descriptiveText.TITLE : data.title;
|
||||
@ -131,11 +132,9 @@ window.renderPortalDetails = function(guid) {
|
||||
),
|
||||
|
||||
modDetails,
|
||||
|
||||
randDetails,
|
||||
|
||||
resoDetails,
|
||||
|
||||
statusDetails,
|
||||
'<div class="linkdetails">' + linkDetails.join('') + '</div>'
|
||||
);
|
||||
|
||||
|
@ -112,7 +112,8 @@ window.getAttackApGain = function(d) {
|
||||
return true;
|
||||
resoCount += 1;
|
||||
var reslevel=parseInt(reso.level);
|
||||
if(reso.ownerGuid === PLAYER.guid) {
|
||||
// NOTE: reso.ownerGuid is actually the name - no player GUIDs are visible in the protocol any more
|
||||
if(reso.ownerGuid === PLAYER.nickname) {
|
||||
if(maxResonators[reslevel] > 0) {
|
||||
maxResonators[reslevel] -= 1;
|
||||
}
|
||||
@ -167,7 +168,8 @@ window.potentialPortalLevel = function(d) {
|
||||
player_resontators[i] = i > PLAYER.level ? 0 : MAX_RESO_PER_PLAYER[i];
|
||||
}
|
||||
$.each(resonators_on_portal, function(ind, reso) {
|
||||
if(reso !== null && reso.ownerGuid === window.PLAYER.guid) {
|
||||
// NOTE: reso.ownerGuid is actually the player name - GUIDs are not in the protocol any more
|
||||
if(reso !== null && reso.ownerGuid === window.PLAYER.nickname) {
|
||||
player_resontators[reso.level]--;
|
||||
}
|
||||
resonator_levels.push(reso === null ? 0 : reso.level);
|
||||
|
Loading…
x
Reference in New Issue
Block a user