Skip to content
4 changes: 2 additions & 2 deletions OpenSim/Region/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public static void Main(string[] args)
}
else
{
XmlConfigurator.Configure(new System.IO.FileInfo("OpenSim.exe.config"));
m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config");
XmlConfigurator.Configure(new System.IO.FileInfo("OpenSim.dll.config"));
m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.dll.config");
}

// temporay set the platform dependent System.Drawing.Common.dll
Expand Down
163 changes: 161 additions & 2 deletions OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
Expand Down Expand Up @@ -4618,6 +4619,156 @@ public void llGiveInventory(LSL_Key destination, LSL_String inventory)
ScriptSleep(m_sleepMsOnGiveInventory);
}

public LSL_Integer llReturnObjectsByID(LSL_List objects)
{
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_RETURN_OBJECTS) == 0)
{
llShout(ScriptBaseClass.DEBUG_CHANNEL, "Permission not granted: PERMISSION_RETURN_OBJECTS");
return ScriptBaseClass.ERR_RUNTIME_PERMISSIONS;
}

// SL Throttle : Max parcel land impact capacity region wide per hour
// TODO: Make a config option to customize the throttle
// The throttle likely should be a multiplier on capacity

int count=0;
var parcel = World.LandChannel.GetLandObject(m_host.GetWorldPosition());
List<SceneObjectGroup> sogs = new List<SceneObjectGroup>();

for(int i=0;i<objects.Length;i++)
{
try
{

// get the ID from the list
string id = objects.GetStringItem(i);
var sop = World.GetSceneObjectPart(UUID.Parse(id));
var objParcel = World.LandChannel.GetLandObject(sop.GetWorldPosition());


if (objParcel == null) continue; // Object no longer exists, skip

if (IsEstateOwnerOrManager(m_host.OwnerID) || parcel.LandData.OwnerID.Equals(m_host.OwnerID))
{
var sog = World.GetSceneObjectGroup(UUID.Parse(id));
if (IsEstateOwnerOrManager(m_host.OwnerID))
{
count++;
sogs.Add(sog);
}
else
{
// If not estate manager or owner, return can only happen for the parcel the object is on
bool canEstateReturn = IsEstateOwnerOrManager(sog.OwnerID);

if (objParcel.LocalID == parcel.LocalID && !canEstateReturn)
{
count++;
sogs.Add(sog);
}
}
}
}
catch (Exception e)
Comment thread Fixed

Check warning

Code scanning / CodeQL

Useless assignment to local variable

This assignment to [e](1) is useless, since its value is never read.
{
llShout(ScriptBaseClass.DEBUG_CHANNEL, $"Error while trying to return object {i}");
}
}

if(sogs==null) m_log.Info($"SOGS is null");
m_log.Info($"SOG List Count {sogs.Count}");

if(sogs.Count>0)
World.returnObjects(sogs.ToArray(), null);

return new LSL_Integer(count);
}

public LSL_Integer llReturnObjectsByOwner(string owner, int scope)
{
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_RETURN_OBJECTS) == 0)
{
llShout(ScriptBaseClass.DEBUG_CHANNEL, "Permission not granted: PERMISSION_RETURN_OBJECTS");
return ScriptBaseClass.ERR_RUNTIME_PERMISSIONS;
}
// TODO: Add throttle via a config option
//Throttled at max parcel land impact capacity region-wide per hour. -SL Wiki

List<SceneObjectGroup> lSogs = new();
var parcel = World.LandChannel.GetLandObject(m_host.GetWorldPosition());
if (parcel.LandData.OwnerID.Equals(m_host.OwnerID) || IsEstateOwnerOrManager(m_host.OwnerID))
{
if (IsEstateOwnerOrManager(m_host.OwnerID))
{
int count = 0;
if (scope == ScriptBaseClass.OBJECT_RETURN_REGION)
{

foreach (SceneObjectGroup sog in World.GetSceneObjectGroups())
{
if (sog.OwnerID.ToString() == owner && !IsEstateOwnerOrManager(sog.OwnerID))
{
count++;
lSogs.Add(sog);

}
}
Comment on lines +4707 to +4715

Check notice

Code scanning / CodeQL

Missed opportunity to use Where

This foreach loop [implicitly filters its target sequence](1) - consider filtering the sequence explicitly using '.Where(...)'.
} else if (scope == ScriptBaseClass.OBJECT_RETURN_PARCEL)
{
var sogs = parcel.GetSceneObjectGroups();
foreach (var sog in sogs)
{
if (sog is SceneObjectGroup sogx)
{

// If owner of SOG is [owner], return it.
if (sogx.OwnerID.ToString() == owner && !IsEstateOwnerOrManager(sog.OwnerID))
{
count++;
lSogs.Add(sogx);
}
}
}
} else if (scope == ScriptBaseClass.OBJECT_RETURN_PARCEL_OWNER)
{
var parcels = World.LandChannel.AllParcels();
foreach (var iParcel in parcels)
{
if (iParcel.OwnerID == m_host.OwnerID || IsEstateOwnerOrManager(m_host.OwnerID))
{
var sogs = iParcel.GetSceneObjectGroups();
foreach (var isog in sogs)
{
if (isog is SceneObjectGroup sog)
{
if (sog.OwnerID.ToString() == owner && !IsEstateOwnerOrManager(sog.OwnerID))
{
count++;
lSogs.Add(sog);
}
}
}
Comment on lines +4740 to +4750

Check notice

Code scanning / CodeQL

Missed opportunity to use Where

This foreach loop [implicitly filters its target sequence](1) - consider filtering the sequence explicitly using '.Where(...)'.
}
}
}

if(lSogs.Count>0)
World.returnObjects(lSogs.ToArray(), null);

return count;
}
else
{
return ScriptBaseClass.ERR_PARCEL_PERMISSIONS;
}
}
else
{
return ScriptBaseClass.ERR_PARCEL_PERMISSIONS;
}

}

