aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-08-25 17:34:08 +0100
committerMelanie2012-08-25 17:34:08 +0100
commita5c6cb2fc9e5fd0c83bbe2bb821fa5e1a2903374 (patch)
tree1465a797a4c6892c0a46d92b56fcafd6ccb5162d
parentFix and refactor region registration. Reorder checks to short-curcuit expensi... (diff)
parentimplementing PRIM_LINK_TARGET on GetPrimParams ala SetPrimParams (diff)
downloadopensim-SC-a5c6cb2fc9e5fd0c83bbe2bb821fa5e1a2903374.zip
opensim-SC-a5c6cb2fc9e5fd0c83bbe2bb821fa5e1a2903374.tar.gz
opensim-SC-a5c6cb2fc9e5fd0c83bbe2bb821fa5e1a2903374.tar.bz2
opensim-SC-a5c6cb2fc9e5fd0c83bbe2bb821fa5e1a2903374.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs88
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs6
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs64
10 files changed, 143 insertions, 49 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 675c64d..3b59dc4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
93 /// </summary> 93 /// </summary>
94 public void StartScripts() 94 public void StartScripts()
95 { 95 {
96 m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName); 96// m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName);
97 97
98 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); 98 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
99 99
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 2701d6e..6e53951 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -468,7 +468,7 @@ namespace OpenSim.Region.Framework.Scenes
468 if (!InventoryService.AddFolder(folder)) 468 if (!InventoryService.AddFolder(folder))
469 { 469 {
470 m_log.WarnFormat( 470 m_log.WarnFormat(
471 "[AGENT INVENTORY]: Failed to move create folder for user {0} {1}", 471 "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
472 remoteClient.Name, remoteClient.AgentId); 472 remoteClient.Name, remoteClient.AgentId);
473 } 473 }
474 } 474 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ad74189..2b4dea4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3562,7 +3562,7 @@ namespace OpenSim.Region.Framework.Scenes
3562 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3562 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3563 sp.Name, sp.UUID, RegionInfo.RegionName); 3563 sp.Name, sp.UUID, RegionInfo.RegionName);
3564 3564
3565 sp.ControllingClient.Close(); 3565 sp.ControllingClient.Close(true);
3566 sp = null; 3566 sp = null;
3567 } 3567 }
3568 3568
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index b6339fb..209a770 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -300,7 +300,7 @@ namespace OpenSim.Region.Framework.Scenes
300 public bool AddNewSceneObject( 300 public bool AddNewSceneObject(
301 SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel) 301 SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel)
302 { 302 {
303 AddNewSceneObject(sceneObject, true, false); 303 AddNewSceneObject(sceneObject, attachToBackup, false);
304 304
305 if (pos != null) 305 if (pos != null)
306 sceneObject.AbsolutePosition = (Vector3)pos; 306 sceneObject.AbsolutePosition = (Vector3)pos;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 65d526f..5bf69ad 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -891,7 +891,9 @@ namespace OpenSim.Region.Framework.Scenes
891 { 891 {
892 if (wasChild && HasAttachments()) 892 if (wasChild && HasAttachments())
893 { 893 {
894 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); 894 m_log.DebugFormat(
895 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
896
895 // Resume scripts 897 // Resume scripts
896 foreach (SceneObjectGroup sog in m_attachments) 898 foreach (SceneObjectGroup sog in m_attachments)
897 { 899 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2bfb9b3..b001c51 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5828,7 +5828,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5828 5828
5829 List<SceneObjectPart> parts = GetLinkParts(linknumber); 5829 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5830 5830
5831 foreach (var part in parts) 5831 foreach (SceneObjectPart part in parts)
5832 { 5832 {
5833 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 5833 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
5834 } 5834 }
@@ -6190,7 +6190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6190 6190
6191 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6191 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6192 6192
6193 foreach (var part in parts) 6193 foreach (SceneObjectPart part in parts)
6194 { 6194 {
6195 SetParticleSystem(part, rules); 6195 SetParticleSystem(part, rules);
6196 } 6196 }
@@ -7238,10 +7238,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7238 foreach (SceneObjectPart part in parts) 7238 foreach (SceneObjectPart part in parts)
7239 remaining = SetPrimParams(part, rules); 7239 remaining = SetPrimParams(part, rules);
7240 7240
7241 while(remaining != null && remaining.Length > 2) 7241 while (remaining != null && remaining.Length > 2)
7242 { 7242 {
7243 linknumber = remaining.GetLSLIntegerItem(0); 7243 linknumber = remaining.GetLSLIntegerItem(0);
7244 rules = remaining.GetSublist(1,-1); 7244 rules = remaining.GetSublist(1, -1);
7245 parts = GetLinkParts(linknumber); 7245 parts = GetLinkParts(linknumber);
7246 7246
7247 foreach (SceneObjectPart part in parts) 7247 foreach (SceneObjectPart part in parts)
@@ -7910,7 +7910,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7910 public LSL_List llGetPrimitiveParams(LSL_List rules) 7910 public LSL_List llGetPrimitiveParams(LSL_List rules)
7911 { 7911 {
7912 m_host.AddScriptLPS(1); 7912 m_host.AddScriptLPS(1);
7913 return GetLinkPrimitiveParams(m_host, rules); 7913
7914 LSL_List result = new LSL_List();
7915
7916 LSL_List remaining = GetPrimParams(m_host, rules, ref result);
7917
7918 while (remaining != null && remaining.Length > 2)
7919 {
7920 int linknumber = remaining.GetLSLIntegerItem(0);
7921 rules = remaining.GetSublist(1, -1);
7922 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7923
7924 foreach (SceneObjectPart part in parts)
7925 remaining = GetPrimParams(part, rules, ref result);
7926 }
7927
7928 return result;
7914 } 7929 }
7915 7930
7916 public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) 7931 public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -7920,19 +7935,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7920 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7935 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7921 7936
7922 LSL_List res = new LSL_List(); 7937 LSL_List res = new LSL_List();
7938 LSL_List remaining = null;
7939
7940 foreach (SceneObjectPart part in parts)
7941 {
7942 remaining = GetPrimParams(part, rules, ref res);
7943 }
7923 7944
7924 foreach (var part in parts) 7945 while (remaining != null && remaining.Length > 2)
7925 { 7946 {
7926 LSL_List partRes = GetLinkPrimitiveParams(part, rules); 7947 linknumber = remaining.GetLSLIntegerItem(0);
7927 res += partRes; 7948 rules = remaining.GetSublist(1, -1);
7949 parts = GetLinkParts(linknumber);
7950
7951 foreach (SceneObjectPart part in parts)
7952 remaining = GetPrimParams(part, rules, ref res);
7928 } 7953 }
7929 7954
7930 return res; 7955 return res;
7931 } 7956 }
7932 7957
7933 public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) 7958 public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
7934 { 7959 {
7935 LSL_List res = new LSL_List();
7936 int idx=0; 7960 int idx=0;
7937 while (idx < rules.Length) 7961 while (idx < rules.Length)
7938 { 7962 {
@@ -8077,7 +8101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8077 8101
8078 case (int)ScriptBaseClass.PRIM_TEXTURE: 8102 case (int)ScriptBaseClass.PRIM_TEXTURE:
8079 if (remain < 1) 8103 if (remain < 1)
8080 return res; 8104 return null;
8081 8105
8082 int face = (int)rules.GetLSLIntegerItem(idx++); 8106 int face = (int)rules.GetLSLIntegerItem(idx++);
8083 Primitive.TextureEntry tex = part.Shape.Textures; 8107 Primitive.TextureEntry tex = part.Shape.Textures;
@@ -8117,7 +8141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8117 8141
8118 case (int)ScriptBaseClass.PRIM_COLOR: 8142 case (int)ScriptBaseClass.PRIM_COLOR:
8119 if (remain < 1) 8143 if (remain < 1)
8120 return res; 8144 return null;
8121 8145
8122 face=(int)rules.GetLSLIntegerItem(idx++); 8146 face=(int)rules.GetLSLIntegerItem(idx++);
8123 8147
@@ -8146,7 +8170,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8146 8170
8147 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8171 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
8148 if (remain < 1) 8172 if (remain < 1)
8149 return res; 8173 return null;
8150 8174
8151 face=(int)rules.GetLSLIntegerItem(idx++); 8175 face=(int)rules.GetLSLIntegerItem(idx++);
8152 8176
@@ -8177,7 +8201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8177 8201
8178 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8202 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
8179 if (remain < 1) 8203 if (remain < 1)
8180 return res; 8204 return null;
8181 8205
8182 face=(int)rules.GetLSLIntegerItem(idx++); 8206 face=(int)rules.GetLSLIntegerItem(idx++);
8183 8207
@@ -8219,7 +8243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8219 8243
8220 case (int)ScriptBaseClass.PRIM_TEXGEN: 8244 case (int)ScriptBaseClass.PRIM_TEXGEN:
8221 if (remain < 1) 8245 if (remain < 1)
8222 return res; 8246 return null;
8223 8247
8224 face=(int)rules.GetLSLIntegerItem(idx++); 8248 face=(int)rules.GetLSLIntegerItem(idx++);
8225 8249
@@ -8260,7 +8284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8260 8284
8261 case (int)ScriptBaseClass.PRIM_GLOW: 8285 case (int)ScriptBaseClass.PRIM_GLOW:
8262 if (remain < 1) 8286 if (remain < 1)
8263 return res; 8287 return null;
8264 8288
8265 face=(int)rules.GetLSLIntegerItem(idx++); 8289 face=(int)rules.GetLSLIntegerItem(idx++);
8266 8290
@@ -8312,9 +8336,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8312 0 8336 0
8313 )); 8337 ));
8314 break; 8338 break;
8339 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8340 if(remain < 3)
8341 return null;
8342
8343 return rules.GetSublist(idx, -1);
8315 } 8344 }
8316 } 8345 }
8317 return res; 8346
8347 return null;
8318 } 8348 }
8319 8349
8320 public LSL_List llGetPrimMediaParams(int face, LSL_List rules) 8350 public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
@@ -10752,16 +10782,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10752 } 10782 }
10753 } 10783 }
10754 10784
10755 public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) 10785 public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
10756 { 10786 {
10757 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); 10787 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
10758 if (obj == null)
10759 return new LSL_List();
10760 10788
10761 if (obj.OwnerID != m_host.OwnerID) 10789 LSL_List result = new LSL_List();
10762 return new LSL_List(); 10790
10791 if (obj != null && obj.OwnerID != m_host.OwnerID)
10792 {
10793 LSL_List remaining = GetPrimParams(obj, rules, ref result);
10794
10795 while (remaining != null && remaining.Length > 2)
10796 {
10797 int linknumber = remaining.GetLSLIntegerItem(0);
10798 rules = remaining.GetSublist(1, -1);
10799 List<SceneObjectPart> parts = GetLinkParts(linknumber);
10763 10800
10764 return GetLinkPrimitiveParams(obj, rules); 10801 foreach (SceneObjectPart part in parts)
10802 remaining = GetPrimParams(part, rules, ref result);
10803 }
10804 }
10805
10806 return result;
10765 } 10807 }
10766 10808
10767 public void print(string str) 10809 public void print(string str)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 5e7c2d9..1afa4fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2246,11 +2246,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2246 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); 2246 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
2247 m_host.AddScriptLPS(1); 2247 m_host.AddScriptLPS(1);
2248 InitLSL(); 2248 InitLSL();
2249 // One needs to cast m_LSL_Api because we're using functions not
2250 // on the ILSL_Api interface.
2251 LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
2249 LSL_List retVal = new LSL_List(); 2252 LSL_List retVal = new LSL_List();
2250 List<SceneObjectPart> parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber); 2253 LSL_List remaining = null;
2254 List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber);
2251 foreach (SceneObjectPart part in parts) 2255 foreach (SceneObjectPart part in parts)
2252 { 2256 {
2253 retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams(part, rules); 2257 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2258 }
2259
2260 while (remaining != null && remaining.Length > 2)
2261 {
2262 linknumber = remaining.GetLSLIntegerItem(0);
2263 rules = remaining.GetSublist(1, -1);
2264 parts = LSL_Api.GetLinkParts(linknumber);
2265
2266 foreach (SceneObjectPart part in parts)
2267 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2254 } 2268 }
2255 return retVal; 2269 return retVal;
2256 } 2270 }
@@ -2965,7 +2979,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2965 m_host.AddScriptLPS(1); 2979 m_host.AddScriptLPS(1);
2966 InitLSL(); 2980 InitLSL();
2967 2981
2968 return m_LSL_Api.GetLinkPrimitiveParamsEx(prim, rules); 2982 return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
2969 } 2983 }
2970 2984
2971 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) 2985 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 3fb463b..cd58614 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -425,6 +425,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
425 void print(string str); 425 void print(string str);
426 426
427 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 427 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
428 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 428 LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
429 } 429 }
430} 430}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 5a3f002..0460f22 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -923,6 +923,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
923 // This delay exists to stop mono problems where script compilation and startup would stop the sim 923 // This delay exists to stop mono problems where script compilation and startup would stop the sim
924 // working properly for the session. 924 // working properly for the session.
925 System.Threading.Thread.Sleep(m_StartDelay); 925 System.Threading.Thread.Sleep(m_StartDelay);
926
927 m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name);
926 } 928 }
927 929
928 object[] o; 930 object[] o;
@@ -938,13 +940,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
938 if (m_InitialStartup) 940 if (m_InitialStartup)
939 if (scriptsStarted % 50 == 0) 941 if (scriptsStarted % 50 == 0)
940 m_log.InfoFormat( 942 m_log.InfoFormat(
941 "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); 943 "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name);
942 } 944 }
943 } 945 }
944 946
945 if (m_InitialStartup) 947 if (m_InitialStartup)
946 m_log.InfoFormat( 948 m_log.InfoFormat(
947 "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); 949 "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name);
948 950
949 // NOTE: Despite having a lockless queue, this lock is required 951 // NOTE: Despite having a lockless queue, this lock is required
950 // to make sure there is never no compile thread while there 952 // to make sure there is never no compile thread while there
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 7518b86..deacd5a 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -229,10 +229,28 @@ namespace OpenSim.Services.InventoryService
229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
230 { 230 {
231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); 231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232
233 InventoryFolderBase rootFolder = GetRootFolder(principalID);
234
235 if (rootFolder == null)
236 {
237 m_log.WarnFormat(
238 "[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
239 principalID, type);
240
241 return null;
242 }
243
244 return GetSystemFolderForType(rootFolder, type);
245 }
246
247 private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type)
248 {
249// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232 250
233 XInventoryFolder[] folders = m_Database.GetFolders( 251 XInventoryFolder[] folders = m_Database.GetFolders(
234 new string[] { "agentID", "type"}, 252 new string[] { "agentID", "parentFolderID", "type"},
235 new string[] { principalID.ToString(), ((int)type).ToString() }); 253 new string[] { rootFolder.Owner.ToString(), rootFolder.ID.ToString(), ((int)type).ToString() });
236 254
237 if (folders.Length == 0) 255 if (folders.Length == 0)
238 { 256 {
@@ -308,22 +326,38 @@ namespace OpenSim.Services.InventoryService
308 if (check != null) 326 if (check != null)
309 return false; 327 return false;
310 328
311 if (folder.Type == (short)AssetType.Folder 329 if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
312 || folder.Type == (short)AssetType.Unknown
313 || folder.Type == (short)AssetType.OutfitFolder
314 || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
315 {
316 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
317 return m_Database.StoreFolder(xFolder);
318 }
319 else
320 { 330 {
321 m_log.WarnFormat( 331 InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
322 "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}", 332
323 folder.Type, folder.Name, folder.ParentID, folder.Owner); 333 if (rootFolder == null)
334 {
335 m_log.WarnFormat(
336 "[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
337 folder.Owner, folder.Type);
338
339 return false;
340 }
341
342 // Check we're not trying to add this as a system folder.
343 if (folder.ParentID == rootFolder.ID)
344 {
345 InventoryFolderBase existingSystemFolder
346 = GetSystemFolderForType(rootFolder, (AssetType)folder.Type);
347
348 if (existingSystemFolder != null)
349 {
350 m_log.WarnFormat(
351 "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
352 folder.Type, folder.Name, folder.ParentID, folder.Owner);
353
354 return false;
355 }
356 }
324 } 357 }
325 358
326 return false; 359 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
360 return m_Database.StoreFolder(xFolder);
327 } 361 }
328 362
329 public virtual bool UpdateFolder(InventoryFolderBase folder) 363 public virtual bool UpdateFolder(InventoryFolderBase folder)