diff options
59 files changed, 2129 insertions, 1643 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 9114fc5..6fa116d 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt | |||
@@ -1,5 +1,4 @@ | |||
1 | <<<>>>>The following people have contributed to OpenSim (Thank you | 1 | The following people have contributed to OpenSim (Thank you for your effort!) |
2 | for your effort!) | ||
3 | 2 | ||
4 | = Current OpenSim Developers (in very rough order of appearance) = | 3 | = Current OpenSim Developers (in very rough order of appearance) = |
5 | These folks represent the current core team for OpenSim, and are the | 4 | These folks represent the current core team for OpenSim, and are the |
@@ -61,8 +60,9 @@ where we are today. | |||
61 | These folks have contributed code patches or content to OpenSimulator to help make it | 60 | These folks have contributed code patches or content to OpenSimulator to help make it |
62 | what it is today. | 61 | what it is today. |
63 | 62 | ||
64 | * aduffy70 | ||
65 | * A_Biondi | 63 | * A_Biondi |
64 | * aduffy70 | ||
65 | * Ai Austin | ||
66 | * alex_carnell | 66 | * alex_carnell |
67 | * Alan Webb (IBM) | 67 | * Alan Webb (IBM) |
68 | * Aleric | 68 | * Aleric |
@@ -173,23 +173,18 @@ what it is today. | |||
173 | * Zha Ewry | 173 | * Zha Ewry |
174 | * ziah | 174 | * ziah |
175 | 175 | ||
176 | |||
177 | = LSL Devs = | 176 | = LSL Devs = |
178 | |||
179 | * Alondria | 177 | * Alondria |
180 | * CharlieO | 178 | * CharlieO |
181 | * Tedd | 179 | * Tedd |
182 | * Melanie Thielker | 180 | * Melanie Thielker |
183 | 181 | ||
184 | |||
185 | = Testers = | 182 | = Testers = |
186 | |||
187 | * Ai Austin | 183 | * Ai Austin |
188 | * CharlieO (LSL) | 184 | * CharlieO (LSL) |
189 | * Ckrinke | 185 | * Ckrinke |
190 | * openlifegrid.com | 186 | * openlifegrid.com |
191 | 187 | ||
192 | |||
193 | This software uses components from the following developers: | 188 | This software uses components from the following developers: |
194 | * Sleepycat Software (Berkeley DB) | 189 | * Sleepycat Software (Berkeley DB) |
195 | * Aurora-Sim (http://aurora-sim.org) | 190 | * Aurora-Sim (http://aurora-sim.org) |
diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs index 050ebd2..5ef068a 100644 --- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs +++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs | |||
@@ -261,6 +261,11 @@ namespace OpenSim.OfflineIM | |||
261 | return m_OfflineIMService.StoreMessage(im, out reason); | 261 | return m_OfflineIMService.StoreMessage(im, out reason); |
262 | } | 262 | } |
263 | 263 | ||
264 | public void DeleteMessages(UUID userID) | ||
265 | { | ||
266 | m_OfflineIMService.DeleteMessages(userID); | ||
267 | } | ||
268 | |||
264 | #endregion | 269 | #endregion |
265 | } | 270 | } |
266 | } | 271 | } |
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs index 69feb76..f6b17e5 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs | |||
@@ -117,6 +117,14 @@ namespace OpenSim.OfflineIM | |||
117 | return true; | 117 | return true; |
118 | } | 118 | } |
119 | 119 | ||
120 | public void DeleteMessages(UUID userID) | ||
121 | { | ||
122 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
123 | sendData["UserID"] = userID; | ||
124 | |||
125 | MakeRequest("DELETE", sendData); | ||
126 | } | ||
127 | |||
120 | #endregion | 128 | #endregion |
121 | 129 | ||
122 | 130 | ||
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs index 32c24db..13b0e7e 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -96,13 +96,14 @@ namespace OpenSim.OfflineIM | |||
96 | string method = request["METHOD"].ToString(); | 96 | string method = request["METHOD"].ToString(); |
97 | request.Remove("METHOD"); | 97 | request.Remove("METHOD"); |
98 | 98 | ||
99 | m_log.DebugFormat("[OfflineIM.V2.Handler]: {0}", method); | ||
100 | switch (method) | 99 | switch (method) |
101 | { | 100 | { |
102 | case "GET": | 101 | case "GET": |
103 | return HandleGet(request); | 102 | return HandleGet(request); |
104 | case "STORE": | 103 | case "STORE": |
105 | return HandleStore(request); | 104 | return HandleStore(request); |
105 | case "DELETE": | ||
106 | return HandleDelete(request); | ||
106 | } | 107 | } |
107 | m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method); | 108 | m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method); |
108 | } | 109 | } |
@@ -159,6 +160,21 @@ namespace OpenSim.OfflineIM | |||
159 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 160 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
160 | } | 161 | } |
161 | 162 | ||
163 | byte[] HandleDelete(Dictionary<string, object> request) | ||
164 | { | ||
165 | if (!request.ContainsKey("UserID")) | ||
166 | { | ||
167 | return FailureResult(); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | UUID userID = new UUID(request["UserID"].ToString()); | ||
172 | m_OfflineIMService.DeleteMessages(userID); | ||
173 | |||
174 | return SuccessResult(); | ||
175 | } | ||
176 | } | ||
177 | |||
162 | #region Helpers | 178 | #region Helpers |
163 | 179 | ||
164 | private void NullResult(Dictionary<string, object> result, string reason) | 180 | private void NullResult(Dictionary<string, object> result, string reason) |
diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs index 6731923..690c955 100644 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs +++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -91,7 +91,7 @@ namespace OpenSim.OfflineIM | |||
91 | { | 91 | { |
92 | reason = string.Empty; | 92 | reason = string.Empty; |
93 | 93 | ||
94 | // TODO Check limits | 94 | // Check limits |
95 | UUID principalID = new UUID(im.toAgentID); | 95 | UUID principalID = new UUID(im.toAgentID); |
96 | long count = m_Database.GetCount("PrincipalID", principalID.ToString()); | 96 | long count = m_Database.GetCount("PrincipalID", principalID.ToString()); |
97 | if (count >= MAX_IM) | 97 | if (count >= MAX_IM) |
@@ -100,7 +100,7 @@ namespace OpenSim.OfflineIM | |||
100 | return false; | 100 | return false; |
101 | } | 101 | } |
102 | 102 | ||
103 | string imXml = string.Empty; | 103 | string imXml; |
104 | using (MemoryStream mstream = new MemoryStream()) | 104 | using (MemoryStream mstream = new MemoryStream()) |
105 | { | 105 | { |
106 | XmlWriterSettings settings = new XmlWriterSettings(); | 106 | XmlWriterSettings settings = new XmlWriterSettings(); |
@@ -110,22 +110,26 @@ namespace OpenSim.OfflineIM | |||
110 | { | 110 | { |
111 | m_serializer.Serialize(writer, im); | 111 | m_serializer.Serialize(writer, im); |
112 | writer.Flush(); | 112 | writer.Flush(); |
113 | |||
114 | mstream.Position = 0; | ||
115 | using (StreamReader sreader = new StreamReader(mstream)) | ||
116 | { | ||
117 | imXml = sreader.ReadToEnd(); | ||
118 | } | ||
119 | } | 113 | } |
114 | |||
115 | imXml = Util.UTF8.GetString(mstream.ToArray()); | ||
120 | } | 116 | } |
121 | 117 | ||
122 | OfflineIMData data = new OfflineIMData(); | 118 | OfflineIMData data = new OfflineIMData(); |
123 | data.PrincipalID = principalID; | 119 | data.PrincipalID = principalID; |
120 | data.FromID = new UUID(im.fromAgentID); | ||
124 | data.Data = new Dictionary<string, string>(); | 121 | data.Data = new Dictionary<string, string>(); |
125 | data.Data["Message"] = imXml; | 122 | data.Data["Message"] = imXml; |
126 | 123 | ||
127 | return m_Database.Store(data); | 124 | return m_Database.Store(data); |
128 | 125 | ||
129 | } | 126 | } |
127 | |||
128 | public void DeleteMessages(UUID userID) | ||
129 | { | ||
130 | m_Database.Delete("PrincipalID", userID.ToString()); | ||
131 | m_Database.Delete("FromID", userID.ToString()); | ||
132 | } | ||
133 | |||
130 | } | 134 | } |
131 | } | 135 | } |
diff --git a/OpenSim/Data/IOfflineIMData.cs b/OpenSim/Data/IOfflineIMData.cs index e780304..58501a3 100644 --- a/OpenSim/Data/IOfflineIMData.cs +++ b/OpenSim/Data/IOfflineIMData.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -34,6 +34,7 @@ namespace OpenSim.Data | |||
34 | public class OfflineIMData | 34 | public class OfflineIMData |
35 | { | 35 | { |
36 | public UUID PrincipalID; | 36 | public UUID PrincipalID; |
37 | public UUID FromID; | ||
37 | public Dictionary<string, string> Data; | 38 | public Dictionary<string, string> Data; |
38 | } | 39 | } |
39 | 40 | ||
diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations index 7cfcd43..f73475e 100644 --- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations | |||
@@ -21,4 +21,14 @@ INSERT INTO `im_offline` SELECT * from `diva_im_offline`; | |||
21 | DROP TABLE `diva_im_offline`; | 21 | DROP TABLE `diva_im_offline`; |
22 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | 22 | DELETE FROM `migrations` WHERE name='diva_im_Store'; |
23 | 23 | ||
24 | COMMIT; \ No newline at end of file | 24 | COMMIT; |
25 | |||
26 | :VERSION 3 # -------------------------- | ||
27 | |||
28 | BEGIN; | ||
29 | |||
30 | ALTER TABLE `im_offline` | ||
31 | ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`, | ||
32 | ADD KEY `FromID` (`FromID`); | ||
33 | |||
34 | COMMIT; | ||
diff --git a/OpenSim/Framework/IImprovedAssetCache.cs b/OpenSim/Framework/IImprovedAssetCache.cs index a0b8b55..a853e90 100644 --- a/OpenSim/Framework/IImprovedAssetCache.cs +++ b/OpenSim/Framework/IImprovedAssetCache.cs | |||
@@ -31,10 +31,34 @@ namespace OpenSim.Framework | |||
31 | { | 31 | { |
32 | public interface IImprovedAssetCache | 32 | public interface IImprovedAssetCache |
33 | { | 33 | { |
34 | /// <summary> | ||
35 | /// Cache the specified asset. | ||
36 | /// </summary> | ||
37 | /// <param name='asset'></param> | ||
34 | void Cache(AssetBase asset); | 38 | void Cache(AssetBase asset); |
39 | |||
40 | /// <summary> | ||
41 | /// Get an asset by its id. | ||
42 | /// </summary> | ||
43 | /// <param name='id'></param> | ||
44 | /// <returns>null if the asset does not exist.</returns> | ||
35 | AssetBase Get(string id); | 45 | AssetBase Get(string id); |
46 | |||
47 | /// <summary> | ||
48 | /// Check whether an asset with the specified id exists in the cache. | ||
49 | /// </summary> | ||
50 | /// <param name='id'></param> | ||
36 | bool Check(string id); | 51 | bool Check(string id); |
52 | |||
53 | /// <summary> | ||
54 | /// Expire an asset from the cache. | ||
55 | /// </summary> | ||
56 | /// <param name='id'></param> | ||
37 | void Expire(string id); | 57 | void Expire(string id); |
58 | |||
59 | /// <summary> | ||
60 | /// Clear the cache. | ||
61 | /// </summary> | ||
38 | void Clear(); | 62 | void Clear(); |
39 | } | 63 | } |
40 | } | 64 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 2c6529d..dec01ea 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs | |||
@@ -504,21 +504,14 @@ namespace OpenSim.Framework | |||
504 | set { m_TelehubEnabled = value; } | 504 | set { m_TelehubEnabled = value; } |
505 | } | 505 | } |
506 | 506 | ||
507 | // Connected Telehub object | 507 | /// <summary> |
508 | private UUID m_TelehubObject = UUID.Zero; | 508 | /// Connected Telehub object |
509 | public UUID TelehubObject | 509 | /// </summary> |
510 | { | 510 | public UUID TelehubObject { get; set; } |
511 | get | ||
512 | { | ||
513 | return m_TelehubObject; | ||
514 | } | ||
515 | set | ||
516 | { | ||
517 | m_TelehubObject = value; | ||
518 | } | ||
519 | } | ||
520 | 511 | ||
521 | // Our Connected Telehub's SpawnPoints | 512 | /// <summary> |
513 | /// Our connected Telehub's SpawnPoints | ||
514 | /// </summary> | ||
522 | public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>(); | 515 | public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>(); |
523 | 516 | ||
524 | // Add a SpawnPoint | 517 | // Add a SpawnPoint |
@@ -549,4 +542,4 @@ namespace OpenSim.Framework | |||
549 | l_SpawnPoints.Clear(); | 542 | l_SpawnPoints.Clear(); |
550 | } | 543 | } |
551 | } | 544 | } |
552 | } \ No newline at end of file | 545 | } |
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index cb73e8f..9249105 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -39,8 +39,32 @@ namespace OpenSim.Framework | |||
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | /// <summary> | ||
43 | /// Asset types used only in OpenSim. | ||
44 | /// To avoid clashing with the code numbers used in Second Life, use only negative numbers here. | ||
45 | /// </summary> | ||
46 | public enum OpenSimAssetType : sbyte | ||
47 | { | ||
48 | Material = -2 | ||
49 | } | ||
50 | |||
51 | |||
42 | #region SL / file extension / content-type conversions | 52 | #region SL / file extension / content-type conversions |
43 | 53 | ||
54 | /// <summary> | ||
55 | /// Returns the Enum entry corresponding to the given code, regardless of whether it belongs | ||
56 | /// to the AssetType or OpenSimAssetType enums. | ||
57 | /// </summary> | ||
58 | public static object AssetTypeFromCode(sbyte assetType) | ||
59 | { | ||
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else if (Enum.IsDefined(typeof(OpenSimAssetType), assetType)) | ||
63 | return (OpenSimAssetType)assetType; | ||
64 | else | ||
65 | return OpenMetaverse.AssetType.Unknown; | ||
66 | } | ||
67 | |||
44 | private class TypeMapping | 68 | private class TypeMapping |
45 | { | 69 | { |
46 | private sbyte assetType; | 70 | private sbyte assetType; |
@@ -56,12 +80,7 @@ namespace OpenSim.Framework | |||
56 | 80 | ||
57 | public object AssetType | 81 | public object AssetType |
58 | { | 82 | { |
59 | get { | 83 | get { return AssetTypeFromCode(assetType); } |
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else | ||
63 | return OpenMetaverse.AssetType.Unknown; | ||
64 | } | ||
65 | } | 84 | } |
66 | 85 | ||
67 | public InventoryType InventoryType | 86 | public InventoryType InventoryType |
@@ -102,6 +121,11 @@ namespace OpenSim.Framework | |||
102 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | 121 | : this((sbyte)assetType, inventoryType, contentType, null, extension) |
103 | { | 122 | { |
104 | } | 123 | } |
124 | |||
125 | public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension) | ||
126 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | ||
127 | { | ||
128 | } | ||
105 | } | 129 | } |
106 | 130 | ||
107 | /// <summary> | 131 | /// <summary> |
@@ -142,7 +166,9 @@ namespace OpenSim.Framework | |||
142 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), | 166 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), |
143 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), | 167 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), |
144 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), | 168 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), |
145 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") | 169 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm"), |
170 | |||
171 | new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material") | ||
146 | }; | 172 | }; |
147 | 173 | ||
148 | private static Dictionary<sbyte, string> asset2Content; | 174 | private static Dictionary<sbyte, string> asset2Content; |
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 0c12787..73ebfae 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
32 | 33 | ||
33 | namespace OpenSim.Framework.Serialization | 34 | namespace OpenSim.Framework.Serialization |
34 | { | 35 | { |
@@ -128,6 +129,7 @@ namespace OpenSim.Framework.Serialization | |||
128 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; | 129 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; |
129 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; | 130 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; |
130 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this | 131 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this |
132 | ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml"; // Not sure if we'll ever see this | ||
131 | 133 | ||
132 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation; | 134 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation; |
133 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart; | 135 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart; |
@@ -152,6 +154,7 @@ namespace OpenSim.Framework.Serialization | |||
152 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; | 154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; |
153 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; | 155 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; |
154 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; | 156 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; |
157 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material; | ||
155 | } | 158 | } |
156 | 159 | ||
157 | public static string CreateOarLandDataPath(LandData ld) | 160 | public static string CreateOarLandDataPath(LandData ld) |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index eefbde5..1775fef 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1043,7 +1043,7 @@ namespace OpenSim.Framework | |||
1043 | else if (typeof(T) == typeof(Int32)) | 1043 | else if (typeof(T) == typeof(Int32)) |
1044 | val = cnf.GetInt(varname, (int)val); | 1044 | val = cnf.GetInt(varname, (int)val); |
1045 | else if (typeof(T) == typeof(float)) | 1045 | else if (typeof(T) == typeof(float)) |
1046 | val = cnf.GetFloat(varname, (int)val); | 1046 | val = cnf.GetFloat(varname, (float)val); |
1047 | else | 1047 | else |
1048 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); | 1048 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); |
1049 | } | 1049 | } |
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index e3e0c01..52e520c 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs | |||
@@ -124,7 +124,7 @@ namespace OpenSim | |||
124 | else | 124 | else |
125 | { | 125 | { |
126 | Application.iniFilePath = Path.GetFullPath( | 126 | Application.iniFilePath = Path.GetFullPath( |
127 | Path.Combine(Util.configDir(), iniFileName)); | 127 | Path.Combine(Util.configDir(), iniFileName)); |
128 | 128 | ||
129 | if (!File.Exists(Application.iniFilePath)) | 129 | if (!File.Exists(Application.iniFilePath)) |
130 | { | 130 | { |
@@ -139,12 +139,29 @@ namespace OpenSim | |||
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | m_config = new OpenSimConfigSource(); | ||
143 | m_config.Source = new IniConfigSource(); | ||
144 | m_config.Source.Merge(DefaultConfig()); | ||
145 | |||
146 | m_log.Info("[CONFIG]: Reading configuration settings"); | ||
147 | |||
148 | for (int i = 0 ; i < sources.Count ; i++) | ||
149 | { | ||
150 | if (ReadConfig(m_config, sources[i])) | ||
151 | { | ||
152 | iniFileExists = true; | ||
153 | AddIncludes(m_config, sources); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | // Override distro settings with contents of inidirectory | ||
142 | string iniDirName = startupConfig.GetString("inidirectory", "config"); | 158 | string iniDirName = startupConfig.GetString("inidirectory", "config"); |
143 | string iniDirPath = Path.Combine(Util.configDir(), iniDirName); | 159 | string iniDirPath = Path.Combine(Util.configDir(), iniDirName); |
144 | 160 | ||
145 | if (Directory.Exists(iniDirPath)) | 161 | if (Directory.Exists(iniDirPath)) |
146 | { | 162 | { |
147 | m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); | 163 | m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath); |
164 | List<string> overrideSources = new List<string>(); | ||
148 | 165 | ||
149 | string[] fileEntries = Directory.GetFiles(iniDirName); | 166 | string[] fileEntries = Directory.GetFiles(iniDirName); |
150 | foreach (string filePath in fileEntries) | 167 | foreach (string filePath in fileEntries) |
@@ -152,33 +169,38 @@ namespace OpenSim | |||
152 | if (Path.GetExtension(filePath).ToLower() == ".ini") | 169 | if (Path.GetExtension(filePath).ToLower() == ".ini") |
153 | { | 170 | { |
154 | if (!sources.Contains(Path.GetFullPath(filePath))) | 171 | if (!sources.Contains(Path.GetFullPath(filePath))) |
172 | { | ||
173 | overrideSources.Add(Path.GetFullPath(filePath)); | ||
174 | // put it in sources too, to avoid circularity | ||
155 | sources.Add(Path.GetFullPath(filePath)); | 175 | sources.Add(Path.GetFullPath(filePath)); |
176 | } | ||
156 | } | 177 | } |
157 | } | 178 | } |
158 | } | ||
159 | 179 | ||
160 | m_config = new OpenSimConfigSource(); | ||
161 | m_config.Source = new IniConfigSource(); | ||
162 | m_config.Source.Merge(DefaultConfig()); | ||
163 | 180 | ||
164 | m_log.Info("[CONFIG]: Reading configuration settings"); | 181 | if (overrideSources.Count > 0) |
182 | { | ||
183 | OpenSimConfigSource overrideConfig = new OpenSimConfigSource(); | ||
184 | overrideConfig.Source = new IniConfigSource(); | ||
185 | |||
186 | for (int i = 0 ; i < overrideSources.Count ; i++) | ||
187 | { | ||
188 | if (ReadConfig(overrideConfig, overrideSources[i])) | ||
189 | { | ||
190 | iniFileExists = true; | ||
191 | AddIncludes(overrideConfig, overrideSources); | ||
192 | } | ||
193 | } | ||
194 | m_config.Source.Merge(overrideConfig.Source); | ||
195 | } | ||
196 | } | ||
165 | 197 | ||
166 | if (sources.Count == 0) | 198 | if (sources.Count == 0) |
167 | { | 199 | { |
168 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); | 200 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); |
169 | Environment.Exit(1); | 201 | Environment.Exit(1); |
170 | } | 202 | } |
171 | 203 | else if (!iniFileExists) | |
172 | for (int i = 0 ; i < sources.Count ; i++) | ||
173 | { | ||
174 | if (ReadConfig(sources[i])) | ||
175 | { | ||
176 | iniFileExists = true; | ||
177 | AddIncludes(sources); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | if (!iniFileExists) | ||
182 | { | 204 | { |
183 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); | 205 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); |
184 | m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); | 206 | m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); |
@@ -214,10 +236,10 @@ namespace OpenSim | |||
214 | /// Adds the included files as ini configuration files | 236 | /// Adds the included files as ini configuration files |
215 | /// </summary> | 237 | /// </summary> |
216 | /// <param name="sources">List of URL strings or filename strings</param> | 238 | /// <param name="sources">List of URL strings or filename strings</param> |
217 | private void AddIncludes(List<string> sources) | 239 | private void AddIncludes(OpenSimConfigSource configSource, List<string> sources) |
218 | { | 240 | { |
219 | //loop over config sources | 241 | //loop over config sources |
220 | foreach (IConfig config in m_config.Source.Configs) | 242 | foreach (IConfig config in configSource.Source.Configs) |
221 | { | 243 | { |
222 | // Look for Include-* in the key name | 244 | // Look for Include-* in the key name |
223 | string[] keys = config.GetKeys(); | 245 | string[] keys = config.GetKeys(); |
@@ -284,7 +306,7 @@ namespace OpenSim | |||
284 | /// </summary> | 306 | /// </summary> |
285 | /// <param name="iniPath">Full path to the ini</param> | 307 | /// <param name="iniPath">Full path to the ini</param> |
286 | /// <returns></returns> | 308 | /// <returns></returns> |
287 | private bool ReadConfig(string iniPath) | 309 | private bool ReadConfig(OpenSimConfigSource configSource, string iniPath) |
288 | { | 310 | { |
289 | bool success = false; | 311 | bool success = false; |
290 | 312 | ||
@@ -292,7 +314,7 @@ namespace OpenSim | |||
292 | { | 314 | { |
293 | m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); | 315 | m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); |
294 | 316 | ||
295 | m_config.Source.Merge(new IniConfigSource(iniPath)); | 317 | configSource.Source.Merge(new IniConfigSource(iniPath)); |
296 | success = true; | 318 | success = true; |
297 | } | 319 | } |
298 | else | 320 | else |
@@ -305,7 +327,7 @@ namespace OpenSim | |||
305 | { | 327 | { |
306 | XmlReader r = XmlReader.Create(iniPath); | 328 | XmlReader r = XmlReader.Create(iniPath); |
307 | XmlConfigSource cs = new XmlConfigSource(r); | 329 | XmlConfigSource cs = new XmlConfigSource(r); |
308 | m_config.Source.Merge(cs); | 330 | configSource.Source.Merge(cs); |
309 | 331 | ||
310 | success = true; | 332 | success = true; |
311 | } | 333 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index d52ad7e..bd4e617 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -163,6 +163,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
163 | private int m_maxRTO = 60000; | 163 | private int m_maxRTO = 60000; |
164 | public bool m_deliverPackets = true; | 164 | public bool m_deliverPackets = true; |
165 | 165 | ||
166 | /// <summary> | ||
167 | /// This is the percentage of the udp texture queue to add to the task queue since | ||
168 | /// textures are now generally handled through http. | ||
169 | /// </summary> | ||
170 | private double m_cannibalrate = 0.0; | ||
171 | |||
166 | private ClientInfo m_info = new ClientInfo(); | 172 | private ClientInfo m_info = new ClientInfo(); |
167 | 173 | ||
168 | /// <summary> | 174 | /// <summary> |
@@ -202,6 +208,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
202 | // Create an array of token buckets for this clients different throttle categories | 208 | // Create an array of token buckets for this clients different throttle categories |
203 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; | 209 | m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; |
204 | 210 | ||
211 | m_cannibalrate = rates.CannibalizeTextureRate; | ||
212 | |||
205 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) | 213 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) |
206 | { | 214 | { |
207 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; | 215 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; |
@@ -350,6 +358,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
350 | texture = Math.Max(texture, LLUDPServer.MTU); | 358 | texture = Math.Max(texture, LLUDPServer.MTU); |
351 | asset = Math.Max(asset, LLUDPServer.MTU); | 359 | asset = Math.Max(asset, LLUDPServer.MTU); |
352 | 360 | ||
361 | // Since most textures are now delivered through http, make it possible | ||
362 | // to cannibalize some of the bw from the texture throttle to use for | ||
363 | // the task queue (e.g. object updates) | ||
364 | task = task + (int)(m_cannibalrate * texture); | ||
365 | texture = (int)((1 - m_cannibalrate) * texture); | ||
366 | |||
353 | //int total = resend + land + wind + cloud + task + texture + asset; | 367 | //int total = resend + land + wind + cloud + task + texture + asset; |
354 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", | 368 | //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", |
355 | // AgentID, resend, land, wind, cloud, task, texture, asset, total); | 369 | // AgentID, resend, land, wind, cloud, task, texture, asset, total); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs index c9aac0b..e5bae6e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs | |||
@@ -59,6 +59,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
59 | /// <summary>Flag used to enable adaptive throttles</summary> | 59 | /// <summary>Flag used to enable adaptive throttles</summary> |
60 | public bool AdaptiveThrottlesEnabled; | 60 | public bool AdaptiveThrottlesEnabled; |
61 | 61 | ||
62 | /// <summary>Amount of the texture throttle to steal for the task throttle</summary> | ||
63 | public double CannibalizeTextureRate; | ||
64 | |||
62 | /// <summary> | 65 | /// <summary> |
63 | /// Default constructor | 66 | /// Default constructor |
64 | /// </summary> | 67 | /// </summary> |
@@ -80,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
80 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); | 83 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); |
81 | 84 | ||
82 | AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); | 85 | AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); |
86 | |||
87 | CannibalizeTextureRate = (double)throttleConfig.GetFloat("CannibalizeTextureRate", 0.0f); | ||
88 | CannibalizeTextureRate = Util.Clamp<double>(CannibalizeTextureRate,0.0, 0.9); | ||
83 | } | 89 | } |
84 | catch (Exception) { } | 90 | catch (Exception) { } |
85 | } | 91 | } |
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index f43305f..9b0e1f4 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -194,10 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IImprovedAssetCache Members |
196 | 196 | ||
197 | |||
198 | public bool Check(string id) | 197 | public bool Check(string id) |
199 | { | 198 | { |
200 | return false; | 199 | AssetBase asset; |
200 | |||
201 | // XXX:This is probably not an efficient implementation. | ||
202 | return m_cache.TryGetValue(id, out asset); | ||
201 | } | 203 | } |
202 | 204 | ||
203 | /// <summary> | 205 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 58ce61a..f720748 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -114,7 +114,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
114 | // | 114 | // |
115 | public bool Check(string id) | 115 | public bool Check(string id) |
116 | { | 116 | { |
117 | return false; | 117 | // XXX This is probably not an efficient implementation. |
118 | return Get(id) != null; | ||
118 | } | 119 | } |
119 | 120 | ||
120 | public void Cache(AssetBase asset) | 121 | public void Cache(AssetBase asset) |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index f1fee63..b270de9 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -248,71 +248,68 @@ namespace OpenSim.Region.CoreModules.Asset | |||
248 | 248 | ||
249 | private void UpdateFileCache(string key, AssetBase asset) | 249 | private void UpdateFileCache(string key, AssetBase asset) |
250 | { | 250 | { |
251 | // TODO: Spawn this off to some seperate thread to do the actual writing | 251 | string filename = GetFileName(key); |
252 | if (asset != null) | ||
253 | { | ||
254 | string filename = GetFileName(key); | ||
255 | 252 | ||
256 | try | 253 | try |
254 | { | ||
255 | // If the file is already cached, don't cache it, just touch it so access time is updated | ||
256 | if (File.Exists(filename)) | ||
257 | { | 257 | { |
258 | // If the file is already cached, don't cache it, just touch it so access time is updated | 258 | // We don't really want to know about sharing |
259 | if (File.Exists(filename)) | 259 | // violations here. If the file is locked, then |
260 | // the other thread has updated the time for us. | ||
261 | try | ||
260 | { | 262 | { |
261 | // We don't really want to know about sharing | 263 | lock (m_CurrentlyWriting) |
262 | // violations here. If the file is locked, then | ||
263 | // the other thread has updated the time for us. | ||
264 | try | ||
265 | { | 264 | { |
266 | lock (m_CurrentlyWriting) | 265 | if (!m_CurrentlyWriting.Contains(filename)) |
267 | { | 266 | File.SetLastAccessTime(filename, DateTime.Now); |
268 | if (!m_CurrentlyWriting.Contains(filename)) | ||
269 | File.SetLastAccessTime(filename, DateTime.Now); | ||
270 | } | ||
271 | } | 267 | } |
272 | catch | 268 | } |
269 | catch | ||
270 | { | ||
271 | } | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | // Once we start writing, make sure we flag that we're writing | ||
276 | // that object to the cache so that we don't try to write the | ||
277 | // same file multiple times. | ||
278 | lock (m_CurrentlyWriting) | ||
279 | { | ||
280 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
281 | if (m_CurrentlyWriting.ContainsKey(filename)) | ||
273 | { | 282 | { |
283 | return; | ||
274 | } | 284 | } |
275 | } else { | 285 | else |
276 | |||
277 | // Once we start writing, make sure we flag that we're writing | ||
278 | // that object to the cache so that we don't try to write the | ||
279 | // same file multiple times. | ||
280 | lock (m_CurrentlyWriting) | ||
281 | { | 286 | { |
282 | #if WAIT_ON_INPROGRESS_REQUESTS | 287 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); |
283 | if (m_CurrentlyWriting.ContainsKey(filename)) | 288 | } |
284 | { | ||
285 | return; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||
290 | } | ||
291 | 289 | ||
292 | #else | 290 | #else |
293 | if (m_CurrentlyWriting.Contains(filename)) | 291 | if (m_CurrentlyWriting.Contains(filename)) |
294 | { | 292 | { |
295 | return; | 293 | return; |
296 | } | ||
297 | else | ||
298 | { | ||
299 | m_CurrentlyWriting.Add(filename); | ||
300 | } | ||
301 | #endif | ||
302 | |||
303 | } | 294 | } |
295 | else | ||
296 | { | ||
297 | m_CurrentlyWriting.Add(filename); | ||
298 | } | ||
299 | #endif | ||
304 | 300 | ||
305 | Util.FireAndForget( | ||
306 | delegate { WriteFileCache(filename, asset); }); | ||
307 | } | 301 | } |
308 | } | 302 | |
309 | catch (Exception e) | 303 | Util.FireAndForget( |
310 | { | 304 | delegate { WriteFileCache(filename, asset); }); |
311 | m_log.ErrorFormat( | ||
312 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
313 | asset.ID, e.Message, e.StackTrace); | ||
314 | } | 305 | } |
315 | } | 306 | } |
307 | catch (Exception e) | ||
308 | { | ||
309 | m_log.ErrorFormat( | ||
310 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
311 | asset.ID, e.Message, e.StackTrace); | ||
312 | } | ||
316 | } | 313 | } |
317 | 314 | ||
318 | public void Cache(AssetBase asset) | 315 | public void Cache(AssetBase asset) |
@@ -347,15 +344,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
347 | 344 | ||
348 | private bool CheckFromMemoryCache(string id) | 345 | private bool CheckFromMemoryCache(string id) |
349 | { | 346 | { |
350 | AssetBase asset = null; | 347 | return m_MemoryCache.Contains(id); |
351 | |||
352 | if (m_MemoryCache.TryGetValue(id, out asset)) | ||
353 | return true; | ||
354 | |||
355 | return false; | ||
356 | } | 348 | } |
357 | 349 | ||
358 | |||
359 | /// <summary> | 350 | /// <summary> |
360 | /// Try to get an asset from the file cache. | 351 | /// Try to get an asset from the file cache. |
361 | /// </summary> | 352 | /// </summary> |
@@ -393,15 +384,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
393 | 384 | ||
394 | if (File.Exists(filename)) | 385 | if (File.Exists(filename)) |
395 | { | 386 | { |
396 | FileStream stream = null; | ||
397 | try | 387 | try |
398 | { | 388 | { |
399 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | 389 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
400 | BinaryFormatter bformatter = new BinaryFormatter(); | 390 | { |
391 | BinaryFormatter bformatter = new BinaryFormatter(); | ||
401 | 392 | ||
402 | asset = (AssetBase)bformatter.Deserialize(stream); | 393 | asset = (AssetBase)bformatter.Deserialize(stream); |
403 | 394 | ||
404 | m_DiskHits++; | 395 | m_DiskHits++; |
396 | } | ||
405 | } | 397 | } |
406 | catch (System.Runtime.Serialization.SerializationException e) | 398 | catch (System.Runtime.Serialization.SerializationException e) |
407 | { | 399 | { |
@@ -420,12 +412,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
420 | m_log.WarnFormat( | 412 | m_log.WarnFormat( |
421 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | 413 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", |
422 | filename, id, e.Message, e.StackTrace); | 414 | filename, id, e.Message, e.StackTrace); |
423 | |||
424 | } | ||
425 | finally | ||
426 | { | ||
427 | if (stream != null) | ||
428 | stream.Close(); | ||
429 | } | 415 | } |
430 | } | 416 | } |
431 | 417 | ||
@@ -437,36 +423,19 @@ namespace OpenSim.Region.CoreModules.Asset | |||
437 | bool found = false; | 423 | bool found = false; |
438 | 424 | ||
439 | string filename = GetFileName(id); | 425 | string filename = GetFileName(id); |
426 | |||
440 | if (File.Exists(filename)) | 427 | if (File.Exists(filename)) |
441 | { | 428 | { |
442 | // actually check if we can open it, and so update expire | ||
443 | FileStream stream = null; | ||
444 | try | 429 | try |
445 | { | 430 | { |
446 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | 431 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
447 | if (stream != null) | ||
448 | { | 432 | { |
449 | found = true; | 433 | if (stream != null) |
450 | stream.Close(); | 434 | found = true; |
451 | } | 435 | } |
452 | |||
453 | } | ||
454 | catch (System.Runtime.Serialization.SerializationException e) | ||
455 | { | ||
456 | found = false; | ||
457 | m_log.ErrorFormat( | ||
458 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
459 | filename, id, e.Message, e.StackTrace); | ||
460 | |||
461 | // If there was a problem deserializing the asset, the asset may | ||
462 | // either be corrupted OR was serialized under an old format | ||
463 | // {different version of AssetBase} -- we should attempt to | ||
464 | // delete it and re-cache | ||
465 | File.Delete(filename); | ||
466 | } | 436 | } |
467 | catch (Exception e) | 437 | catch (Exception e) |
468 | { | 438 | { |
469 | found = false; | ||
470 | m_log.ErrorFormat( | 439 | m_log.ErrorFormat( |
471 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | 440 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", |
472 | filename, id, e.Message, e.StackTrace); | 441 | filename, id, e.Message, e.StackTrace); |
@@ -518,11 +487,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
518 | return Get(id); | 487 | return Get(id); |
519 | } | 488 | } |
520 | 489 | ||
521 | public AssetBase CheckCached(string id) | ||
522 | { | ||
523 | return Get(id); | ||
524 | } | ||
525 | |||
526 | public void Expire(string id) | 490 | public void Expire(string id) |
527 | { | 491 | { |
528 | if (m_LogLevel >= 2) | 492 | if (m_LogLevel >= 2) |
@@ -807,7 +771,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
807 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 771 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
808 | 772 | ||
809 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); | 773 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); |
810 | Dictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>(); | 774 | Dictionary<UUID, sbyte> assets = new Dictionary<UUID, sbyte>(); |
811 | 775 | ||
812 | foreach (Scene s in m_Scenes) | 776 | foreach (Scene s in m_Scenes) |
813 | { | 777 | { |
@@ -830,7 +794,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
830 | else if (storeUncached) | 794 | else if (storeUncached) |
831 | { | 795 | { |
832 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | 796 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); |
833 | if (cachedAsset == null && assets[assetID] != AssetType.Unknown) | 797 | if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) |
834 | m_log.DebugFormat( | 798 | m_log.DebugFormat( |
835 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", | 799 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", |
836 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); | 800 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); |
@@ -1067,11 +1031,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1067 | return asset.Data; | 1031 | return asset.Data; |
1068 | } | 1032 | } |
1069 | 1033 | ||
1070 | public bool CheckData(string id) | ||
1071 | { | ||
1072 | return Check(id); ; | ||
1073 | } | ||
1074 | |||
1075 | public bool Get(string id, object sender, AssetRetrieved handler) | 1034 | public bool Get(string id, object sender, AssetRetrieved handler) |
1076 | { | 1035 | { |
1077 | AssetBase asset = Get(id); | 1036 | AssetBase asset = Get(id); |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index ce9b546..5f76ac2 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
117 | 117 | ||
118 | public bool Check(string id) | 118 | public bool Check(string id) |
119 | { | 119 | { |
120 | return false; | 120 | return m_Cache.Contains(id); |
121 | } | 121 | } |
122 | 122 | ||
123 | public void Cache(AssetBase asset) | 123 | public void Cache(AssetBase asset) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 4ec8ae7..4292719 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
78 | /// <value> | 78 | /// <value> |
79 | /// Used to collect the uuids of the assets that we need to save into the archive | 79 | /// Used to collect the uuids of the assets that we need to save into the archive |
80 | /// </value> | 80 | /// </value> |
81 | protected Dictionary<UUID, AssetType> m_assetUuids = new Dictionary<UUID, AssetType>(); | 81 | protected Dictionary<UUID, sbyte> m_assetUuids = new Dictionary<UUID, sbyte>(); |
82 | 82 | ||
83 | /// <value> | 83 | /// <value> |
84 | /// Used to collect the uuids of the users that we need to save into the archive | 84 | /// Used to collect the uuids of the users that we need to save into the archive |
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
187 | 187 | ||
188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset | 188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset |
189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) | 189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) |
190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); | 190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids); |
191 | } | 191 | } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 246b253..5fea0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1385,7 +1385,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1385 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) | 1385 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) |
1386 | { | 1386 | { |
1387 | version = String.Empty; | 1387 | version = String.Empty; |
1388 | newpos = new Vector3(pos.X, pos.Y, pos.Z); | 1388 | newpos = pos; |
1389 | 1389 | ||
1390 | // m_log.DebugFormat( | 1390 | // m_log.DebugFormat( |
1391 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); | 1391 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 74b834a..7abdc21 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -182,11 +182,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
182 | { | 182 | { |
183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); |
184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); | 184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); |
185 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 185 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); | 186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); |
187 | uuidGatherer.GatherAssetUuids(so, ids); | 187 | uuidGatherer.GatherAssetUuids(so, ids); |
188 | 188 | ||
189 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) | 189 | foreach (KeyValuePair<UUID, sbyte> kvp in ids) |
190 | uuidGatherer.FetchAsset(kvp.Key); | 190 | uuidGatherer.FetchAsset(kvp.Key); |
191 | } | 191 | } |
192 | } | 192 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index b7a4d1a..d4fb1ba 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -260,9 +260,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
260 | 260 | ||
261 | // The act of gathering UUIDs downloads some assets from the remote server | 261 | // The act of gathering UUIDs downloads some assets from the remote server |
262 | // but not all... | 262 | // but not all... |
263 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 263 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); | 264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); |
265 | uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); | 265 | uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids); |
266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); | 266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); |
267 | bool success = true; | 267 | bool success = true; |
268 | foreach (UUID uuid in ids.Keys) | 268 | foreach (UUID uuid in ids.Keys) |
@@ -286,9 +286,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
287 | if (asset != null) | 287 | if (asset != null) |
288 | { | 288 | { |
289 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); |
291 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | 291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); |
292 | bool success = false; | 292 | bool success = false; |
293 | foreach (UUID uuid in ids.Keys) | 293 | foreach (UUID uuid in ids.Keys) |
294 | { | 294 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3be80eb..7a6a174 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
174 | 174 | ||
175 | #endregion | 175 | #endregion |
176 | 176 | ||
177 | #region ISimulation | 177 | #region ISimulationService |
178 | 178 | ||
179 | public IScene GetScene(UUID regionId) | 179 | public IScene GetScene(UUID regionId) |
180 | { | 180 | { |
@@ -352,7 +352,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
352 | return false; | 352 | return false; |
353 | } | 353 | } |
354 | 354 | ||
355 | #endregion /* IInterregionComms */ | 355 | #endregion |
356 | 356 | ||
357 | #region Misc | 357 | #region Misc |
358 | 358 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 8bd1d10..ab912ed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
146 | 146 | ||
147 | #endregion | 147 | #endregion |
148 | 148 | ||
149 | #region IInterregionComms | 149 | #region ISimulationService |
150 | 150 | ||
151 | public IScene GetScene(UUID regionId) | 151 | public IScene GetScene(UUID regionId) |
152 | { | 152 | { |
@@ -278,6 +278,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
278 | return false; | 278 | return false; |
279 | } | 279 | } |
280 | 280 | ||
281 | #endregion /* IInterregionComms */ | 281 | #endregion |
282 | } | 282 | } |
283 | } | 283 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index a990898..7a844f4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
178 | 178 | ||
179 | // Archive the regions | 179 | // Archive the regions |
180 | 180 | ||
181 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 181 | Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>(); |
182 | 182 | ||
183 | scenesGroup.ForEachScene(delegate(Scene scene) | 183 | scenesGroup.ForEachScene(delegate(Scene scene) |
184 | { | 184 | { |
@@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) | 219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids) |
220 | { | 220 | { |
221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); | 221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); |
222 | 222 | ||
@@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; | 276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; |
277 | 277 | ||
278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) | 278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) |
279 | assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture; | 279 | assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture; |
280 | 280 | ||
281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) | 281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) |
282 | assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture; | 282 | assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture; |
283 | 283 | ||
284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) | 284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) |
285 | assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture; | 285 | assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture; |
286 | 286 | ||
287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) | 287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) |
288 | assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture; | 288 | assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture; |
289 | 289 | ||
290 | Save(scene, sceneObjects, regionDir); | 290 | Save(scene, sceneObjects, regionDir); |
291 | } | 291 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index ada7ecc..6c2a631 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
81 | /// <value> | 81 | /// <value> |
82 | /// uuids to request | 82 | /// uuids to request |
83 | /// </value> | 83 | /// </value> |
84 | protected IDictionary<UUID, AssetType> m_uuids; | 84 | protected IDictionary<UUID, sbyte> m_uuids; |
85 | 85 | ||
86 | /// <value> | 86 | /// <value> |
87 | /// Callback used when all the assets requested have been received. | 87 | /// Callback used when all the assets requested have been received. |
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
115 | protected Dictionary<string, object> m_options; | 115 | protected Dictionary<string, object> m_options; |
116 | 116 | ||
117 | protected internal AssetsRequest( | 117 | protected internal AssetsRequest( |
118 | AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, | 118 | AssetsArchiver assetsArchiver, IDictionary<UUID, sbyte> uuids, |
119 | IAssetService assetService, IUserAccountService userService, | 119 | IAssetService assetService, IUserAccountService userService, |
120 | UUID scope, Dictionary<string, object> options, | 120 | UUID scope, Dictionary<string, object> options, |
121 | AssetsRequestCallback assetsRequestCallback) | 121 | AssetsRequestCallback assetsRequestCallback) |
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
154 | 154 | ||
155 | m_requestCallbackTimer.Enabled = true; | 155 | m_requestCallbackTimer.Enabled = true; |
156 | 156 | ||
157 | foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids) | 157 | foreach (KeyValuePair<UUID, sbyte> kvp in m_uuids) |
158 | { | 158 | { |
159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); | 159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); |
160 | 160 | ||
@@ -235,9 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer | 235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer |
236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) | 236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) |
237 | { | 237 | { |
238 | AssetType type = (AssetType)assetType; | 238 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType)); |
239 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type); | 239 | fetchedAsset.Type = (sbyte)assetType; |
240 | fetchedAsset.Type = (sbyte)type; | ||
241 | } | 240 | } |
242 | 241 | ||
243 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); | 242 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 173b603..1659493 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
60 | 60 | ||
61 | public void Initialise() | 61 | public void Initialise() |
62 | { | 62 | { |
63 | m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); | 63 | // m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); |
64 | 64 | ||
65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", | 65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", |
66 | "set terrain texture <number> <uuid> [<x>] [<y>]", | 66 | "set terrain texture <number> <uuid> [<x>] [<y>]", |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 4750b46..7aa1ced 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -712,7 +712,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) | 715 | public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) |
716 | { | 716 | { |
717 | SceneObjectPart part; | 717 | SceneObjectPart part; |
718 | 718 | ||
@@ -752,7 +752,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
752 | default: | 752 | default: |
753 | break; | 753 | break; |
754 | } | 754 | } |
755 | SendTelehubInfo(client); | 755 | |
756 | if (client != null) | ||
757 | SendTelehubInfo(client); | ||
756 | } | 758 | } |
757 | 759 | ||
758 | private void SendSimulatorBlueBoxMessage( | 760 | private void SendSimulatorBlueBoxMessage( |
@@ -1224,7 +1226,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1224 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; | 1226 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; |
1225 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; | 1227 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; |
1226 | client.OnEstateChangeInfo += handleEstateChangeInfo; | 1228 | client.OnEstateChangeInfo += handleEstateChangeInfo; |
1227 | client.OnEstateManageTelehub += handleOnEstateManageTelehub; | 1229 | client.OnEstateManageTelehub += HandleOnEstateManageTelehub; |
1228 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; | 1230 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; |
1229 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; | 1231 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; |
1230 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; | 1232 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 40638f8..bc52a43 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
55 | public struct DrawStruct | 55 | public struct DrawStruct |
56 | { | 56 | { |
57 | public DrawRoutine dr; | 57 | public DrawRoutine dr; |
58 | public Rectangle rect; | 58 | // public Rectangle rect; |
59 | public SolidBrush brush; | 59 | public SolidBrush brush; |
60 | public face[] trns; | 60 | public face[] trns; |
61 | } | 61 | } |
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
119 | { | 119 | { |
120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); | 120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); |
121 | } | 121 | } |
122 | |||
122 | return mapbmp; | 123 | return mapbmp; |
123 | } | 124 | } |
124 | 125 | ||
@@ -127,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
127 | try | 128 | try |
128 | { | 129 | { |
129 | using (Bitmap mapbmp = CreateMapTile()) | 130 | using (Bitmap mapbmp = CreateMapTile()) |
130 | return OpenJPEG.EncodeFromImage(mapbmp, true); | 131 | { |
132 | if (mapbmp != null) | ||
133 | return OpenJPEG.EncodeFromImage(mapbmp, true); | ||
134 | } | ||
131 | } | 135 | } |
132 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 136 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
133 | { | 137 | { |
@@ -277,321 +281,331 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
277 | tc = Environment.TickCount; | 281 | tc = Environment.TickCount; |
278 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | 282 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |
279 | EntityBase[] objs = whichScene.GetEntities(); | 283 | EntityBase[] objs = whichScene.GetEntities(); |
280 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
281 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); | ||
282 | List<float> z_sortheights = new List<float>(); | 284 | List<float> z_sortheights = new List<float>(); |
283 | List<uint> z_localIDs = new List<uint>(); | 285 | List<uint> z_localIDs = new List<uint>(); |
286 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
284 | 287 | ||
285 | lock (objs) | 288 | try |
286 | { | 289 | { |
287 | foreach (EntityBase obj in objs) | 290 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); |
291 | |||
292 | lock (objs) | ||
288 | { | 293 | { |
289 | // Only draw the contents of SceneObjectGroup | 294 | foreach (EntityBase obj in objs) |
290 | if (obj is SceneObjectGroup) | ||
291 | { | 295 | { |
292 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; | 296 | // Only draw the contents of SceneObjectGroup |
293 | Color mapdotspot = Color.Gray; // Default color when prim color is white | 297 | if (obj is SceneObjectGroup) |
294 | |||
295 | // Loop over prim in group | ||
296 | foreach (SceneObjectPart part in mapdot.Parts) | ||
297 | { | 298 | { |
298 | if (part == null) | 299 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; |
299 | continue; | 300 | Color mapdotspot = Color.Gray; // Default color when prim color is white |
300 | 301 | ||
301 | // Draw if the object is at least 1 meter wide in any direction | 302 | // Loop over prim in group |
302 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | 303 | foreach (SceneObjectPart part in mapdot.Parts) |
303 | { | 304 | { |
304 | // Try to get the RGBA of the default texture entry.. | 305 | if (part == null) |
305 | // | 306 | continue; |
306 | try | 307 | |
308 | // Draw if the object is at least 1 meter wide in any direction | ||
309 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | ||
307 | { | 310 | { |
308 | // get the null checks out of the way | 311 | // Try to get the RGBA of the default texture entry.. |
309 | // skip the ones that break | 312 | // |
310 | if (part == null) | 313 | try |
311 | continue; | 314 | { |
315 | // get the null checks out of the way | ||
316 | // skip the ones that break | ||
317 | if (part == null) | ||
318 | continue; | ||
312 | 319 | ||
313 | if (part.Shape == null) | 320 | if (part.Shape == null) |
314 | continue; | 321 | continue; |
315 | 322 | ||
316 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) | 323 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) |
317 | continue; // eliminates trees from this since we don't really have a good tree representation | 324 | continue; // eliminates trees from this since we don't really have a good tree representation |
318 | // if you want tree blocks on the map comment the above line and uncomment the below line | 325 | // if you want tree blocks on the map comment the above line and uncomment the below line |
319 | //mapdotspot = Color.PaleGreen; | 326 | //mapdotspot = Color.PaleGreen; |
320 | 327 | ||
321 | Primitive.TextureEntry textureEntry = part.Shape.Textures; | 328 | Primitive.TextureEntry textureEntry = part.Shape.Textures; |
322 | 329 | ||
323 | if (textureEntry == null || textureEntry.DefaultTexture == null) | 330 | if (textureEntry == null || textureEntry.DefaultTexture == null) |
324 | continue; | 331 | continue; |
325 | 332 | ||
326 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; | 333 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; |
327 | 334 | ||
328 | // Not sure why some of these are null, oh well. | 335 | // Not sure why some of these are null, oh well. |
329 | 336 | ||
330 | int colorr = 255 - (int)(texcolor.R * 255f); | 337 | int colorr = 255 - (int)(texcolor.R * 255f); |
331 | int colorg = 255 - (int)(texcolor.G * 255f); | 338 | int colorg = 255 - (int)(texcolor.G * 255f); |
332 | int colorb = 255 - (int)(texcolor.B * 255f); | 339 | int colorb = 255 - (int)(texcolor.B * 255f); |
333 | 340 | ||
334 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) | 341 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) |
335 | { | ||
336 | //Try to set the map spot color | ||
337 | try | ||
338 | { | ||
339 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
340 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
341 | } | ||
342 | catch (ArgumentException) | ||
343 | { | 342 | { |
343 | //Try to set the map spot color | ||
344 | try | ||
345 | { | ||
346 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
347 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
348 | } | ||
349 | catch (ArgumentException) | ||
350 | { | ||
351 | } | ||
344 | } | 352 | } |
345 | } | 353 | } |
346 | } | 354 | catch (IndexOutOfRangeException) |
347 | catch (IndexOutOfRangeException) | 355 | { |
348 | { | 356 | // Windows Array |
349 | // Windows Array | 357 | } |
350 | } | 358 | catch (ArgumentOutOfRangeException) |
351 | catch (ArgumentOutOfRangeException) | 359 | { |
352 | { | 360 | // Mono Array |
353 | // Mono Array | 361 | } |
354 | } | ||
355 | |||
356 | Vector3 pos = part.GetWorldPosition(); | ||
357 | |||
358 | // skip prim outside of retion | ||
359 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) | ||
360 | continue; | ||
361 | |||
362 | // skip prim in non-finite position | ||
363 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || | ||
364 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | ||
365 | continue; | ||
366 | |||
367 | // Figure out if object is under 256m above the height of the terrain | ||
368 | bool isBelow256AboveTerrain = false; | ||
369 | 362 | ||
370 | try | 363 | Vector3 pos = part.GetWorldPosition(); |
371 | { | ||
372 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); | ||
373 | } | ||
374 | catch (Exception) | ||
375 | { | ||
376 | } | ||
377 | 364 | ||
378 | if (isBelow256AboveTerrain) | 365 | // skip prim outside of retion |
379 | { | 366 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) |
380 | // Translate scale by rotation so scale is represented properly when object is rotated | ||
381 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
382 | Vector3 scale = new Vector3(); | ||
383 | Vector3 tScale = new Vector3(); | ||
384 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
385 | |||
386 | Quaternion llrot = part.GetWorldRotation(); | ||
387 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
388 | scale = lscale * rot; | ||
389 | |||
390 | // negative scales don't work in this situation | ||
391 | scale.X = Math.Abs(scale.X); | ||
392 | scale.Y = Math.Abs(scale.Y); | ||
393 | scale.Z = Math.Abs(scale.Z); | ||
394 | |||
395 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
396 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
397 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
398 | int mapdrawendX = (int)(pos.X + scale.X); | ||
399 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
400 | |||
401 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
402 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
403 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
404 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
405 | continue; | 367 | continue; |
406 | 368 | ||
407 | #region obb face reconstruction part duex | 369 | // skip prim in non-finite position |
408 | Vector3[] vertexes = new Vector3[8]; | 370 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || |
409 | 371 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | |
410 | // float[] distance = new float[6]; | 372 | continue; |
411 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
412 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
413 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
414 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
415 | |||
416 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
417 | scale = ((tScale * rot)); | ||
418 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
419 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
420 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
421 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
422 | |||
423 | FaceA[0] = vertexes[0]; | ||
424 | FaceB[3] = vertexes[0]; | ||
425 | FaceA[4] = vertexes[0]; | ||
426 | |||
427 | tScale = lscale; | ||
428 | scale = ((tScale * rot)); | ||
429 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
430 | |||
431 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
432 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
433 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
434 | |||
435 | FaceB[0] = vertexes[1]; | ||
436 | FaceA[1] = vertexes[1]; | ||
437 | FaceC[4] = vertexes[1]; | ||
438 | |||
439 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
440 | scale = ((tScale * rot)); | ||
441 | |||
442 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
443 | |||
444 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
445 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
446 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
447 | |||
448 | FaceC[0] = vertexes[2]; | ||
449 | FaceD[3] = vertexes[2]; | ||
450 | FaceC[5] = vertexes[2]; | ||
451 | |||
452 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
453 | scale = ((tScale * rot)); | ||
454 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
455 | |||
456 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
457 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
458 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
459 | |||
460 | FaceD[0] = vertexes[3]; | ||
461 | FaceC[1] = vertexes[3]; | ||
462 | FaceA[5] = vertexes[3]; | ||
463 | |||
464 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
465 | scale = ((tScale * rot)); | ||
466 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
467 | |||
468 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
469 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
470 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
471 | |||
472 | FaceB[1] = vertexes[4]; | ||
473 | FaceA[2] = vertexes[4]; | ||
474 | FaceD[4] = vertexes[4]; | ||
475 | |||
476 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
477 | scale = ((tScale * rot)); | ||
478 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
479 | |||
480 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
481 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
482 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
483 | |||
484 | FaceD[1] = vertexes[5]; | ||
485 | FaceC[2] = vertexes[5]; | ||
486 | FaceB[5] = vertexes[5]; | ||
487 | 373 | ||
488 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | 374 | // Figure out if object is under 256m above the height of the terrain |
489 | scale = ((tScale * rot)); | 375 | bool isBelow256AboveTerrain = false; |
490 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
491 | 376 | ||
492 | // vertexes[6].x = pos.X + vertexes[6].x; | 377 | try |
493 | // vertexes[6].y = pos.Y + vertexes[6].y; | 378 | { |
494 | // vertexes[6].z = pos.Z + vertexes[6].z; | 379 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); |
380 | } | ||
381 | catch (Exception) | ||
382 | { | ||
383 | } | ||
495 | 384 | ||
496 | FaceB[2] = vertexes[6]; | 385 | if (isBelow256AboveTerrain) |
497 | FaceA[3] = vertexes[6]; | 386 | { |
498 | FaceB[4] = vertexes[6]; | 387 | // Translate scale by rotation so scale is represented properly when object is rotated |
388 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
389 | Vector3 scale = new Vector3(); | ||
390 | Vector3 tScale = new Vector3(); | ||
391 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
392 | |||
393 | Quaternion llrot = part.GetWorldRotation(); | ||
394 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
395 | scale = lscale * rot; | ||
396 | |||
397 | // negative scales don't work in this situation | ||
398 | scale.X = Math.Abs(scale.X); | ||
399 | scale.Y = Math.Abs(scale.Y); | ||
400 | scale.Z = Math.Abs(scale.Z); | ||
401 | |||
402 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
403 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
404 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
405 | int mapdrawendX = (int)(pos.X + scale.X); | ||
406 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
407 | |||
408 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
409 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
410 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
411 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
412 | continue; | ||
413 | |||
414 | #region obb face reconstruction part duex | ||
415 | Vector3[] vertexes = new Vector3[8]; | ||
416 | |||
417 | // float[] distance = new float[6]; | ||
418 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
419 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
420 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
421 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
422 | |||
423 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
424 | scale = ((tScale * rot)); | ||
425 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
426 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
427 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
428 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
429 | |||
430 | FaceA[0] = vertexes[0]; | ||
431 | FaceB[3] = vertexes[0]; | ||
432 | FaceA[4] = vertexes[0]; | ||
433 | |||
434 | tScale = lscale; | ||
435 | scale = ((tScale * rot)); | ||
436 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
437 | |||
438 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
439 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
440 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
441 | |||
442 | FaceB[0] = vertexes[1]; | ||
443 | FaceA[1] = vertexes[1]; | ||
444 | FaceC[4] = vertexes[1]; | ||
445 | |||
446 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
447 | scale = ((tScale * rot)); | ||
448 | |||
449 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
450 | |||
451 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
452 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
453 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
454 | |||
455 | FaceC[0] = vertexes[2]; | ||
456 | FaceD[3] = vertexes[2]; | ||
457 | FaceC[5] = vertexes[2]; | ||
458 | |||
459 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
460 | scale = ((tScale * rot)); | ||
461 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
462 | |||
463 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
464 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
465 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
466 | |||
467 | FaceD[0] = vertexes[3]; | ||
468 | FaceC[1] = vertexes[3]; | ||
469 | FaceA[5] = vertexes[3]; | ||
470 | |||
471 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
472 | scale = ((tScale * rot)); | ||
473 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
474 | |||
475 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
476 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
477 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
478 | |||
479 | FaceB[1] = vertexes[4]; | ||
480 | FaceA[2] = vertexes[4]; | ||
481 | FaceD[4] = vertexes[4]; | ||
482 | |||
483 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
484 | scale = ((tScale * rot)); | ||
485 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
486 | |||
487 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
488 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
489 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
490 | |||
491 | FaceD[1] = vertexes[5]; | ||
492 | FaceC[2] = vertexes[5]; | ||
493 | FaceB[5] = vertexes[5]; | ||
494 | |||
495 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | ||
496 | scale = ((tScale * rot)); | ||
497 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
498 | |||
499 | // vertexes[6].x = pos.X + vertexes[6].x; | ||
500 | // vertexes[6].y = pos.Y + vertexes[6].y; | ||
501 | // vertexes[6].z = pos.Z + vertexes[6].z; | ||
502 | |||
503 | FaceB[2] = vertexes[6]; | ||
504 | FaceA[3] = vertexes[6]; | ||
505 | FaceB[4] = vertexes[6]; | ||
499 | 506 | ||
500 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); | 507 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); |
501 | scale = ((tScale * rot)); | 508 | scale = ((tScale * rot)); |
502 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | 509 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); |
503 | 510 | ||
504 | // vertexes[7].x = pos.X + vertexes[7].x; | 511 | // vertexes[7].x = pos.X + vertexes[7].x; |
505 | // vertexes[7].y = pos.Y + vertexes[7].y; | 512 | // vertexes[7].y = pos.Y + vertexes[7].y; |
506 | // vertexes[7].z = pos.Z + vertexes[7].z; | 513 | // vertexes[7].z = pos.Z + vertexes[7].z; |
507 | 514 | ||
508 | FaceD[2] = vertexes[7]; | 515 | FaceD[2] = vertexes[7]; |
509 | FaceC[3] = vertexes[7]; | 516 | FaceC[3] = vertexes[7]; |
510 | FaceD[5] = vertexes[7]; | 517 | FaceD[5] = vertexes[7]; |
511 | #endregion | 518 | #endregion |
512 | 519 | ||
513 | //int wy = 0; | 520 | //int wy = 0; |
514 | 521 | ||
515 | //bool breakYN = false; // If we run into an error drawing, break out of the | 522 | //bool breakYN = false; // If we run into an error drawing, break out of the |
516 | // loop so we don't lag to death on error handling | 523 | // loop so we don't lag to death on error handling |
517 | DrawStruct ds = new DrawStruct(); | 524 | DrawStruct ds = new DrawStruct(); |
518 | ds.brush = new SolidBrush(mapdotspot); | 525 | ds.brush = new SolidBrush(mapdotspot); |
519 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); | 526 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); |
520 | 527 | ||
521 | ds.trns = new face[FaceA.Length]; | 528 | ds.trns = new face[FaceA.Length]; |
522 | 529 | ||
523 | for (int i = 0; i < FaceA.Length; i++) | 530 | for (int i = 0; i < FaceA.Length; i++) |
524 | { | 531 | { |
525 | Point[] working = new Point[5]; | 532 | Point[] working = new Point[5]; |
526 | working[0] = project(FaceA[i], axPos); | 533 | working[0] = project(FaceA[i], axPos); |
527 | working[1] = project(FaceB[i], axPos); | 534 | working[1] = project(FaceB[i], axPos); |
528 | working[2] = project(FaceD[i], axPos); | 535 | working[2] = project(FaceD[i], axPos); |
529 | working[3] = project(FaceC[i], axPos); | 536 | working[3] = project(FaceC[i], axPos); |
530 | working[4] = project(FaceA[i], axPos); | 537 | working[4] = project(FaceA[i], axPos); |
531 | 538 | ||
532 | face workingface = new face(); | 539 | face workingface = new face(); |
533 | workingface.pts = working; | 540 | workingface.pts = working; |
534 | 541 | ||
535 | ds.trns[i] = workingface; | 542 | ds.trns[i] = workingface; |
536 | } | 543 | } |
537 | 544 | ||
538 | z_sort.Add(part.LocalId, ds); | 545 | z_sort.Add(part.LocalId, ds); |
539 | z_localIDs.Add(part.LocalId); | 546 | z_localIDs.Add(part.LocalId); |
540 | z_sortheights.Add(pos.Z); | 547 | z_sortheights.Add(pos.Z); |
541 | 548 | ||
542 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) | 549 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) |
543 | //{ | ||
544 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) | ||
545 | //{ | 550 | //{ |
546 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); | 551 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) |
547 | //try | ||
548 | //{ | ||
549 | // Remember, flip the y! | ||
550 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
551 | //} | ||
552 | //catch (ArgumentException) | ||
553 | //{ | 552 | //{ |
554 | // breakYN = true; | 553 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); |
554 | //try | ||
555 | //{ | ||
556 | // Remember, flip the y! | ||
557 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
558 | //} | ||
559 | //catch (ArgumentException) | ||
560 | //{ | ||
561 | // breakYN = true; | ||
562 | //} | ||
563 | |||
564 | //if (breakYN) | ||
565 | // break; | ||
555 | //} | 566 | //} |
556 | 567 | ||
557 | //if (breakYN) | 568 | //if (breakYN) |
558 | // break; | 569 | // break; |
559 | //} | 570 | //} |
571 | } // Object is within 256m Z of terrain | ||
572 | } // object is at least a meter wide | ||
573 | } // loop over group children | ||
574 | } // entitybase is sceneobject group | ||
575 | } // foreach loop over entities | ||
560 | 576 | ||
561 | //if (breakYN) | 577 | float[] sortedZHeights = z_sortheights.ToArray(); |
562 | // break; | 578 | uint[] sortedlocalIds = z_localIDs.ToArray(); |
563 | //} | ||
564 | } // Object is within 256m Z of terrain | ||
565 | } // object is at least a meter wide | ||
566 | } // loop over group children | ||
567 | } // entitybase is sceneobject group | ||
568 | } // foreach loop over entities | ||
569 | |||
570 | float[] sortedZHeights = z_sortheights.ToArray(); | ||
571 | uint[] sortedlocalIds = z_localIDs.ToArray(); | ||
572 | |||
573 | // Sort prim by Z position | ||
574 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
575 | 579 | ||
576 | Graphics g = Graphics.FromImage(mapbmp); | 580 | // Sort prim by Z position |
581 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
577 | 582 | ||
578 | for (int s = 0; s < sortedZHeights.Length; s++) | 583 | using (Graphics g = Graphics.FromImage(mapbmp)) |
579 | { | ||
580 | if (z_sort.ContainsKey(sortedlocalIds[s])) | ||
581 | { | 584 | { |
582 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | 585 | for (int s = 0; s < sortedZHeights.Length; s++) |
583 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
584 | { | 586 | { |
585 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | 587 | if (z_sort.ContainsKey(sortedlocalIds[s])) |
588 | { | ||
589 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | ||
590 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
591 | { | ||
592 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | ||
593 | } | ||
594 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
595 | } | ||
586 | } | 596 | } |
587 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
588 | } | 597 | } |
589 | } | 598 | } // lock entities objs |
590 | 599 | ||
591 | g.Dispose(); | 600 | } |
592 | } // lock entities objs | 601 | finally |
602 | { | ||
603 | foreach (DrawStruct ds in z_sort.Values) | ||
604 | ds.brush.Dispose(); | ||
605 | } | ||
593 | 606 | ||
594 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); | 607 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); |
608 | |||
595 | return mapbmp; | 609 | return mapbmp; |
596 | } | 610 | } |
597 | 611 | ||
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index 992bff3..cb06fd4 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
54 | public void TerrainToBitmap(Bitmap mapbmp) | 54 | public void TerrainToBitmap(Bitmap mapbmp) |
55 | { | 55 | { |
56 | int tc = Environment.TickCount; | 56 | int tc = Environment.TickCount; |
57 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 57 | m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain"); |
58 | 58 | ||
59 | double[,] hm = m_scene.Heightmap.GetDoubles(); | 59 | double[,] hm = m_scene.Heightmap.GetDoubles(); |
60 | bool ShadowDebugContinue = true; | 60 | bool ShadowDebugContinue = true; |
@@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
199 | { | 199 | { |
200 | if (!terraincorruptedwarningsaid) | 200 | if (!terraincorruptedwarningsaid) |
201 | { | 201 | { |
202 | m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); | 202 | m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); |
203 | terraincorruptedwarningsaid = true; | 203 | terraincorruptedwarningsaid = true; |
204 | } | 204 | } |
205 | color = Color.Black; | 205 | color = Color.Black; |
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
229 | { | 229 | { |
230 | if (!terraincorruptedwarningsaid) | 230 | if (!terraincorruptedwarningsaid) |
231 | { | 231 | { |
232 | m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); | 232 | m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); |
233 | terraincorruptedwarningsaid = true; | 233 | terraincorruptedwarningsaid = true; |
234 | } | 234 | } |
235 | Color black = Color.Black; | 235 | Color black = Color.Black; |
@@ -238,7 +238,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 241 | |
242 | m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | ||
242 | } | 243 | } |
243 | } | 244 | } |
244 | } | 245 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index d13c2ef..e895178 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
173 | private Bitmap fetchTexture(UUID id) | 173 | private Bitmap fetchTexture(UUID id) |
174 | { | 174 | { |
175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); | 175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); |
176 | m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); | 176 | m_log.DebugFormat("[TEXTURED MAP TILE RENDERER]: Fetched texture {0}, found: {1}", id, asset != null); |
177 | if (asset == null) return null; | 177 | if (asset == null) return null; |
178 | 178 | ||
179 | ManagedImage managedImage; | 179 | ManagedImage managedImage; |
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
188 | } | 188 | } |
189 | catch (DllNotFoundException) | 189 | catch (DllNotFoundException) |
190 | { | 190 | { |
191 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); | 191 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); |
192 | 192 | ||
193 | } | 193 | } |
194 | catch (IndexOutOfRangeException) | 194 | catch (IndexOutOfRangeException) |
195 | { | 195 | { |
196 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); | 196 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
197 | 197 | ||
198 | } | 198 | } |
199 | catch (Exception) | 199 | catch (Exception) |
200 | { | 200 | { |
201 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); | 201 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
202 | 202 | ||
203 | } | 203 | } |
204 | return null; | 204 | return null; |
@@ -233,10 +233,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
233 | if (textureID == UUID.Zero) return defaultColor; // not set | 233 | if (textureID == UUID.Zero) return defaultColor; // not set |
234 | if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures | 234 | if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures |
235 | 235 | ||
236 | Bitmap bmp = fetchTexture(textureID); | 236 | Color color; |
237 | Color color = bmp == null ? defaultColor : computeAverageColor(bmp); | 237 | |
238 | // store it for future reference | 238 | using (Bitmap bmp = fetchTexture(textureID)) |
239 | m_mapping[textureID] = color; | 239 | { |
240 | color = bmp == null ? defaultColor : computeAverageColor(bmp); | ||
241 | // store it for future reference | ||
242 | m_mapping[textureID] = color; | ||
243 | } | ||
240 | 244 | ||
241 | return color; | 245 | return color; |
242 | } | 246 | } |
@@ -278,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
278 | public void TerrainToBitmap(Bitmap mapbmp) | 282 | public void TerrainToBitmap(Bitmap mapbmp) |
279 | { | 283 | { |
280 | int tc = Environment.TickCount; | 284 | int tc = Environment.TickCount; |
281 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 285 | m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain"); |
282 | 286 | ||
283 | // These textures should be in the AssetCache anyway, as every client conneting to this | 287 | // These textures should be in the AssetCache anyway, as every client conneting to this |
284 | // region needs them. Except on start, when the map is recreated (before anyone connected), | 288 | // region needs them. Except on start, when the map is recreated (before anyone connected), |
@@ -412,7 +416,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
412 | } | 416 | } |
413 | } | 417 | } |
414 | } | 418 | } |
415 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 419 | |
420 | m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | ||
416 | } | 421 | } |
417 | } | 422 | } |
418 | } | 423 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 98fa763..5412359 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
115 | "export-map [<path>]", | 115 | "export-map [<path>]", |
116 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | 116 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); |
117 | 117 | ||
118 | m_scene.AddCommand( | ||
119 | "Regions", this, "generate map", | ||
120 | "generate map", | ||
121 | "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand); | ||
122 | |||
118 | AddHandlers(); | 123 | AddHandlers(); |
119 | } | 124 | } |
120 | } | 125 | } |
@@ -1324,6 +1329,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1324 | m_scene.RegionInfo.RegionName, exportPath); | 1329 | m_scene.RegionInfo.RegionName, exportPath); |
1325 | } | 1330 | } |
1326 | 1331 | ||
1332 | public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams) | ||
1333 | { | ||
1334 | Scene consoleScene = m_scene.ConsoleScene(); | ||
1335 | |||
1336 | if (consoleScene != null && consoleScene != m_scene) | ||
1337 | return; | ||
1338 | |||
1339 | GenerateMaptile(); | ||
1340 | } | ||
1341 | |||
1327 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) | 1342 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) |
1328 | { | 1343 | { |
1329 | uint xstart = 0; | 1344 | uint xstart = 0; |
@@ -1561,88 +1576,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1561 | 1576 | ||
1562 | private Byte[] GenerateOverlay() | 1577 | private Byte[] GenerateOverlay() |
1563 | { | 1578 | { |
1564 | Bitmap overlay = new Bitmap(256, 256); | 1579 | using (Bitmap overlay = new Bitmap(256, 256)) |
1565 | |||
1566 | bool[,] saleBitmap = new bool[64, 64]; | ||
1567 | for (int x = 0 ; x < 64 ; x++) | ||
1568 | { | 1580 | { |
1569 | for (int y = 0 ; y < 64 ; y++) | 1581 | bool[,] saleBitmap = new bool[64, 64]; |
1570 | saleBitmap[x, y] = false; | 1582 | for (int x = 0 ; x < 64 ; x++) |
1571 | } | 1583 | { |
1572 | 1584 | for (int y = 0 ; y < 64 ; y++) | |
1573 | bool landForSale = false; | 1585 | saleBitmap[x, y] = false; |
1586 | } | ||
1574 | 1587 | ||
1575 | List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); | 1588 | bool landForSale = false; |
1576 | 1589 | ||
1577 | Color background = Color.FromArgb(0, 0, 0, 0); | 1590 | List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); |
1578 | SolidBrush transparent = new SolidBrush(background); | ||
1579 | Graphics g = Graphics.FromImage(overlay); | ||
1580 | g.FillRectangle(transparent, 0, 0, 255, 255); | ||
1581 | 1591 | ||
1582 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1592 | Color background = Color.FromArgb(0, 0, 0, 0); |
1583 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1584 | 1593 | ||
1585 | foreach (ILandObject land in parcels) | 1594 | using (Graphics g = Graphics.FromImage(overlay)) |
1586 | { | ||
1587 | // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); | ||
1588 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | ||
1589 | { | 1595 | { |
1590 | landForSale = true; | 1596 | using (SolidBrush transparent = new SolidBrush(background)) |
1591 | 1597 | g.FillRectangle(transparent, 0, 0, 256, 256); | |
1592 | bool[,] landBitmap = land.GetLandBitmap(); | 1598 | |
1599 | |||
1600 | foreach (ILandObject land in parcels) | ||
1601 | { | ||
1602 | // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); | ||
1603 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | ||
1604 | { | ||
1605 | landForSale = true; | ||
1606 | |||
1607 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | ||
1608 | } | ||
1609 | } | ||
1610 | |||
1611 | if (!landForSale) | ||
1612 | { | ||
1613 | m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); | ||
1614 | return null; | ||
1615 | } | ||
1616 | |||
1617 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | ||
1593 | 1618 | ||
1594 | for (int x = 0 ; x < 64 ; x++) | 1619 | using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9))) |
1595 | { | 1620 | { |
1596 | for (int y = 0 ; y < 64 ; y++) | 1621 | for (int x = 0 ; x < 64 ; x++) |
1597 | { | 1622 | { |
1598 | if (landBitmap[x, y]) | 1623 | for (int y = 0 ; y < 64 ; y++) |
1599 | { | 1624 | { |
1600 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | 1625 | if (saleBitmap[x, y]) |
1601 | 1626 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | |
1602 | if (x > 0) | ||
1603 | { | ||
1604 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1605 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1606 | } | ||
1607 | if (y > 0) | ||
1608 | { | ||
1609 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1610 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1611 | } | ||
1612 | if (x < 63) | ||
1613 | { | ||
1614 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1615 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1616 | } | ||
1617 | if (y < 63) | ||
1618 | { | ||
1619 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1620 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1621 | } | ||
1622 | } | 1627 | } |
1623 | } | 1628 | } |
1624 | } | 1629 | } |
1625 | |||
1626 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); | ||
1627 | } | 1630 | } |
1628 | } | ||
1629 | 1631 | ||
1630 | if (!landForSale) | 1632 | try |
1631 | { | 1633 | { |
1632 | m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); | 1634 | return OpenJPEG.EncodeFromImage(overlay, true); |
1633 | return null; | 1635 | } |
1636 | catch (Exception e) | ||
1637 | { | ||
1638 | m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); | ||
1639 | } | ||
1634 | } | 1640 | } |
1635 | 1641 | ||
1636 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | ||
1637 | |||
1638 | try | ||
1639 | { | ||
1640 | return OpenJPEG.EncodeFromImage(overlay, true); | ||
1641 | } | ||
1642 | catch (Exception e) | ||
1643 | { | ||
1644 | m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); | ||
1645 | } | ||
1646 | return null; | 1642 | return null; |
1647 | } | 1643 | } |
1648 | } | 1644 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 1949a90..214b07a 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -47,13 +47,33 @@ namespace OpenSim.Region.Framework.Interfaces | |||
47 | /// The handle of the destination region. If it's the same as the region currently | 47 | /// The handle of the destination region. If it's the same as the region currently |
48 | /// occupied by the agent then the teleport will be within that region. | 48 | /// occupied by the agent then the teleport will be within that region. |
49 | /// </param> | 49 | /// </param> |
50 | /// <param name='agent'></param> | ||
51 | /// <param name='regionHandle'></param> | ||
50 | /// <param name='position'></param> | 52 | /// <param name='position'></param> |
51 | /// <param name='lookAt'></param> | 53 | /// <param name='lookAt'></param> |
52 | /// <param name='teleportFlags'></param> | 54 | /// <param name='teleportFlags'></param> |
53 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); | 55 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); |
54 | 56 | ||
57 | /// <summary> | ||
58 | /// Teleports the agent for the given client to their home destination. | ||
59 | /// </summary> | ||
60 | /// <param name='id'></param> | ||
61 | /// <param name='client'></param> | ||
55 | bool TeleportHome(UUID id, IClientAPI client); | 62 | bool TeleportHome(UUID id, IClientAPI client); |
56 | 63 | ||
64 | /// <summary> | ||
65 | /// Teleport an agent directly to a given region without checking whether the region should be substituted. | ||
66 | /// </summary> | ||
67 | /// <remarks> | ||
68 | /// Please use Teleport() instead unless you know exactly what you're doing. | ||
69 | /// Do not use for same region teleports. | ||
70 | /// </remarks> | ||
71 | /// <param name='sp'></param> | ||
72 | /// <param name='reg'></param> | ||
73 | /// <param name='finalDestination'>/param> | ||
74 | /// <param name='position'></param> | ||
75 | /// <param name='lookAt'></param> | ||
76 | /// <param name='teleportFlags'></param> | ||
57 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, | 77 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, |
58 | Vector3 position, Vector3 lookAt, uint teleportFlags); | 78 | Vector3 position, Vector3 lookAt, uint teleportFlags); |
59 | 79 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs deleted file mode 100644 index 67a500f..0000000 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Region.Framework.Scenes; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public delegate bool ChildAgentUpdateReceived(AgentData data); | ||
35 | |||
36 | public interface IInterregionCommsOut | ||
37 | { | ||
38 | #region Agents | ||
39 | |||
40 | bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason); | ||
41 | |||
42 | /// <summary> | ||
43 | /// Full child agent update. | ||
44 | /// </summary> | ||
45 | /// <param name="regionHandle"></param> | ||
46 | /// <param name="data"></param> | ||
47 | /// <returns></returns> | ||
48 | bool SendChildAgentUpdate(ulong regionHandle, AgentData data); | ||
49 | |||
50 | /// <summary> | ||
51 | /// Short child agent update, mostly for position. | ||
52 | /// </summary> | ||
53 | /// <param name="regionHandle"></param> | ||
54 | /// <param name="data"></param> | ||
55 | /// <returns></returns> | ||
56 | bool SendChildAgentUpdate(ulong regionHandle, AgentPosition data); | ||
57 | |||
58 | bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent); | ||
59 | |||
60 | /// <summary> | ||
61 | /// Message from receiving region to departing region, telling it got contacted by the client. | ||
62 | /// When sent over REST, it invokes the opaque uri. | ||
63 | /// </summary> | ||
64 | /// <param name="regionHandle"></param> | ||
65 | /// <param name="id"></param> | ||
66 | /// <param name="uri"></param> | ||
67 | /// <returns></returns> | ||
68 | bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); | ||
69 | |||
70 | /// <summary> | ||
71 | /// Close chid agent. | ||
72 | /// </summary> | ||
73 | /// <param name="regionHandle"></param> | ||
74 | /// <param name="id"></param> | ||
75 | /// <returns></returns> | ||
76 | bool SendCloseChildAgent(ulong regionHandle, UUID id); | ||
77 | |||
78 | /// <summary> | ||
79 | /// Close agent. | ||
80 | /// </summary> | ||
81 | /// <param name="regionHandle"></param> | ||
82 | /// <param name="id"></param> | ||
83 | /// <returns></returns> | ||
84 | bool SendCloseAgent(ulong regionHandle, UUID id); | ||
85 | |||
86 | #endregion Agents | ||
87 | |||
88 | #region Objects | ||
89 | |||
90 | /// <summary> | ||
91 | /// Create an object in the destination region. This message is used primarily for prim crossing. | ||
92 | /// </summary> | ||
93 | /// <param name="regionHandle"></param> | ||
94 | /// <param name="sog"></param> | ||
95 | /// <param name="isLocalCall"></param> | ||
96 | /// <returns></returns> | ||
97 | bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall); | ||
98 | |||
99 | /// <summary> | ||
100 | /// Create an object from the user's inventory in the destination region. | ||
101 | /// This message is used primarily by clients. | ||
102 | /// </summary> | ||
103 | /// <param name="regionHandle"></param> | ||
104 | /// <param name="userID"></param> | ||
105 | /// <param name="itemID"></param> | ||
106 | /// <returns></returns> | ||
107 | bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID); | ||
108 | |||
109 | #endregion Objects | ||
110 | |||
111 | } | ||
112 | |||
113 | // This may not be needed, but having it here for now. | ||
114 | public interface IInterregionCommsIn | ||
115 | { | ||
116 | event ChildAgentUpdateReceived OnChildAgentUpdate; | ||
117 | } | ||
118 | |||
119 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs index b67312e..1a89721 100644 --- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -51,10 +51,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
51 | UUID = 5 | 51 | UUID = 5 |
52 | } | 52 | } |
53 | 53 | ||
54 | public struct JsonStoreStats | ||
55 | { | ||
56 | public int StoreCount; | ||
57 | } | ||
58 | |||
54 | public delegate void TakeValueCallback(string s); | 59 | public delegate void TakeValueCallback(string s); |
55 | 60 | ||
56 | public interface IJsonStoreModule | 61 | public interface IJsonStoreModule |
57 | { | 62 | { |
63 | JsonStoreStats GetStoreStats(); | ||
64 | |||
58 | bool AttachObjectStore(UUID objectID); | 65 | bool AttachObjectStore(UUID objectID); |
59 | bool CreateStore(string value, ref UUID result); | 66 | bool CreateStore(string value, ref UUID result); |
60 | bool DestroyStore(UUID storeID); | 67 | bool DestroyStore(UUID storeID); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3fd7485..55766cf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4121,32 +4121,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
4121 | } | 4121 | } |
4122 | } | 4122 | } |
4123 | 4123 | ||
4124 | // m_log.DebugFormat( | ||
4125 | // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", | ||
4126 | // RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); | ||
4127 | |||
4124 | // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags | 4128 | // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags |
4125 | if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && | 4129 | if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && |
4126 | RegionInfo.EstateSettings.AllowDirectTeleport == false && | 4130 | RegionInfo.EstateSettings.AllowDirectTeleport == false && |
4127 | !viahome && !godlike) | 4131 | !viahome && !godlike) |
4128 | { | 4132 | { |
4129 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); | 4133 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); |
4130 | // Can have multiple SpawnPoints | 4134 | |
4131 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); | 4135 | if (telehub != null) |
4132 | if (spawnpoints.Count > 1) | ||
4133 | { | 4136 | { |
4134 | // We have multiple SpawnPoints, Route the agent to a random or sequential one | 4137 | // Can have multiple SpawnPoints |
4135 | if (SpawnPointRouting == "random") | 4138 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); |
4136 | acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( | 4139 | if (spawnpoints.Count > 1) |
4137 | telehub.AbsolutePosition, | 4140 | { |
4138 | telehub.GroupRotation | 4141 | // We have multiple SpawnPoints, Route the agent to a random or sequential one |
4139 | ); | 4142 | if (SpawnPointRouting == "random") |
4143 | acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( | ||
4144 | telehub.AbsolutePosition, | ||
4145 | telehub.GroupRotation | ||
4146 | ); | ||
4147 | else | ||
4148 | acd.startpos = spawnpoints[SpawnPoint()].GetLocation( | ||
4149 | telehub.AbsolutePosition, | ||
4150 | telehub.GroupRotation | ||
4151 | ); | ||
4152 | } | ||
4153 | else if (spawnpoints.Count == 1) | ||
4154 | { | ||
4155 | // We have a single SpawnPoint and will route the agent to it | ||
4156 | acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | ||
4157 | } | ||
4140 | else | 4158 | else |
4141 | acd.startpos = spawnpoints[SpawnPoint()].GetLocation( | 4159 | { |
4142 | telehub.AbsolutePosition, | 4160 | m_log.DebugFormat( |
4143 | telehub.GroupRotation | 4161 | "[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.", |
4144 | ); | 4162 | RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); |
4163 | } | ||
4145 | } | 4164 | } |
4146 | else | 4165 | else |
4147 | { | 4166 | { |
4148 | // We have a single SpawnPoint and will route the agent to it | 4167 | m_log.DebugFormat( |
4149 | acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | 4168 | "[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.", |
4169 | RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); | ||
4150 | } | 4170 | } |
4151 | 4171 | ||
4152 | return true; | 4172 | return true; |
@@ -4593,18 +4613,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4593 | return sp; | 4613 | return sp; |
4594 | } | 4614 | } |
4595 | 4615 | ||
4596 | public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) | ||
4597 | { | ||
4598 | agent = null; | ||
4599 | ScenePresence sp = GetScenePresence(id); | ||
4600 | if ((sp != null) && (!sp.IsChildAgent)) | ||
4601 | { | ||
4602 | sp.IsChildAgent = true; | ||
4603 | return sp.CopyAgent(out agent); | ||
4604 | } | ||
4605 | |||
4606 | return false; | ||
4607 | } | ||
4608 | /// <summary> | 4616 | /// <summary> |
4609 | /// Authenticated close (via network) | 4617 | /// Authenticated close (via network) |
4610 | /// </summary> | 4618 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 252c72f..f57d4fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -109,6 +109,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | /// <summary> | ||
113 | /// This exists to prevent race conditions between two CompleteMovement threads if the simulator is slow and | ||
114 | /// the viewer fires these in quick succession. | ||
115 | /// </summary> | ||
116 | /// <remarks> | ||
117 | /// TODO: The child -> agent transition should be folded into LifecycleState and the CompleteMovement | ||
118 | /// regulation done there. | ||
119 | /// </remarks> | ||
120 | private object m_completeMovementLock = new object(); | ||
121 | |||
112 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 122 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
113 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); | 123 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
114 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | 124 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); |
@@ -984,6 +994,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
984 | /// <summary> | 994 | /// <summary> |
985 | /// Turns a child agent into a root agent. | 995 | /// Turns a child agent into a root agent. |
986 | /// </summary> | 996 | /// </summary> |
997 | /// <remarks> | ||
987 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the | 998 | /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the |
988 | /// avatar is actual in the sim. They can perform all actions. | 999 | /// avatar is actual in the sim. They can perform all actions. |
989 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, | 1000 | /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, |
@@ -991,49 +1002,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
991 | /// | 1002 | /// |
992 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here | 1003 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here |
993 | /// delays that crossing. | 1004 | /// delays that crossing. |
994 | /// </summary> | 1005 | /// </remarks> |
995 | private void MakeRootAgent(Vector3 pos, bool isFlying) | 1006 | private bool MakeRootAgent(Vector3 pos, bool isFlying) |
996 | { | 1007 | { |
997 | // m_log.InfoFormat( | 1008 | lock (m_completeMovementLock) |
998 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | ||
999 | // Name, m_scene.RegionInfo.RegionName); | ||
1000 | |||
1001 | if (ParentUUID != UUID.Zero) | ||
1002 | { | 1009 | { |
1003 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | 1010 | if (!IsChildAgent) |
1004 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | 1011 | return false; |
1005 | if (part == null) | 1012 | |
1013 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
1014 | |||
1015 | // m_log.InfoFormat( | ||
1016 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | ||
1017 | // Name, m_scene.RegionInfo.RegionName); | ||
1018 | |||
1019 | if (ParentUUID != UUID.Zero) | ||
1006 | { | 1020 | { |
1007 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | 1021 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); |
1022 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
1023 | if (part == null) | ||
1024 | { | ||
1025 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
1026 | } | ||
1027 | else | ||
1028 | { | ||
1029 | part.ParentGroup.AddAvatar(UUID); | ||
1030 | if (part.SitTargetPosition != Vector3.Zero) | ||
1031 | part.SitTargetAvatar = UUID; | ||
1032 | // ParentPosition = part.GetWorldPosition(); | ||
1033 | ParentID = part.LocalId; | ||
1034 | ParentPart = part; | ||
1035 | m_pos = PrevSitOffset; | ||
1036 | // pos = ParentPosition; | ||
1037 | pos = part.GetWorldPosition(); | ||
1038 | } | ||
1039 | ParentUUID = UUID.Zero; | ||
1040 | |||
1041 | // Animator.TrySetMovementAnimation("SIT"); | ||
1008 | } | 1042 | } |
1009 | else | 1043 | else |
1010 | { | 1044 | { |
1011 | part.ParentGroup.AddAvatar(UUID); | 1045 | IsLoggingIn = false; |
1012 | if (part.SitTargetPosition != Vector3.Zero) | ||
1013 | part.SitTargetAvatar = UUID; | ||
1014 | // ParentPosition = part.GetWorldPosition(); | ||
1015 | ParentID = part.LocalId; | ||
1016 | ParentPart = part; | ||
1017 | m_pos = PrevSitOffset; | ||
1018 | // pos = ParentPosition; | ||
1019 | pos = part.GetWorldPosition(); | ||
1020 | } | 1046 | } |
1021 | ParentUUID = UUID.Zero; | ||
1022 | |||
1023 | IsChildAgent = false; | ||
1024 | 1047 | ||
1025 | // Animator.TrySetMovementAnimation("SIT"); | ||
1026 | } | ||
1027 | else | ||
1028 | { | ||
1029 | IsChildAgent = false; | 1048 | IsChildAgent = false; |
1030 | IsLoggingIn = false; | ||
1031 | } | 1049 | } |
1032 | 1050 | ||
1033 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
1034 | |||
1035 | IsChildAgent = false; | ||
1036 | |||
1037 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag | 1051 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag |
1038 | // set and prevent the close of the connection on a subsequent re-teleport. | 1052 | // set and prevent the close of the connection on a subsequent re-teleport. |
1039 | // Should not be needed if we are not trying to tell this region to close | 1053 | // Should not be needed if we are not trying to tell this region to close |
@@ -1178,22 +1192,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1178 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | 1192 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently |
1179 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | 1193 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are |
1180 | // not transporting the required data. | 1194 | // not transporting the required data. |
1181 | lock (m_attachments) | 1195 | // |
1196 | // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT | ||
1197 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | ||
1198 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | ||
1199 | // not transporting the required data. | ||
1200 | // | ||
1201 | // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of | ||
1202 | // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here | ||
1203 | // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. | ||
1204 | // | ||
1205 | // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). | ||
1206 | // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing | ||
1207 | // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the | ||
1208 | // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. | ||
1209 | // | ||
1210 | // One cannot simply iterate over attachments in a fire and forget thread because this would no longer | ||
1211 | // be locked, allowing race conditions if other code changes the attachments list. | ||
1212 | List<SceneObjectGroup> attachments = GetAttachments(); | ||
1213 | |||
1214 | if (attachments.Count > 0) | ||
1182 | { | 1215 | { |
1183 | if (HasAttachments()) | 1216 | m_log.DebugFormat( |
1184 | { | 1217 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
1185 | m_log.DebugFormat( | ||
1186 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
1187 | 1218 | ||
1188 | // Resume scripts | 1219 | // Resume scripts |
1189 | Util.FireAndForget(delegate(object x) { | 1220 | foreach (SceneObjectGroup sog in attachments) |
1190 | foreach (SceneObjectGroup sog in m_attachments) | 1221 | { |
1191 | { | 1222 | sog.ScheduleGroupForFullUpdate(); |
1192 | sog.ScheduleGroupForFullUpdate(); | 1223 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
1193 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1224 | sog.ResumeScripts(); |
1194 | sog.ResumeScripts(); | ||
1195 | } | ||
1196 | }); | ||
1197 | } | 1225 | } |
1198 | } | 1226 | } |
1199 | } | 1227 | } |
@@ -1215,6 +1243,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1215 | 1243 | ||
1216 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1244 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1217 | 1245 | ||
1246 | return true; | ||
1218 | } | 1247 | } |
1219 | 1248 | ||
1220 | public int GetStateSource() | 1249 | public int GetStateSource() |
@@ -1637,7 +1666,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1637 | } | 1666 | } |
1638 | 1667 | ||
1639 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1668 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1640 | MakeRootAgent(AbsolutePosition, flying); | 1669 | if (!MakeRootAgent(AbsolutePosition, flying)) |
1670 | { | ||
1671 | m_log.DebugFormat( | ||
1672 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", | ||
1673 | Name, Scene.Name); | ||
1674 | |||
1675 | return; | ||
1676 | } | ||
1641 | 1677 | ||
1642 | // Tell the client that we're totally ready | 1678 | // Tell the client that we're totally ready |
1643 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 1679 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
@@ -2884,7 +2920,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2884 | Rotation = newRot; | 2920 | Rotation = newRot; |
2885 | 2921 | ||
2886 | // ParentPosition = part.AbsolutePosition; | 2922 | // ParentPosition = part.AbsolutePosition; |
2887 | part.ParentGroup.AddAvatar(UUID); | ||
2888 | } | 2923 | } |
2889 | else | 2924 | else |
2890 | { | 2925 | { |
@@ -2893,13 +2928,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2893 | m_pos -= part.GroupPosition; | 2928 | m_pos -= part.GroupPosition; |
2894 | 2929 | ||
2895 | // ParentPosition = part.AbsolutePosition; | 2930 | // ParentPosition = part.AbsolutePosition; |
2896 | part.ParentGroup.AddAvatar(UUID); | ||
2897 | 2931 | ||
2898 | // m_log.DebugFormat( | 2932 | // m_log.DebugFormat( |
2899 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2933 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
2900 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); | 2934 | // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); |
2901 | } | 2935 | } |
2902 | 2936 | ||
2937 | part.ParentGroup.AddAvatar(UUID); | ||
2903 | ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); | 2938 | ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
2904 | ParentID = m_requestedSitTargetID; | 2939 | ParentID = m_requestedSitTargetID; |
2905 | m_AngularVelocity = Vector3.Zero; | 2940 | m_AngularVelocity = Vector3.Zero; |
@@ -3210,6 +3245,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | // again here... this comes after the cached appearance check because the avatars | 3245 | // again here... this comes after the cached appearance check because the avatars |
3211 | // appearance goes into the avatar update packet | 3246 | // appearance goes into the avatar update packet |
3212 | SendAvatarDataToAllAgents(); | 3247 | SendAvatarDataToAllAgents(); |
3248 | |||
3249 | // This invocation always shows up in the viewer logs as an error. Is it needed? | ||
3213 | SendAppearanceToAgent(this); | 3250 | SendAppearanceToAgent(this); |
3214 | 3251 | ||
3215 | // If we are using the the cached appearance then send it out to everyone | 3252 | // If we are using the the cached appearance then send it out to everyone |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index d1aeaee..1ff1329 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -111,6 +111,45 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
111 | Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); | 111 | Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); |
112 | } | 112 | } |
113 | 113 | ||
114 | /// <summary> | ||
115 | /// Test that duplicate complete movement calls are ignored. | ||
116 | /// </summary> | ||
117 | /// <remarks> | ||
118 | /// If duplicate calls are not ignored then there is a risk of race conditions or other unexpected effects. | ||
119 | /// </remarks> | ||
120 | [Test] | ||
121 | public void TestDupeCompleteMovementCalls() | ||
122 | { | ||
123 | TestHelpers.InMethod(); | ||
124 | // TestHelpers.EnableLogging(); | ||
125 | |||
126 | UUID spUuid = TestHelpers.ParseTail(0x1); | ||
127 | |||
128 | TestScene scene = new SceneHelpers().SetupScene(); | ||
129 | |||
130 | int makeRootAgentEvents = 0; | ||
131 | scene.EventManager.OnMakeRootAgent += spi => makeRootAgentEvents++; | ||
132 | |||
133 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, spUuid); | ||
134 | |||
135 | Assert.That(makeRootAgentEvents, Is.EqualTo(1)); | ||
136 | |||
137 | // Normally these would be invoked by a CompleteMovement message coming in to the UDP stack. But for | ||
138 | // convenience, here we will invoke it manually. | ||
139 | sp.CompleteMovement(sp.ControllingClient, true); | ||
140 | |||
141 | Assert.That(makeRootAgentEvents, Is.EqualTo(1)); | ||
142 | |||
143 | // Check rest of exepcted parameters. | ||
144 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null); | ||
145 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); | ||
146 | |||
147 | Assert.That(sp.IsChildAgent, Is.False); | ||
148 | Assert.That(sp.UUID, Is.EqualTo(spUuid)); | ||
149 | |||
150 | Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); | ||
151 | } | ||
152 | |||
114 | [Test] | 153 | [Test] |
115 | public void TestCreateDuplicateRootScenePresence() | 154 | public void TestCreateDuplicateRootScenePresence() |
116 | { | 155 | { |
@@ -249,58 +288,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
249 | // Assert.That(childPresence, Is.Not.Null); | 288 | // Assert.That(childPresence, Is.Not.Null); |
250 | // Assert.That(childPresence.IsChildAgent, Is.True); | 289 | // Assert.That(childPresence.IsChildAgent, Is.True); |
251 | } | 290 | } |
252 | |||
253 | // /// <summary> | ||
254 | // /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. | ||
255 | // /// </summary> | ||
256 | // [Test] | ||
257 | // public void T010_TestAddRootAgent() | ||
258 | // { | ||
259 | // TestHelpers.InMethod(); | ||
260 | // | ||
261 | // string firstName = "testfirstname"; | ||
262 | // | ||
263 | // AgentCircuitData agent = new AgentCircuitData(); | ||
264 | // agent.AgentID = agent1; | ||
265 | // agent.firstname = firstName; | ||
266 | // agent.lastname = "testlastname"; | ||
267 | // agent.SessionID = UUID.Random(); | ||
268 | // agent.SecureSessionID = UUID.Random(); | ||
269 | // agent.circuitcode = 123; | ||
270 | // agent.BaseFolder = UUID.Zero; | ||
271 | // agent.InventoryFolder = UUID.Zero; | ||
272 | // agent.startpos = Vector3.Zero; | ||
273 | // agent.CapsPath = GetRandomCapsObjectPath(); | ||
274 | // agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
275 | // agent.child = true; | ||
276 | // | ||
277 | // scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | ||
278 | // | ||
279 | // string reason; | ||
280 | // scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); | ||
281 | // testclient = new TestClient(agent, scene); | ||
282 | // scene.AddNewAgent(testclient); | ||
283 | // | ||
284 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
285 | // | ||
286 | // Assert.That(presence, Is.Not.Null, "presence is null"); | ||
287 | // Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same"); | ||
288 | // acd1 = agent; | ||
289 | // } | ||
290 | // | ||
291 | // /// <summary> | ||
292 | // /// Test removing an uncrossed root agent from a scene. | ||
293 | // /// </summary> | ||
294 | // [Test] | ||
295 | // public void T011_TestRemoveRootAgent() | ||
296 | // { | ||
297 | // TestHelpers.InMethod(); | ||
298 | // | ||
299 | // scene.RemoveClient(agent1); | ||
300 | // | ||
301 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
302 | // | ||
303 | // Assert.That(presence, Is.Null, "presence is not null"); | ||
304 | // } | ||
305 | } | 291 | } |
306 | } \ No newline at end of file | 292 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs new file mode 100644 index 0000000..9a97acc --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * Redistribution and use in source and binary forms, with or without | ||
3 | * modification, are permitted provided that the following conditions are met: | ||
4 | * * Redistributions of source code must retain the above copyright | ||
5 | * notice, this list of conditions and the following disclaimer. | ||
6 | * * Redistributions in binary form must reproduce the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer in the | ||
8 | * documentation and/or other materials provided with the distribution. | ||
9 | * * Neither the name of the OpenSimulator Project nor the | ||
10 | * names of its contributors may be used to endorse or promote products | ||
11 | * derived from this software without specific prior written permission. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
16 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
17 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
18 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
19 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
20 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
22 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | using System; | ||
26 | using Nini.Config; | ||
27 | using NUnit.Framework; | ||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Region.CoreModules.World.Estate; | ||
31 | using OpenSim.Region.Framework.Scenes; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Tests.Common; | ||
35 | using OpenSim.Tests.Common.Mock; | ||
36 | |||
37 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Scene telehub tests | ||
41 | /// </summary> | ||
42 | /// <remarks> | ||
43 | /// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour | ||
44 | /// in the case of an error condition | ||
45 | /// </remarks> | ||
46 | [TestFixture] | ||
47 | public class SceneTelehubTests : OpenSimTestCase | ||
48 | { | ||
49 | /// <summary> | ||
50 | /// Test for desired behaviour when a telehub has no spawn points | ||
51 | /// </summary> | ||
52 | [Test] | ||
53 | public void TestNoTelehubSpawnPoints() | ||
54 | { | ||
55 | TestHelpers.InMethod(); | ||
56 | // TestHelpers.EnableLogging(); | ||
57 | |||
58 | EstateManagementModule emm = new EstateManagementModule(); | ||
59 | |||
60 | SceneHelpers sh = new SceneHelpers(); | ||
61 | Scene scene = sh.SetupScene(); | ||
62 | SceneHelpers.SetupSceneModules(scene, emm); | ||
63 | |||
64 | UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1); | ||
65 | |||
66 | SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner); | ||
67 | |||
68 | emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId); | ||
69 | scene.RegionInfo.EstateSettings.AllowDirectTeleport = false; | ||
70 | |||
71 | // Must still be possible to successfully log in | ||
72 | UUID loggingInUserId = TestHelpers.ParseTail(0x2); | ||
73 | |||
74 | UserAccount ua | ||
75 | = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password"); | ||
76 | |||
77 | SceneHelpers.AddScenePresence(scene, ua); | ||
78 | |||
79 | Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Test for desired behaviour when the scene object nominated as a telehub object does not exist. | ||
84 | /// </summary> | ||
85 | [Test] | ||
86 | public void TestNoTelehubSceneObject() | ||
87 | { | ||
88 | TestHelpers.InMethod(); | ||
89 | // TestHelpers.EnableLogging(); | ||
90 | |||
91 | EstateManagementModule emm = new EstateManagementModule(); | ||
92 | |||
93 | SceneHelpers sh = new SceneHelpers(); | ||
94 | Scene scene = sh.SetupScene(); | ||
95 | SceneHelpers.SetupSceneModules(scene, emm); | ||
96 | |||
97 | UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1); | ||
98 | |||
99 | SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner); | ||
100 | SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner); | ||
101 | |||
102 | emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId); | ||
103 | emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId); | ||
104 | scene.RegionInfo.EstateSettings.AllowDirectTeleport = false; | ||
105 | |||
106 | scene.DeleteSceneObject(telehubSo, false); | ||
107 | |||
108 | // Must still be possible to successfully log in | ||
109 | UUID loggingInUserId = TestHelpers.ParseTail(0x2); | ||
110 | |||
111 | UserAccount ua | ||
112 | = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password"); | ||
113 | |||
114 | SceneHelpers.AddScenePresence(scene, ua); | ||
115 | |||
116 | Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null); | ||
117 | } | ||
118 | } | ||
119 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index dd27294..1e59e3f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -62,8 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
62 | = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); | 62 | = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); |
63 | m_assetService.Store(corruptAsset); | 63 | m_assetService.Store(corruptAsset); |
64 | 64 | ||
65 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 65 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); | 66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); |
67 | 67 | ||
68 | // We count the uuid as gathered even if the asset itself is corrupt. | 68 | // We count the uuid as gathered even if the asset itself is corrupt. |
69 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | 69 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); |
@@ -78,9 +78,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
78 | TestHelpers.InMethod(); | 78 | TestHelpers.InMethod(); |
79 | 79 | ||
80 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | 80 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); |
81 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 81 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
82 | 82 | ||
83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); | 83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, (sbyte)AssetType.Object, foundAssetUuids); |
84 | 84 | ||
85 | // We count the uuid as gathered even if the asset itself is missing. | 85 | // We count the uuid as gathered even if the asset itself is missing. |
86 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | 86 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); |
@@ -103,8 +103,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
103 | AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); | 103 | AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); |
104 | m_assetService.Store(ncAsset); | 104 | m_assetService.Store(ncAsset); |
105 | 105 | ||
106 | IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); | 106 | IDictionary<UUID, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); |
107 | m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids); | 107 | m_uuidGatherer.GatherAssetUuids(ncAssetId, (sbyte)AssetType.Notecard, foundAssetUuids); |
108 | 108 | ||
109 | // We count the uuid as gathered even if the asset itself is corrupt. | 109 | // We count the uuid as gathered even if the asset itself is corrupt. |
110 | Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); | 110 | Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index d8309d8..67655d6 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse.StructuredData; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.Framework.Scenes.Serialization; | 39 | using OpenSim.Region.Framework.Scenes.Serialization; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
41 | 42 | ||
42 | namespace OpenSim.Region.Framework.Scenes | 43 | namespace OpenSim.Region.Framework.Scenes |
43 | { | 44 | { |
@@ -83,29 +84,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
83 | /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> | 84 | /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> |
84 | /// <param name="assetType">The type of the asset for the uuid given</param> | 85 | /// <param name="assetType">The type of the asset for the uuid given</param> |
85 | /// <param name="assetUuids">The assets gathered</param> | 86 | /// <param name="assetUuids">The assets gathered</param> |
86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 87 | public void GatherAssetUuids(UUID assetUuid, sbyte assetType, IDictionary<UUID, sbyte> assetUuids) |
87 | { | 88 | { |
88 | try | 89 | try |
89 | { | 90 | { |
90 | assetUuids[assetUuid] = assetType; | 91 | assetUuids[assetUuid] = assetType; |
91 | 92 | ||
92 | if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) | 93 | if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) |
93 | { | 94 | { |
94 | GetWearableAssetUuids(assetUuid, assetUuids); | 95 | GetWearableAssetUuids(assetUuid, assetUuids); |
95 | } | 96 | } |
96 | else if (AssetType.Gesture == assetType) | 97 | else if ((sbyte)AssetType.Gesture == assetType) |
97 | { | 98 | { |
98 | GetGestureAssetUuids(assetUuid, assetUuids); | 99 | GetGestureAssetUuids(assetUuid, assetUuids); |
99 | } | 100 | } |
100 | else if (AssetType.Notecard == assetType) | 101 | else if ((sbyte)AssetType.Notecard == assetType) |
101 | { | 102 | { |
102 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | 103 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); |
103 | } | 104 | } |
104 | else if (AssetType.LSLText == assetType) | 105 | else if ((sbyte)AssetType.LSLText == assetType) |
105 | { | 106 | { |
106 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | 107 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); |
107 | } | 108 | } |
108 | else if (AssetType.Object == assetType) | 109 | else if ((sbyte)OpenSimAssetType.Material == assetType) |
110 | { | ||
111 | GetMaterialAssetUuids(assetUuid, assetUuids); | ||
112 | } | ||
113 | else if ((sbyte)AssetType.Object == assetType) | ||
109 | { | 114 | { |
110 | GetSceneObjectAssetUuids(assetUuid, assetUuids); | 115 | GetSceneObjectAssetUuids(assetUuid, assetUuids); |
111 | } | 116 | } |
@@ -132,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
132 | /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. | 137 | /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. |
133 | /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. | 138 | /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. |
134 | /// </param> | 139 | /// </param> |
135 | public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) | 140 | public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, sbyte> assetUuids) |
136 | { | 141 | { |
137 | // m_log.DebugFormat( | 142 | // m_log.DebugFormat( |
138 | // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); | 143 | // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); |
@@ -152,7 +157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
152 | { | 157 | { |
153 | // Get the prim's default texture. This will be used for faces which don't have their own texture | 158 | // Get the prim's default texture. This will be used for faces which don't have their own texture |
154 | if (textureEntry.DefaultTexture != null) | 159 | if (textureEntry.DefaultTexture != null) |
155 | assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; | 160 | assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture; |
156 | 161 | ||
157 | if (textureEntry.FaceTextures != null) | 162 | if (textureEntry.FaceTextures != null) |
158 | { | 163 | { |
@@ -160,20 +165,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) | 165 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) |
161 | { | 166 | { |
162 | if (texture != null) | 167 | if (texture != null) |
163 | assetUuids[texture.TextureID] = AssetType.Texture; | 168 | assetUuids[texture.TextureID] = (sbyte)AssetType.Texture; |
164 | } | 169 | } |
165 | } | 170 | } |
166 | } | 171 | } |
167 | 172 | ||
168 | // If the prim is a sculpt then preserve this information too | 173 | // If the prim is a sculpt then preserve this information too |
169 | if (part.Shape.SculptTexture != UUID.Zero) | 174 | if (part.Shape.SculptTexture != UUID.Zero) |
170 | assetUuids[part.Shape.SculptTexture] = AssetType.Texture; | 175 | assetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture; |
171 | 176 | ||
172 | if (part.Shape.ProjectionTextureUUID != UUID.Zero) | 177 | if (part.Shape.ProjectionTextureUUID != UUID.Zero) |
173 | assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture; | 178 | assetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture; |
174 | 179 | ||
175 | if (part.CollisionSound != UUID.Zero) | 180 | if (part.CollisionSound != UUID.Zero) |
176 | assetUuids[part.CollisionSound] = AssetType.Sound; | 181 | assetUuids[part.CollisionSound] = (sbyte)AssetType.Sound; |
177 | 182 | ||
178 | if (part.ParticleSystem.Length > 0) | 183 | if (part.ParticleSystem.Length > 0) |
179 | { | 184 | { |
@@ -181,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
181 | { | 186 | { |
182 | Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); | 187 | Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); |
183 | if (ps.Texture != UUID.Zero) | 188 | if (ps.Texture != UUID.Zero) |
184 | assetUuids[ps.Texture] = AssetType.Texture; | 189 | assetUuids[ps.Texture] = (sbyte)AssetType.Texture; |
185 | } | 190 | } |
186 | catch (Exception e) | 191 | catch (Exception e) |
187 | { | 192 | { |
@@ -201,7 +206,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
201 | // tii.Name, tii.Type, part.Name, part.UUID); | 206 | // tii.Name, tii.Type, part.Name, part.UUID); |
202 | 207 | ||
203 | if (!assetUuids.ContainsKey(tii.AssetID)) | 208 | if (!assetUuids.ContainsKey(tii.AssetID)) |
204 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); | 209 | GatherAssetUuids(tii.AssetID, (sbyte)tii.Type, assetUuids); |
205 | } | 210 | } |
206 | 211 | ||
207 | // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed | 212 | // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed |
@@ -210,7 +215,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
210 | // Scene.EventManager is present. | 215 | // Scene.EventManager is present. |
211 | // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); | 216 | // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); |
212 | 217 | ||
213 | GatherMaterialsUuids(part, assetUuids); | 218 | |
219 | // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs | ||
220 | GatherMaterialsUuids(part, assetUuids); | ||
214 | } | 221 | } |
215 | catch (Exception e) | 222 | catch (Exception e) |
216 | { | 223 | { |
@@ -221,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | } | 228 | } |
222 | } | 229 | } |
223 | } | 230 | } |
224 | 231 | ||
225 | // /// <summary> | 232 | // /// <summary> |
226 | // /// The callback made when we request the asset for an object from the asset service. | 233 | // /// The callback made when we request the asset for an object from the asset service. |
227 | // /// </summary> | 234 | // /// </summary> |
@@ -237,10 +244,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | 244 | ||
238 | /// <summary> | 245 | /// <summary> |
239 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | 246 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps |
247 | /// stored in legacy format in part.DynAttrs | ||
240 | /// </summary> | 248 | /// </summary> |
241 | /// <param name="part"></param> | 249 | /// <param name="part"></param> |
242 | /// <param name="assetUuids"></param> | 250 | /// <param name="assetUuids"></param> |
243 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | 251 | //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) |
252 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids) | ||
244 | { | 253 | { |
245 | // scan thru the dynAttrs map of this part for any textures used as materials | 254 | // scan thru the dynAttrs map of this part for any textures used as materials |
246 | OSD osdMaterials = null; | 255 | OSD osdMaterials = null; |
@@ -276,7 +285,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
276 | UUID normalMapId = mat["NormMap"].AsUUID(); | 285 | UUID normalMapId = mat["NormMap"].AsUUID(); |
277 | if (normalMapId != UUID.Zero) | 286 | if (normalMapId != UUID.Zero) |
278 | { | 287 | { |
279 | assetUuids[normalMapId] = AssetType.Texture; | 288 | assetUuids[normalMapId] = (sbyte)AssetType.Texture; |
280 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | 289 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); |
281 | } | 290 | } |
282 | } | 291 | } |
@@ -285,7 +294,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
285 | UUID specularMapId = mat["SpecMap"].AsUUID(); | 294 | UUID specularMapId = mat["SpecMap"].AsUUID(); |
286 | if (specularMapId != UUID.Zero) | 295 | if (specularMapId != UUID.Zero) |
287 | { | 296 | { |
288 | assetUuids[specularMapId] = AssetType.Texture; | 297 | assetUuids[specularMapId] = (sbyte)AssetType.Texture; |
289 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | 298 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); |
290 | } | 299 | } |
291 | } | 300 | } |
@@ -340,7 +349,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | /// </summary> | 349 | /// </summary> |
341 | /// <param name="scriptUuid"></param> | 350 | /// <param name="scriptUuid"></param> |
342 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 351 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
343 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) | 352 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids) |
344 | { | 353 | { |
345 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); | 354 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); |
346 | 355 | ||
@@ -360,7 +369,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
360 | 369 | ||
361 | // Embedded asset references (if not false positives) could be for many types of asset, so we will | 370 | // Embedded asset references (if not false positives) could be for many types of asset, so we will |
362 | // label these as unknown. | 371 | // label these as unknown. |
363 | assetUuids[uuid] = AssetType.Unknown; | 372 | assetUuids[uuid] = (sbyte)AssetType.Unknown; |
364 | } | 373 | } |
365 | } | 374 | } |
366 | } | 375 | } |
@@ -370,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
370 | /// </summary> | 379 | /// </summary> |
371 | /// <param name="wearableAssetUuid"></param> | 380 | /// <param name="wearableAssetUuid"></param> |
372 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 381 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
373 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) | 382 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids) |
374 | { | 383 | { |
375 | AssetBase assetBase = GetAsset(wearableAssetUuid); | 384 | AssetBase assetBase = GetAsset(wearableAssetUuid); |
376 | 385 | ||
@@ -385,7 +394,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
385 | 394 | ||
386 | foreach (UUID uuid in wearableAsset.Textures.Values) | 395 | foreach (UUID uuid in wearableAsset.Textures.Values) |
387 | { | 396 | { |
388 | assetUuids[uuid] = AssetType.Texture; | 397 | assetUuids[uuid] = (sbyte)AssetType.Texture; |
389 | } | 398 | } |
390 | } | 399 | } |
391 | } | 400 | } |
@@ -397,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
397 | /// </summary> | 406 | /// </summary> |
398 | /// <param name="sceneObject"></param> | 407 | /// <param name="sceneObject"></param> |
399 | /// <param name="assetUuids"></param> | 408 | /// <param name="assetUuids"></param> |
400 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) | 409 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids) |
401 | { | 410 | { |
402 | AssetBase objectAsset = GetAsset(sceneObjectUuid); | 411 | AssetBase objectAsset = GetAsset(sceneObjectUuid); |
403 | 412 | ||
@@ -426,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | /// </summary> | 435 | /// </summary> |
427 | /// <param name="gestureUuid"></param> | 436 | /// <param name="gestureUuid"></param> |
428 | /// <param name="assetUuids"></param> | 437 | /// <param name="assetUuids"></param> |
429 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) | 438 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids) |
430 | { | 439 | { |
431 | AssetBase assetBase = GetAsset(gestureUuid); | 440 | AssetBase assetBase = GetAsset(gestureUuid); |
432 | if (null == assetBase) | 441 | if (null == assetBase) |
@@ -460,9 +469,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | // If it can be parsed as a UUID, it is an asset ID | 469 | // If it can be parsed as a UUID, it is an asset ID |
461 | UUID uuid; | 470 | UUID uuid; |
462 | if (UUID.TryParse(id, out uuid)) | 471 | if (UUID.TryParse(id, out uuid)) |
463 | assetUuids[uuid] = AssetType.Animation; | 472 | assetUuids[uuid] = (sbyte)AssetType.Animation; |
464 | } | 473 | } |
465 | } | 474 | } |
475 | |||
476 | /// <summary> | ||
477 | /// Get the asset uuid's referenced in a material. | ||
478 | /// </summary> | ||
479 | private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids) | ||
480 | { | ||
481 | AssetBase assetBase = GetAsset(materialUuid); | ||
482 | if (null == assetBase) | ||
483 | return; | ||
484 | |||
485 | OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data); | ||
486 | |||
487 | UUID normMap = mat["NormMap"].AsUUID(); | ||
488 | if (normMap != UUID.Zero) | ||
489 | assetUuids[normMap] = (sbyte)AssetType.Texture; | ||
490 | |||
491 | UUID specMap = mat["SpecMap"].AsUUID(); | ||
492 | if (specMap != UUID.Zero) | ||
493 | assetUuids[specMap] = (sbyte)AssetType.Texture; | ||
494 | } | ||
466 | } | 495 | } |
467 | 496 | ||
468 | public class HGUuidGatherer : UuidGatherer | 497 | public class HGUuidGatherer : UuidGatherer |
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 1eb0a6b..ec18db0 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -304,7 +304,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
304 | private string GetImageQueuesReport(string[] showParams) | 304 | private string GetImageQueuesReport(string[] showParams) |
305 | { | 305 | { |
306 | if (showParams.Length < 5 || showParams.Length > 6) | 306 | if (showParams.Length < 5 || showParams.Length > 6) |
307 | return "Usage: image queues show <first-name> <last-name> [full]"; | 307 | return "Usage: show image queues <first-name> <last-name> [full]"; |
308 | 308 | ||
309 | string firstName = showParams[3]; | 309 | string firstName = showParams[3]; |
310 | string lastName = showParams[4]; | 310 | string lastName = showParams[4]; |
@@ -395,7 +395,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
395 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); | 395 | report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); |
396 | 396 | ||
397 | report.AppendFormat( | 397 | report.AppendFormat( |
398 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", | 398 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", |
399 | "Since", | 399 | "Since", |
400 | "Pkts", | 400 | "Pkts", |
401 | "Pkts", | 401 | "Pkts", |
@@ -407,12 +407,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
407 | "Q Pkts", | 407 | "Q Pkts", |
408 | "Q Pkts", | 408 | "Q Pkts", |
409 | "Q Pkts", | 409 | "Q Pkts", |
410 | "Q Pkts", | ||
411 | "Q Pkts"); | 410 | "Q Pkts"); |
412 | 411 | ||
413 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); | 412 | report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); |
414 | report.AppendFormat( | 413 | report.AppendFormat( |
415 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", | 414 | "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", |
416 | "Last In", | 415 | "Last In", |
417 | "In", | 416 | "In", |
418 | "Out", | 417 | "Out", |
@@ -424,8 +423,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
424 | "Cloud", | 423 | "Cloud", |
425 | "Task", | 424 | "Task", |
426 | "Texture", | 425 | "Texture", |
427 | "Asset", | 426 | "Asset"); |
428 | "State"); | ||
429 | 427 | ||
430 | lock (m_scenes) | 428 | lock (m_scenes) |
431 | { | 429 | { |
@@ -434,24 +432,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden | |||
434 | scene.ForEachClient( | 432 | scene.ForEachClient( |
435 | delegate(IClientAPI client) | 433 | delegate(IClientAPI client) |
436 | { | 434 | { |
437 | bool isChild = client.SceneAgent.IsChildAgent; | ||
438 | if (isChild && !showChildren) | ||
439 | return; | ||
440 | |||
441 | string name = client.Name; | ||
442 | if (pname != "" && name != pname) | ||
443 | return; | ||
444 | |||
445 | string regionName = scene.RegionInfo.RegionName; | ||
446 | |||
447 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); | ||
448 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); | ||
449 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); | ||
450 | |||
451 | if (client is IStatsCollector) | 435 | if (client is IStatsCollector) |
452 | { | 436 | { |
453 | IStatsCollector stats = (IStatsCollector)client; | 437 | |
438 | bool isChild = client.SceneAgent.IsChildAgent; | ||
439 | if (isChild && !showChildren) | ||
440 | return; | ||
454 | 441 | ||
442 | string name = client.Name; | ||
443 | if (pname != "" && name != pname) | ||
444 | return; | ||
445 | |||
446 | string regionName = scene.RegionInfo.RegionName; | ||
447 | |||
448 | report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); | ||
449 | report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); | ||
450 | report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); | ||
451 | |||
452 | IStatsCollector stats = (IStatsCollector)client; | ||
455 | report.AppendLine(stats.Report()); | 453 | report.AppendLine(stats.Report()); |
456 | } | 454 | } |
457 | }); | 455 | }); |
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs deleted file mode 100644 index d8f5563..0000000 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ /dev/null | |||
@@ -1,657 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Security.Cryptography; // for computing md5 hash | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | |||
46 | using Ionic.Zlib; | ||
47 | |||
48 | // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already | ||
49 | // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans | ||
50 | // the available DLLs | ||
51 | //[assembly: Addin("MaterialsDemoModule", "1.0")] | ||
52 | //[assembly: AddinDependency("OpenSim", "0.5")] | ||
53 | |||
54 | namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | ||
55 | { | ||
56 | /// <summary> | ||
57 | /// | ||
58 | // # # ## ##### # # # # # #### | ||
59 | // # # # # # # ## # # ## # # # | ||
60 | // # # # # # # # # # # # # # # | ||
61 | // # ## # ###### ##### # # # # # # # # ### | ||
62 | // ## ## # # # # # ## # # ## # # | ||
63 | // # # # # # # # # # # # #### | ||
64 | // | ||
65 | // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION! | ||
66 | // | ||
67 | ////////////// WARNING ////////////////////////////////////////////////////////////////// | ||
68 | /// This is an *Experimental* module for developing support for materials-capable viewers | ||
69 | /// This module should NOT be used in a production environment! It may cause data corruption and | ||
70 | /// viewer crashes. It should be only used to evaluate implementations of materials. | ||
71 | /// | ||
72 | /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature | ||
73 | /// of OpenSimulator and is not field proven at the time this module was written. Persistence | ||
74 | /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials | ||
75 | /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means | ||
76 | /// of archiving however the texture resources used by these materials probably will not as they | ||
77 | /// may not be adequately referenced to ensure proper archiving. | ||
78 | /// | ||
79 | /// | ||
80 | /// | ||
81 | /// To enable this module, add this string at the bottom of OpenSim.ini: | ||
82 | /// [MaterialsDemoModule] | ||
83 | /// | ||
84 | /// </summary> | ||
85 | /// | ||
86 | |||
87 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")] | ||
88 | public class MaterialsDemoModule : INonSharedRegionModule | ||
89 | { | ||
90 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
91 | |||
92 | public string Name { get { return "MaterialsDemoModule"; } } | ||
93 | |||
94 | public Type ReplaceableInterface { get { return null; } } | ||
95 | |||
96 | private Scene m_scene = null; | ||
97 | private bool m_enabled = false; | ||
98 | |||
99 | public Dictionary<UUID, OSDMap> m_knownMaterials = new Dictionary<UUID, OSDMap>(); | ||
100 | |||
101 | public void Initialise(IConfigSource source) | ||
102 | { | ||
103 | m_enabled = (source.Configs["MaterialsDemoModule"] != null); | ||
104 | if (!m_enabled) | ||
105 | return; | ||
106 | |||
107 | m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_enabled) | ||
113 | return; | ||
114 | |||
115 | m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); | ||
116 | } | ||
117 | |||
118 | public void AddRegion(Scene scene) | ||
119 | { | ||
120 | if (!m_enabled) | ||
121 | return; | ||
122 | |||
123 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
124 | |||
125 | m_scene = scene; | ||
126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
127 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | ||
128 | // m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; | ||
129 | } | ||
130 | |||
131 | void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | ||
132 | { | ||
133 | foreach (var part in obj.Parts) | ||
134 | if (part != null) | ||
135 | GetStoredMaterialsForPart(part); | ||
136 | } | ||
137 | |||
138 | void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) | ||
139 | { | ||
140 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
141 | |||
142 | IRequestHandler renderMaterialsPostHandler | ||
143 | = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
144 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); | ||
145 | |||
146 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET | ||
147 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST | ||
148 | // handler normally and then add a GET handler via MainServer | ||
149 | |||
150 | IRequestHandler renderMaterialsGetHandler | ||
151 | = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); | ||
152 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); | ||
153 | |||
154 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well | ||
155 | IRequestHandler renderMaterialsPutHandler | ||
156 | = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
157 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); | ||
158 | } | ||
159 | |||
160 | public void RemoveRegion(Scene scene) | ||
161 | { | ||
162 | if (!m_enabled) | ||
163 | return; | ||
164 | |||
165 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
166 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | ||
167 | // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; | ||
168 | |||
169 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
170 | } | ||
171 | |||
172 | public void RegionLoaded(Scene scene) | ||
173 | { | ||
174 | } | ||
175 | |||
176 | OSDMap GetMaterial(UUID id) | ||
177 | { | ||
178 | OSDMap map = null; | ||
179 | lock (m_knownMaterials) | ||
180 | { | ||
181 | if (m_knownMaterials.ContainsKey(id)) | ||
182 | { | ||
183 | map = new OSDMap(); | ||
184 | map["ID"] = OSD.FromBinary(id.GetBytes()); | ||
185 | map["Material"] = m_knownMaterials[id]; | ||
186 | } | ||
187 | } | ||
188 | return map; | ||
189 | } | ||
190 | |||
191 | void GetStoredMaterialsForPart(SceneObjectPart part) | ||
192 | { | ||
193 | OSD OSMaterials = null; | ||
194 | OSDArray matsArr = null; | ||
195 | |||
196 | if (part.DynAttrs == null) | ||
197 | { | ||
198 | m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); | ||
199 | } | ||
200 | |||
201 | lock (part.DynAttrs) | ||
202 | { | ||
203 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
204 | { | ||
205 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
206 | |||
207 | if (materialsStore == null) | ||
208 | return; | ||
209 | |||
210 | materialsStore.TryGetValue("Materials", out OSMaterials); | ||
211 | } | ||
212 | |||
213 | if (OSMaterials != null && OSMaterials is OSDArray) | ||
214 | matsArr = OSMaterials as OSDArray; | ||
215 | else | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); | ||
220 | |||
221 | if (matsArr == null) | ||
222 | { | ||
223 | m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); | ||
224 | return; | ||
225 | } | ||
226 | |||
227 | foreach (OSD elemOsd in matsArr) | ||
228 | { | ||
229 | if (elemOsd != null && elemOsd is OSDMap) | ||
230 | { | ||
231 | OSDMap matMap = elemOsd as OSDMap; | ||
232 | if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) | ||
233 | { | ||
234 | try | ||
235 | { | ||
236 | lock (m_knownMaterials) | ||
237 | m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; | ||
238 | } | ||
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString()); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | void StoreMaterialsForPart(SceneObjectPart part) | ||
249 | { | ||
250 | try | ||
251 | { | ||
252 | if (part == null || part.Shape == null) | ||
253 | return; | ||
254 | |||
255 | Dictionary<UUID, OSDMap> mats = new Dictionary<UUID, OSDMap>(); | ||
256 | |||
257 | Primitive.TextureEntry te = part.Shape.Textures; | ||
258 | |||
259 | if (te.DefaultTexture != null) | ||
260 | { | ||
261 | lock (m_knownMaterials) | ||
262 | { | ||
263 | if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) | ||
264 | mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (te.FaceTextures != null) | ||
269 | { | ||
270 | foreach (var face in te.FaceTextures) | ||
271 | { | ||
272 | if (face != null) | ||
273 | { | ||
274 | lock (m_knownMaterials) | ||
275 | { | ||
276 | if (m_knownMaterials.ContainsKey(face.MaterialID)) | ||
277 | mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | if (mats.Count == 0) | ||
283 | return; | ||
284 | |||
285 | OSDArray matsArr = new OSDArray(); | ||
286 | foreach (KeyValuePair<UUID, OSDMap> kvp in mats) | ||
287 | { | ||
288 | OSDMap matOsd = new OSDMap(); | ||
289 | matOsd["ID"] = OSD.FromUUID(kvp.Key); | ||
290 | matOsd["Material"] = kvp.Value; | ||
291 | matsArr.Add(matOsd); | ||
292 | } | ||
293 | |||
294 | OSDMap OSMaterials = new OSDMap(); | ||
295 | OSMaterials["Materials"] = matsArr; | ||
296 | |||
297 | lock (part.DynAttrs) | ||
298 | part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials); | ||
299 | } | ||
300 | catch (Exception e) | ||
301 | { | ||
302 | m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString()); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | public string RenderMaterialsPostCap(string request, string path, | ||
307 | string param, IOSHttpRequest httpRequest, | ||
308 | IOSHttpResponse httpResponse) | ||
309 | { | ||
310 | m_log.Debug("[MaterialsDemoModule]: POST cap handler"); | ||
311 | |||
312 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
313 | OSDMap resp = new OSDMap(); | ||
314 | |||
315 | OSDMap materialsFromViewer = null; | ||
316 | |||
317 | OSDArray respArr = new OSDArray(); | ||
318 | |||
319 | if (req.ContainsKey("Zipped")) | ||
320 | { | ||
321 | OSD osd = null; | ||
322 | |||
323 | byte[] inBytes = req["Zipped"].AsBinary(); | ||
324 | |||
325 | try | ||
326 | { | ||
327 | osd = ZDecompressBytesToOsd(inBytes); | ||
328 | |||
329 | if (osd != null) | ||
330 | { | ||
331 | if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries | ||
332 | { | ||
333 | foreach (OSD elem in (OSDArray)osd) | ||
334 | { | ||
335 | |||
336 | try | ||
337 | { | ||
338 | UUID id = new UUID(elem.AsBinary(), 0); | ||
339 | |||
340 | lock (m_knownMaterials) | ||
341 | { | ||
342 | if (m_knownMaterials.ContainsKey(id)) | ||
343 | { | ||
344 | m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); | ||
345 | OSDMap matMap = new OSDMap(); | ||
346 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); | ||
347 | |||
348 | matMap["Material"] = m_knownMaterials[id]; | ||
349 | respArr.Add(matMap); | ||
350 | } | ||
351 | else | ||
352 | m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); | ||
353 | } | ||
354 | } | ||
355 | catch (Exception e) | ||
356 | { | ||
357 | // report something here? | ||
358 | continue; | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | else if (osd is OSDMap) // reqest to assign a material | ||
363 | { | ||
364 | materialsFromViewer = osd as OSDMap; | ||
365 | |||
366 | if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) | ||
367 | { | ||
368 | OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; | ||
369 | if (matsOsd is OSDArray) | ||
370 | { | ||
371 | OSDArray matsArr = matsOsd as OSDArray; | ||
372 | |||
373 | try | ||
374 | { | ||
375 | foreach (OSDMap matsMap in matsArr) | ||
376 | { | ||
377 | m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); | ||
378 | |||
379 | uint matLocalID = 0; | ||
380 | try { matLocalID = matsMap["ID"].AsUInteger(); } | ||
381 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } | ||
382 | m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); | ||
383 | |||
384 | |||
385 | OSDMap mat = null; | ||
386 | try { mat = matsMap["Material"] as OSDMap; } | ||
387 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } | ||
388 | m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); | ||
389 | |||
390 | UUID id = HashOsd(mat); | ||
391 | lock (m_knownMaterials) | ||
392 | m_knownMaterials[id] = mat; | ||
393 | |||
394 | |||
395 | var sop = m_scene.GetSceneObjectPart(matLocalID); | ||
396 | if (sop == null) | ||
397 | m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); | ||
398 | else | ||
399 | { | ||
400 | var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); | ||
401 | |||
402 | if (te == null) | ||
403 | { | ||
404 | m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | int face = -1; | ||
409 | |||
410 | if (matsMap.ContainsKey("Face")) | ||
411 | { | ||
412 | face = matsMap["Face"].AsInteger(); | ||
413 | if (te.FaceTextures == null) // && face == 0) | ||
414 | { | ||
415 | if (te.DefaultTexture == null) | ||
416 | m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); | ||
417 | else | ||
418 | te.DefaultTexture.MaterialID = id; | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | if (te.FaceTextures.Length >= face - 1) | ||
423 | { | ||
424 | if (te.FaceTextures[face] == null) | ||
425 | te.DefaultTexture.MaterialID = id; | ||
426 | else | ||
427 | te.FaceTextures[face].MaterialID = id; | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | if (te.DefaultTexture != null) | ||
434 | te.DefaultTexture.MaterialID = id; | ||
435 | } | ||
436 | |||
437 | m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); | ||
438 | |||
439 | //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually | ||
440 | |||
441 | if (sop.ParentGroup != null) | ||
442 | { | ||
443 | sop.Shape.TextureEntry = te.GetBytes(); | ||
444 | sop.TriggerScriptChangedEvent(Changed.TEXTURE); | ||
445 | sop.UpdateFlag = UpdateRequired.FULL; | ||
446 | sop.ParentGroup.HasGroupChanged = true; | ||
447 | |||
448 | sop.ScheduleFullUpdate(); | ||
449 | |||
450 | StoreMaterialsForPart(sop); | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | catch (Exception e) | ||
457 | { | ||
458 | m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); | ||
459 | } | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | |||
465 | } | ||
466 | catch (Exception e) | ||
467 | { | ||
468 | m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message); | ||
469 | //return ""; | ||
470 | } | ||
471 | m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); | ||
472 | } | ||
473 | |||
474 | |||
475 | resp["Zipped"] = ZCompressOSD(respArr, false); | ||
476 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
477 | |||
478 | //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); | ||
479 | m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); | ||
480 | m_log.Debug("[MaterialsDemoModule]: cap response: " + response); | ||
481 | return response; | ||
482 | } | ||
483 | |||
484 | |||
485 | public string RenderMaterialsGetCap(string request, string path, | ||
486 | string param, IOSHttpRequest httpRequest, | ||
487 | IOSHttpResponse httpResponse) | ||
488 | { | ||
489 | m_log.Debug("[MaterialsDemoModule]: GET cap handler"); | ||
490 | |||
491 | OSDMap resp = new OSDMap(); | ||
492 | int matsCount = 0; | ||
493 | OSDArray allOsd = new OSDArray(); | ||
494 | |||
495 | lock (m_knownMaterials) | ||
496 | { | ||
497 | foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials) | ||
498 | { | ||
499 | OSDMap matMap = new OSDMap(); | ||
500 | |||
501 | matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); | ||
502 | matMap["Material"] = kvp.Value; | ||
503 | allOsd.Add(matMap); | ||
504 | matsCount++; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | resp["Zipped"] = ZCompressOSD(allOsd, false); | ||
509 | m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); | ||
510 | |||
511 | return OSDParser.SerializeLLSDXmlString(resp); | ||
512 | } | ||
513 | |||
514 | static string ZippedOsdBytesToString(byte[] bytes) | ||
515 | { | ||
516 | try | ||
517 | { | ||
518 | return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); | ||
519 | } | ||
520 | catch (Exception e) | ||
521 | { | ||
522 | return "ZippedOsdBytesToString caught an exception: " + e.ToString(); | ||
523 | } | ||
524 | } | ||
525 | |||
526 | /// <summary> | ||
527 | /// computes a UUID by hashing a OSD object | ||
528 | /// </summary> | ||
529 | /// <param name="osd"></param> | ||
530 | /// <returns></returns> | ||
531 | private static UUID HashOsd(OSD osd) | ||
532 | { | ||
533 | using (var md5 = MD5.Create()) | ||
534 | using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false))) | ||
535 | return new UUID(md5.ComputeHash(ms), 0); | ||
536 | } | ||
537 | |||
538 | public static OSD ZCompressOSD(OSD inOsd, bool useHeader) | ||
539 | { | ||
540 | OSD osd = null; | ||
541 | |||
542 | using (MemoryStream msSinkCompressed = new MemoryStream()) | ||
543 | { | ||
544 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, | ||
545 | Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) | ||
546 | { | ||
547 | CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut); | ||
548 | zOut.Close(); | ||
549 | } | ||
550 | |||
551 | msSinkCompressed.Seek(0L, SeekOrigin.Begin); | ||
552 | osd = OSD.FromBinary( msSinkCompressed.ToArray()); | ||
553 | } | ||
554 | |||
555 | return osd; | ||
556 | } | ||
557 | |||
558 | |||
559 | public static OSD ZDecompressBytesToOsd(byte[] input) | ||
560 | { | ||
561 | OSD osd = null; | ||
562 | |||
563 | using (MemoryStream msSinkUnCompressed = new MemoryStream()) | ||
564 | { | ||
565 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) | ||
566 | { | ||
567 | CopyStream(new MemoryStream(input), zOut); | ||
568 | zOut.Close(); | ||
569 | } | ||
570 | msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); | ||
571 | osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); | ||
572 | } | ||
573 | |||
574 | return osd; | ||
575 | } | ||
576 | |||
577 | static void CopyStream(System.IO.Stream input, System.IO.Stream output) | ||
578 | { | ||
579 | byte[] buffer = new byte[2048]; | ||
580 | int len; | ||
581 | while ((len = input.Read(buffer, 0, 2048)) > 0) | ||
582 | { | ||
583 | output.Write(buffer, 0, len); | ||
584 | } | ||
585 | |||
586 | output.Flush(); | ||
587 | } | ||
588 | |||
589 | // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some | ||
590 | // calls to the gatherer are done for objects with no scene. | ||
591 | // /// <summary> | ||
592 | // /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | ||
593 | // /// </summary> | ||
594 | // /// <param name="part"></param> | ||
595 | // /// <param name="assetUuids"></param> | ||
596 | // private void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | ||
597 | // { | ||
598 | // // scan thru the dynAttrs map of this part for any textures used as materials | ||
599 | // OSD osdMaterials = null; | ||
600 | // | ||
601 | // lock (part.DynAttrs) | ||
602 | // { | ||
603 | // if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
604 | // { | ||
605 | // OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
606 | // if (materialsStore == null) | ||
607 | // return; | ||
608 | // | ||
609 | // materialsStore.TryGetValue("Materials", out osdMaterials); | ||
610 | // } | ||
611 | // | ||
612 | // if (osdMaterials != null) | ||
613 | // { | ||
614 | // //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); | ||
615 | // | ||
616 | // if (osdMaterials is OSDArray) | ||
617 | // { | ||
618 | // OSDArray matsArr = osdMaterials as OSDArray; | ||
619 | // foreach (OSDMap matMap in matsArr) | ||
620 | // { | ||
621 | // try | ||
622 | // { | ||
623 | // if (matMap.ContainsKey("Material")) | ||
624 | // { | ||
625 | // OSDMap mat = matMap["Material"] as OSDMap; | ||
626 | // if (mat.ContainsKey("NormMap")) | ||
627 | // { | ||
628 | // UUID normalMapId = mat["NormMap"].AsUUID(); | ||
629 | // if (normalMapId != UUID.Zero) | ||
630 | // { | ||
631 | // assetUuids[normalMapId] = AssetType.Texture; | ||
632 | // //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | ||
633 | // } | ||
634 | // } | ||
635 | // if (mat.ContainsKey("SpecMap")) | ||
636 | // { | ||
637 | // UUID specularMapId = mat["SpecMap"].AsUUID(); | ||
638 | // if (specularMapId != UUID.Zero) | ||
639 | // { | ||
640 | // assetUuids[specularMapId] = AssetType.Texture; | ||
641 | // //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | ||
642 | // } | ||
643 | // } | ||
644 | // } | ||
645 | // | ||
646 | // } | ||
647 | // catch (Exception e) | ||
648 | // { | ||
649 | // m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); | ||
650 | // } | ||
651 | // } | ||
652 | // } | ||
653 | // } | ||
654 | // } | ||
655 | // } | ||
656 | } | ||
657 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs new file mode 100644 index 0000000..afb788b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs | |||
@@ -0,0 +1,590 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Security.Cryptography; // for computing md5 hash | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
46 | |||
47 | using Ionic.Zlib; | ||
48 | |||
49 | // You will need to uncomment these lines if you are adding a region module to some other assembly which does not already | ||
50 | // specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans | ||
51 | // the available DLLs | ||
52 | //[assembly: Addin("MaterialsModule", "1.0")] | ||
53 | //[assembly: AddinDependency("OpenSim", "0.5")] | ||
54 | |||
55 | namespace OpenSim.Region.OptionalModules.Materials | ||
56 | { | ||
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsModule")] | ||
58 | public class MaterialsModule : INonSharedRegionModule | ||
59 | { | ||
60 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
61 | |||
62 | public string Name { get { return "MaterialsModule"; } } | ||
63 | |||
64 | public Type ReplaceableInterface { get { return null; } } | ||
65 | |||
66 | private Scene m_scene = null; | ||
67 | private bool m_enabled = false; | ||
68 | |||
69 | public Dictionary<UUID, OSDMap> m_regionMaterials = new Dictionary<UUID, OSDMap>(); | ||
70 | |||
71 | public void Initialise(IConfigSource source) | ||
72 | { | ||
73 | IConfig config = source.Configs["Materials"]; | ||
74 | if (config == null) | ||
75 | return; | ||
76 | |||
77 | m_enabled = config.GetBoolean("enable_materials", true); | ||
78 | if (!m_enabled) | ||
79 | return; | ||
80 | |||
81 | m_log.DebugFormat("[Materials]: Initialized"); | ||
82 | } | ||
83 | |||
84 | public void Close() | ||
85 | { | ||
86 | if (!m_enabled) | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | public void AddRegion(Scene scene) | ||
91 | { | ||
92 | if (!m_enabled) | ||
93 | return; | ||
94 | |||
95 | m_scene = scene; | ||
96 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
97 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | ||
98 | } | ||
99 | |||
100 | private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | ||
101 | { | ||
102 | foreach (var part in obj.Parts) | ||
103 | if (part != null) | ||
104 | GetStoredMaterialsInPart(part); | ||
105 | } | ||
106 | |||
107 | private void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) | ||
108 | { | ||
109 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
110 | |||
111 | IRequestHandler renderMaterialsPostHandler | ||
112 | = new RestStreamHandler("POST", capsBase + "/", | ||
113 | (request, path, param, httpRequest, httpResponse) | ||
114 | => RenderMaterialsPostCap(request, agentID), | ||
115 | "RenderMaterials", null); | ||
116 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); | ||
117 | |||
118 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET | ||
119 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST | ||
120 | // handler normally and then add a GET handler via MainServer | ||
121 | |||
122 | IRequestHandler renderMaterialsGetHandler | ||
123 | = new RestStreamHandler("GET", capsBase + "/", | ||
124 | (request, path, param, httpRequest, httpResponse) | ||
125 | => RenderMaterialsGetCap(request), | ||
126 | "RenderMaterials", null); | ||
127 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); | ||
128 | |||
129 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well | ||
130 | IRequestHandler renderMaterialsPutHandler | ||
131 | = new RestStreamHandler("PUT", capsBase + "/", | ||
132 | (request, path, param, httpRequest, httpResponse) | ||
133 | => RenderMaterialsPostCap(request, agentID), | ||
134 | "RenderMaterials", null); | ||
135 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); | ||
136 | } | ||
137 | |||
138 | public void RemoveRegion(Scene scene) | ||
139 | { | ||
140 | if (!m_enabled) | ||
141 | return; | ||
142 | |||
143 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
144 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | ||
145 | } | ||
146 | |||
147 | public void RegionLoaded(Scene scene) | ||
148 | { | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'. | ||
153 | /// </summary> | ||
154 | /// <param name="part"></param> | ||
155 | private void GetLegacyStoredMaterialsInPart(SceneObjectPart part) | ||
156 | { | ||
157 | if (part.DynAttrs == null) | ||
158 | return; | ||
159 | |||
160 | OSD OSMaterials = null; | ||
161 | OSDArray matsArr = null; | ||
162 | |||
163 | lock (part.DynAttrs) | ||
164 | { | ||
165 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
166 | { | ||
167 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
168 | |||
169 | if (materialsStore == null) | ||
170 | return; | ||
171 | |||
172 | materialsStore.TryGetValue("Materials", out OSMaterials); | ||
173 | } | ||
174 | |||
175 | if (OSMaterials != null && OSMaterials is OSDArray) | ||
176 | matsArr = OSMaterials as OSDArray; | ||
177 | else | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | if (matsArr == null) | ||
182 | return; | ||
183 | |||
184 | foreach (OSD elemOsd in matsArr) | ||
185 | { | ||
186 | if (elemOsd != null && elemOsd is OSDMap) | ||
187 | { | ||
188 | OSDMap matMap = elemOsd as OSDMap; | ||
189 | if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) | ||
190 | { | ||
191 | try | ||
192 | { | ||
193 | lock (m_regionMaterials) | ||
194 | m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; | ||
195 | } | ||
196 | catch (Exception e) | ||
197 | { | ||
198 | m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString()); | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// Find the materials used in the SOP, and add them to 'm_regionMaterials'. | ||
207 | /// </summary> | ||
208 | private void GetStoredMaterialsInPart(SceneObjectPart part) | ||
209 | { | ||
210 | if (part.Shape == null) | ||
211 | return; | ||
212 | |||
213 | var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length); | ||
214 | if (te == null) | ||
215 | return; | ||
216 | |||
217 | GetLegacyStoredMaterialsInPart(part); | ||
218 | |||
219 | GetStoredMaterialInFace(part, te.DefaultTexture); | ||
220 | |||
221 | foreach (Primitive.TextureEntryFace face in te.FaceTextures) | ||
222 | { | ||
223 | if (face != null) | ||
224 | GetStoredMaterialInFace(part, face); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | /// <summary> | ||
229 | /// Find the materials used in one Face, and add them to 'm_regionMaterials'. | ||
230 | /// </summary> | ||
231 | private void GetStoredMaterialInFace(SceneObjectPart part, Primitive.TextureEntryFace face) | ||
232 | { | ||
233 | UUID id = face.MaterialID; | ||
234 | if (id == UUID.Zero) | ||
235 | return; | ||
236 | |||
237 | lock (m_regionMaterials) | ||
238 | { | ||
239 | if (m_regionMaterials.ContainsKey(id)) | ||
240 | return; | ||
241 | |||
242 | byte[] data = m_scene.AssetService.GetData(id.ToString()); | ||
243 | if (data == null) | ||
244 | { | ||
245 | m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); | ||
246 | return; | ||
247 | } | ||
248 | |||
249 | OSDMap mat; | ||
250 | try | ||
251 | { | ||
252 | mat = (OSDMap)OSDParser.DeserializeLLSDXml(data); | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", id, e.Message); | ||
257 | return; | ||
258 | } | ||
259 | |||
260 | m_regionMaterials[id] = mat; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | public string RenderMaterialsPostCap(string request, UUID agentID) | ||
265 | { | ||
266 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
267 | OSDMap resp = new OSDMap(); | ||
268 | |||
269 | OSDMap materialsFromViewer = null; | ||
270 | |||
271 | OSDArray respArr = new OSDArray(); | ||
272 | |||
273 | if (req.ContainsKey("Zipped")) | ||
274 | { | ||
275 | OSD osd = null; | ||
276 | |||
277 | byte[] inBytes = req["Zipped"].AsBinary(); | ||
278 | |||
279 | try | ||
280 | { | ||
281 | osd = ZDecompressBytesToOsd(inBytes); | ||
282 | |||
283 | if (osd != null) | ||
284 | { | ||
285 | if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries | ||
286 | { | ||
287 | foreach (OSD elem in (OSDArray)osd) | ||
288 | { | ||
289 | try | ||
290 | { | ||
291 | UUID id = new UUID(elem.AsBinary(), 0); | ||
292 | |||
293 | lock (m_regionMaterials) | ||
294 | { | ||
295 | if (m_regionMaterials.ContainsKey(id)) | ||
296 | { | ||
297 | OSDMap matMap = new OSDMap(); | ||
298 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); | ||
299 | matMap["Material"] = m_regionMaterials[id]; | ||
300 | respArr.Add(matMap); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString()); | ||
305 | |||
306 | // Theoretically we could try to load the material from the assets service, | ||
307 | // but that shouldn't be necessary because the viewer should only request | ||
308 | // materials that exist in a prim on the region, and all of these materials | ||
309 | // are already stored in m_regionMaterials. | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.Error("Error getting materials in response to viewer request", e); | ||
316 | continue; | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | else if (osd is OSDMap) // request to assign a material | ||
321 | { | ||
322 | materialsFromViewer = osd as OSDMap; | ||
323 | |||
324 | if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) | ||
325 | { | ||
326 | OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; | ||
327 | if (matsOsd is OSDArray) | ||
328 | { | ||
329 | OSDArray matsArr = matsOsd as OSDArray; | ||
330 | |||
331 | try | ||
332 | { | ||
333 | foreach (OSDMap matsMap in matsArr) | ||
334 | { | ||
335 | uint primLocalID = 0; | ||
336 | try { | ||
337 | primLocalID = matsMap["ID"].AsUInteger(); | ||
338 | } | ||
339 | catch (Exception e) { | ||
340 | m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); | ||
341 | continue; | ||
342 | } | ||
343 | |||
344 | OSDMap mat = null; | ||
345 | try | ||
346 | { | ||
347 | mat = matsMap["Material"] as OSDMap; | ||
348 | } | ||
349 | catch (Exception e) | ||
350 | { | ||
351 | m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message); | ||
352 | continue; | ||
353 | } | ||
354 | |||
355 | SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); | ||
356 | if (sop == null) | ||
357 | { | ||
358 | m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); | ||
359 | continue; | ||
360 | } | ||
361 | |||
362 | if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) | ||
363 | { | ||
364 | m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); | ||
365 | continue; | ||
366 | } | ||
367 | |||
368 | Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); | ||
369 | if (te == null) | ||
370 | { | ||
371 | m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); | ||
372 | continue; | ||
373 | } | ||
374 | |||
375 | |||
376 | UUID id; | ||
377 | if (mat == null) | ||
378 | { | ||
379 | // This happens then the user removes a material from a prim | ||
380 | id = UUID.Zero; | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | id = StoreMaterialAsAsset(agentID, mat, sop); | ||
385 | } | ||
386 | |||
387 | |||
388 | int face = -1; | ||
389 | |||
390 | if (matsMap.ContainsKey("Face")) | ||
391 | { | ||
392 | face = matsMap["Face"].AsInteger(); | ||
393 | Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face); | ||
394 | faceEntry.MaterialID = id; | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | if (te.DefaultTexture == null) | ||
399 | m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); | ||
400 | else | ||
401 | te.DefaultTexture.MaterialID = id; | ||
402 | } | ||
403 | |||
404 | //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); | ||
405 | |||
406 | // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually | ||
407 | sop.Shape.TextureEntry = te.GetBytes(); | ||
408 | |||
409 | if (sop.ParentGroup != null) | ||
410 | { | ||
411 | sop.TriggerScriptChangedEvent(Changed.TEXTURE); | ||
412 | sop.UpdateFlag = UpdateRequired.FULL; | ||
413 | sop.ParentGroup.HasGroupChanged = true; | ||
414 | sop.ScheduleFullUpdate(); | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | catch (Exception e) | ||
419 | { | ||
420 | m_log.Warn("[Materials]: exception processing received material ", e); | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | |||
427 | } | ||
428 | catch (Exception e) | ||
429 | { | ||
430 | m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e); | ||
431 | //return ""; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | |||
436 | resp["Zipped"] = ZCompressOSD(respArr, false); | ||
437 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
438 | |||
439 | //m_log.Debug("[Materials]: cap request: " + request); | ||
440 | //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); | ||
441 | //m_log.Debug("[Materials]: cap response: " + response); | ||
442 | return response; | ||
443 | } | ||
444 | |||
445 | private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop) | ||
446 | { | ||
447 | UUID id; | ||
448 | // Material UUID = hash of the material's data. | ||
449 | // This makes materials deduplicate across the entire grid (but isn't otherwise required). | ||
450 | byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat)); | ||
451 | using (var md5 = MD5.Create()) | ||
452 | id = new UUID(md5.ComputeHash(data), 0); | ||
453 | |||
454 | lock (m_regionMaterials) | ||
455 | { | ||
456 | if (!m_regionMaterials.ContainsKey(id)) | ||
457 | { | ||
458 | m_regionMaterials[id] = mat; | ||
459 | |||
460 | // This asset might exist already, but it's ok to try to store it again | ||
461 | string name = "Material " + ChooseMaterialName(mat, sop); | ||
462 | name = name.Substring(0, Math.Min(64, name.Length)).Trim(); | ||
463 | AssetBase asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString()); | ||
464 | asset.Data = data; | ||
465 | m_scene.AssetService.Store(asset); | ||
466 | } | ||
467 | } | ||
468 | return id; | ||
469 | } | ||
470 | |||
471 | /// <summary> | ||
472 | /// Use heuristics to choose a good name for the material. | ||
473 | /// </summary> | ||
474 | private string ChooseMaterialName(OSDMap mat, SceneObjectPart sop) | ||
475 | { | ||
476 | UUID normMap = mat["NormMap"].AsUUID(); | ||
477 | if (normMap != UUID.Zero) | ||
478 | { | ||
479 | AssetBase asset = m_scene.AssetService.GetCached(normMap.ToString()); | ||
480 | if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) | ||
481 | return asset.Name; | ||
482 | } | ||
483 | |||
484 | UUID specMap = mat["SpecMap"].AsUUID(); | ||
485 | if (specMap != UUID.Zero) | ||
486 | { | ||
487 | AssetBase asset = m_scene.AssetService.GetCached(specMap.ToString()); | ||
488 | if ((asset != null) && (asset.Name.Length > 0) && !asset.Name.Equals("From IAR")) | ||
489 | return asset.Name; | ||
490 | } | ||
491 | |||
492 | if (sop.Name != "Primitive") | ||
493 | return sop.Name; | ||
494 | |||
495 | if ((sop.ParentGroup != null) && (sop.ParentGroup.Name != "Primitive")) | ||
496 | return sop.ParentGroup.Name; | ||
497 | |||
498 | return ""; | ||
499 | } | ||
500 | |||
501 | |||
502 | public string RenderMaterialsGetCap(string request) | ||
503 | { | ||
504 | OSDMap resp = new OSDMap(); | ||
505 | int matsCount = 0; | ||
506 | OSDArray allOsd = new OSDArray(); | ||
507 | |||
508 | lock (m_regionMaterials) | ||
509 | { | ||
510 | foreach (KeyValuePair<UUID, OSDMap> kvp in m_regionMaterials) | ||
511 | { | ||
512 | OSDMap matMap = new OSDMap(); | ||
513 | |||
514 | matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); | ||
515 | matMap["Material"] = kvp.Value; | ||
516 | allOsd.Add(matMap); | ||
517 | matsCount++; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | resp["Zipped"] = ZCompressOSD(allOsd, false); | ||
522 | |||
523 | return OSDParser.SerializeLLSDXmlString(resp); | ||
524 | } | ||
525 | |||
526 | private static string ZippedOsdBytesToString(byte[] bytes) | ||
527 | { | ||
528 | try | ||
529 | { | ||
530 | return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes)); | ||
531 | } | ||
532 | catch (Exception e) | ||
533 | { | ||
534 | return "ZippedOsdBytesToString caught an exception: " + e.ToString(); | ||
535 | } | ||
536 | } | ||
537 | |||
538 | /// <summary> | ||
539 | /// computes a UUID by hashing a OSD object | ||
540 | /// </summary> | ||
541 | /// <param name="osd"></param> | ||
542 | /// <returns></returns> | ||
543 | private static UUID HashOsd(OSD osd) | ||
544 | { | ||
545 | byte[] data = OSDParser.SerializeLLSDBinary(osd, false); | ||
546 | using (var md5 = MD5.Create()) | ||
547 | return new UUID(md5.ComputeHash(data), 0); | ||
548 | } | ||
549 | |||
550 | public static OSD ZCompressOSD(OSD inOsd, bool useHeader) | ||
551 | { | ||
552 | OSD osd = null; | ||
553 | |||
554 | byte[] data = OSDParser.SerializeLLSDBinary(inOsd, useHeader); | ||
555 | |||
556 | using (MemoryStream msSinkCompressed = new MemoryStream()) | ||
557 | { | ||
558 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, | ||
559 | Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) | ||
560 | { | ||
561 | zOut.Write(data, 0, data.Length); | ||
562 | } | ||
563 | |||
564 | msSinkCompressed.Seek(0L, SeekOrigin.Begin); | ||
565 | osd = OSD.FromBinary(msSinkCompressed.ToArray()); | ||
566 | } | ||
567 | |||
568 | return osd; | ||
569 | } | ||
570 | |||
571 | |||
572 | public static OSD ZDecompressBytesToOsd(byte[] input) | ||
573 | { | ||
574 | OSD osd = null; | ||
575 | |||
576 | using (MemoryStream msSinkUnCompressed = new MemoryStream()) | ||
577 | { | ||
578 | using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true)) | ||
579 | { | ||
580 | zOut.Write(input, 0, input.Length); | ||
581 | } | ||
582 | |||
583 | msSinkUnCompressed.Seek(0L, SeekOrigin.Begin); | ||
584 | osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray()); | ||
585 | } | ||
586 | |||
587 | return osd; | ||
588 | } | ||
589 | } | ||
590 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs new file mode 100644 index 0000000..d4b19dd --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using Mono.Addins; | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Text; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using System.Collections.Generic; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreCommandsModule")] | ||
48 | |||
49 | public class JsonStoreCommandsModule : INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = | ||
52 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private IConfig m_config = null; | ||
55 | private bool m_enabled = false; | ||
56 | |||
57 | private Scene m_scene = null; | ||
58 | //private IJsonStoreModule m_store; | ||
59 | private JsonStoreModule m_store; | ||
60 | |||
61 | #region Region Module interface | ||
62 | |||
63 | // ----------------------------------------------------------------- | ||
64 | /// <summary> | ||
65 | /// Name of this shared module is it's class name | ||
66 | /// </summary> | ||
67 | // ----------------------------------------------------------------- | ||
68 | public string Name | ||
69 | { | ||
70 | get { return this.GetType().Name; } | ||
71 | } | ||
72 | |||
73 | // ----------------------------------------------------------------- | ||
74 | /// <summary> | ||
75 | /// Initialise this shared module | ||
76 | /// </summary> | ||
77 | /// <param name="scene">this region is getting initialised</param> | ||
78 | /// <param name="source">nini config, we are not using this</param> | ||
79 | // ----------------------------------------------------------------- | ||
80 | public void Initialise(IConfigSource config) | ||
81 | { | ||
82 | try | ||
83 | { | ||
84 | if ((m_config = config.Configs["JsonStore"]) == null) | ||
85 | { | ||
86 | // There is no configuration, the module is disabled | ||
87 | // m_log.InfoFormat("[JsonStore] no configuration info"); | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
92 | } | ||
93 | catch (Exception e) | ||
94 | { | ||
95 | m_log.Error("[JsonStore]: initialization error: {0}", e); | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | if (m_enabled) | ||
100 | m_log.DebugFormat("[JsonStore]: module is enabled"); | ||
101 | } | ||
102 | |||
103 | // ----------------------------------------------------------------- | ||
104 | /// <summary> | ||
105 | /// everything is loaded, perform post load configuration | ||
106 | /// </summary> | ||
107 | // ----------------------------------------------------------------- | ||
108 | public void PostInitialise() | ||
109 | { | ||
110 | } | ||
111 | |||
112 | // ----------------------------------------------------------------- | ||
113 | /// <summary> | ||
114 | /// Nothing to do on close | ||
115 | /// </summary> | ||
116 | // ----------------------------------------------------------------- | ||
117 | public void Close() | ||
118 | { | ||
119 | } | ||
120 | |||
121 | // ----------------------------------------------------------------- | ||
122 | /// <summary> | ||
123 | /// </summary> | ||
124 | // ----------------------------------------------------------------- | ||
125 | public void AddRegion(Scene scene) | ||
126 | { | ||
127 | if (m_enabled) | ||
128 | { | ||
129 | m_scene = scene; | ||
130 | |||
131 | } | ||
132 | } | ||
133 | |||
134 | // ----------------------------------------------------------------- | ||
135 | /// <summary> | ||
136 | /// </summary> | ||
137 | // ----------------------------------------------------------------- | ||
138 | public void RemoveRegion(Scene scene) | ||
139 | { | ||
140 | // need to remove all references to the scene in the subscription | ||
141 | // list to enable full garbage collection of the scene object | ||
142 | } | ||
143 | |||
144 | // ----------------------------------------------------------------- | ||
145 | /// <summary> | ||
146 | /// Called when all modules have been added for a region. This is | ||
147 | /// where we hook up events | ||
148 | /// </summary> | ||
149 | // ----------------------------------------------------------------- | ||
150 | public void RegionLoaded(Scene scene) | ||
151 | { | ||
152 | if (m_enabled) | ||
153 | { | ||
154 | m_scene = scene; | ||
155 | |||
156 | m_store = (JsonStoreModule) m_scene.RequestModuleInterface<IJsonStoreModule>(); | ||
157 | if (m_store == null) | ||
158 | { | ||
159 | m_log.ErrorFormat("[JsonStoreCommands]: JsonModule interface not defined"); | ||
160 | m_enabled = false; | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | scene.AddCommand("JsonStore", this, "jsonstore stats", "jsonstore stats", | ||
165 | "Display statistics about the state of the JsonStore module", "", | ||
166 | CmdStats); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | /// ----------------------------------------------------------------- | ||
171 | /// <summary> | ||
172 | /// </summary> | ||
173 | // ----------------------------------------------------------------- | ||
174 | public Type ReplaceableInterface | ||
175 | { | ||
176 | get { return null; } | ||
177 | } | ||
178 | |||
179 | #endregion | ||
180 | |||
181 | #region Commands | ||
182 | |||
183 | private void CmdStats(string module, string[] cmd) | ||
184 | { | ||
185 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
186 | return; | ||
187 | |||
188 | JsonStoreStats stats = m_store.GetStoreStats(); | ||
189 | MainConsole.Instance.OutputFormat("{0}\t{1}",m_scene.RegionInfo.RegionName,stats.StoreCount); | ||
190 | } | ||
191 | |||
192 | #endregion | ||
193 | |||
194 | } | ||
195 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 5fbfcc5..b502a55 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -42,7 +42,6 @@ using OpenSim.Region.Framework.Scenes; | |||
42 | using System.Collections.Generic; | 42 | using System.Collections.Generic; |
43 | using System.Text.RegularExpressions; | 43 | using System.Text.RegularExpressions; |
44 | 44 | ||
45 | |||
46 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | 45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore |
47 | { | 46 | { |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] | 47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] |
@@ -60,6 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
60 | private Scene m_scene = null; | 59 | private Scene m_scene = null; |
61 | 60 | ||
62 | private Dictionary<UUID,JsonStore> m_JsonValueStore; | 61 | private Dictionary<UUID,JsonStore> m_JsonValueStore; |
62 | |||
63 | private UUID m_sharedStore; | 63 | private UUID m_sharedStore; |
64 | 64 | ||
65 | #region Region Module interface | 65 | #region Region Module interface |
@@ -140,6 +140,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
140 | m_sharedStore = UUID.Zero; | 140 | m_sharedStore = UUID.Zero; |
141 | m_JsonValueStore = new Dictionary<UUID,JsonStore>(); | 141 | m_JsonValueStore = new Dictionary<UUID,JsonStore>(); |
142 | m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); | 142 | m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); |
143 | |||
144 | scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; | ||
143 | } | 145 | } |
144 | } | 146 | } |
145 | 147 | ||
@@ -149,6 +151,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
149 | // ----------------------------------------------------------------- | 151 | // ----------------------------------------------------------------- |
150 | public void RemoveRegion(Scene scene) | 152 | public void RemoveRegion(Scene scene) |
151 | { | 153 | { |
154 | scene.EventManager.OnObjectBeingRemovedFromScene -= EventManagerOnObjectBeingRemovedFromScene; | ||
155 | |||
152 | // need to remove all references to the scene in the subscription | 156 | // need to remove all references to the scene in the subscription |
153 | // list to enable full garbage collection of the scene object | 157 | // list to enable full garbage collection of the scene object |
154 | } | 158 | } |
@@ -161,7 +165,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
161 | // ----------------------------------------------------------------- | 165 | // ----------------------------------------------------------------- |
162 | public void RegionLoaded(Scene scene) | 166 | public void RegionLoaded(Scene scene) |
163 | { | 167 | { |
164 | if (m_enabled) {} | 168 | if (m_enabled) |
169 | { | ||
170 | } | ||
165 | } | 171 | } |
166 | 172 | ||
167 | /// ----------------------------------------------------------------- | 173 | /// ----------------------------------------------------------------- |
@@ -175,8 +181,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
175 | 181 | ||
176 | #endregion | 182 | #endregion |
177 | 183 | ||
184 | #region SceneEvents | ||
185 | // ----------------------------------------------------------------- | ||
186 | /// <summary> | ||
187 | /// | ||
188 | /// </summary> | ||
189 | // ----------------------------------------------------------------- | ||
190 | public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj) | ||
191 | { | ||
192 | obj.ForEachPart(delegate(SceneObjectPart sop) { DestroyStore(sop.UUID); } ); | ||
193 | } | ||
194 | |||
195 | #endregion | ||
196 | |||
178 | #region ScriptInvocationInteface | 197 | #region ScriptInvocationInteface |
179 | 198 | ||
199 | |||
200 | // ----------------------------------------------------------------- | ||
201 | /// <summary> | ||
202 | /// | ||
203 | /// </summary> | ||
204 | // ----------------------------------------------------------------- | ||
205 | public JsonStoreStats GetStoreStats() | ||
206 | { | ||
207 | JsonStoreStats stats; | ||
208 | |||
209 | lock (m_JsonValueStore) | ||
210 | { | ||
211 | stats.StoreCount = m_JsonValueStore.Count; | ||
212 | } | ||
213 | |||
214 | return stats; | ||
215 | } | ||
216 | |||
180 | // ----------------------------------------------------------------- | 217 | // ----------------------------------------------------------------- |
181 | /// <summary> | 218 | /// <summary> |
182 | /// | 219 | /// |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 1bb5aee..9fbfb66 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -59,7 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
59 | 59 | ||
60 | private IScriptModuleComms m_comms; | 60 | private IScriptModuleComms m_comms; |
61 | private IJsonStoreModule m_store; | 61 | private IJsonStoreModule m_store; |
62 | 62 | ||
63 | private Dictionary<UUID,HashSet<UUID>> m_scriptStores = new Dictionary<UUID,HashSet<UUID>>(); | ||
64 | |||
63 | #region Region Module interface | 65 | #region Region Module interface |
64 | 66 | ||
65 | // ----------------------------------------------------------------- | 67 | // ----------------------------------------------------------------- |
@@ -126,6 +128,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
126 | // ----------------------------------------------------------------- | 128 | // ----------------------------------------------------------------- |
127 | public void AddRegion(Scene scene) | 129 | public void AddRegion(Scene scene) |
128 | { | 130 | { |
131 | scene.EventManager.OnScriptReset += HandleScriptReset; | ||
132 | scene.EventManager.OnRemoveScript += HandleScriptReset; | ||
129 | } | 133 | } |
130 | 134 | ||
131 | // ----------------------------------------------------------------- | 135 | // ----------------------------------------------------------------- |
@@ -134,12 +138,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
134 | // ----------------------------------------------------------------- | 138 | // ----------------------------------------------------------------- |
135 | public void RemoveRegion(Scene scene) | 139 | public void RemoveRegion(Scene scene) |
136 | { | 140 | { |
141 | scene.EventManager.OnScriptReset -= HandleScriptReset; | ||
142 | scene.EventManager.OnRemoveScript -= HandleScriptReset; | ||
143 | |||
137 | // need to remove all references to the scene in the subscription | 144 | // need to remove all references to the scene in the subscription |
138 | // list to enable full garbage collection of the scene object | 145 | // list to enable full garbage collection of the scene object |
139 | } | 146 | } |
140 | 147 | ||
141 | // ----------------------------------------------------------------- | 148 | // ----------------------------------------------------------------- |
142 | /// <summary> | 149 | /// <summary> |
150 | /// </summary> | ||
151 | // ----------------------------------------------------------------- | ||
152 | private void HandleScriptReset(uint localID, UUID itemID) | ||
153 | { | ||
154 | HashSet<UUID> stores; | ||
155 | |||
156 | lock (m_scriptStores) | ||
157 | { | ||
158 | if (! m_scriptStores.TryGetValue(itemID, out stores)) | ||
159 | return; | ||
160 | m_scriptStores.Remove(itemID); | ||
161 | } | ||
162 | |||
163 | foreach (UUID id in stores) | ||
164 | m_store.DestroyStore(id); | ||
165 | } | ||
166 | |||
167 | // ----------------------------------------------------------------- | ||
168 | /// <summary> | ||
143 | /// Called when all modules have been added for a region. This is | 169 | /// Called when all modules have been added for a region. This is |
144 | /// where we hook up events | 170 | /// where we hook up events |
145 | /// </summary> | 171 | /// </summary> |
@@ -250,6 +276,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
250 | if (! m_store.CreateStore(value, ref uuid)) | 276 | if (! m_store.CreateStore(value, ref uuid)) |
251 | GenerateRuntimeError("Failed to create Json store"); | 277 | GenerateRuntimeError("Failed to create Json store"); |
252 | 278 | ||
279 | lock (m_scriptStores) | ||
280 | { | ||
281 | if (! m_scriptStores.ContainsKey(scriptID)) | ||
282 | m_scriptStores[scriptID] = new HashSet<UUID>(); | ||
283 | |||
284 | m_scriptStores[scriptID].Add(uuid); | ||
285 | } | ||
253 | return uuid; | 286 | return uuid; |
254 | } | 287 | } |
255 | 288 | ||
@@ -261,6 +294,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
261 | [ScriptInvocation] | 294 | [ScriptInvocation] |
262 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) | 295 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) |
263 | { | 296 | { |
297 | lock(m_scriptStores) | ||
298 | { | ||
299 | if (m_scriptStores.ContainsKey(scriptID)) | ||
300 | m_scriptStores[scriptID].Remove(storeID); | ||
301 | } | ||
302 | |||
264 | return m_store.DestroyStore(storeID) ? 1 : 0; | 303 | return m_store.DestroyStore(storeID) ? 1 : 0; |
265 | } | 304 | } |
266 | 305 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 1d6cb6d..b13a5ae 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -434,6 +434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
434 | } | 434 | } |
435 | return wl; | 435 | return wl; |
436 | } | 436 | } |
437 | |||
437 | /// <summary> | 438 | /// <summary> |
438 | /// Set the current Windlight scene | 439 | /// Set the current Windlight scene |
439 | /// </summary> | 440 | /// </summary> |
@@ -446,13 +447,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
446 | LSShoutError("LightShare functions are not enabled."); | 447 | LSShoutError("LightShare functions are not enabled."); |
447 | return 0; | 448 | return 0; |
448 | } | 449 | } |
449 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 450 | |
451 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) | ||
450 | { | 452 | { |
451 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 453 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
452 | return 0; | 454 | |
455 | if (sp == null || sp.GodLevel < 200) | ||
456 | { | ||
457 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | ||
458 | return 0; | ||
459 | } | ||
453 | } | 460 | } |
461 | |||
454 | int success = 0; | 462 | int success = 0; |
455 | m_host.AddScriptLPS(1); | 463 | m_host.AddScriptLPS(1); |
464 | |||
456 | if (LightShareModule.EnableWindlight) | 465 | if (LightShareModule.EnableWindlight) |
457 | { | 466 | { |
458 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | 467 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
@@ -465,8 +474,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
465 | LSShoutError("Windlight module is disabled"); | 474 | LSShoutError("Windlight module is disabled"); |
466 | return 0; | 475 | return 0; |
467 | } | 476 | } |
477 | |||
468 | return success; | 478 | return success; |
469 | } | 479 | } |
480 | |||
470 | public void lsClearWindlightScene() | 481 | public void lsClearWindlightScene() |
471 | { | 482 | { |
472 | if (!m_LSFunctionsEnabled) | 483 | if (!m_LSFunctionsEnabled) |
@@ -474,17 +485,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
474 | LSShoutError("LightShare functions are not enabled."); | 485 | LSShoutError("LightShare functions are not enabled."); |
475 | return; | 486 | return; |
476 | } | 487 | } |
477 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 488 | |
489 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) | ||
478 | { | 490 | { |
479 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 491 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
480 | return; | 492 | |
493 | if (sp == null || sp.GodLevel < 200) | ||
494 | { | ||
495 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | ||
496 | return; | ||
497 | } | ||
481 | } | 498 | } |
482 | 499 | ||
483 | m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false; | 500 | m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false; |
484 | if (m_host.ParentGroup.Scene.SimulationDataService != null) | 501 | if (m_host.ParentGroup.Scene.SimulationDataService != null) |
485 | m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID); | 502 | m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID); |
503 | |||
486 | m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile(); | 504 | m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile(); |
487 | } | 505 | } |
506 | |||
488 | /// <summary> | 507 | /// <summary> |
489 | /// Set the current Windlight scene to a target avatar | 508 | /// Set the current Windlight scene to a target avatar |
490 | /// </summary> | 509 | /// </summary> |
@@ -497,13 +516,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
497 | LSShoutError("LightShare functions are not enabled."); | 516 | LSShoutError("LightShare functions are not enabled."); |
498 | return 0; | 517 | return 0; |
499 | } | 518 | } |
500 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 519 | |
520 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) | ||
501 | { | 521 | { |
502 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 522 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
503 | return 0; | 523 | |
524 | if (sp == null || sp.GodLevel < 200) | ||
525 | { | ||
526 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
527 | return 0; | ||
528 | } | ||
504 | } | 529 | } |
530 | |||
505 | int success = 0; | 531 | int success = 0; |
506 | m_host.AddScriptLPS(1); | 532 | m_host.AddScriptLPS(1); |
533 | |||
507 | if (LightShareModule.EnableWindlight) | 534 | if (LightShareModule.EnableWindlight) |
508 | { | 535 | { |
509 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | 536 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
@@ -515,8 +542,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
515 | LSShoutError("Windlight module is disabled"); | 542 | LSShoutError("Windlight module is disabled"); |
516 | return 0; | 543 | return 0; |
517 | } | 544 | } |
545 | |||
518 | return success; | 546 | return success; |
519 | } | 547 | } |
520 | |||
521 | } | 548 | } |
522 | } | 549 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5c57971..c474173 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3005,6 +3005,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3005 | return ret; | 3005 | return ret; |
3006 | } | 3006 | } |
3007 | 3007 | ||
3008 | public LSL_Vector osGetRegionSize() | ||
3009 | { | ||
3010 | CheckThreatLevel(ThreatLevel.None, "osGetRegionSize"); | ||
3011 | m_host.AddScriptLPS(1); | ||
3012 | |||
3013 | bool isMegaregion; | ||
3014 | IRegionCombinerModule rcMod = World.RequestModuleInterface<IRegionCombinerModule>(); | ||
3015 | if (rcMod != null) | ||
3016 | isMegaregion = rcMod.IsRootForMegaregion(World.RegionInfo.RegionID); | ||
3017 | else | ||
3018 | isMegaregion = false; | ||
3019 | |||
3020 | if (isMegaregion) | ||
3021 | { | ||
3022 | Vector2 size = rcMod.GetSizeOfMegaregion(World.RegionInfo.RegionID); | ||
3023 | return new LSL_Vector(size.X, size.Y, Constants.RegionHeight); | ||
3024 | } | ||
3025 | else | ||
3026 | { | ||
3027 | return new LSL_Vector((float)Constants.RegionSize, (float)Constants.RegionSize, Constants.RegionHeight); | ||
3028 | } | ||
3029 | } | ||
3030 | |||
3008 | public int osGetSimulatorMemory() | 3031 | public int osGetSimulatorMemory() |
3009 | { | 3032 | { |
3010 | CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); | 3033 | CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index a652cb8..d80d389 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -336,6 +336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
336 | key osGetMapTexture(); | 336 | key osGetMapTexture(); |
337 | key osGetRegionMapTexture(string regionName); | 337 | key osGetRegionMapTexture(string regionName); |
338 | LSL_List osGetRegionStats(); | 338 | LSL_List osGetRegionStats(); |
339 | vector osGetRegionSize(); | ||
339 | 340 | ||
340 | int osGetSimulatorMemory(); | 341 | int osGetSimulatorMemory(); |
341 | void osKickAvatar(string FirstName,string SurName,string alert); | 342 | void osKickAvatar(string FirstName,string SurName,string alert); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index b63773b..9cf7b35 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -858,6 +858,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
858 | return m_OSSL_Functions.osGetRegionStats(); | 858 | return m_OSSL_Functions.osGetRegionStats(); |
859 | } | 859 | } |
860 | 860 | ||
861 | public vector osGetRegionSize() | ||
862 | { | ||
863 | return m_OSSL_Functions.osGetRegionSize(); | ||
864 | } | ||
865 | |||
861 | /// <summary> | 866 | /// <summary> |
862 | /// Returns the amount of memory in use by the Simulator Daemon. | 867 | /// Returns the amount of memory in use by the Simulator Daemon. |
863 | /// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware) | 868 | /// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware) |
diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs index 2848967..588aaaf 100644 --- a/OpenSim/Services/Interfaces/IOfflineIMService.cs +++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs | |||
@@ -35,7 +35,14 @@ namespace OpenSim.Services.Interfaces | |||
35 | public interface IOfflineIMService | 35 | public interface IOfflineIMService |
36 | { | 36 | { |
37 | List<GridInstantMessage> GetMessages(UUID principalID); | 37 | List<GridInstantMessage> GetMessages(UUID principalID); |
38 | |||
38 | bool StoreMessage(GridInstantMessage im, out string reason); | 39 | bool StoreMessage(GridInstantMessage im, out string reason); |
40 | |||
41 | /// <summary> | ||
42 | /// Delete messages to or from this user (or group). | ||
43 | /// </summary> | ||
44 | /// <param name="userID">A user or group ID</param> | ||
45 | void DeleteMessages(UUID userID); | ||
39 | } | 46 | } |
40 | 47 | ||
41 | public class OfflineIMDataUtils | 48 | public class OfflineIMDataUtils |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index e8520f2..52e0134 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -799,11 +799,6 @@ namespace OpenSim.Tests.Common.Mock | |||
799 | { | 799 | { |
800 | OnRegionHandShakeReply(this); | 800 | OnRegionHandShakeReply(this); |
801 | } | 801 | } |
802 | |||
803 | if (OnCompleteMovementToRegion != null) | ||
804 | { | ||
805 | OnCompleteMovementToRegion(this, true); | ||
806 | } | ||
807 | } | 802 | } |
808 | 803 | ||
809 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) | 804 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) |
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index a684d72..6bf23f8 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -117,8 +117,6 @@ namespace OpenSim.Tests.Common | |||
117 | /// Parse a UUID stem into a full UUID. | 117 | /// Parse a UUID stem into a full UUID. |
118 | /// </summary> | 118 | /// </summary> |
119 | /// <remarks> | 119 | /// <remarks> |
120 | /// Yes, this is completely inconsistent with ParseTail but this is probably a better way to do it, | ||
121 | /// UUIDs are conceptually not hexadecmial numbers. | ||
122 | /// The fragment will come at the start of the UUID. The rest will be 0s | 120 | /// The fragment will come at the start of the UUID. The rest will be 0s |
123 | /// </remarks> | 121 | /// </remarks> |
124 | /// <returns></returns> | 122 | /// <returns></returns> |
@@ -143,5 +141,24 @@ namespace OpenSim.Tests.Common | |||
143 | { | 141 | { |
144 | return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail)); | 142 | return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail)); |
145 | } | 143 | } |
144 | |||
145 | /// <summary> | ||
146 | /// Parse a UUID tail section into a full UUID. | ||
147 | /// </summary> | ||
148 | /// <remarks> | ||
149 | /// The fragment will come at the end of the UUID. The rest will be 0s | ||
150 | /// </remarks> | ||
151 | /// <returns></returns> | ||
152 | /// <param name='frag'> | ||
153 | /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain | ||
154 | /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is | ||
155 | /// given as the 'fragment'. | ||
156 | /// </param> | ||
157 | public static UUID ParseTail(string stem) | ||
158 | { | ||
159 | string rawUuid = stem.PadLeft(32, '0'); | ||
160 | |||
161 | return UUID.Parse(rawUuid); | ||
162 | } | ||
146 | } | 163 | } |
147 | } | 164 | } |
diff --git a/bin/OpenMetaverse.StructuredData.XML b/bin/OpenMetaverse.StructuredData.XML index 789ad5b..3999d99 100644 --- a/bin/OpenMetaverse.StructuredData.XML +++ b/bin/OpenMetaverse.StructuredData.XML | |||
@@ -4,123 +4,6 @@ | |||
4 | <name>OpenMetaverse.StructuredData</name> | 4 | <name>OpenMetaverse.StructuredData</name> |
5 | </assembly> | 5 | </assembly> |
6 | <members> | 6 | <members> |
7 | <member name="T:OpenMetaverse.StructuredData.OSDType"> | ||
8 | <summary> | ||
9 | |||
10 | </summary> | ||
11 | </member> | ||
12 | <member name="F:OpenMetaverse.StructuredData.OSDType.Unknown"> | ||
13 | <summary></summary> | ||
14 | </member> | ||
15 | <member name="F:OpenMetaverse.StructuredData.OSDType.Boolean"> | ||
16 | <summary></summary> | ||
17 | </member> | ||
18 | <member name="F:OpenMetaverse.StructuredData.OSDType.Integer"> | ||
19 | <summary></summary> | ||
20 | </member> | ||
21 | <member name="F:OpenMetaverse.StructuredData.OSDType.Real"> | ||
22 | <summary></summary> | ||
23 | </member> | ||
24 | <member name="F:OpenMetaverse.StructuredData.OSDType.String"> | ||
25 | <summary></summary> | ||
26 | </member> | ||
27 | <member name="F:OpenMetaverse.StructuredData.OSDType.UUID"> | ||
28 | <summary></summary> | ||
29 | </member> | ||
30 | <member name="F:OpenMetaverse.StructuredData.OSDType.Date"> | ||
31 | <summary></summary> | ||
32 | </member> | ||
33 | <member name="F:OpenMetaverse.StructuredData.OSDType.URI"> | ||
34 | <summary></summary> | ||
35 | </member> | ||
36 | <member name="F:OpenMetaverse.StructuredData.OSDType.Binary"> | ||
37 | <summary></summary> | ||
38 | </member> | ||
39 | <member name="F:OpenMetaverse.StructuredData.OSDType.Map"> | ||
40 | <summary></summary> | ||
41 | </member> | ||
42 | <member name="F:OpenMetaverse.StructuredData.OSDType.Array"> | ||
43 | <summary></summary> | ||
44 | </member> | ||
45 | <member name="T:OpenMetaverse.StructuredData.OSDException"> | ||
46 | <summary> | ||
47 | |||
48 | </summary> | ||
49 | </member> | ||
50 | <member name="T:OpenMetaverse.StructuredData.OSD"> | ||
51 | <summary> | ||
52 | |||
53 | </summary> | ||
54 | </member> | ||
55 | <member name="M:OpenMetaverse.StructuredData.OSD.SerializeMembers(System.Object)"> | ||
56 | <summary> | ||
57 | Uses reflection to create an SDMap from all of the SD | ||
58 | serializable types in an object | ||
59 | </summary> | ||
60 | <param name="obj">Class or struct containing serializable types</param> | ||
61 | <returns>An SDMap holding the serialized values from the | ||
62 | container object</returns> | ||
63 | </member> | ||
64 | <member name="M:OpenMetaverse.StructuredData.OSD.DeserializeMembers(System.Object@,OpenMetaverse.StructuredData.OSDMap)"> | ||
65 | <summary> | ||
66 | Uses reflection to deserialize member variables in an object from | ||
67 | an SDMap | ||
68 | </summary> | ||
69 | <param name="obj">Reference to an object to fill with deserialized | ||
70 | values</param> | ||
71 | <param name="serialized">Serialized values to put in the target | ||
72 | object</param> | ||
73 | </member> | ||
74 | <member name="T:OpenMetaverse.StructuredData.OSDBoolean"> | ||
75 | <summary> | ||
76 | |||
77 | </summary> | ||
78 | </member> | ||
79 | <member name="T:OpenMetaverse.StructuredData.OSDInteger"> | ||
80 | <summary> | ||
81 | |||
82 | </summary> | ||
83 | </member> | ||
84 | <member name="T:OpenMetaverse.StructuredData.OSDReal"> | ||
85 | <summary> | ||
86 | |||
87 | </summary> | ||
88 | </member> | ||
89 | <member name="T:OpenMetaverse.StructuredData.OSDString"> | ||
90 | <summary> | ||
91 | |||
92 | </summary> | ||
93 | </member> | ||
94 | <member name="T:OpenMetaverse.StructuredData.OSDUUID"> | ||
95 | <summary> | ||
96 | |||
97 | </summary> | ||
98 | </member> | ||
99 | <member name="T:OpenMetaverse.StructuredData.OSDDate"> | ||
100 | <summary> | ||
101 | |||
102 | </summary> | ||
103 | </member> | ||
104 | <member name="T:OpenMetaverse.StructuredData.OSDUri"> | ||
105 | <summary> | ||
106 | |||
107 | </summary> | ||
108 | </member> | ||
109 | <member name="T:OpenMetaverse.StructuredData.OSDBinary"> | ||
110 | <summary> | ||
111 | |||
112 | </summary> | ||
113 | </member> | ||
114 | <member name="T:OpenMetaverse.StructuredData.OSDMap"> | ||
115 | <summary> | ||
116 | |||
117 | </summary> | ||
118 | </member> | ||
119 | <member name="T:OpenMetaverse.StructuredData.OSDArray"> | ||
120 | <summary> | ||
121 | |||
122 | </summary> | ||
123 | </member> | ||
124 | <member name="T:OpenMetaverse.StructuredData.OSDParser"> | 7 | <member name="T:OpenMetaverse.StructuredData.OSDParser"> |
125 | <summary> | 8 | <summary> |
126 | 9 | ||
@@ -345,5 +228,122 @@ | |||
345 | <param name="c"></param> | 228 | <param name="c"></param> |
346 | <returns></returns> | 229 | <returns></returns> |
347 | </member> | 230 | </member> |
231 | <member name="T:OpenMetaverse.StructuredData.OSDType"> | ||
232 | <summary> | ||
233 | |||
234 | </summary> | ||
235 | </member> | ||
236 | <member name="F:OpenMetaverse.StructuredData.OSDType.Unknown"> | ||
237 | <summary></summary> | ||
238 | </member> | ||
239 | <member name="F:OpenMetaverse.StructuredData.OSDType.Boolean"> | ||
240 | <summary></summary> | ||
241 | </member> | ||
242 | <member name="F:OpenMetaverse.StructuredData.OSDType.Integer"> | ||
243 | <summary></summary> | ||
244 | </member> | ||
245 | <member name="F:OpenMetaverse.StructuredData.OSDType.Real"> | ||
246 | <summary></summary> | ||
247 | </member> | ||
248 | <member name="F:OpenMetaverse.StructuredData.OSDType.String"> | ||
249 | <summary></summary> | ||
250 | </member> | ||
251 | <member name="F:OpenMetaverse.StructuredData.OSDType.UUID"> | ||
252 | <summary></summary> | ||
253 | </member> | ||
254 | <member name="F:OpenMetaverse.StructuredData.OSDType.Date"> | ||
255 | <summary></summary> | ||
256 | </member> | ||
257 | <member name="F:OpenMetaverse.StructuredData.OSDType.URI"> | ||
258 | <summary></summary> | ||
259 | </member> | ||
260 | <member name="F:OpenMetaverse.StructuredData.OSDType.Binary"> | ||
261 | <summary></summary> | ||
262 | </member> | ||
263 | <member name="F:OpenMetaverse.StructuredData.OSDType.Map"> | ||
264 | <summary></summary> | ||
265 | </member> | ||
266 | <member name="F:OpenMetaverse.StructuredData.OSDType.Array"> | ||
267 | <summary></summary> | ||
268 | </member> | ||
269 | <member name="T:OpenMetaverse.StructuredData.OSDException"> | ||
270 | <summary> | ||
271 | |||
272 | </summary> | ||
273 | </member> | ||
274 | <member name="T:OpenMetaverse.StructuredData.OSD"> | ||
275 | <summary> | ||
276 | |||
277 | </summary> | ||
278 | </member> | ||
279 | <member name="M:OpenMetaverse.StructuredData.OSD.SerializeMembers(System.Object)"> | ||
280 | <summary> | ||
281 | Uses reflection to create an SDMap from all of the SD | ||
282 | serializable types in an object | ||
283 | </summary> | ||
284 | <param name="obj">Class or struct containing serializable types</param> | ||
285 | <returns>An SDMap holding the serialized values from the | ||
286 | container object</returns> | ||
287 | </member> | ||
288 | <member name="M:OpenMetaverse.StructuredData.OSD.DeserializeMembers(System.Object@,OpenMetaverse.StructuredData.OSDMap)"> | ||
289 | <summary> | ||
290 | Uses reflection to deserialize member variables in an object from | ||
291 | an SDMap | ||
292 | </summary> | ||
293 | <param name="obj">Reference to an object to fill with deserialized | ||
294 | values</param> | ||
295 | <param name="serialized">Serialized values to put in the target | ||
296 | object</param> | ||
297 | </member> | ||
298 | <member name="T:OpenMetaverse.StructuredData.OSDBoolean"> | ||
299 | <summary> | ||
300 | |||
301 | </summary> | ||
302 | </member> | ||
303 | <member name="T:OpenMetaverse.StructuredData.OSDInteger"> | ||
304 | <summary> | ||
305 | |||
306 | </summary> | ||
307 | </member> | ||
308 | <member name="T:OpenMetaverse.StructuredData.OSDReal"> | ||
309 | <summary> | ||
310 | |||
311 | </summary> | ||
312 | </member> | ||
313 | <member name="T:OpenMetaverse.StructuredData.OSDString"> | ||
314 | <summary> | ||
315 | |||
316 | </summary> | ||
317 | </member> | ||
318 | <member name="T:OpenMetaverse.StructuredData.OSDUUID"> | ||
319 | <summary> | ||
320 | |||
321 | </summary> | ||
322 | </member> | ||
323 | <member name="T:OpenMetaverse.StructuredData.OSDDate"> | ||
324 | <summary> | ||
325 | |||
326 | </summary> | ||
327 | </member> | ||
328 | <member name="T:OpenMetaverse.StructuredData.OSDUri"> | ||
329 | <summary> | ||
330 | |||
331 | </summary> | ||
332 | </member> | ||
333 | <member name="T:OpenMetaverse.StructuredData.OSDBinary"> | ||
334 | <summary> | ||
335 | |||
336 | </summary> | ||
337 | </member> | ||
338 | <member name="T:OpenMetaverse.StructuredData.OSDMap"> | ||
339 | <summary> | ||
340 | |||
341 | </summary> | ||
342 | </member> | ||
343 | <member name="T:OpenMetaverse.StructuredData.OSDArray"> | ||
344 | <summary> | ||
345 | |||
346 | </summary> | ||
347 | </member> | ||
348 | </members> | 348 | </members> |
349 | </doc> | 349 | </doc> |
diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index d980531..ed613e7 100755 --- a/bin/OpenMetaverse.StructuredData.dll +++ b/bin/OpenMetaverse.StructuredData.dll | |||
Binary files differ | |||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 83f6642..6608d05 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -687,6 +687,12 @@ | |||
687 | ; enable_windlight = false | 687 | ; enable_windlight = false |
688 | 688 | ||
689 | 689 | ||
690 | [Materials] | ||
691 | ;# {enable_materials} {} {Enable Materials support?} {true false} true | ||
692 | ;; This enables the use of Materials. | ||
693 | ; enable_materials = true | ||
694 | |||
695 | |||
690 | [DataSnapshot] | 696 | [DataSnapshot] |
691 | ;# {index_sims} {} {Enable data snapshotting (search)?} {true false} false | 697 | ;# {index_sims} {} {Enable data snapshotting (search)?} {true false} false |
692 | ;; The following set of configs pertains to search. | 698 | ;; The following set of configs pertains to search. |
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 97429de..911dc90 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini | |||
@@ -539,6 +539,16 @@ | |||
539 | ; | 539 | ; |
540 | ;TextureSendLimit = 20 | 540 | ;TextureSendLimit = 20 |
541 | 541 | ||
542 | ; CannibalizeTextureRate allows bandwidth to be moved from the | ||
543 | ; UDP texture throttle to the task throttle. Since most viewers | ||
544 | ; use HTTP textures, this provides a means of using what is largely | ||
545 | ; unused bandwidth in the total throttle. The value is the proportion | ||
546 | ; of the texture rate to move to the task queue. It must be between | ||
547 | ; 0.0 (none of the bandwidth is cannibalized) and 0.9 (90% of the | ||
548 | ; bandwidth is grabbed) | ||
549 | ; | ||
550 | ; CannibalizeTextureRate = 0.5 | ||
551 | |||
542 | ; Quash and remove any light properties from attachments not on the | 552 | ; Quash and remove any light properties from attachments not on the |
543 | ; hands. This allows flashlights and lanterns to function, but kills | 553 | ; hands. This allows flashlights and lanterns to function, but kills |
544 | ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps | 554 | ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps |