some fixes on env protocol, forced env, etc

master
UbitUmarov 2020-06-21 01:41:14 +01:00
parent 17e7e9b354
commit 5b56a09cb2
6 changed files with 70 additions and 54 deletions

View File

@ -898,7 +898,7 @@ namespace OpenSim.Framework
public int DayOffset = 57600;
public int Flags = 0;
float[] Altitudes = new float[3] {1000f, 2000f, 3000f };
public float[] Altitudes = new float[3] {1000f, 2000f, 3000f };
//DayHash;
public bool IsLegacy = false;
@ -1158,27 +1158,32 @@ namespace OpenSim.Framework
for(int i = 0; i < alt.Count && i < 3; ++i)
Altitudes[i] = alt[i];
for(int i = 0; i < 2; ++i)
{
float h = Altitudes[i];
for(int j = i + 1; j < 3; ++j)
{
if(h > Altitudes[j])
{
Altitudes[i] = Altitudes[j];
Altitudes[j] = h;
List<DayCycle.TrackEntry> tet = Cycle.skyTracks[i];
Cycle.skyTracks[i] = Cycle.skyTracks[j];
Cycle.skyTracks[j] = tet;
h = Altitudes[i];
}
}
}
SortAltitudes();
}
IsLegacy = false;
}
public void SortAltitudes()
{
for (int i = 0; i < 2; ++i)
{
float h = Altitudes[i];
for (int j = i + 1; j < 3; ++j)
{
if (h > Altitudes[j])
{
Altitudes[i] = Altitudes[j];
Altitudes[j] = h;
List<DayCycle.TrackEntry> tet = Cycle.skyTracks[i];
Cycle.skyTracks[i] = Cycle.skyTracks[j];
Cycle.skyTracks[j] = tet;
h = Altitudes[i];
}
}
}
}
public bool CycleFromOSD(OSD osd)
{
OSDMap map = osd as OSDMap;

View File

@ -6565,8 +6565,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLSDxmlEncode.AddEndMapAndArray(sb);
bool allowenvovr = (regionFlags & (uint)RegionFlags.AllowEnvironmentOverride) != 0;
int envVersion;
if(allowenvovr)
{
ScenePresence sp = SceneAgent as ScenePresence;
if(sp != null && sp .EnvironmentVersion > 0)
envVersion = sp.EnvironmentVersion;
else
envVersion = landData.EnvironmentVersion;
}
else
envVersion = -1;
LLSDxmlEncode.AddArrayAndMap("ParcelEnvironmentBlock", sb);
LLSDxmlEncode.AddElem("ParcelEnvironmentVersion", allowenvovr ? landData.EnvironmentVersion : -1, sb);
LLSDxmlEncode.AddElem("ParcelEnvironmentVersion", envVersion, sb);
LLSDxmlEncode.AddElem("RegionAllowEnvironmentOverride", allowenvovr, sb);
LLSDxmlEncode.AddEndMapAndArray(sb);

View File

@ -215,7 +215,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
#endregion
#region IEnvironmentModule
private void StoreOnRegion(ViewerEnvironment VEnv)
public void StoreOnRegion(ViewerEnvironment VEnv)
{
try
{
@ -455,46 +455,48 @@ namespace OpenSim.Region.CoreModules.World.LightShare
private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
{
int parcel = -1;
int parcelid = -1;
if (httpRequest.Query.Count > 0)
{
if (httpRequest.Query.ContainsKey("parcelid"))
{
Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel);
Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid);
}
}
ViewerEnvironment VEnv = null;
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp == null || sp.IsChildAgent || sp.IsNPC)
{
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
ViewerEnvironment VEnv;
if(sp.Environment != null)
if(sp != null && sp.Environment != null)
{
VEnv = sp.Environment;
else if (parcel == -1)
}
else if (parcelid == -1)
VEnv = GetRegionEnvironment();
else
{
ILandObject land = m_scene.LandChannel.GetLandObject(parcel);
if (land != null && land.LandData != null && land.LandData.Environment != null)
VEnv = land.LandData.Environment;
else
if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
{
/* not working for some reason
OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcel);
ILandObject land = m_scene.LandChannel.GetLandObject(parcelid);
if(land != null && land.LandData != null && land.LandData.Environment != null)
VEnv = land.LandData.Environment;
}
if(VEnv == null)
{
OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid);
httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def);
httpResponse.StatusCode = (int)HttpStatusCode.OK;
return;
*/
VEnv = GetRegionEnvironment();
}
}
OSDMap map = new OSDMap();
map["environment"] = VEnv.ToOSD();
OSDMap cenv = (OSDMap)VEnv.ToOSD();
cenv["parcel_id"] = parcelid;
cenv["region_id"] = regionID;
map["environment"] = cenv;
map["parcel_id"] = parcelid;
map["success"] = true;
string env = OSDParser.SerializeLLSDXmlString(map);
@ -560,7 +562,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
ILandObject lchannel;
if (parcel == -1)
{
if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
if (!m_scene.Permissions.CanIssueEstateCommand(agentID, true))
{
message = "Insufficient estate permissions, settings has not been saved.";
goto Error;
@ -686,22 +688,19 @@ namespace OpenSim.Region.CoreModules.World.LightShare
// m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
// Name, agentID, caps.RegionName);
ViewerEnvironment VEnv = null;
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp == null || sp.IsChildAgent || sp.IsNPC)
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
ViewerEnvironment VEnv;
if (sp.Environment != null)
if (sp != null && sp.Environment != null)
VEnv = sp.Environment;
else
{
if(m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
{
ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y);
if (land != null && land.LandData != null && land.LandData.Environment != null)
VEnv = land.LandData.Environment;
else
}
if(VEnv == null)
VEnv = GetRegionEnvironment();
}

View File

@ -5883,7 +5883,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_host.ClearObjectAnimations();
}
public LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment)
public LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String daycycle)
{
m_host.AddScriptLPS(1);
if(!string.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.Moderate, "osReplaceAgentEnvironment")))
@ -5896,14 +5896,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sp == null || sp.IsChildAgent || sp.IsNPC || sp.IsInTransit)
return -4;
if(string.IsNullOrEmpty(environment) || environment == UUID.Zero.ToString())
if(string.IsNullOrEmpty(daycycle) || daycycle == UUID.Zero.ToString())
{
sp.Environment = null;
m_envModule.WindlightRefresh(sp, transition);
return 1;
}
UUID envID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, environment);
UUID envID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, daycycle);
if (envID == UUID.Zero)
return -3;

View File

@ -579,6 +579,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Float osGetApparentRegionTime();
LSL_String osGetApparentRegionTimeString(LSL_Integer format24);
LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String environment);
LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String daycycle);
}
}

View File

@ -1502,9 +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)
public LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String daycycle)
{
return m_OSSL_Functions.osReplaceAgentEnvironment(agentkey, transition, environment);
return m_OSSL_Functions.osReplaceAgentEnvironment(agentkey, transition, daycycle);
}
}
}