add LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment). note this is a hack, we cant do the ll* one

This commit is contained in:
UbitUmarov
2020-06-19 19:55:40 +01:00
parent d322248fd1
commit e3ecf0ddbe
7 changed files with 174 additions and 18 deletions

View File

@@ -5882,5 +5882,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return m_host.ClearObjectAnimations();
}
public LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment)
{
m_host.AddScriptLPS(1);
// if(!string.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.Moderate, "osReplaceAgentEnvironment")))
// return -2;
if (!UUID.TryParse(agentkey, out UUID agentid))
return -4;
ScenePresence sp = World.GetScenePresence(agentid);
if(sp == null || sp.IsChildAgent || sp.IsNPC || sp.IsInTransit)
return -4;
if(string.IsNullOrEmpty(environment) || environment == UUID.Zero.ToString())
{
sp.Environment = null;
m_envModule.WindlightRefresh(sp, transition);
return 1;
}
UUID envID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, environment);
if (envID == UUID.Zero)
return -3;
AssetBase asset = World.AssetService.Get(envID.ToString());
if(asset == null || asset.Type != (byte)AssetType.Settings)
return -3;
// cant use stupid broken asset flags for subtype
try
{
OSD oenv = OSDParser.Deserialize(asset.Data);
ViewerEnvironment VEnv = m_envModule.GetRegionEnvironment().Clone();
if(!VEnv.CycleFromOSD(oenv))
return -3;
sp.Environment = VEnv;
m_envModule.WindlightRefresh(sp, transition);
}
catch
{
sp.Environment = null;
m_envModule.WindlightRefresh(sp, transition);
return -9;
}
return 1;
}
}
}

View File

@@ -578,5 +578,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String osGetApparentTimeString(LSL_Integer format24);
LSL_Float osGetApparentRegionTime();
LSL_String osGetApparentRegionTimeString(LSL_Integer format24);
LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment);
}
}

View File

@@ -1502,5 +1502,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetApparentRegionTimeString(format24);
}
public LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment)
{
return m_OSSL_Functions.osReplaceAgentEnvironment(agentkey, transition, environment);
}
}
}