From b7a0855c3afea27f207655fca25651b19b41636a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 14 May 2008 06:09:39 +0000 Subject: More formatting cleanup. Minor refactoring. --- OpenSim/Data/NHibernate/NHibernateAssetData.cs | 48 +++++--- OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 132 ++++++++++++++------- OpenSim/Data/NHibernate/NHibernateUserData.cs | 107 +++++++++++------ .../Manager/OpenGridServices.Manager/MainWindow.cs | 9 +- .../Compiler/LSO/LSL_BaseClass_Builtins.cs | 15 ++- .../DotNetEngine/Compiler/LSO/LSO_Enums.cs | 3 +- OpenSim/Grid/UserServer/UserLoginService.cs | 3 +- OpenSim/Region/Application/OpenSimMain.cs | 8 +- ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | 4 +- 9 files changed, 219 insertions(+), 110 deletions(-) diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index 875f4e5..4eb9eef 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs @@ -60,7 +60,8 @@ namespace OpenSim.Data.NHibernate // Split out the dialect, driver, and connect string char[] split = {';'}; string[] parts = connect.Split(split, 3); - if (parts.Length != 3) { + if (parts.Length != 3) + { // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } @@ -96,15 +97,22 @@ namespace OpenSim.Data.NHibernate { string regex = @"no such table: Assets"; Regex RE = new Regex(regex, RegexOptions.Multiline); - try { - using (ISession session = factory.OpenSession()) { + try + { + using (ISession session = factory.OpenSession()) + { session.Load(typeof(AssetBase), LLUUID.Zero); } - } catch (ObjectNotFoundException) { + } + catch (ObjectNotFoundException) + { // yes, we know it's not there, but that's ok - } catch (ADOException e) { + } + catch (ADOException e) + { Match m = RE.Match(e.ToString()); - if (m.Success) { + if (m.Success) + { // We don't have this table, so create it. new SchemaExport(cfg).Create(true, true); } @@ -113,10 +121,14 @@ namespace OpenSim.Data.NHibernate override public AssetBase FetchAsset(LLUUID uuid) { - using (ISession session = factory.OpenSession()) { - try { + using (ISession session = factory.OpenSession()) + { + try + { return session.Load(typeof(AssetBase), uuid) as AssetBase; - } catch { + } + catch + { return null; } } @@ -124,9 +136,12 @@ namespace OpenSim.Data.NHibernate override public void CreateAsset(AssetBase asset) { - if (!ExistsAsset(asset.FullID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (!ExistsAsset(asset.FullID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Save(asset); transaction.Commit(); } @@ -136,9 +151,12 @@ namespace OpenSim.Data.NHibernate override public void UpdateAsset(AssetBase asset) { - if (ExistsAsset(asset.FullID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (ExistsAsset(asset.FullID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Update(asset); transaction.Commit(); } diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 6ee1b4a..8305646 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs @@ -57,7 +57,8 @@ namespace OpenSim.Data.NHibernate // Split out the dialect, driver, and connect string char[] split = {';'}; string[] parts = connect.Split(split, 3); - if (parts.Length != 3) { + if (parts.Length != 3) + { // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } @@ -94,15 +95,22 @@ namespace OpenSim.Data.NHibernate { string regex = @"no such table: Inventory"; Regex RE = new Regex(regex, RegexOptions.Multiline); - try { - using (ISession session = factory.OpenSession()) { + try + { + using (ISession session = factory.OpenSession()) + { session.Load(typeof(InventoryItemBase), LLUUID.Zero); } - } catch (ObjectNotFoundException) { + } + catch (ObjectNotFoundException) + { // yes, we know it's not there, but that's ok - } catch (ADOException e) { + } + catch (ADOException e) + { Match m = RE.Match(e.ToString()); - if (m.Success) { + if (m.Success) + { // We don't have this table, so create it. new SchemaExport(cfg).Create(true, true); } @@ -125,10 +133,14 @@ namespace OpenSim.Data.NHibernate /// A class containing item information public InventoryItemBase getInventoryItem(LLUUID item) { - using (ISession session = factory.OpenSession()) { - try { + using (ISession session = factory.OpenSession()) + { + try + { return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase; - } catch { + } + catch + { m_log.ErrorFormat("Couldn't find inventory item: {0}", item); return null; } @@ -141,14 +153,19 @@ namespace OpenSim.Data.NHibernate /// The item to be created public void addInventoryItem(InventoryItemBase item) { - if (!ExistsItem(item.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (!ExistsItem(item.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Save(item); transaction.Commit(); } } - } else { + } + else + { m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID); updateInventoryItem(item); } @@ -160,14 +177,19 @@ namespace OpenSim.Data.NHibernate /// The updated item public void updateInventoryItem(InventoryItemBase item) { - if (ExistsItem(item.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (ExistsItem(item.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Update(item); transaction.Commit(); } } - } else { + } + else + { m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID); } } @@ -178,15 +200,16 @@ namespace OpenSim.Data.NHibernate /// public void deleteInventoryItem(LLUUID itemID) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Delete(itemID); transaction.Commit(); } } } - /// /// Returns an inventory folder by its UUID /// @@ -194,10 +217,14 @@ namespace OpenSim.Data.NHibernate /// A class containing folder information public InventoryFolderBase getInventoryFolder(LLUUID folder) { - using (ISession session = factory.OpenSession()) { - try { + using (ISession session = factory.OpenSession()) + { + try + { return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase; - } catch { + } + catch + { m_log.ErrorFormat("Couldn't find inventory item: {0}", folder); return null; } @@ -210,14 +237,19 @@ namespace OpenSim.Data.NHibernate /// The folder to be created public void addInventoryFolder(InventoryFolderBase folder) { - if (!ExistsFolder(folder.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (!ExistsFolder(folder.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Save(folder); transaction.Commit(); } } - } else { + } + else + { m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID); updateInventoryFolder(folder); } @@ -229,14 +261,19 @@ namespace OpenSim.Data.NHibernate /// The updated folder public void updateInventoryFolder(InventoryFolderBase folder) { - if (ExistsFolder(folder.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (ExistsFolder(folder.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Update(folder); transaction.Commit(); } } - } else { + } + else + { m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists", folder.ID); } } @@ -247,8 +284,10 @@ namespace OpenSim.Data.NHibernate /// public void deleteInventoryFolder(LLUUID folderID) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Delete(folderID.ToString()); transaction.Commit(); } @@ -324,7 +363,8 @@ namespace OpenSim.Data.NHibernate /// A List of InventoryItemBase items public List getInventoryInFolder(LLUUID folderID) { - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { // try { ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase)); criteria.Add(Expression.Eq("Folder", folderID)); @@ -334,7 +374,9 @@ namespace OpenSim.Data.NHibernate list.Add(item); } return list; -// } catch { +// } +// catch +// { // return new List(); // } } @@ -348,8 +390,10 @@ namespace OpenSim.Data.NHibernate // see InventoryItemBase.getUserRootFolder public InventoryFolderBase getUserRootFolder(LLUUID user) { - using (ISession session = factory.OpenSession()) { - // try { + using (ISession session = factory.OpenSession()) + { + // try + // { ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase)); criteria.Add(Expression.Eq("ParentID", LLUUID.Zero)); criteria.Add(Expression.Eq("Owner", user)); @@ -359,7 +403,9 @@ namespace OpenSim.Data.NHibernate } m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user); return new InventoryFolderBase(); -// } catch { +// } +// catch +// { // return new InventoryFolderBase(); // } } @@ -372,15 +418,19 @@ namespace OpenSim.Data.NHibernate /// ID of parent private void getInventoryFolders(ref List folders, LLUUID parentID) { - using (ISession session = factory.OpenSession()) { - // try { + using (ISession session = factory.OpenSession()) + { + // try +// { ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase)); criteria.Add(Expression.Eq("ParentID", parentID)); foreach (InventoryFolderBase item in criteria.List()) { folders.Add(item); } - // } catch { + // } + // catch + // { // m_log.ErrorFormat("Can't run getInventoryFolders for Folder ID: {0}", parentID); // } } diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index 2c84ef9..43d8c32 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs @@ -56,7 +56,8 @@ namespace OpenSim.Data.NHibernate { char[] split = {';'}; string[] parts = connect.Split(split, 3); - if (parts.Length != 3) { + if (parts.Length != 3) + { // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } @@ -87,15 +88,22 @@ namespace OpenSim.Data.NHibernate { string regex = @"no such table: UserProfiles"; Regex RE = new Regex(regex, RegexOptions.Multiline); - try { - using (ISession session = factory.OpenSession()) { + try + { + using (ISession session = factory.OpenSession()) + { session.Load(typeof(UserProfileData), LLUUID.Zero); } - } catch (ObjectNotFoundException) { + } + catch (ObjectNotFoundException) + { // yes, we know it's not there, but that's ok - } catch (ADOException e) { + } + catch (ADOException e) + { Match m = RE.Match(e.ToString()); - if (m.Success) { + if (m.Success) + { // We don't have this table, so create it. new SchemaExport(cfg).Create(true, true); } @@ -105,12 +113,15 @@ namespace OpenSim.Data.NHibernate private bool ExistsUser(LLUUID uuid) { UserProfileData user = null; - try { - using (ISession session = factory.OpenSession()) { + try + { + using (ISession session = factory.OpenSession()) + { user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; } // BUG: CATCHALL IS BAD. - } catch (Exception) {} + } + catch (Exception) {} return (user != null); } @@ -119,7 +130,8 @@ namespace OpenSim.Data.NHibernate { UserProfileData user; // TODO: I'm sure I'll have to do something silly here - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; user.CurrentAgent = GetAgentByUUID(uuid); } @@ -128,16 +140,21 @@ namespace OpenSim.Data.NHibernate override public void AddNewUserProfile(UserProfileData profile) { - if (!ExistsUser(profile.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (!ExistsUser(profile.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Save(profile); SetAgentData(profile.ID, profile.CurrentAgent, session); // TODO: save agent transaction.Commit(); } } - } else { + } + else + { m_log.ErrorFormat("Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName); UpdateUserProfile(profile); } @@ -165,16 +182,21 @@ namespace OpenSim.Data.NHibernate } override public bool UpdateUserProfile(UserProfileData profile) { - if (ExistsUser(profile.ID)) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + if (ExistsUser(profile.ID)) + { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Update(profile); SetAgentData(profile.ID, profile.CurrentAgent, session); transaction.Commit(); return true; } } - } else { + } + else + { m_log.ErrorFormat("Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName); AddNewUserProfile(profile); return true; @@ -183,8 +205,10 @@ namespace OpenSim.Data.NHibernate override public void AddNewUserAgent(UserAgentData agent) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Save(agent); transaction.Commit(); } @@ -193,30 +217,35 @@ namespace OpenSim.Data.NHibernate public void UpdateUserAgent(UserAgentData agent) { - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { session.Update(agent); transaction.Commit(); } } } - - override public UserAgentData GetAgentByUUID(LLUUID uuid) { - try { - using (ISession session = factory.OpenSession()) { + try + { + using (ISession session = factory.OpenSession()) + { return session.Load(typeof(UserAgentData), uuid) as UserAgentData; } - } catch { + } + catch + { return null; } } override public UserProfileData GetUserByName(string fname, string lname) { - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); criteria.Add(Expression.Eq("FirstName", fname)); criteria.Add(Expression.Eq("SurName", lname)); @@ -247,7 +276,8 @@ namespace OpenSim.Data.NHibernate if (querysplit.Length == 2) { - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); criteria.Add(Expression.Like("FirstName", querysplit[0])); criteria.Add(Expression.Like("SurName", querysplit[1])); @@ -280,7 +310,8 @@ namespace OpenSim.Data.NHibernate { UserAppearance appearance; // TODO: I'm sure I'll have to do something silly here - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { appearance = session.Load(typeof(UserAppearance), user) as UserAppearance; } return appearance; @@ -289,7 +320,8 @@ namespace OpenSim.Data.NHibernate private bool ExistsAppearance(LLUUID uuid) { UserAppearance appearance; - using (ISession session = factory.OpenSession()) { + using (ISession session = factory.OpenSession()) + { appearance = session.Load(typeof(UserAppearance), uuid) as UserAppearance; } return (appearance == null) ? false : true; @@ -299,11 +331,16 @@ namespace OpenSim.Data.NHibernate override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) { bool exists = ExistsAppearance(user); - using (ISession session = factory.OpenSession()) { - using (ITransaction transaction = session.BeginTransaction()) { - if (exists) { + using (ISession session = factory.OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { + if (exists) + { session.Update(appearance); - } else { + } + else + { session.Save(appearance); } transaction.Commit(); diff --git a/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs b/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs index 4892b8e..64a9b0d 100644 --- a/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs +++ b/OpenSim/Grid/Manager/OpenGridServices.Manager/MainWindow.cs @@ -32,7 +32,7 @@ namespace OpenGridServices.Manager { public partial class MainWindow: Gtk.Window { - public MainWindow (): base (Gtk.WindowType.Toplevel) + public MainWindow() : base (Gtk.WindowType.Toplevel) { Build(); } @@ -57,10 +57,13 @@ namespace OpenGridServices.Manager public void SetGridServerConnected(bool connected) { - if (connected) { + if (connected) + { this.ConnectToGridserver.Visible=false; this.DisconnectFromGridServer.Visible=true; - } else { + } + else + { this.ConnectToGridserver.Visible=true; this.DisconnectFromGridServer.Visible=false; } diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_Builtins.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_Builtins.cs index d2e565d..a551fde 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_Builtins.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_Builtins.cs @@ -35,24 +35,29 @@ // { -// public float llSin() { +// public float llSin() +// { // float f = (float)LSLStack.Pop(); // return LSL_Builtins.llSin(f); // } -// public float llCos() { +// public float llCos() +// { // float f = (float)LSLStack.Pop(); // return LSL_Builtins.llCos(f); // } -// public float llTan() { +// public float llTan() +// { // float f = (float)LSLStack.Pop(); // return LSL_Builtins.llTan(f); // } -// public float llAtan2() { +// public float llAtan2() +// { // float x = (float)LSLStack.Pop(); // float y = (float)LSLStack.Pop(); // return LSL_Builtins.llAtan2(x, y); // } -// public float llSqrt() { +// public float llSqrt() +// { // float f = (float)LSLStack.Pop(); // return LSL_Builtins.llSqrt(f); // } diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs index c679e49..97ccc18 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs @@ -34,7 +34,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { //public System.Collections.Generic.Dictionary OpCode_Add_Types; - //LSO_Enums() { + //LSO_Enums() + //{ // OpCode_Add_Types.Add(51, typeof(String)); // OpCode_Add_Types.Add(17, typeof(UInt32)); //} diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index b123b8c..32b1ada 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -163,7 +163,8 @@ namespace OpenSim.Grid.UserServer theUser.CurrentAgent.Region = SimInfo.UUID; theUser.CurrentAgent.Handle = SimInfo.regionHandle; - if (start_x >= 0 && start_y >= 0 && start_z >= 0) { + if (start_x >= 0 && start_y >= 0 && start_z >= 0) + { LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z); theUser.CurrentAgent.Position = tmp_v; } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index c7094c7..639e3c2 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -745,13 +745,7 @@ namespace OpenSim /// The first out parameter describing the number of regions public void GetRegionNumber(out int regionnum) { - int accounter = 0; - //List regionNameList = new List(); - - m_sceneManager.ForEachScene(delegate(Scene scene) { - accounter++; - }); - regionnum = accounter; + regionnum = m_sceneManager.Scenes.Count; } } } diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index 2732751..9d3bba3 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs @@ -147,7 +147,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer foreach (ScenePresence pre in presences) { IClientAPI client = pre.ControllingClient; - //if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { + //if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) if (client.IsActive) { get_scene_presence_filter++; @@ -160,7 +160,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer foreach (ScenePresence pre in avatars) { IClientAPI client = pre.ControllingClient; - //if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { + //if (pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) if (client.IsActive) { get_avatar_filter++; -- cgit v1.1