From cac98171e5143dbcd37acca00a9e4ed87ec4e477 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 14:56:23 +0000 Subject: Very partial Avatar Appearance (ie, clothes/body parts) "storage". In standalone mode it will mean that when you log off and log back on ,as long as the region server hasn't been restarted , your avatar will start with wearing the clothes that it wore on log off. In grid mode its even more limited in that wearing/removing clothes/body parts are only stored in the region server instance you are one. so if you are in a different region to your login region (which are on different region server instances), and then change clothes, those changes won't be remembered. So as said, its very limited but is a small step towards having proper appearance persist. Just need to store this data out to a database. --- .../Communications/Cache/AssetTransactions.cs | 2 +- .../Communications/CommunicationsManager.cs | 16 ++-- .../Environment/Modules/AvatarFactoryModule.cs | 99 ++++++++++++++++++---- .../Region/Environment/Scenes/Scene.Inventory.cs | 20 ++--- OpenSim/Region/Environment/Scenes/Scene.cs | 8 +- 5 files changed, 104 insertions(+), 41 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index acd57b6..f7e80c9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -333,7 +333,7 @@ namespace OpenSim.Framework.Communications.Cache //really need to fix this call, if lbsa71 saw this he would die. m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); CachedUserInfo userInfo = - m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); + m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d4ddead..bfdd118 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -64,11 +64,11 @@ namespace OpenSim.Framework.Communications get { return m_interRegion; } } - protected UserProfileCacheService m_userProfileCache; + protected UserProfileCacheService m_userProfileCacheService; - public UserProfileCacheService UserProfileCache + public UserProfileCacheService UserProfileCacheService { - get { return m_userProfileCache; } + get { return m_userProfileCacheService; } } protected AssetTransactionManager m_transactionsManager; @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications { m_networkServersInfo = serversInfo; m_assetCache = assetCache; - m_userProfileCache = new UserProfileCacheService(this); + m_userProfileCacheService = new UserProfileCacheService(this); m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } @@ -156,7 +156,7 @@ namespace OpenSim.Framework.Communications public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfileCache.libraryRoot.agentID) + if (uuid == m_userProfileCacheService.libraryRoot.agentID) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } @@ -175,11 +175,7 @@ namespace OpenSim.Framework.Communications } public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { - - - List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); - - + List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); return pickerlist; } diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index 820a26b..b6c373c 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -1,5 +1,6 @@ using System; using libsecondlife; +using System.Collections.Generic; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -11,18 +12,30 @@ namespace OpenSim.Region.Environment.Modules public class AvatarFactoryModule : IAvatarFactory { private Scene m_scene = null; + private Dictionary m_avatarsClothes = new Dictionary(); public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, out byte[] visualParams) { - GetDefaultAvatarAppearance(out wearables, out visualParams); - return true; + if (!m_avatarsClothes.ContainsKey(avatarId)) + { + GetDefaultAvatarAppearance(out wearables, out visualParams); + AvatarWearing wearing = new AvatarWearing(wearables); + m_avatarsClothes[avatarId] = wearing; + return true; + } + else + { + visualParams = SetDefaultVisualParams(); + wearables = m_avatarsClothes[avatarId].IsWearing; + return true; + } } public void Initialise(Scene scene, IConfigSource source) { scene.RegisterModuleInterface(this); - // scene.EventManager.OnNewClient += NewClient; + scene.EventManager.OnNewClient += NewClient; if (m_scene == null) { @@ -50,43 +63,97 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { - // client.OnAvatarNowWearing += AvatarIsWearing; + client.OnAvatarNowWearing += AvatarIsWearing; } public void RemoveClient(IClientAPI client) { - // client.OnAvatarNowWearing -= AvatarIsWearing; + // client.OnAvatarNowWearing -= AvatarIsWearing; } public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { - IClientAPI clientView = (IClientAPI) sender; + IClientAPI clientView = (IClientAPI)sender; //Todo look up the assetid from the inventory cache (or something) for each itemId that is in AvatarWearingArgs // then store assetid and itemId and wearable type in a database - foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) - { - LLUUID assetId; - CachedUserInfo profile = m_scene.CommsManager.UserProfileCache.GetUserDetails(clientView.AgentId); - if (profile != null) + foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { - InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); - if (baseItem != null) + if (wear.Type < 13) { - assetId = baseItem.assetID; + LLUUID assetId; + CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); + if (profile != null) + { + InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); + if (baseItem != null) + { + assetId = baseItem.assetID; + //Tempoaray dictionary storage. This is be storing to a database + if (m_avatarsClothes.ContainsKey(clientView.AgentId)) + { + AvatarWearing avWearing = m_avatarsClothes[clientView.AgentId]; + avWearing.IsWearing[wear.Type].AssetID = assetId; + avWearing.IsWearing[wear.Type].ItemID = wear.ItemID; + } + } + } } } - } } public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) { + visualParams = SetDefaultVisualParams(); + + wearables = AvatarWearable.DefaultWearables; + } + + private static byte[] SetDefaultVisualParams() + { + byte[] visualParams; visualParams = new byte[218]; for (int i = 0; i < 218; i++) { visualParams[i] = 100; } + return visualParams; + } - wearables = AvatarWearable.DefaultWearables; + public class AvatarWearing + { + public AvatarWearable[] IsWearing; + + public AvatarWearing() + { + IsWearing = new AvatarWearable[13]; + for (int i = 0; i < 13; i++) + { + IsWearing[i] = new AvatarWearable(); + } + } + + public AvatarWearing(AvatarWearable[] wearing) + { + if (wearing.Length == 13) + { + IsWearing = new AvatarWearable[13]; + for (int i = 0; i < 13; i++) + { + IsWearing[i] = new AvatarWearable(); + IsWearing[i].AssetID = wearing[i].AssetID; + IsWearing[i].ItemID = wearing[i].ItemID; + } + } + else + { + IsWearing = new AvatarWearable[13]; + for (int i = 0; i < 13; i++) + { + IsWearing[i] = new AvatarWearable(); + } + } + } } } + } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 759d070..6370bcb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.Environment.Scenes public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { userInfo.AddItem(remoteClient.AgentId, item); @@ -75,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { if (userInfo.RootFolder != null) @@ -109,7 +109,7 @@ namespace OpenSim.Region.Environment.Scenes public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { if (userInfo.RootFolder != null) @@ -157,10 +157,10 @@ namespace OpenSim.Region.Environment.Scenes public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) { - InventoryItemBase item = CommsManager.UserProfileCache.libraryRoot.HasItem(oldItemID); + InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); if (item == null) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(oldAgentID); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); if (userInfo == null) { MainLog.Instance.Warn("INVENTORY", "Failed to find user " + oldAgentID.ToString()); @@ -212,7 +212,7 @@ namespace OpenSim.Region.Environment.Scenes private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, AssetBase asset, uint nextOwnerMask) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); @@ -252,7 +252,7 @@ namespace OpenSim.Region.Environment.Scenes { if (transActionID == LLUUID.Zero) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = CreateAsset(name, description, invType, assetType, null); @@ -320,7 +320,7 @@ namespace OpenSim.Region.Environment.Scenes public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); LLUUID copyID = LLUUID.Random(); if (userInfo != null) { @@ -398,7 +398,7 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) { string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = CreateAsset( @@ -454,7 +454,7 @@ namespace OpenSim.Region.Environment.Scenes public virtual void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) { - CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { if (userInfo.RootFolder != null) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index ade0e35..19e0064 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -949,7 +949,7 @@ namespace OpenSim.Region.Environment.Scenes CreateAndAddScenePresence(client, child); m_LandManager.sendParcelOverlay(client); - CommsManager.UserProfileCache.AddNewUser(client.AgentId); + CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); CommsManager.TransactionsManager.AddUser(client.AgentId); } @@ -999,10 +999,10 @@ namespace OpenSim.Region.Environment.Scenes client.OnGodKickUser += handleGodlikeKickUser; client.OnCreateNewInventoryItem += CreateNewInventoryItem; - client.OnCreateNewInventoryFolder += CommsManager.UserProfileCache.HandleCreateInventoryFolder; - client.OnFetchInventoryDescendents += CommsManager.UserProfileCache.HandleFecthInventoryDescendents; + client.OnCreateNewInventoryFolder += CommsManager.UserProfileCacheService.HandleCreateInventoryFolder; + client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents; client.OnRequestTaskInventory += RequestTaskInventory; - client.OnFetchInventory += CommsManager.UserProfileCache.HandleFetchInventory; + client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory; client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; client.OnCopyInventoryItem += CopyInventoryItem; client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; -- cgit v1.1