From dfd99d8c26bc2fb7146b7a94c42cb80c64f3020d Mon Sep 17 00:00:00 2001 From: Madpeter Date: Sun, 26 Apr 2020 03:01:04 +0100 Subject: [PATCH] adds master_uuid auto loading getMaster_uuid (public) value and master key2name avatar storage protection --- Core/bottypes/AVstorageBot.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Core/bottypes/AVstorageBot.cs b/Core/bottypes/AVstorageBot.cs index effe68b..81dc987 100644 --- a/Core/bottypes/AVstorageBot.cs +++ b/Core/bottypes/AVstorageBot.cs @@ -9,6 +9,9 @@ namespace BSB.bottypes { public abstract class AVstorageBot : AtHome { + protected UUID master_uuid = UUID.Zero; + public UUID getMaster_uuid { get { return master_uuid; } } + protected Dictionary AvatarStorageLastUsed = new Dictionary(); protected Dictionary AvatarName2Key = new Dictionary(); protected Dictionary AvatarKey2Name = new Dictionary(); @@ -137,10 +140,13 @@ namespace BSB.bottypes } foreach(string purge in PurgeAvatars) { - AvatarStorageLastUsed.Remove(purge); - UUID avuuid = AvatarName2Key[purge]; - AvatarName2Key.Remove(purge); - AvatarKey2Name.Remove(avuuid); + if (purge != myconfig.master) + { + AvatarStorageLastUsed.Remove(purge); + UUID avuuid = AvatarName2Key[purge]; + AvatarName2Key.Remove(purge); + AvatarKey2Name.Remove(avuuid); + } } } @@ -151,6 +157,10 @@ namespace BSB.bottypes { Client.Avatars.UUIDNameReply += Key2NameEvent; Client.Directory.DirPeopleReply += Name2KeyEvent; + if(helpers.notempty(myconfig.master) == true) + { + FindAvatarName2Key(myconfig.master); + } } } @@ -187,6 +197,13 @@ namespace BSB.bottypes PendingAvatarFinds_viauuid.Remove(av_uuid); } } + if (helpers.notempty(myconfig.master) == true) + { + if(myconfig.master == av_name) + { + master_uuid = av_uuid; + } + } } }