refactor: Use ILandChannel.GetLandObject(Vector3) in LSL_Api rather than having to continually take intermediate Vector3s to avoid race conditions

user_profiles
Justin Clark-Casey (justincc) 2013-03-14 23:05:21 +00:00
parent c1115e4c2e
commit ca99f418d8
1 changed files with 21 additions and 41 deletions

View File

@ -4176,13 +4176,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence != null) if (presence != null)
{ {
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject( if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
{ {
World.TeleportClientHome(agentId, presence.ControllingClient); World.TeleportClientHome(agentId, presence.ControllingClient);
} }
} }
} }
ScriptSleep(5000); ScriptSleep(5000);
} }
@ -4202,10 +4202,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (destination == String.Empty) if (destination == String.Empty)
destination = World.RegionInfo.RegionName; destination = World.RegionInfo.RegionName;
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID) if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
{ {
DoLLTeleport(presence, destination, targetPos, targetLookAt); DoLLTeleport(presence, destination, targetPos, targetLookAt);
} }
@ -4235,10 +4233,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// agent must not be a god // agent must not be a god
if (presence.GodLevel >= 200) return; if (presence.GodLevel >= 200) return;
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID) if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
{ {
World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation);
} }
@ -4442,7 +4438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (pushrestricted) if (pushrestricted)
{ {
ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos.X, PusheePos.Y); ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos);
// We didn't find the parcel but region is push restricted so assume it is NOT ok // We didn't find the parcel but region is push restricted so assume it is NOT ok
if (targetlandObj == null) if (targetlandObj == null)
@ -4457,7 +4453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
else else
{ {
ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos.X, PusheePos.Y); ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos);
if (targetlandObj == null) if (targetlandObj == null)
{ {
// We didn't find the parcel but region isn't push restricted so assume it's ok // We didn't find the parcel but region isn't push restricted so assume it's ok
@ -5715,8 +5711,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID id = UUID.Zero; UUID id = UUID.Zero;
if (parcel || parcelOwned) if (parcel || parcelOwned)
{ {
pos = m_host.ParentGroup.RootPart.GetWorldPosition(); land = World.LandChannel.GetLandObject(m_host.ParentGroup.RootPart.GetWorldPosition());
land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land == null) if (land == null)
{ {
id = UUID.Zero; id = UUID.Zero;
@ -5742,8 +5737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (!regionWide) if (!regionWide)
{ {
pos = ssp.AbsolutePosition; land = World.LandChannel.GetLandObject(ssp.AbsolutePosition);
land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land != null) if (land != null)
{ {
if (parcelOwned && land.LandData.OwnerID == id || if (parcelOwned && land.LandData.OwnerID == id ||
@ -5867,10 +5861,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(agentID); ScenePresence presence = World.GetScenePresence(agentID);
if (presence != null) if (presence != null)
{ {
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y); ILandObject land = World.LandChannel.GetLandObject(presence.AbsolutePosition);
if (land == null) if (land == null)
return; return;
@ -5892,9 +5884,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(key); ScenePresence presence = World.GetScenePresence(key);
if (presence != null) // object is an avatar if (presence != null) // object is an avatar
{ {
Vector3 pos = presence.AbsolutePosition; if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID)
return 1; return 1;
} }
else // object is not an avatar else // object is not an avatar
@ -5903,9 +5893,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj != null) if (obj != null)
{ {
Vector3 pos = obj.AbsolutePosition; if (m_host.OwnerID == World.LandChannel.GetLandObject(obj.AbsolutePosition).LandData.OwnerID)
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID)
return 1; return 1;
} }
} }
@ -5985,10 +5973,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// if the land is group owned and the object is group owned by the same group // if the land is group owned and the object is group owned by the same group
// or // or
// if the object is owned by a person with estate access. // if the object is owned by a person with estate access.
ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition);
Vector3 pos = av.AbsolutePosition;
ILandObject parcel = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (parcel != null) if (parcel != null)
{ {
if (m_host.OwnerID == parcel.LandData.OwnerID || if (m_host.OwnerID == parcel.LandData.OwnerID ||
@ -6571,9 +6556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
int expires = 0; int expires = 0;
@ -7802,8 +7786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
return; return;
@ -7817,8 +7800,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
return String.Empty; return String.Empty;
@ -9595,9 +9577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// according to the docs, this command only works if script owner and land owner are the same // according to the docs, this command only works if script owner and land owner are the same
// lets add estate owners and gods, too, and use the generic permission check. // lets add estate owners and gods, too, and use the generic permission check.
Vector3 pos = m_host.AbsolutePosition; ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject landObject = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return; if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return;
bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)?
@ -10022,7 +10002,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
int expires = 0; int expires = 0;
@ -10063,7 +10043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed))
{ {
if (UUID.TryParse(avatar, out key)) if (UUID.TryParse(avatar, out key))
@ -10090,7 +10070,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
if (UUID.TryParse(avatar, out key)) if (UUID.TryParse(avatar, out key))
@ -10352,7 +10332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llResetLandBanList() public void llResetLandBanList()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData;
if (land.OwnerID == m_host.OwnerID) if (land.OwnerID == m_host.OwnerID)
{ {
foreach (LandAccessEntry entry in land.ParcelAccessList) foreach (LandAccessEntry entry in land.ParcelAccessList)
@ -10369,7 +10349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llResetLandPassList() public void llResetLandPassList()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData;
if (land.OwnerID == m_host.OwnerID) if (land.OwnerID == m_host.OwnerID)
{ {
foreach (LandAccessEntry entry in land.ParcelAccessList) foreach (LandAccessEntry entry in land.ParcelAccessList)