Photon logging fixes

This commit is contained in:
Natsumi
2021-12-10 02:02:16 +13:00
parent 1bf5bcf1f3
commit 85a6304053
4 changed files with 114 additions and 135 deletions
+105 -129
View File
@@ -8199,25 +8199,11 @@ speechSynthesis.getVoices();
} }
if (!joinTime || joinTime + 120000 < dtNow) { if (!joinTime || joinTime + 120000 < dtNow) {
// wait 2mins for user to load in // wait 2mins for user to load in
var displayName = ''; hudTimeout.unshift({
var userId = ''; userId: this.getUserIdFromPhotonId(id),
var ref = this.photonLobby.get(id); displayName: this.getDisplayNameFromPhotonId(id),
displayName = `ID:${id}`; time: Math.round(timeSinceLastEvent / 1000)
if (typeof ref !== 'undefined') { });
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
var time = Math.round(timeSinceLastEvent / 1000);
var feed = {
userId,
displayName,
time
};
hudTimeout.unshift(feed);
} }
} }
}); });
@@ -8278,70 +8264,32 @@ speechSynthesis.getVoices();
if (isInvisible) { if (isInvisible) {
text = 'User has joined invisible'; text = 'User has joined invisible';
} else if (avatarEyeHeight < 0) { } else if (avatarEyeHeight < 0) {
text = 'Photon bot has joined'; text = 'Photon bot has joined, a';
} else if ( } else if (
joinTime && joinTime &&
joinTime + 10000 < dtNow && joinTime + 10000 < dtNow &&
!hasInstantiated !hasInstantiated
) { ) {
text = 'Photon bot has joined'; text = 'Photon bot has joined, b';
} else if ( } else if (
(!joinTime || joinTime + 3000 < dtNow) && (!joinTime || joinTime + 3000 < dtNow) &&
typeof ref === 'undefined' && typeof ref === 'undefined' &&
!event7PhotonIds.includes(id.toString()) !event7PhotonIds.includes(id.toString())
) { ) {
text = 'Photon bot has joined'; text = 'Photon bot has joined, c';
} }
if (text) { if (text) {
if (!this.photonLobbyBots.includes(id)) { if (!this.photonLobbyBots.includes(id)) {
var displayName = `ID:${id}`;
var userId = '';
if (typeof ref !== 'undefined') {
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: id, photonId: id,
displayName,
userId,
text, text,
color: 'yellow',
created_at: new Date().toJSON() created_at: new Date().toJSON()
}); });
} }
photonBots.unshift(id); photonBots.unshift(id);
} }
}); });
this.photonLobbyBots.forEach((id) => {
if (!photonBots.includes(id)) {
var ref = this.photonLobby.get(id);
var userId = '';
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
var displayName = `ID:${id}`;
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
var time = '';
if (this.photonLobbyJointime.has(id)) {
var {joinTime} = this.photonLobbyJointime.get(id);
if (typeof joinTime !== 'undefined') {
time = ` ${timeToText(Date.now() - joinTime)}`;
}
}
this.addEntryPhotonEvent({
photonId: id,
displayName,
userId,
text: `Photon bot has left${time}`,
created_at: new Date().toJSON()
});
}
});
if (this.photonLobbyBots.length !== photonBots.length) { if (this.photonLobbyBots.length !== photonBots.length) {
this.updatePhotonLobbyBotSize(photonBots.length); this.updatePhotonLobbyBotSize(photonBots.length);
} }
@@ -8366,7 +8314,12 @@ speechSynthesis.getVoices();
} }
}; };
$app.methods.addEntryPhotonEvent = function (feed) { $app.methods.addEntryPhotonEvent = function (input) {
var feed = {
displayName: this.getDisplayNameFromPhotonId(input.photonId),
userId: this.getUserIdFromPhotonId(input.photonId),
...input
};
this.photonEventTable.data.unshift(feed); this.photonEventTable.data.unshift(feed);
if (this.photonEventOverlay) { if (this.photonEventOverlay) {
if ( if (
@@ -8409,6 +8362,17 @@ speechSynthesis.getVoices();
return displayName; return displayName;
}; };
$app.methods.getUserIdFromPhotonId = function (photonId) {
var userId = '';
if (photonId) {
var ref = this.photonLobby.get(photonId);
if (typeof ref !== 'undefined' && typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
return userId;
};
$app.methods.showUserFromPhotonId = function (photonId) { $app.methods.showUserFromPhotonId = function (photonId) {
if (photonId) { if (photonId) {
var ref = this.photonLobby.get(photonId); var ref = this.photonLobby.get(photonId);
@@ -8472,15 +8436,6 @@ speechSynthesis.getVoices();
); );
this.parsePhotonAvatar(data.Parameters[251].avatarDict); this.parsePhotonAvatar(data.Parameters[251].avatarDict);
this.parsePhotonAvatar(data.Parameters[251].favatarDict); this.parsePhotonAvatar(data.Parameters[251].favatarDict);
var lobbyJointime = this.photonLobbyJointime.get(
data.Parameters[253]
);
if (typeof lobbyJointime !== 'undefined') {
this.photonLobbyJointime.set(data.Parameters[253], {
...lobbyJointime,
hasInstantiated: true
});
}
if (typeof data.Parameters[251].inVRMode !== 'undefined') { if (typeof data.Parameters[251].inVRMode !== 'undefined') {
this.photonLobbyInVrMode.set( this.photonLobbyInVrMode.set(
data.Parameters[253], data.Parameters[253],
@@ -8521,16 +8476,18 @@ speechSynthesis.getVoices();
this.startLobbyWatcherLoop(); this.startLobbyWatcherLoop();
} else if (data.Code === 254) { } else if (data.Code === 254) {
// Leave // Leave
this.checkPhotonBotLeave(data.Parameters[254], gameLogDate);
this.photonUserLeave(data.Parameters[254], gameLogDate);
this.photonLobbyCurrent.delete(data.Parameters[254]); this.photonLobbyCurrent.delete(data.Parameters[254]);
this.photonLobbyJointime.delete(data.Parameters[254]); this.photonLobbyJointime.delete(data.Parameters[254]);
this.photonLobbyInVrMode.delete(data.Parameters[254]); this.photonLobbyInVrMode.delete(data.Parameters[254]);
this.parsePhotonLobbyIds(data.Parameters[252].$values); this.parsePhotonLobbyIds(data.Parameters[252].$values);
if (typeof data.Parameters[203] !== 'undefined') { if (typeof data.Parameters[203] !== 'undefined') {
this.setPhotonLobbyMaster(data.Parameters[203]); this.setPhotonLobbyMaster(data.Parameters[203], gameLogDate);
} }
} else if (data.Code === 4) { } else if (data.Code === 4) {
// Sync // Sync
this.setPhotonLobbyMaster(data.Parameters[254]); this.setPhotonLobbyMaster(data.Parameters[254], gameLogDate);
} else if (data.Code === 33) { } else if (data.Code === 33) {
// Moderation // Moderation
if (data.Parameters[245]['0'] === 21) { if (data.Parameters[245]['0'] === 21) {
@@ -8556,21 +8513,10 @@ speechSynthesis.getVoices();
gameLogDate gameLogDate
}); });
if (block || mute) { if (block || mute) {
var displayName = `ID:${photonId}`;
var userId = '';
if (typeof ref !== 'undefined') {
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
displayName,
userId,
text: `mute:${mute} block:${block}`, text: `mute:${mute} block:${block}`,
color: 'yellow',
created_at: gameLogDate created_at: gameLogDate
}); });
} }
@@ -8621,6 +8567,15 @@ speechSynthesis.getVoices();
if (!this.photonLobbyCurrent.has(data.Parameters[254])) { if (!this.photonLobbyCurrent.has(data.Parameters[254])) {
this.photonLobbyCurrent.set(data.Parameters[254]); this.photonLobbyCurrent.set(data.Parameters[254]);
} }
var lobbyJointime = this.photonLobbyJointime.get(
data.Parameters[254]
);
if (typeof lobbyJointime !== 'undefined') {
this.photonLobbyJointime.set(data.Parameters[254], {
...lobbyJointime,
hasInstantiated: true
});
}
} else if (data.Code === 6) { } else if (data.Code === 6) {
var senderId = data.Parameters[254]; var senderId = data.Parameters[254];
// VRC Event // VRC Event
@@ -8642,20 +8597,6 @@ speechSynthesis.getVoices();
) { ) {
return; return;
} }
var displayName = '';
var userId = '';
if (senderId) {
var ref = this.photonLobby.get(senderId);
displayName = `ID:${senderId}`;
if (typeof ref !== 'undefined') {
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
}
if ( if (
data.EventType === '_InstantiateObject' && data.EventType === '_InstantiateObject' &&
data.Data[0] === 'Portals/PortalInternalDynamic' data.Data[0] === 'Portals/PortalInternalDynamic'
@@ -8671,8 +8612,6 @@ speechSynthesis.getVoices();
var time = timeToText(Date.parse(gameLogDate) - date); var time = timeToText(Date.parse(gameLogDate) - date);
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: senderId, photonId: senderId,
displayName,
userId,
text: `DeletedPortal ${time}`, text: `DeletedPortal ${time}`,
created_at: gameLogDate created_at: gameLogDate
}); });
@@ -8686,18 +8625,11 @@ speechSynthesis.getVoices();
); );
this.lastPortalId = ''; this.lastPortalId = '';
} }
var ref = this.photonLobby.get(senderId); var displayName = this.getDisplayNameFromPhotonId(senderId);
if ( if (displayName) {
typeof ref !== 'undefined' &&
typeof ref.displayName !== 'undefined'
) {
var userId = '';
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
var ref1 = { var ref1 = {
id: userId, id: this.getUserIdFromPhotonId(senderId),
displayName: ref.displayName displayName
}; };
this.portalQueue = 'skip'; this.portalQueue = 'skip';
this.parsePhotonPortalSpawn(gameLogDate, instanceId, ref1); this.parsePhotonPortalSpawn(gameLogDate, instanceId, ref1);
@@ -8745,8 +8677,6 @@ speechSynthesis.getVoices();
} }
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: senderId, photonId: senderId,
displayName,
userId,
text, text,
created_at: gameLogDate created_at: gameLogDate
}); });
@@ -8813,37 +8743,61 @@ speechSynthesis.getVoices();
} }
}; };
$app.methods.setPhotonLobbyMaster = function (photonId) { $app.methods.setPhotonLobbyMaster = function (photonId, gameLogDate) {
if (this.photonLobbyMaster !== photonId) { if (this.photonLobbyMaster !== photonId) {
if (this.photonLobbyMaster !== 0) { if (this.photonLobbyMaster !== 0) {
var ref = this.photonLobby.get(photonId);
var displayName = `ID:${photonId}`;
var userId = '';
if (typeof ref !== 'undefined') {
if (typeof ref.displayName !== 'undefined') {
displayName = ref.displayName;
}
if (typeof ref.id !== 'undefined') {
userId = ref.id;
}
}
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
displayName,
userId,
text: `Photon Migrate Master`, text: `Photon Migrate Master`,
created_at: new Date().toJSON() created_at: gameLogDate
}); });
} }
this.photonLobbyMaster = photonId; this.photonLobbyMaster = photonId;
} }
}; };
$app.methods.checkPhotonBotLeave = function (photonId, gameLogDate) {
var text = '';
var lobbyJointime = this.photonLobbyJointime.get(photonId);
if (
typeof lobbyJointime !== 'undefined' &&
!lobbyJointime.hasInstantiated
) {
var time = timeToText(Date.now() - lobbyJointime.joinTime);
text = `Left without instantiating ${time}`;
} else if (this.photonLobbyBots.includes(photonId)) {
var text = 'Photon bot has left';
if (typeof lobbyJointime !== 'undefined') {
var time = timeToText(Date.now() - lobbyJointime.joinTime);
text = `Photon bot has left ${time}`;
}
}
if (text) {
this.addEntryPhotonEvent({
photonId,
text,
color: 'yellow',
created_at: gameLogDate
});
}
};
$app.methods.parsePhotonUser = async function ( $app.methods.parsePhotonUser = async function (
photonId, photonId,
user, user,
gameLogDate gameLogDate
) { ) {
var lobbyJointime = this.photonLobbyJointime.get(photonId);
if (
typeof lobbyJointime !== 'undefined' &&
!lobbyJointime.hasInstantiated
) {
this.photonLobbyJointime.set(photonId, {
...lobbyJointime,
hasInstantiated: true
});
}
var hasJoined = this.photonLobbyCurrent.has(photonId);
var tags = []; var tags = [];
if ( if (
typeof user.tags !== 'undefined' && typeof user.tags !== 'undefined' &&
@@ -8914,6 +8868,28 @@ speechSynthesis.getVoices();
this.photonModerationUpdate(ref, block, mute, gameLogDate); this.photonModerationUpdate(ref, block, mute, gameLogDate);
} }
} }
if (!hasJoined) {
this.photonUserJoin(photonId, ref, gameLogDate);
}
};
$app.methods.photonUserJoin = function (photonId, ref, gameLogDate) {
if (ref.id === API.currentUser.id) {
return;
}
this.addEntryPhotonEvent({
photonId,
text: 'has joined',
created_at: gameLogDate
});
};
$app.methods.photonUserLeave = function (photonId, gameLogDate) {
this.addEntryPhotonEvent({
photonId,
text: 'has left',
created_at: gameLogDate
});
}; };
$app.methods.photonModerationUpdate = function ( $app.methods.photonModerationUpdate = function (
+3 -3
View File
@@ -1279,14 +1279,14 @@ html
span(v-else-if="userDialog.ref.status === 'busy'") Do Not Disturb span(v-else-if="userDialog.ref.status === 'busy'") Do Not Disturb
span(v-else) Offline span(v-else) Offline
i.x-user-status(:class="userStatusClass(userDialog.ref)") i.x-user-status(:class="userStatusClass(userDialog.ref)")
span(v-text="userDialog.ref.displayName" style="margin-left:5px;font-weight:bold") span(v-text="userDialog.ref.displayName" style="margin-left:5px;margin-right:5px;font-weight:bold")
el-popover(placement="top" trigger="click") el-popover(placement="top" trigger="click")
span(slot="reference" v-text="userDialog.ref.username" style="margin-left:5px;color:#909399;font-family:monospace;font-size:12px;cursor:pointer") span(slot="reference" v-text="userDialog.ref.username" style="margin-right:5px;color:#909399;font-family:monospace;font-size:12px;cursor:pointer")
span(style="display:block;text-align:center;font-family:monospace") {{ userDialog.ref.username | textToHex }} span(style="display:block;text-align:center;font-family:monospace") {{ userDialog.ref.username | textToHex }}
el-tooltip(v-for="item in userDialog.ref.$languages" :key="item.key" placement="top") el-tooltip(v-for="item in userDialog.ref.$languages" :key="item.key" placement="top")
template(#content) template(#content)
span {{ item.value }} ({{ item.key }}) span {{ item.value }} ({{ item.key }})
span.famfamfam-flags(:class="languageClass(item.key)" style="display:inline-block;margin-left:5px") span.famfamfam-flags(:class="languageClass(item.key)" style="display:inline-block;margin-right:5px")
div div
el-tag.name(type="info" effect="plain" size="mini" :class="userDialog.ref.$trustClass" v-text="userDialog.ref.$trustLevel" style="margin-right:5px;margin-top:5px") el-tag.name(type="info" effect="plain" size="mini" :class="userDialog.ref.$trustClass" v-text="userDialog.ref.$trustLevel" style="margin-right:5px;margin-top:5px")
el-tag.x-tag-friend(v-if="userDialog.isFriend && userDialog.friend" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") Friend No.{{userDialog.friend.no}} el-tag.x-tag-friend(v-if="userDialog.isFriend && userDialog.friend" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") Friend No.{{userDialog.friend.no}}
+3 -2
View File
@@ -567,7 +567,7 @@ Vue.component('marquee-text', MarqueeText);
}; };
$app.methods.addEntryHudFeed = function (json) { $app.methods.addEntryHudFeed = function (json) {
var {displayName, text} = JSON.parse(json); var {displayName, text, color} = JSON.parse(json);
var combo = 1; var combo = 1;
this.hudFeed.forEach((item) => { this.hudFeed.forEach((item) => {
if (item.displayName === displayName && item.text === text) { if (item.displayName === displayName && item.text === text) {
@@ -579,7 +579,8 @@ Vue.component('marquee-text', MarqueeText);
time: Date.now(), time: Date.now(),
displayName, displayName,
text, text,
combo combo,
color
}); });
this.cleanHudFeed(); this.cleanHudFeed();
}; };
+3 -1
View File
@@ -416,7 +416,9 @@ html
circle(class="np-progress-circle-stroke" cx="60" cy="60" stroke="white" r="30" fill="transparent" stroke-width="60") circle(class="np-progress-circle-stroke" cx="60" cy="60" stroke="white" r="30" fill="transparent" stroke-width="60")
.hud-feed .hud-feed
div(v-for="feed in hudFeed") div(v-for="feed in hudFeed")
.item <strong>{{ feed.displayName }}</strong> {{ feed.text }} .item <strong>{{ feed.displayName }}</strong>
span(v-if="feed.color === 'yellow'" style="color: yellow") {{ feed.text }}
span(v-else) {{ feed.text }}
template(v-if="feed.combo > 1") template(v-if="feed.combo > 1")
span.combo x{{ feed.combo }} span.combo x{{ feed.combo }}
.hud-timeout(v-if="hudTimeout.length > 0") .hud-timeout(v-if="hudTimeout.length > 0")