ok add 2 much, so now the rest

This commit is contained in:
UbitUmarov
2022-04-17 22:26:41 +01:00
parent fdf79a3775
commit d9fb48cdcf
5 changed files with 144 additions and 41 deletions

View File

@@ -2737,45 +2737,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return successYN;
}
/// <summary>
/// Cross the attachments for an avatar into the destination region.
/// </summary>
/// <remarks>
/// This is only invoked for simulators released prior to April 2011. Versions of OpenSimulator since then
/// transfer attachments in one go as part of the ChildAgentDataUpdate data passed in the update agent call.
/// </remarks>
/// <param name='destination'></param>
/// <param name='sp'></param>
/// <param name='silent'></param>
protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
{
List<SceneObjectGroup> attachments = sp.GetAttachments();
// m_log.DebugFormat(
// "[ENTITY TRANSFER MODULE]: Crossing {0} attachments into {1} for {2}",
// m_attachments.Count, destination.RegionName, sp.Name);
foreach (SceneObjectGroup gobj in attachments)
{
// If the prim group is null then something must have happened to it!
if (gobj != null && !gobj.IsDeleted)
{
SceneObjectGroup clone = (SceneObjectGroup)gobj.CloneForNewScene();
clone.RootPart.GroupPosition = gobj.RootPart.AttachedPos;
clone.IsAttachment = false;
//gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}",
clone.UUID, destination.RegionName);
CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, clone, silent,true);
}
}
sp.ClearAttachments();
}
#endregion
#region Misc
@@ -2797,7 +2758,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (i < sp.InTransitScriptStates.Count)
{
sog.SetState(sp.InTransitScriptStates[i++], sp.Scene);
sog.CreateScriptInstances(0, false, sp.Scene.DefaultScriptEngine, 0);
sog.CreateScriptInstances(0, false, sp.Scene.DefaultScriptEngine, -1);
sog.ResumeScripts();
}
else
@@ -2866,6 +2827,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return true;
}
public virtual bool HandleIncomingAttachments(ScenePresence sp, List<SceneObjectGroup> attachments)
{
if (sp.IsDeleted)
return false;
if (m_sceneRegionInfo.EstateSettings.IsBanned(sp.UUID))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Denied Attachments for banned avatar {0}", sp.Name);
return false;
}
foreach(SceneObjectGroup so in attachments)
{
if (!m_scene.AddSceneObject(so))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Problem adding attachment {0} {1} into {2} ",
so.Name, so.UUID, m_sceneName);
continue;
}
}
sp.GotAttachmentsData = true;
return true;
}
private int GetStateSource(SceneObjectGroup sog)
{
ScenePresence sp = m_scene.GetScenePresence(sog.OwnerID);

View File

@@ -754,6 +754,95 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return true;
}
public override bool HandleIncomingAttachments(ScenePresence sp, List<SceneObjectGroup> attachments)
{
UUID OwnerID = sp.UUID;
if (m_sceneRegionInfo.EstateSettings.IsBanned(OwnerID))
{
m_log.DebugFormat(
"[HG TRANSFER MODULE]: Attachments of banned avatar {0} into {1}", sp.Name, m_sceneName);
return false;
}
if (OwnerID.IsZero() || m_scene.UserManagementModule.IsLocalGridUser(OwnerID))
return base.HandleIncomingAttachments(sp, attachments);
// foreign user
AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(OwnerID);
if (aCircuit != null)
{
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) == 0)
{
// first region in local grid did pull the necessary attachments from the source grid.
base.HandleIncomingAttachments(sp, attachments);
}
else
{
if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
{
ScenePresence defsp = sp;
List<SceneObjectGroup> deftatt = attachments;
List<SceneObjectGroup> toadd = new List<SceneObjectGroup>(deftatt.Count);
m_incomingSceneObjectEngine.QueueJob(
string.Format("HG UUID Gather attachments {0}", defsp.Name), () =>
{
string url = aCircuit.ServiceURLs["AssetServerURI"].ToString();
IDictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, url, ids);
foreach (SceneObjectGroup defso in deftatt)
{
uuidGatherer.AddForInspection(defso);
while (!uuidGatherer.Complete)
{
if (sp.IsDeleted)
{
deftatt = null;
defsp = null;
uuidGatherer = null;
toadd = null;
return;
}
uuidGatherer.GatherNext();
}
toadd.Add(defso);
}
deftatt = null;
foreach (UUID id in ids.Keys)
{
int tickStart = Util.EnvironmentTickCount();
uuidGatherer.FetchAsset(id);
int ticksElapsed = Util.EnvironmentTickCountSubtract(tickStart);
if (sp.IsDeleted || ticksElapsed > 30000)
{
m_log.WarnFormat(
"[HG ENTITY TRANSFER]: Aborting fetch attachments assets for HG user {0}", sp.Name);
defsp = null;
uuidGatherer = null;
toadd = null;
return;
}
}
base.HandleIncomingAttachments(sp, toadd);
defsp = null;
uuidGatherer = null;
toadd = null;
},
OwnerID.ToString());
}
}
}
return true;
}
#endregion
#region IUserAgentVerificationModule