public ILandObject GetLandObject(int x, int y) { //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) { return(RootRegionLandChannel.GetLandObject(x, y)); } else { int offsetX = (x / (int)Constants.RegionSize); int offsetY = (y / (int)Constants.RegionSize); offsetX *= (int)Constants.RegionSize; offsetY *= (int)Constants.RegionSize; foreach (RegionData regionData in RegionConnections) { if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) { return(regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY)); } } ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); obj.LandData.Name = "NO LAND"; return(obj); } }
private void SetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID, Caps caps) { bool success = false; string message = "Could not process request"; int parcel = -1; int track = -1; StringBuilder sb = LLSDxmlEncode.Start(); ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp == null || sp.IsChildAgent || sp.IsNPC) { message = "Could not locate your avatar"; goto Error; } if (httpRequest.Query.Count > 0) { if (httpRequest.Query.ContainsKey("parcelid")) { if (!Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel)) { message = "Failed to decode request"; goto Error; } } if (httpRequest.Query.ContainsKey("trackno")) { if (!Int32.TryParse((string)httpRequest.Query["trackno"], out track)) { message = "Failed to decode request"; goto Error; } } if (track != -1) { message = "Environment Track not supported"; goto Error; } } ViewerEnvironment VEnv = m_scene.RegionEnvironment; ILandObject lchannel; if (parcel == -1) { if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { message = "Insufficient estate permissions, settings has not been saved."; goto Error; } VEnv = m_scene.RegionEnvironment; lchannel = null; } else { lchannel = m_landChannel.GetLandObject(parcel); if (lchannel == null || lchannel.LandData == null) { message = "Could not locate requested parcel"; goto Error; } if (!m_scene.Permissions.CanEditParcelProperties(agentID, lchannel, (GroupPowers.AllowEnvironment | GroupPowers.LandEdit), true)) // wrong { message = "No permission to change parcel environment"; goto Error; } VEnv = lchannel.LandData.Environment; } try { OSD req = OSDParser.Deserialize(httpRequest.InputStream); if (req is OpenMetaverse.StructuredData.OSDMap) { OSDMap map = req as OpenMetaverse.StructuredData.OSDMap; if (map.TryGetValue("environment", out OSD env)) { if (VEnv == null) { // need a proper clone VEnv = m_DefaultEnv.Clone(); } OSDMap evmap = (OSDMap)env; if (evmap.TryGetValue("day_asset", out OSD tmp) && !evmap.ContainsKey("day_cycle")) { string id = tmp.AsString(); AssetBase asset = m_assetService.Get(id); if (asset == null || asset.Data == null || asset.Data.Length == 0) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } try { OSD oenv = OSDParser.Deserialize(asset.Data); VEnv.CycleFromOSD(oenv); } catch { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } } VEnv.FromOSD(env); if (lchannel == null) { StoreOnRegion(VEnv); m_log.InfoFormat("[{0}]: ExtEnvironment region {1} settings from agentID {2} saved", Name, caps.RegionName, agentID); } else { lchannel.StoreEnvironment(VEnv); m_log.InfoFormat("[{0}]: ExtEnvironment parcel {1} of region {2} settings from agentID {3} saved", Name, parcel, caps.RegionName, agentID); } WindlightRefresh(0, lchannel == null); success = true; } } else if (req is OSDArray) { VEnv = new ViewerEnvironment(); VEnv.FromWLOSD(req); StoreOnRegion(VEnv); success = true; WindlightRefresh(0); m_log.InfoFormat("[{0}]: ExtEnvironment region {1} settings from agentID {2} saved", Name, caps.RegionName, agentID); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("success", success, sb); LLSDxmlEncode.AddEndMap(sb); httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb)); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } } catch (Exception e) { m_log.ErrorFormat("[{0}]: ExtEnvironment settings not saved for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); success = false; message = String.Format("ExtEnvironment Set for region {0} has failed, settings not saved.", caps.RegionName); } Error: string response; LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("success", success, sb); if (!success) { LLSDxmlEncode.AddElem("message", message, sb); } LLSDxmlEncode.AddEndMap(sb); response = LLSDxmlEncode.End(sb); httpResponse.RawBuffer = Util.UTF8NBGetbytes(response); httpResponse.StatusCode = (int)HttpStatusCode.OK; }
public ILandObject GetLandObject(int localID) { // XXX: Possibly should be looking in every land channel, not just the root. return(RootRegionLandChannel.GetLandObject(localID)); }