change ParcelPropertiesUpdate

master
UbitUmarov 2020-04-25 20:49:13 +01:00
parent d44baf20cd
commit cafe49d44b
1 changed files with 82 additions and 58 deletions

View File

@ -28,7 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.Text;
using log4net;
@ -1917,6 +1917,7 @@ namespace OpenSim.Region.CoreModules.World.Land
private void EventManagerOnRegisterCaps(UUID agentID, Caps caps)
{
string cap = "/CAPS/" + UUID.Random();
caps.RegisterHandler(
"RemoteParcelRequest",
@ -1927,32 +1928,61 @@ namespace OpenSim.Region.CoreModules.World.Land
"RemoteParcelRequest",
agentID.ToString()));
cap = "/CAPS/" + UUID.Random();
caps.RegisterHandler(
"ParcelPropertiesUpdate",
new RestStreamHandler(
"POST", cap,
(request, path, param, httpRequest, httpResponse)
=> ProcessPropertiesUpdate(request, path, param, agentID, caps),
"ParcelPropertiesUpdate",
agentID.ToString()));
}
private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
caps.RegisterSimpleHandler("ParcelPropertiesUpdate", new SimpleStreamHandler("/" + UUID.Random(),
delegate (IOSHttpRequest request, IOSHttpResponse response)
{
ProcessPropertiesUpdate(request, response, agentID);
}));
}
private void ProcessPropertiesUpdate(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
{
if (request.HttpMethod != "POST")
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
IClientAPI client;
if (!m_scene.TryGetClient(agentID, out client))
{
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
response.StatusCode = (int)HttpStatusCode.Gone;
return;
}
ParcelPropertiesUpdateMessage properties = new ParcelPropertiesUpdateMessage();
OpenMetaverse.StructuredData.OSDMap args = (OpenMetaverse.StructuredData.OSDMap) OSDParser.DeserializeLLSDXml(request);
OpenMetaverse.StructuredData.OSDMap args;
ParcelPropertiesUpdateMessage properties;
try
{
args = (OpenMetaverse.StructuredData.OSDMap)OSDParser.DeserializeLLSDXml(request.InputStream);
properties = new ParcelPropertiesUpdateMessage();
properties.Deserialize(args);
}
catch
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
LandUpdateArgs land_update = new LandUpdateArgs();
int parcelID = properties.LocalID;
ILandObject land = null;
lock (m_landList)
{
m_landList.TryGetValue(parcelID, out land);
}
if (land == null)
{
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
try
{
LandUpdateArgs land_update = new LandUpdateArgs();
land_update.AuthBuyerID = properties.AuthBuyerID;
land_update.Category = properties.Category;
land_update.Desc = properties.Desc;
@ -1991,24 +2021,18 @@ namespace OpenSim.Region.CoreModules.World.Land
land_update.GroupAVSounds = true;
}
ILandObject land = null;
lock (m_landList)
{
m_landList.TryGetValue(parcelID, out land);
}
if (land != null)
{
UpdateLandProperties(land,land_update, client);
m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client);
}
else
catch
{
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
response.StatusCode = (int)HttpStatusCode.InternalServerError;
return;
}
return LLSDxmlEncode.LLSDEmpty;
response.StatusCode = (int)HttpStatusCode.OK;
}
// we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
// "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to.
// So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x