Просмотр исходного кода

Following on from 50ea2e0, only fetch scene presence for check if lightscript function has failed initial IsEstateManagerOrOwner() check

Justin Clark-Casey (justincc) 10 лет назад
Родитель
Сommit
e9454d4672
1 измененных файлов с 38 добавлено и 17 удалено
  1. 38 17
      OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs

+ 38 - 17
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs

@@ -434,6 +434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             }
             return wl;
         }
+
         /// <summary>
         /// Set the current Windlight scene
         /// </summary>
@@ -447,14 +448,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 return 0;
             }
 
-            ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
-            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && (sp == null || sp.GodLevel < 200))
+            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
             {
-                LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
-                return 0;
+                ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
+
+                if (sp == null || sp.GodLevel < 200)
+                {
+                    LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
+                    return 0;
+                }
             }
+
             int success = 0;
             m_host.AddScriptLPS(1);
+
             if (LightShareModule.EnableWindlight)
             {
                 RegionLightShareData wl = getWindlightProfileFromRules(rules);
@@ -467,8 +474,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 LSShoutError("Windlight module is disabled");
                 return 0;
             }
+
             return success;
         }
+
         public void lsClearWindlightScene()
         {
             if (!m_LSFunctionsEnabled)
@@ -476,19 +485,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 LSShoutError("LightShare functions are not enabled.");
                 return;
             }
-            
-            ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
-            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && (sp == null || sp.GodLevel < 200))
+
+            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
             {
-                LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
-                return;
+                ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
+
+                if (sp == null || sp.GodLevel < 200)
+                {
+                    LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
+                    return;
+                }
             }
 
             m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false;
             if (m_host.ParentGroup.Scene.SimulationDataService != null)
                 m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID);
+
             m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile();
         }
+
         /// <summary>
         /// Set the current Windlight scene to a target avatar
         /// </summary>
@@ -501,15 +516,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 LSShoutError("LightShare functions are not enabled.");
                 return 0;
             }
-            
-            ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
-            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && (sp == null || sp.GodLevel < 200))
+
+            if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
             {
-                LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
-                return 0;
+                ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
+
+                if (sp == null || sp.GodLevel < 200)
+                {
+                    LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
+                    return 0;
+                }
             }
+
             int success = 0;
             m_host.AddScriptLPS(1);
+
             if (LightShareModule.EnableWindlight)
             { 
                 RegionLightShareData wl = getWindlightProfileFromRules(rules);
@@ -521,8 +542,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 LSShoutError("Windlight module is disabled");
                 return 0;
             }
+
             return success;
-        }
-        
+        }        
     }
-}
+}