potentially some fixes idk

This commit is contained in:
Stanley Dimant
2023-03-27 10:22:14 +02:00
parent bc8d61b19d
commit 6b35b2bf4a
5 changed files with 78 additions and 44 deletions

View File

@@ -35,7 +35,7 @@ public class Pair
public bool CachedPlayerExists => CachedPlayer?.CheckExistence() ?? false;
public Dictionary<GroupFullInfoDto, GroupPairFullInfoDto> GroupPair { get; set; } = new(GroupDtoComparer.Instance);
public bool HasCachedPlayer => CachedPlayer != null && !string.IsNullOrEmpty(CachedPlayer.PlayerName);
public bool HasCachedPlayer => CachedPlayer != null && !string.IsNullOrEmpty(CachedPlayer.PlayerName) && _onlineUserIdentDto != null;
public bool IsOnline => CachedPlayer != null;
public bool IsPaused => UserPair != null && UserPair.OtherPermissions.IsPaired() ? UserPair.OtherPermissions.IsPaused() || UserPair.OwnPermissions.IsPaused()
@@ -44,7 +44,21 @@ public class Pair
public bool IsVisible => CachedPlayer?.PlayerName != null;
public CharacterData? LastReceivedCharacterData { get; set; }
public string? PlayerName => CachedPlayer?.PlayerName ?? string.Empty;
public string PlayerNameHash => CachedPlayer?.PlayerNameHash ?? string.Empty;
public string GetPlayerNameHash()
{
try
{
return CachedPlayer?.PlayerNameHash ?? string.Empty;
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Error accessing PlayerNameHash, recreating CachedPlayer");
RecreateCachedPlayer();
}
return string.Empty;
}
public UserData UserData => UserPair?.User ?? GroupPair.First().Value.User;
public UserPairDto? UserPair { get; set; }
private CachedPlayer? CachedPlayer { get; set; }
@@ -138,7 +152,12 @@ public class Pair
public void RecreateCachedPlayer(OnlineUserIdentDto? dto = null)
{
if (dto == null && _onlineUserIdentDto == null) return;
if (dto == null && _onlineUserIdentDto == null)
{
CachedPlayer?.Dispose();
CachedPlayer = null;
return;
}
if (dto != null)
{
_onlineUserIdentDto = dto;