From 66619b599654397fb09da0f40d3d7e69dafcfb41 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 12 Jun 2010 12:08:45 -0700 Subject: [PATCH 1/6] Added checks for failed UpdateAgent calls. --- .../EntityTransfer/EntityTransferModule.cs | 46 ++++++++++++------- OpenSim/Region/Framework/Scenes/Scene.cs | 2 + 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index a33f5c50ee..5d50a83e51 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -396,7 +396,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.Position = position; SetCallbackURL(agent, sp.Scene.RegionInfo); - UpdateAgent(reg, finalDestination, agent); + if (!UpdateAgent(reg, finalDestination, agent)) + { + // Region doesn't take it + Fail(sp, finalDestination); + return; + } m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); @@ -421,21 +426,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // that the client contacted the destination before we send the attachments and close things here. if (!WaitForCallback(sp.UUID)) { - // Client never contacted destination. Let's restore everything back - sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); - - // Fail. Reset it back - sp.IsChildAgent = false; - - ResetFromTransit(sp.UUID); - - // Yikes! We should just have a ref to scene here. - //sp.Scene.InformClientOfNeighbours(sp); - EnableChildAgents(sp); - - // Finally, kill the agent we just created at the destination. - m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); - + Fail(sp, finalDestination); return; } @@ -475,6 +466,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } + private void Fail(ScenePresence sp, GridRegion finalDestination) + { + // Client never contacted destination. Let's restore everything back + sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); + + // Fail. Reset it back + sp.IsChildAgent = false; + + ResetFromTransit(sp.UUID); + + EnableChildAgents(sp); + + // Finally, kill the agent we just created at the destination. + m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); + + } protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { @@ -813,7 +820,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; - m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent); + if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) + { + // region doesn't take it + ResetFromTransit(agent.UUID); + return agent; + } // Next, let's close the child agent connections that are too far away. agent.CloseChildAgents(neighbourx, neighboury); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2b2c04aa4b..bcfb4c9d5f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3903,6 +3903,8 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); + // XPTO: if this agent is not allowed here as root, always return false + // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); From eff641ab83c124bded9434dfb776838926028b65 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 12 Jun 2010 17:08:05 -0700 Subject: [PATCH 2/6] Added Old Guids=true to all MySql connection strings. --- bin/OpenSim.ini.example | 2 +- bin/Robust.HG.ini.example | 2 +- bin/Robust.ini.example | 2 +- bin/config-include/StandaloneCommon.ini.example | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index b14206a066..0bc3d87833 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -126,7 +126,7 @@ ; -->>> There are multiple connection strings defined in several places. Check it carefully! ; ; storage_plugin="OpenSim.Data.MySQL.dll" - ; storage_connection_string="Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;"; + ; storage_connection_string="Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;Old Guids=true;"; ; If you want to use a different database/server for estate data, then ; uncomment and change this connect string. Defaults to the above if not set ; estate_connection_string="Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;"; diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 9af1e4cdf3..2d69382b10 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -28,7 +28,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 [DatabaseService] StorageProvider = "OpenSim.Data.MySQL.dll" - ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;Old Guids=true;" ; * As an example, the below configuration precisely mimicks the legacy ; * asset server. It is read by the asset IN connector (defined above) diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index f1b91269a7..8331db85b1 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -28,7 +28,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 [DatabaseService] StorageProvider = "OpenSim.Data.MySQL.dll" - ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;Old Guids=true;" ; * As an example, the below configuration precisely mimicks the legacy diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index 572c153bef..bfa67259ab 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -17,7 +17,7 @@ ; Uncomment these lines if you want to use mysql storage ; Change the connection string to your db details ;StorageProvider = "OpenSim.Data.MySQL.dll" - ;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;" + ;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;Old Guids=true;" [AssetService] DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" From 14c587bea1e0acfca0ba1842c5a1fa10bdf45548 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 13 Jun 2010 21:45:39 +0100 Subject: [PATCH 3/6] Thank you, Snoopy2, for a patch to fix RemoteAdmin. Committed with the following changes: - Start location is NOT optional. The signature was defined with it being mandataory and there is no reason to change it - Adjusted comments to remove misleading or no longer true comments. Default is neuter, according to the code, not male, as the comment stated. --- .../RemoteController/RemoteAdminPlugin.cs | 941 +++++++++++------- .../SimianUserAccountServiceConnector.cs | 2 +- .../UserAccountService/UserAccountService.cs | 24 +- 3 files changed, 620 insertions(+), 347 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 7ebb5de6dd..b248d1117a 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -998,35 +998,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController string firstname = (string) requestData["user_firstname"]; string lastname = (string) requestData["user_lastname"]; string passwd = (string) requestData["user_password"]; - uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); - uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + + regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); string email = ""; // empty string for email if (requestData.Contains("user_email")) email = (string)requestData["user_email"]; - UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + UUID scopeID = scene.RegionInfo.ScopeID; - UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname); + UserAccount account = CreateUser(scopeID, firstname, lastname, passwd, email); - if (null != account) - throw new Exception(String.Format("Account {0} {1} already exists", firstname, lastname)); - - account = new UserAccount(scopeID, firstname, lastname, email); - - bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); - - if (!success) + if (null == account) throw new Exception(String.Format("failed to create new user {0} {1}", firstname, lastname)); - // Store the password - m_app.SceneManager.CurrentOrFirstScene.AuthenticationService.SetPassword(account.PrincipalID, passwd); + // Set home position - GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, + GridRegion home = scene.GridService.GetRegionByPosition(scopeID, (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); - if (home == null) + if (null == home) { m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname); + } else { + scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname); + } // Establish the avatar's initial appearance @@ -1169,9 +1167,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// start_region_y /// avatar's start region coordinates, Y /// value (changeable) - /// about_real_world + /// about_real_world (not implemented yet) /// "about" text of avatar owner (changeable) - /// about_virtual_world + /// about_virtual_world (not implemented yet) /// "about" text of avatar (changeable) /// /// @@ -1182,6 +1180,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// true or false /// error /// error message if success is false + /// avatar_uuid + /// UUID of the updated avatar + /// account; UUID.Zero if failed. + /// /// /// @@ -1189,31 +1191,34 @@ namespace OpenSim.ApplicationPlugins.RemoteController { m_log.Info("[RADMIN]: UpdateUserAccount: new request"); m_log.Warn("[RADMIN]: This method needs update for 0.7"); + + FailIfRemoteAdminDisabled("UpdateUserAccount"); + XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - //lock (rslock) - //{ - // try - // { - // Hashtable requestData = (Hashtable) request.Params[0]; + lock (rslock) + { + try + { + Hashtable requestData = (Hashtable) request.Params[0]; - // // check completeness - // checkStringParameters(request, new string[] { - // "password", "user_firstname", - // "user_lastname"}); + // check completeness + checkStringParameters(request, new string[] { + "password", "user_firstname", + "user_lastname"}); - // // check password - // if (!String.IsNullOrEmpty(m_requiredPassword) && - // (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); + // check password + if (!String.IsNullOrEmpty(m_requiredPassword) && + (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); - // // do the job - // string firstname = (string) requestData["user_firstname"]; - // string lastname = (string) requestData["user_lastname"]; + // do the job + string firstname = (string) requestData["user_firstname"]; + string lastname = (string) requestData["user_lastname"]; - // string passwd = String.Empty; - // uint? regX = null; - // uint? regY = null; + string passwd = String.Empty; + uint? regX = null; + uint? regY = null; // uint? ulaX = null; // uint? ulaY = null; // uint? ulaZ = null; @@ -1223,11 +1228,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController // string aboutFirstLive = String.Empty; // string aboutAvatar = String.Empty; - // if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; - // if (requestData.ContainsKey("start_region_x")) - // regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); - // if (requestData.ContainsKey("start_region_y")) - // regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; + if (requestData.ContainsKey("start_region_x")) + regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + if (requestData.ContainsKey("start_region_y")) + regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); // if (requestData.ContainsKey("start_lookat_x")) // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); @@ -1247,21 +1252,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController // if (requestData.ContainsKey("about_virtual_world")) // aboutAvatar = (string)requestData["about_virtual_world"]; - // UserProfileData userProfile - // = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + UUID scopeID = scene.RegionInfo.ScopeID; + UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, firstname, lastname); - // if (null == userProfile) - // throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); + if (null == account) + throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); - // if (!String.IsNullOrEmpty(passwd)) - // { - // m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname); - // string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); - // userProfile.PasswordHash = md5PasswdHash; - // } - - // if (null != regX) userProfile.HomeRegionX = (uint) regX; - // if (null != regY) userProfile.HomeRegionY = (uint) regY; + if (!String.IsNullOrEmpty(passwd)) + { + m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname); + ChangeUserPassword(firstname, lastname, passwd); + } // if (null != usaX) userProfile.HomeLocationX = (uint) usaX; // if (null != usaY) userProfile.HomeLocationY = (uint) usaY; @@ -1274,35 +1276,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive; // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar; - // // User has been created. Now establish gender and appearance. + // Set home position - // updateUserAppearance(responseData, requestData, userProfile.ID); + if ((null != regX) && (null != regY)) + { + GridRegion home = scene.GridService.GetRegionByPosition(scopeID, + (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); + if (null == home) { + m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstname, lastname); + } else { + scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname); + } + } - // if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) - // throw new Exception("did not manage to update user profile"); + // User has been created. Now establish gender and appearance. - // responseData["success"] = true; + updateUserAppearance(responseData, requestData, account.PrincipalID); - // response.Value = responseData; + responseData["success"] = true; + responseData["avatar_uuid"] = account.PrincipalID.ToString(); - // m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", - // firstname, lastname, - // userProfile.ID); - // } - // catch (Exception e) - // { - // m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); - // m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); + response.Value = responseData; - // responseData["success"] = false; - // responseData["error"] = e.Message; + m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", + firstname, lastname, + account.PrincipalID); + } + catch (Exception e) + { - // response.Value = responseData; - // } - //} + m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); + m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); - m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); - return response; + responseData["success"] = false; + responseData["avatar_uuid"] = UUID.Zero.ToString(); + responseData["error"] = e.Message; + + response.Value = responseData; + } + m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); + return response; + } } /// @@ -1316,73 +1331,74 @@ namespace OpenSim.ApplicationPlugins.RemoteController private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid) { m_log.DebugFormat("[RADMIN] updateUserAppearance"); - m_log.Warn("[RADMIN]: This method needs update for 0.7"); - //string dmale = m_config.GetString("default_male", "Default Male"); - //string dfemale = m_config.GetString("default_female", "Default Female"); - //string dneut = m_config.GetString("default_female", "Default Default"); + string dmale = m_config.GetString("default_male", "Default Male"); + string dfemale = m_config.GetString("default_female", "Default Female"); + string dneut = m_config.GetString("default_female", "Default Default"); string model = String.Empty; - //// Has a gender preference been supplied? + // Has a gender preference been supplied? - //if (requestData.Contains("gender")) - //{ - // switch ((string)requestData["gender"]) - // { - // case "m" : - // model = dmale; - // break; - // case "f" : - // model = dfemale; - // break; - // case "n" : - // default : - // model = dneut; - // break; - // } - //} + if (requestData.Contains("gender")) + { + switch ((string)requestData["gender"]) + { + case "m" : + case "male" : + model = dmale; + break; + case "f" : + case "female" : + model = dfemale; + break; + case "n" : + case "neutral" : + default : + model = dneut; + break; + } + } - //// Has an explicit model been specified? + // Has an explicit model been specified? - //if (requestData.Contains("model")) - //{ - // model = (string)requestData["model"]; - //} + if (requestData.Contains("model") && (String.IsNullOrEmpty((string)requestData["gender"]))) + { + model = (string)requestData["model"]; + } - //// No appearance attributes were set + // No appearance attributes were set - //if (model == String.Empty) - //{ - // m_log.DebugFormat("[RADMIN] Appearance update not requested"); - // return; - //} + if (String.IsNullOrEmpty(model)) + { + m_log.DebugFormat("[RADMIN] Appearance update not requested"); + return; + } - //m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model); + m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model <{1}>", userid, model); - //string[] nomens = model.Split(); - //if (nomens.Length != 2) - //{ - // m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); - // // nomens = dmodel.Split(); - // return; - //} + string[] nomens = model.Split(); + if (nomens.Length != 2) + { + m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); + // nomens = dmodel.Split(); + return; + } - //UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + UUID scopeID = scene.RegionInfo.ScopeID; + UserAccount mprof = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); - //// Is this the first time one of the default models has been used? Create it if that is the case - //// otherwise default to male. + if (mprof == null) + { + m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); + return; + } - //if (mprof == null) - //{ - // m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); - // return; - //} + // Set current user's appearance. This bit is easy. The appearance structure is populated with + // actual asset ids, however to complete the magic we need to populate the inventory with the + // assets in question. - //// Set current user's appearance. This bit is easy. The appearance structure is populated with - //// actual asset ids, however to complete the magic we need to populate the inventory with the - //// assets in question. - - //establishAppearance(userid, mprof.ID); + establishAppearance(userid, mprof.PrincipalID); m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", userid, model); @@ -1397,116 +1413,312 @@ namespace OpenSim.ApplicationPlugins.RemoteController private void establishAppearance(UUID dest, UUID srca) { m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); + Scene scene = m_app.SceneManager.CurrentOrFirstScene; AvatarAppearance ava = null; - AvatarData avatar = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(srca); + AvatarData avatar = scene.AvatarService.GetAvatar(srca); if (avatar != null) ava = avatar.ToAvatarAppearance(srca); // If the model has no associated appearance we're done. - - // if (ava == null) - // { - // return new AvatarAppearance(); - // } - if (ava == null) return; - UICallback sic = new UICallback(); - UICallback dic = new UICallback(); - IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; + // Simple appearance copy or copy Clothing and Bodyparts folders? + bool copyFolders = m_config.GetBoolean("copy_folders", false); + if (!copyFolders) + { + // Simple copy of wearables and appearance update + try + { + copyWearablesAndAttachments(dest, srca, ava); + + AvatarData adata = new AvatarData(ava); + scene.AvatarService.SetAvatar(dest, adata); + } + catch (Exception e) + { + m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}", + dest, e.Message); + } + + return; + } + + // Copy Clothing and Bodypart folders and appearance update try { Dictionary imap = new Dictionary(); + copyInventoryFolders(dest, srca, AssetType.Clothing, imap, ava); + copyInventoryFolders(dest, srca, AssetType.Bodypart, imap, ava); - iserv.GetUserInventory(dest, dic.callback); - iserv.GetUserInventory(srca, sic.callback); + AvatarWearable[] wearables = ava.Wearables; - dic.GetInventory(); - sic.GetInventory(); - - if (sic.OK && dic.OK) + for (int i=0; i + /// + /// This method is called by establishAppearance to do a copy all inventory items + /// worn or attached to the Clothing inventory folder of the receiving avatar. + /// In parallel the avatar wearables and attachments are updated. + /// + + private void copyWearablesAndAttachments(UUID dest, UUID srca, AvatarAppearance ava) + { + IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; + + // Get Clothing folder of receiver + InventoryFolderBase dstf = iserv.GetFolderForType(dest, AssetType.Clothing); + + if (dstf == null) + throw new Exception("Cannot locate folder(s)"); + + // Missing destination folder? This should *never* be the case + if (dstf.Type != (short)AssetType.Clothing) + { + dstf = new InventoryFolderBase(); + dstf.ID = UUID.Random(); + dstf.Name = "Clothing"; + dstf.Owner = dest; + dstf.Type = (short)AssetType.Clothing; + dstf.ParentID = iserv.GetRootFolder(dest).ID; + dstf.Version = 1; + iserv.AddFolder(dstf); // store base record + m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca); + } + + // Wearables + AvatarWearable[] wearables = ava.Wearables; + AvatarWearable wearable; + + for (int i=0; i attachments = ava.GetAttachmentDictionary(); + + foreach (KeyValuePair kvp in attachments) + { + int attachpoint = kvp.Key; + UUID itemID = kvp.Value[0]; + + if (itemID != UUID.Zero) + { + // Get inventory item and copy it + InventoryItemBase item = new InventoryItemBase(itemID, srca); + item = iserv.GetItem(item); + + if (item != null) + { + InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest); + dsti.Name = item.Name; + dsti.Description = item.Description; + dsti.InvType = item.InvType; + dsti.CreatorId = item.CreatorId; + dsti.CreatorIdAsUuid = item.CreatorIdAsUuid; + dsti.NextPermissions = item.NextPermissions; + dsti.CurrentPermissions = item.CurrentPermissions; + dsti.BasePermissions = item.BasePermissions; + dsti.EveryOnePermissions = item.EveryOnePermissions; + dsti.GroupPermissions = item.GroupPermissions; + dsti.AssetType = item.AssetType; + dsti.AssetID = item.AssetID; + dsti.GroupID = item.GroupID; + dsti.GroupOwned = item.GroupOwned; + dsti.SalePrice = item.SalePrice; + dsti.SaleType = item.SaleType; + dsti.Flags = item.Flags; + dsti.CreationDate = item.CreationDate; + dsti.Folder = dstf.ID; + + iserv.AddItem(dsti); + m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, dstf.ID); + + // Attach item + ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID); + m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID); + } + else + { + m_log.WarnFormat("[RADMIN] Error transferring {0} to folder {1}", itemID, dstf.ID); + } + } + } + + + } + + /// + /// This method is called by establishAppearance to copy inventory folders to make + /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments + /// + + private void copyInventoryFolders(UUID dest, UUID srca, AssetType assettype, Dictionary imap, + AvatarAppearance ava) + { + IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; + + InventoryFolderBase srcf = iserv.GetFolderForType(srca, assettype); + InventoryFolderBase dstf = iserv.GetFolderForType(dest, assettype); + + if (srcf == null || dstf == null) + throw new Exception("Cannot locate folder(s)"); + + // Missing source folder? This should *never* be the case + if (srcf.Type != (short)assettype) + { + srcf = new InventoryFolderBase(); + srcf.ID = UUID.Random(); + if (assettype == AssetType.Clothing) { + srcf.Name = "Clothing"; + } else { + srcf.Name = "Body Parts"; + } + srcf.Owner = srca; + srcf.Type = (short)assettype; + srcf.ParentID = iserv.GetRootFolder(srca).ID; + srcf.Version = 1; + iserv.AddFolder(srcf); // store base record + m_log.ErrorFormat("[RADMIN] Created folder for source {0}", srca); + } + + // Missing destination folder? This should *never* be the case + if (dstf.Type != (short)assettype) + { + dstf = new InventoryFolderBase(); + dstf.ID = UUID.Random(); + dstf.Name = assettype.ToString(); + dstf.Owner = dest; + dstf.Type = (short)assettype; + dstf.ParentID = iserv.GetRootFolder(dest).ID; + dstf.Version = 1; + iserv.AddFolder(dstf); // store base record + m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca); + } + + InventoryFolderBase efolder; + List folders = iserv.GetFolderContent(srca, srcf.ID).Folders; + + foreach (InventoryFolderBase folder in folders) + { + + efolder = new InventoryFolderBase(); + efolder.ID = UUID.Random(); + efolder.Name = folder.Name; + efolder.Owner = dest; + efolder.Type = folder.Type; + efolder.Version = folder.Version; + efolder.ParentID = dstf.ID; + iserv.AddFolder(efolder); + + m_log.DebugFormat("[RADMIN] Added folder {0} to folder {1}", efolder.ID, srcf.ID); + + List items = iserv.GetFolderContent(srca, folder.ID).Items; + + foreach (InventoryItemBase item in items) + { + InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest); + dsti.Name = item.Name; + dsti.Description = item.Description; + dsti.InvType = item.InvType; + dsti.CreatorId = item.CreatorId; + dsti.CreatorIdAsUuid = item.CreatorIdAsUuid; + dsti.NextPermissions = item.NextPermissions; + dsti.CurrentPermissions = item.CurrentPermissions; + dsti.BasePermissions = item.BasePermissions; + dsti.EveryOnePermissions = item.EveryOnePermissions; + dsti.GroupPermissions = item.GroupPermissions; + dsti.AssetType = item.AssetType; + dsti.AssetID = item.AssetID; + dsti.GroupID = item.GroupID; + dsti.GroupOwned = item.GroupOwned; + dsti.SalePrice = item.SalePrice; + dsti.SaleType = item.SaleType; + dsti.Flags = item.Flags; + dsti.CreationDate = item.CreationDate; + dsti.Folder = efolder.ID; + + iserv.AddItem(dsti); + imap.Add(item.ID, dsti.ID); + m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID); + + // Attach item, if original is attached + int attachpoint = ava.GetAttachpoint(item.ID); + if (attachpoint != 0) + { + ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID); + m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID); + } + } + } + } + + /// /// This method is called if a given model avatar name can not be found. If the external /// file has already been loaded once, then control returns immediately. If not, then it /// looks for a default appearance file. This file contains XML definitions of zero or more named @@ -1557,9 +1769,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController bool include = false; bool select = false; - UICallback uic; - IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; - IAssetService aserv = m_app.SceneManager.CurrentOrFirstScene.AssetService; + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + IInventoryService iserv = scene.InventoryService; + IAssetService aserv = scene.AssetService; doc.LoadXml(File.ReadAllText(dafn)); @@ -1596,29 +1808,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController passwd = GetStringAttribute(avatar,"password",passwd); string[] nomens = name.Split(); - UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; - UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); + UUID scopeID = scene.RegionInfo.ScopeID; + UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); if (null == account) { - account = new UserAccount(scopeID, nomens[0], nomens[1], email); - bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); - if (!success) + account = CreateUser(scopeID, nomens[0], nomens[1], passwd, email); + if (null == account) { m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); return false; } - // !!! REFACTORING PROBLEM: need to set the password + } - GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, - (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); - if (home != null) - m_app.SceneManager.CurrentOrFirstScene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); - } - else - { - ID = account.PrincipalID; + // Set home position + + GridRegion home = scene.GridService.GetRegionByPosition(scopeID, + (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); + if (null == home) { + m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", nomens[0], nomens[1]); + } else { + scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, nomens[0], nomens[1]); } + ID = account.PrincipalID; + m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); include = true; } @@ -1635,46 +1849,36 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (include) { - uic = new UICallback(); - // Request the inventory - iserv.GetUserInventory(ID, uic.callback); - - // While the inventory is being fetched, setup for appearance processing - AvatarData adata = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(ID); + // Setup for appearance processing + AvatarData adata = scene.AvatarService.GetAvatar(ID); if (adata != null) mava = adata.ToAvatarAppearance(ID); else mava = new AvatarAppearance(); + AvatarWearable[] wearables = mava.Wearables; + for (int i=0; i folders = iserv.GetFolderContent(ID, cfolder.ID).Folders; + efolder = null; + + foreach (InventoryFolderBase folder in folders) { - if (folder.Name == oname && folder.ParentID == cfolder.ID) + if (folder.Name == oname) { efolder = folder; break; @@ -1711,14 +1918,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (efolder == null) { m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name); - efolder = new InventoryFolderImpl(); + efolder = new InventoryFolderBase(); efolder.ID = UUID.Random(); efolder.Name = oname; - efolder.Type = 5; - efolder.Version = 1; efolder.Owner = ID; - cfolder.AddChildFolder(efolder); // make connection - iserv.AddFolder(efolder); // store base record + efolder.Type = (short)AssetType.Clothing; + efolder.Version = 1; + efolder.ParentID = cfolder.ID; + iserv.AddFolder(efolder); m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID); } @@ -1745,26 +1952,55 @@ namespace OpenSim.ApplicationPlugins.RemoteController InventoryItemBase iitem = null; - if ((iitem = efolder.FindAsset(assetid)) == null) + // Check if asset is in inventory already + iitem = null; + List iitems = iserv.GetFolderContent(ID, efolder.ID).Items; + + foreach (InventoryItemBase litem in iitems) { - iitem = new InventoryItemBase(); - iitem.ID = UUID.Random(); + if (litem.AssetID == assetid) + { + iitem = litem; + break; + } + } + + // Create inventory item + if (iitem == null) + { + iitem = new InventoryItemBase(UUID.Random(), ID); iitem.Name = GetStringAttribute(item,"name",""); iitem.Description = GetStringAttribute(item,"desc",""); iitem.InvType = GetIntegerAttribute(item,"invtype",-1); - iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); - iitem.Flags = GetUnsignedAttribute(item,"flags",0); - iitem.AssetID = assetid; // associated asset - iitem.Folder = efolder.ID; // Parent folder - iitem.Owner = ID; // Agent ID - iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); + iitem.CreatorId = GetStringAttribute(item,"creatorid",""); + iitem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid",""); iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff); iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); - iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); + iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); - m_log.DebugFormat("[RADMIN] Adding item {0} to folder {1}", iitem.ID, efolder.ID); + iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); + iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); + iitem.AssetID = assetid; // associated asset + iitem.GroupID = (UUID)GetStringAttribute(item,"groupid",""); + iitem.GroupOwned = (GetStringAttribute(item,"groupowned","false") == "true"); + iitem.SalePrice = GetIntegerAttribute(item,"saleprice",0); + iitem.SaleType = (byte)GetIntegerAttribute(item,"saletype",0); + iitem.Flags = GetUnsignedAttribute(item,"flags",0); + iitem.CreationDate = GetIntegerAttribute(item,"creationdate",Util.UnixTimeSinceEpoch()); + iitem.Folder = efolder.ID; // Parent folder + iserv.AddItem(iitem); + m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", iitem.ID, efolder.ID); } + + // Attach item, if attachpoint is specified + int attachpoint = GetIntegerAttribute(item,"attachpoint",0); + if (attachpoint != 0) + { + mava.SetAttachment(attachpoint, iitem.ID, iitem.AssetID); + m_log.DebugFormat("[RADMIN] Attached {0}", iitem.ID); + } + // Record whether or not the item is to be initially worn try { @@ -1774,25 +2010,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController mava.Wearables[iitem.Flags].AssetID = iitem.AssetID; } } - catch {} + catch (Exception e) + { + m_log.WarnFormat("[RADMIN] Error wearing item {0} : {1}", iitem.ID, e.Message); + } } // foreach item in outfit m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); } // foreach outfit m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); AvatarData adata2 = new AvatarData(mava); - m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(ID, adata2); + scene.AvatarService.SetAvatar(ID, adata2); } catch (Exception e) { m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}", name, e.Message); } - else - { - m_log.WarnFormat("[RADMIN] Unable to retrieve inventory for {0}[{1}]", - name, ID); - // continue to next avatar - } } // End of include } m_log.DebugFormat("[RADMIN] Default avatar loading complete"); @@ -2660,81 +2893,115 @@ namespace OpenSim.ApplicationPlugins.RemoteController public void Dispose() { } - } - class UICallback - { - private Object uilock = new Object(); - internal InventoryFolderImpl root = null; - internal List folders; - internal List items; - internal bool OK = false; - - public void callback(ICollection p_folders, ICollection p_items) + /// + /// Create a user + /// + /// + /// + /// + /// + /// + private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) { - lock (uilock) - { - folders = (List) p_folders; - items = (List) p_items; - OK = true; - System.Threading.Monitor.Pulse(uilock); - } - } + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + IUserAccountService m_UserAccountService = scene.UserAccountService; + IGridService m_GridService = scene.GridService; + IAuthenticationService m_AuthenticationService = scene.AuthenticationService; + IGridUserService m_GridUserService = scene.GridUserService; + IInventoryService m_InventoryService = scene.InventoryService; - public void GetInventory() - { - Dictionary fmap = new Dictionary(); - - if (OK == false) + UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName); + if (null == account) { - lock (uilock) + account = new UserAccount(scopeID, firstName, lastName, email); + if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) { - if (OK == false) - System.Threading.Monitor.Wait(uilock); + account.ServiceURLs = new Dictionary(); + account.ServiceURLs["HomeURI"] = string.Empty; + account.ServiceURLs["GatekeeperURI"] = string.Empty; + account.ServiceURLs["InventoryServerURI"] = string.Empty; + account.ServiceURLs["AssetServerURI"] = string.Empty; } - } - // Got the inventory OK. So now merge the content of the default appearance - // file with whatever we already have in-world. For convenience we initialize - // the inventory hierarchy. - - // Find root and build an index - - foreach (InventoryFolderImpl folder in folders) - { - if (folder.ParentID == UUID.Zero) + if (m_UserAccountService.StoreUserAccount(account)) { - if (root == null) + bool success; + if (m_AuthenticationService != null) { - root = folder; + success = m_AuthenticationService.SetPassword(account.PrincipalID, password); + if (!success) + m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", + firstName, lastName); + } + + GridRegion home = null; + if (m_GridService != null) + { + List defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); + if (defaultRegions != null && defaultRegions.Count >= 1) + home = defaultRegions[0]; + + if (m_GridUserService != null && home != null) + m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + else + m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.", + firstName, lastName); } else + m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.", + firstName, lastName); + + if (m_InventoryService != null) { - throw new Exception("Multiple root folders found"); + success = m_InventoryService.CreateUserInventory(account.PrincipalID); + if (!success) + m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.", + firstName, lastName); } - } - fmap.Add(folder.ID, folder); - } - // Hard to continue if the root folder is not there - if (root == null) - { - throw new Exception("Root folder not found"); - } - - // Construct the folder hierarchy - foreach (InventoryFolderImpl folder in folders) - { - if (folder.ID != root.ID) - { - fmap[folder.ParentID].AddChildFolder(folder); + m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName); + return account; + } else { + m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName); } } - - // Find a home for every pre-existing item - foreach (InventoryItemBase item in items) + else { - fmap[item.Folder].Items.Add(item.ID, item); + m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName); + } + return null; + } + + /// + /// Change password + /// + /// + /// + /// + private bool ChangeUserPassword(string firstName, string lastName, string password) + { + Scene scene = m_app.SceneManager.CurrentOrFirstScene; + IUserAccountService m_UserAccountService = scene.UserAccountService; + IAuthenticationService m_AuthenticationService = scene.AuthenticationService; + + UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); + if (null != account) + { + bool success = false; + if (m_AuthenticationService != null) + success = m_AuthenticationService.SetPassword(account.PrincipalID, password); + if (!success) { + m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", + firstName, lastName); + return false; + } + return true; + } + else + { + m_log.ErrorFormat("[RADMIN]: No such user"); + return false; } } } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 874f1a2fdd..56c73ec7c9 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 063251a58c..326e502017 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -357,7 +357,7 @@ namespace OpenSim.Services.UserAccountService /// /// /// - public void CreateUser(string firstName, string lastName, string password, string email) + private void CreateUser(string firstName, string lastName, string password, string email) { UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); if (null == account) @@ -374,12 +374,14 @@ namespace OpenSim.Services.UserAccountService if (StoreUserAccount(account)) { - bool success = false; + bool success; if (m_AuthenticationService != null) + { success = m_AuthenticationService.SetPassword(account.PrincipalID, password); - if (!success) - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", - firstName, lastName); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", + firstName, lastName); + } GridRegion home = null; if (m_GridService != null) @@ -399,18 +401,22 @@ namespace OpenSim.Services.UserAccountService firstName, lastName); if (m_InventoryService != null) + { success = m_InventoryService.CreateUserInventory(account.PrincipalID); - if (!success) - m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", - firstName, lastName); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", + firstName, lastName); + } m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); + } else { + m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); } } else { m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); } - } + } } } From 9069114d0fb86371839338f16e9d306686ea60ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 13 Jun 2010 21:57:56 +0100 Subject: [PATCH 4/6] Fox my changes to radmin --- .../ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index b248d1117a..e57aaa08f7 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -999,8 +999,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController string lastname = (string) requestData["user_lastname"]; string passwd = (string) requestData["user_password"]; - regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); - regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); string email = ""; // empty string for email if (requestData.Contains("user_email")) From 19558f380a1e9cbaff849eb15262266ea79b60d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 13 Jun 2010 19:06:22 -0700 Subject: [PATCH 5/6] Fixes the long-standing RegionUp bug! Plus lots of other cleanups related to neighbours. --- .../Avatar/Attachments/AttachmentsModule.cs | 2 +- .../AvatarFactory/AvatarFactoryModule.cs | 2 +- .../EntityTransfer/EntityTransferModule.cs | 28 ++++++++++++++++++ .../NeighbourServiceInConnectorModule.cs | 5 +--- .../Grid/LocalGridServiceConnector.cs | 17 +---------- .../Grid/RemoteGridServiceConnector.cs | 5 +--- .../LocalNeighbourServiceConnector.cs | 8 ++--- .../Simulation/RemoteSimulationConnector.cs | 1 - OpenSim/Region/Framework/Scenes/Scene.cs | 29 +++---------------- .../Scenes/SceneCommunicationService.cs | 21 +++++--------- .../Connectors/Grid/GridServiceConnector.cs | 9 ++---- .../Simulation/SimulationServiceConnector.cs | 2 +- OpenSim/Services/GridService/GridService.cs | 5 ++-- 13 files changed, 55 insertions(+), 79 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 6d16c52862..a7b4c66d2b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -352,7 +352,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Save avatar attachment information if (m_scene.AvatarFactory != null) { - m_log.Debug("[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); + m_log.Debug("[ATTACHMENTS MODULE]: Dettaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); } } diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 22c89370a7..7e5a8ec9f1 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -198,7 +198,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void UpdateDatabase(UUID user, AvatarAppearance appearance) { - //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); + m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); AvatarData adata = new AvatarData(appearance); m_scene.AvatarService.SetAvatar(user, adata); } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 5d50a83e51..ab1cfc352b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -922,12 +922,40 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// public void EnableChildAgent(ScenePresence sp, GridRegion region) { + m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighour {0}", region.RegionName); + + AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); agent.BaseFolder = UUID.Zero; agent.InventoryFolder = UUID.Zero; agent.startpos = new Vector3(128, 128, 70); agent.child = true; agent.Appearance = sp.Appearance; + agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + + agent.ChildrenCapSeeds = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); + m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count); + + if (!agent.ChildrenCapSeeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) + agent.ChildrenCapSeeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); + m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); + + sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); + foreach (ulong h in agent.ChildrenCapSeeds.Keys) + m_log.DebugFormat("[XXX] --> {0}", h); + m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle); + agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); + + if (sp.Scene.CapsModule != null) + { + sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, agent.ChildrenCapSeeds); + } + + if (currentAgentCircuit != null) + { + agent.ServiceURLs = currentAgentCircuit.ServiceURLs; + agent.Viewer = currentAgentCircuit.Viewer; + } InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs index 8a903701fa..35518d59f8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs @@ -123,17 +123,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) { - m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", - thisRegion.RegionName, regionHandle, m_Scenes.Count); foreach (Scene s in m_Scenes) { if (s.RegionInfo.RegionHandle == regionHandle) { - m_log.Debug("[NEIGHBOUR IN CONNECTOR]: Found region to SendHelloNeighbour"); + //m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0} to {1}", thisRegion.RegionName, s.RegionInfo.RegionName); return s.IncomingHelloNeighbour(thisRegion); } } - m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle); return null; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 1b00c8a9d7..b2e3f4f7f5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -181,22 +181,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public List GetNeighbours(UUID scopeID, UUID regionID) { - if (m_LocalCache.ContainsKey(regionID)) - { - List neighbours = m_LocalCache[regionID].GetNeighbours(); - if (neighbours.Count == 0) - // try the DB - neighbours = m_GridService.GetNeighbours(scopeID, regionID); - return neighbours; - } - else - { - m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID); - return new List(); - } - - // Don't go to the DB - //return m_GridService.GetNeighbours(scopeID, regionID); + return m_GridService.GetNeighbours(scopeID, regionID); } public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 46741a58ec..16e25e6f11 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -153,12 +153,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return false; } - // Let's override GetNeighbours completely -- never go to the grid server - // Neighbours are/should be cached locally - // For retrieval from the DB, caller should call GetRegionByPosition public override List GetNeighbours(UUID scopeID, UUID regionID) { - return m_LocalGridService.GetNeighbours(scopeID, regionID); + return base.GetNeighbours(scopeID, regionID); } public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index daba0b3bb4..f71bf4634b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs @@ -121,17 +121,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) { - m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", - thisRegion.RegionName, regionHandle, m_Scenes.Count); + m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}.", + thisRegion.RegionName, regionHandle); foreach (Scene s in m_Scenes) { if (s.RegionInfo.RegionHandle == regionHandle) { - m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); + //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); return s.IncomingHelloNeighbour(thisRegion); } } - m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); + //m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); return null; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 9e8454f72f..3f577f2ad6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -181,7 +181,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { - //m_regionClient.SendUserInformation(regInfo, aCircuit); return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); } return false; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55060c3e8a..2ff611ec30 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -948,12 +948,6 @@ namespace OpenSim.Region.Framework.Scenes // Let the grid service module know, so this can be cached m_eventManager.TriggerOnRegionUp(otherRegion); - RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName); - regInfo.RegionID = otherRegion.RegionID; - regInfo.RegionName = otherRegion.RegionName; - regInfo.ScopeID = otherRegion.ScopeID; - regInfo.ExternalHostName = otherRegion.ExternalHostName; - GridRegion r = new GridRegion(regInfo); try { ForEachScenePresence(delegate(ScenePresence agent) @@ -968,7 +962,7 @@ namespace OpenSim.Region.Framework.Scenes old.Add(otherRegion.RegionHandle); agent.DropOldNeighbours(old); if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, r); + m_teleportModule.EnableChildAgent(agent, otherRegion); } } ); @@ -1518,6 +1512,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); LoginsDisabled = false; + m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); } } } @@ -1802,6 +1797,8 @@ namespace OpenSim.Region.Framework.Scenes { RegisterCommsEvents(); + m_sceneGridService.SetScene(this); + // These two 'commands' *must be* next to each other or sim rebooting fails. //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); @@ -1812,24 +1809,6 @@ namespace OpenSim.Region.Framework.Scenes throw new Exception(error); } - m_sceneGridService.SetScene(this); - m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); - - //Dictionary dGridSettings = m_sceneGridService.GetGridSettings(); - - //if (dGridSettings.ContainsKey("allow_forceful_banlines")) - //{ - // if (dGridSettings["allow_forceful_banlines"] != "TRUE") - // { - // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); - // EventManager.TriggerSetAllowForcefulBan(false); - // } - // else - // { - // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); - // EventManager.TriggerSetAllowForcefulBan(true); - // } - //} } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index bd8ccce6e1..c675322185 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -182,24 +182,17 @@ namespace OpenSim.Region.Framework.Scenes { //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); - for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++) + List neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); + m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); + foreach (GridRegion n in neighbours) { - for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++) - { - if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region - { - ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize); - InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; - - d.BeginInvoke(neighbourService, region, handle, - InformNeighborsThatRegionisUpCompleted, - d); - } - } + InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; + d.BeginInvoke(neighbourService, region, n.RegionHandle, + InformNeighborsThatRegionisUpCompleted, + d); } } - public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); /// diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 0ec8912abd..18315337ac 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -210,9 +210,6 @@ namespace OpenSim.Services.Connectors GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } - else - m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}", - scopeID, regionID, r.GetType()); } } else @@ -299,9 +296,9 @@ namespace OpenSim.Services.Connectors { if (replyData["result"] is Dictionary) rinfo = new GridRegion((Dictionary)replyData["result"]); - else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region", - scopeID, x, y); + //else + // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region", + // scopeID, x, y); } else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index ff0dd7e622..32f02fbf37 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -479,7 +479,7 @@ namespace OpenSim.Services.Connectors.Simulation } catch (WebException ex) { - m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent delete {0}", ex.Message); + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent delete from {0}: {1}", destination.RegionName, ex.Message); return false; } finally diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 7c9864270c..225530f6ab 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -273,14 +273,15 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, - region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, + region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); foreach (RegionData rdata in rdatas) if (rdata.RegionID != regionID) rinfos.Add(RegionData2RegionInfo(rdata)); } + m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count); return rinfos; } From bd346ab8c7bc8358d467b39dd21070d935a9131b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 13 Jun 2010 19:18:17 -0700 Subject: [PATCH 6/6] Fixes attachments coming back upon being detached in neighbouring regions and crossing. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c1e835e85a..6c119c2f5c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3128,6 +3128,7 @@ namespace OpenSim.Region.Framework.Scenes { if (cAgent.Attachments != null) { + m_appearance.ClearAttachments(); foreach (AttachmentData att in cAgent.Attachments) { m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);