[DebuggerNonUserCode]
public void llRemoveInventory(string name)
{
Expand Down Expand Up @@ -16669,14 +16820,22 @@ private static int UUID2LinkNumber(SceneObjectPart part, UUID id)
return 0;
}

public bool IsEstateOwnerOrManager(UUID owner)
{

EstateSettings estate = World.RegionInfo.EstateSettings;
if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
return false;
return true;
}

public LSL_Integer llManageEstateAccess(int action, string avatar)
{
if (!UUID.TryParse(avatar, out UUID id) || id.IsZero())
return 0;

if (!IsEstateOwnerOrManager(m_host.OwnerID)) return 0;
EstateSettings estate = World.RegionInfo.EstateSettings;
if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
return 0;

UserAccount account = m_userAccountService.GetUserAccount(RegionScopeID, id);
bool isAccount = account is not null;
Expand Down
2 changes: 2 additions & 0 deletions OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ public interface ILSL_Api
void llRemoveFromLandPassList(string avatar);
void llRemoveInventory(string item);
void llRemoveVehicleFlags(int flags);
LSL_Integer llReturnObjectsByID(LSL_List objects);
LSL_Integer llReturnObjectsByOwner(string owner, int scope);
LSL_Key llRequestUserKey(LSL_String username);
LSL_Key llRequestAgentData(string id, int data);
LSL_Key llRequestInventoryData(LSL_String name);
Expand Down
11 changes: 11 additions & 0 deletions OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,17 @@ public partial class ScriptBaseClass
public const int OBJECT_TEXT_COLOR = 48;
public const int OBJECT_TEXT_ALPHA = 49;

// Return objects By* command return errors
public const int ERR_GENERIC = -1;
public const int ERR_PARCEL_PERMISSIONS = -2;
public const int ERR_MALFORMED_PARAMS = -3;
public const int ERR_RUNTIME_PERMISSIONS = -4;
public const int ERR_THROTTLED = -5;

public const int OBJECT_RETURN_PARCEL = 1;
public const int OBJECT_RETURN_PARCEL_OWNER = 2;
public const int OBJECT_RETURN_REGION = 4;


// Pathfinding types
//ApiDesc not supported
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Server/Base/ServicesServerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public ServicesServerBase(string prompt, string[] args) : base()
}
else
{
XmlConfigurator.Configure(new FileInfo("Robust.exe.config"));
XmlConfigurator.Configure(new FileInfo("Robust.dll.config"));
}

RegisterCommonAppenders(startupConfig);
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Tools/pCampBot/pCampBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class pCampBot
[STAThread]
public static void Main(string[] args)
{
XmlConfigurator.Configure(new System.IO.FileInfo("pCampBot.exe.config"));
XmlConfigurator.Configure(new System.IO.FileInfo("pCampBot.dll.config"));

IConfig commandLineConfig = ParseConfig(args);
if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null)
Expand Down
93 changes: 92 additions & 1 deletion bin/ScriptSyntax.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
9a2d5a5e-484a-40b0-82bc-092443b08ff7
4bb6b867-9eec-492d-8ea6-7fe898c37841
<llsd><map><key>llsd-lsl-syntax-version</key><integer>2</integer>
<key>controls</key>
<map>
Expand Down Expand Up @@ -1025,6 +1025,41 @@
<key>type</key><string>integer</string>
<key>value</key><string>5</string>
</map>
<key>ERR_GENERIC</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>-1</string>
</map>
<key>ERR_PARCEL_PERMISSIONS</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>-2</string>
</map>
<key>ERR_MALFORMED_PARAMS</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>-3</string>
</map>
<key>ERR_RUNTIME_PERMISSIONS</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>-4</string>
</map>
<key>ERR_THROTTLED</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>-5</string>
</map>
<key>FALSE</key><map>
<key>type</key><string>integer</string>
<key>value</key><string>0</string>
Expand Down Expand Up @@ -1697,6 +1732,27 @@
<key>type</key><string>integer</string>
<key>value</key><string>5</string>
</map>
<key>OBJECT_RETURN_PARCEL</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>1</string>
</map>
<key>OBJECT_RETURN_PARCEL_OWNER</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>2</string>
</map>
<key>OBJECT_RETURN_REGION</key>
<map>
<key>type</key>
<string>integer</string>
<key>value</key>
<string>4</string>
</map>
<key>OPT_AVATAR</key><map>
<key>type</key><string>integer</string>
<key>value</key><string>1</string>
Expand Down Expand Up @@ -6107,6 +6163,41 @@
<map><key>id</key><map><key>type</key><string>key</string></map></map>
</array>
</map>
<key>llReturnObjectsByID</key>
<map>
<key>return</key>
<string>integer</string>
<key>arguments</key>
<array>
<map>
<key>objects</key>
<map>
<key>type</key>
<string>list</string>
</map>
</map>
</array>
</map>
<key>llReturnObjectsByOwner</key>
<map>
<key>return</key>
<string>integer</string>
<key>arguments</key>
<array>
<map>
<key>owner</key>
<map>
<key>type</key>
<string>key</string>
</map>
<key>scope</key>
<map>
<key>type</key>
<string>integer</string>
</map>
</map>
</array>
</map>
<key>llResetAnimationOverride</key>
<map>
<key>arguments</key><array>
Expand Down