From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- .../World/AutoBackup/AutoBackupModule.cs | 123 +++++++++++++++- .../World/AutoBackup/AutoBackupModuleState.cs | 14 ++ .../World/MoneyModule/SampleMoneyModule.cs | 34 ++--- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 69 ++++++--- .../Region/OptionalModules/World/NPC/NPCModule.cs | 98 ++++++++----- .../World/NPC/Tests/NPCModuleTests.cs | 154 ++++++++++++++++++--- .../World/SceneCommands/SceneCommandsModule.cs | 142 ++++++++++++++++--- .../World/TreePopulator/TreePopulatorModule.cs | 4 +- .../World/WorldView/WorldViewRequestHandler.cs | 2 +- 9 files changed, 527 insertions(+), 113 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index 1d35c54..ceb3332 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -76,6 +76,10 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// AutoBackupBusyCheck: True/False. Default: True. /// If True, we will only take an auto-backup if a set of conditions are met. /// These conditions are heuristics to try and avoid taking a backup when the sim is busy. + /// AutoBackupSkipAssets + /// If true, assets are not saved to the oar file. Considerably reduces impact on simulator when backing up. Intended for when assets db is backed up separately + /// AutoBackupKeepFilesForDays + /// Backup files older than this value (in days) are deleted during the current backup process, 0 will disable this and keep all backup files indefinitely /// AutoBackupScript: String. Default: not specified (disabled). /// File path to an executable script or binary to run when an automatic backup is taken. /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary. @@ -111,6 +115,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup private delegate T DefaultGetter(string settingName, T defaultValue); private bool m_enabled; + private ICommandConsole m_console; + private List m_Scenes = new List (); + /// /// Whether the shared module should be enabled at all. NOT the same as m_Enabled in AutoBackupModuleState! @@ -202,8 +209,20 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded. /// /// - void IRegionModuleBase.AddRegion(Scene scene) + void IRegionModuleBase.AddRegion (Scene scene) { + if (!this.m_enabled) { + return; + } + lock (m_Scenes) { + m_Scenes.Add (scene); + } + m_console = MainConsole.Instance; + + m_console.Commands.AddCommand ( + "AutoBackup", false, "dobackup", + "dobackup", + "do backup.", DoBackup); } /// @@ -216,7 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup { return; } - + m_Scenes.Remove (scene); if (this.m_states.ContainsKey(scene)) { AutoBackupModuleState abms = this.m_states[scene]; @@ -258,6 +277,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup AutoBackupModuleState abms = this.ParseConfig(scene, false); m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); + + m_states.Add(scene, abms); } /// @@ -269,6 +290,28 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup #endregion + private void DoBackup (string module, string[] args) + { + if (args.Length != 2) { + MainConsole.Instance.OutputFormat ("Usage: dobackup "); + return; + } + bool found = false; + string name = args [1]; + lock (m_Scenes) { + foreach (Scene s in m_Scenes) { + string test = s.Name.ToString (); + if (test == name) { + found = true; + DoRegionBackup (s); + } + } + if (!found) { + MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name); + } + } + } + /// /// Set up internal state for a given scene. Fairly complex code. /// When this method returns, we've started auto-backup timers, put members in Dictionaries, and created a State object for this scene. @@ -334,7 +377,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup double interval = this.ResolveDouble("AutoBackupInterval", this.m_defaultState.IntervalMinutes, config, regionConfig) * 60000.0; - if (state == null && interval != this.m_defaultState.IntervalMinutes*60000.0) + if (state == null && interval != this.m_defaultState.IntervalMinutes * 60000.0) { state = new AutoBackupModuleState(); } @@ -412,6 +455,32 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup state.BusyCheck = tmpBusyCheck; } + // Included Option To Skip Assets + bool tmpSkipAssets = ResolveBoolean("AutoBackupSkipAssets", + this.m_defaultState.SkipAssets, config, regionConfig); + if (state == null && tmpSkipAssets != this.m_defaultState.SkipAssets) + { + state = new AutoBackupModuleState(); + } + + if (state != null) + { + state.SkipAssets = tmpSkipAssets; + } + + // How long to keep backup files in days, 0 Disables this feature + int tmpKeepFilesForDays = ResolveInt("AutoBackupKeepFilesForDays", + this.m_defaultState.KeepFilesForDays, config, regionConfig); + if (state == null && tmpKeepFilesForDays != this.m_defaultState.KeepFilesForDays) + { + state = new AutoBackupModuleState(); + } + + if (state != null) + { + state.KeepFilesForDays = tmpKeepFilesForDays; + } + // Set file naming algorithm string stmpNamingType = ResolveString("AutoBackupNaming", this.m_defaultState.NamingType.ToString(), config, regionConfig); @@ -480,7 +549,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup catch (Exception e) { m_log.Warn( - "BAD NEWS. You won't be able to save backups to directory " + + "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " + state.BackupDir + " because it doesn't exist or there's a permissions issue with it. Here's the exception.", e); @@ -488,6 +557,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } } + if(state == null) + return m_defaultState; + return state; } @@ -594,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup bool heuristicsPassed = false; if (!this.m_timerMap.ContainsKey((Timer) sender)) { - m_log.Debug("Code-up error: timerMap doesn't contain timer " + sender); + m_log.Debug("[AUTO BACKUP]: Code-up error: timerMap doesn't contain timer " + sender); } List tmap = this.m_timerMap[(Timer) sender]; @@ -630,6 +702,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } this.DoRegionBackup(scene); } + + // Remove Old Backups + this.RemoveOldFiles(state); } } } @@ -640,7 +715,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// private void DoRegionBackup(IScene scene) { - if (scene.RegionStatus != RegionStatus.Up) + if (!scene.Ready) { // We won't backup a region that isn't operating normally. m_log.Warn("[AUTO BACKUP]: Not backing up region " + scene.RegionInfo.RegionName + @@ -662,7 +737,41 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup m_pendingSaves.Add(guid, scene); state.LiveRequests.Add(guid, savePath); ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved); - iram.ArchiveRegion(savePath, guid, null); + + m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName); + + // Must pass options, even if dictionary is empty! + Dictionary options = new Dictionary(); + + if (state.SkipAssets) + options["noassets"] = true; + + iram.ArchiveRegion(savePath, guid, options); + } + + // For the given state, remove backup files older than the states KeepFilesForDays property + private void RemoveOldFiles(AutoBackupModuleState state) + { + // 0 Means Disabled, Keep Files Indefinitely + if (state.KeepFilesForDays > 0) + { + string[] files = Directory.GetFiles(state.BackupDir, "*.oar"); + DateTime CuttOffDate = DateTime.Now.AddDays(0 - state.KeepFilesForDays); + + foreach (string file in files) + { + try + { + FileInfo fi = new FileInfo(file); + if (fi.CreationTime < CuttOffDate) + fi.Delete(); + } + catch (Exception Ex) + { + m_log.Error("[AUTO BACKUP]: Error deleting old backup file '" + file + "': " + Ex.Message); + } + } + } } /// diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs index f9e118b..ce7c368 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs @@ -45,9 +45,11 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup this.Enabled = false; this.BackupDir = "."; this.BusyCheck = true; + this.SkipAssets = false; this.Timer = null; this.NamingType = NamingType.Time; this.Script = null; + this.KeepFilesForDays = 0; } public Dictionary LiveRequests @@ -91,6 +93,12 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup set; } + public bool SkipAssets + { + get; + set; + } + public string Script { get; @@ -109,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup set; } + public int KeepFilesForDays + { + get; + set; + } + public new string ToString() { string retval = ""; diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index a999b7f..4cd5676 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -103,7 +103,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule #region IMoneyModule Members +#pragma warning disable 0067 public event ObjectPaid OnObjectPaid; +#pragma warning restore 0067 public int UploadCharge { @@ -191,9 +193,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule // Please do not refactor these to be just one method // Existing implementations need the distinction // - public void ApplyCharge(UUID agentID, int amount, string text) + public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData) { } + + public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type) + { + } + public void ApplyUploadCharge(UUID agentID, int amount, string text) { } @@ -322,7 +329,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule client.SendAlertMessage(e.Message + " "); } - client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds); + client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds, 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } else { @@ -385,12 +392,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule { if (sender != null) { - sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID)); + sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } if (receiver != null) { - receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID)); + receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); } } } @@ -555,7 +562,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule /// private int GetFundsForAgentID(UUID AgentID) { - int returnfunds = 75004; // Set it to the OpenSim version, plus the IG build number. Muahahaha; + int returnfunds = 0; return returnfunds; } @@ -688,19 +695,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule /// Event called Economy Data Request handler. /// /// - public void EconomyDataRequestHandler(UUID agentId) + public void EconomyDataRequestHandler(IClientAPI user) { - IClientAPI user = LocateClientObject(agentId); + Scene s = (Scene)user.Scene; - if (user != null) - { - Scene s = LocateSceneClientIn(user.AgentId); - - user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, - PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, - PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, - TeleportMinPrice, TeleportPriceExponent); - } + user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, + PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, + PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, + TeleportMinPrice, TeleportPriceExponent); } private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 5ea2bcd..fb644b7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -44,10 +44,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public bool SenseAsAgent { get; set; } + public delegate void ChatToNPC( + string message, byte type, Vector3 fromPos, string fromName, + UUID fromAgentID, UUID ownerID, byte source, byte audible); + + /// + /// Fired when the NPC receives a chat message. + /// + public event ChatToNPC OnChatToNPC; + + /// + /// Fired when the NPC receives an instant message. + /// + public event Action OnInstantMessageToNPC; + private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; - private readonly UUID m_uuid = UUID.Random(); + private readonly UUID m_uuid; private readonly Scene m_scene; private readonly UUID m_ownerID; @@ -57,6 +71,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_firstname = firstname; m_lastname = lastname; m_startPos = position; + m_uuid = UUID.Random(); + m_scene = scene; + m_ownerID = ownerID; + SenseAsAgent = senseAsAgent; + } + + public NPCAvatar( + string firstname, string lastname, UUID agentID, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) + { + m_firstname = firstname; + m_lastname = lastname; + m_startPos = position; + m_uuid = agentID; m_scene = scene; m_ownerID = ownerID; SenseAsAgent = senseAsAgent; @@ -258,6 +285,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; @@ -391,6 +419,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; public event EstateChangeInfo OnEstateChangeInfo; public event EstateManageTelehub OnEstateManageTelehub; + public event CachedTextureRequest OnCachedTextureRequest; public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; @@ -569,6 +598,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List cachedTextures) + { + + } + public virtual void Kick(string message) { } @@ -586,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC } - public virtual void SendKillObject(ulong regionHandle, List localID) + public virtual void SendKillObject(List localID) { } @@ -607,25 +641,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) { - } + ChatToNPC ctn = OnChatToNPC; - public virtual void SendChatMessage( - byte[] message, byte type, Vector3 fromPos, string fromName, - UUID fromAgentID, UUID ownerID, byte source, byte audible) - { + if (ctn != null) + ctn(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); } public void SendInstantMessage(GridInstantMessage im) { - + Action oimtn = OnInstantMessageToNPC; + + if (oimtn != null) + oimtn(im); } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } - public void SendGenericMessage(string method, List message) + public void SendGenericMessage(string method, UUID invoice, List message) { } @@ -688,7 +723,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) + public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item) { } @@ -860,11 +895,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public bool AddMoney(int debit) - { - return false; - } - public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) { } @@ -1227,12 +1257,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) { } + + public void SendPartPhysicsProprieties(ISceneEntity entity) + { + } + } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d6cf1ab..9232db9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -116,7 +116,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; // Delete existing npc attachments - scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); + if(scene.AttachmentsModule != null) + scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet // since it doesn't transfer attachments @@ -125,7 +126,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC npc.Appearance = npcAppearance; // Rez needed npc attachments - scene.AttachmentsModule.RezAttachments(npc); + if (scene.AttachmentsModule != null) + scene.AttachmentsModule.RezAttachments(npc); IAvatarFactoryModule module = scene.RequestModuleInterface(); @@ -138,15 +140,37 @@ namespace OpenSim.Region.OptionalModules.World.NPC Vector3 position, UUID owner, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { - NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, - owner, senseAsAgent, scene); + return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance); + } + + public UUID CreateNPC(string firstname, string lastname, + Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, + AvatarAppearance appearance) + { + NPCAvatar npcAvatar = null; + + try + { + if (agentID == UUID.Zero) + npcAvatar = new NPCAvatar(firstname, lastname, position, + owner, senseAsAgent, scene); + else + npcAvatar = new NPCAvatar(firstname, lastname, agentID, position, + owner, senseAsAgent, scene); + } + catch (Exception e) + { + m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString()); + return UUID.Zero; + } + npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); m_log.DebugFormat( - "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", - firstname, lastname, npcAvatar.AgentId, owner, - senseAsAgent, position, scene.RegionInfo.RegionName); + "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", + firstname, lastname, npcAvatar.AgentId, owner, + senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; @@ -154,8 +178,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC acd.lastname = lastname; acd.ServiceURLs = new Dictionary(); - AvatarAppearance npcAppearance = new AvatarAppearance(appearance, - true); + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; /* @@ -173,7 +196,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); - scene.AddNewClient(npcAvatar, PresenceType.Npc); + scene.AddNewAgent(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) @@ -186,16 +209,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); - m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", - npcAvatar.AgentId, sp.Name); + m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); return npcAvatar.AgentId; } else { m_log.WarnFormat( - "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", - sp.Name, sp.UUID); + "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", + sp.Name, sp.UUID); + return UUID.Zero; } } @@ -211,12 +234,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - /* - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, - noFly, landAtTarget); - */ + if (sp.IsSatOnObject || sp.SitGround) + return false; + +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, +// noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; @@ -293,9 +317,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - sp.HandleAgentRequestSit(m_avatars[agentID], agentID, - partID, Vector3.Zero); - //sp.HandleAgentSit(m_avatars[agentID], agentID); + sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); return true; } @@ -376,23 +398,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC public bool DeleteNPC(UUID agentID, Scene scene) { + bool doRemove = false; + NPCAvatar av; lock (m_avatars) { - NPCAvatar av; if (m_avatars.TryGetValue(agentID, out av)) { /* m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name); */ - scene.RemoveClient(agentID, false); + doRemove = true; + } + } + + if (doRemove) + { + scene.CloseAgent(agentID, false); + lock (m_avatars) + { m_avatars.Remove(agentID); - /* - m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", - agentID, av.Name); - */ - return true; } + m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", + agentID, av.Name); + return true; } /* m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", @@ -416,13 +445,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC /// /// Check if the caller has permission to manipulate the given NPC. /// + /// + /// A caller has permission if + /// * The caller UUID given is UUID.Zero. + /// * The avatar is unowned (owner is UUID.Zero). + /// * The avatar is owned and the owner and callerID match. + /// * The avatar is owned and the callerID matches its agentID. + /// /// /// /// true if they do, false if they don't. private bool CheckPermissions(NPCAvatar av, UUID callerID) { return callerID == UUID.Zero || av.OwnerID == UUID.Zero || - av.OwnerID == callerID; + av.OwnerID == callerID || av.AgentId == callerID; } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index bf23040..77dfd40 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -33,7 +33,6 @@ using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications; using OpenSim.Region.CoreModules.Avatar.Attachments; using OpenSim.Region.CoreModules.Avatar.AvatarFactory; using OpenSim.Region.CoreModules.Framework.InventoryAccess; @@ -43,7 +42,6 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.AvatarService; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.OptionalModules.World.NPC.Tests { @@ -71,11 +69,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } - [SetUp] - public void Init() + public void SetUpScene() { - base.SetUp(); + SetUpScene(256, 256); + } + public void SetUpScene(uint sizeX, uint sizeY) + { IConfigSource config = new IniConfigSource(); config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); @@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests m_attMod = new AttachmentsModule(); m_npcMod = new NPCModule(); - m_scene = new SceneHelpers().SetupScene(); + m_scene = new SceneHelpers().SetupScene("test scene", UUID.Random(), 1000, 1000, sizeX, sizeY, config); SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); } @@ -97,6 +97,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + SetUpScene(); + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -110,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); - m_afMod.SetAppearance(sp, originalTe, null); + m_afMod.SetAppearance(sp, originalTe, null, null); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); @@ -133,6 +135,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + SetUpScene(); + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -155,7 +159,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestCreateWithAttachments() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); + + SetUpScene(); UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(m_scene, userId); @@ -191,11 +197,66 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests } [Test] + public void TestCreateWithMultiAttachments() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + SetUpScene(); +// m_attMod.DebugLevel = 1; + + UUID userId = TestHelpers.ParseTail(0x1); + UserAccountHelpers.CreateUserWithInventory(m_scene, userId); + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); + + InventoryItemBase att1Item + = UserInventoryHelpers.CreateInventoryItem( + m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); + InventoryItemBase att2Item + = UserInventoryHelpers.CreateInventoryItem( + m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); + + m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest); + m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80); + + UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); + + ScenePresence npc = m_scene.GetScenePresence(npcId); + + // Check scene presence status + Assert.That(npc.HasAttachments(), Is.True); + List attachments = npc.GetAttachments(); + Assert.That(attachments.Count, Is.EqualTo(2)); + + // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item + // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. +// Assert.That(attSo.Name, Is.EqualTo(attName)); + + TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID); + TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID); + + // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least + // on Singularity 1.8.5. Otherwise, only one (the first ObjectUpdate sent) appears. + Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID); + } + + private void TestAttachedObject(SceneObjectGroup attSo, AttachmentPoint attPoint, UUID ownerId) + { + Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)attPoint)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); + Assert.That(attSo.OwnerID, Is.EqualTo(ownerId)); + } + + [Test] public void TestLoadAppearance() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + SetUpScene(); + UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); @@ -237,7 +298,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestMove() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); + + SetUpScene(); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -303,11 +366,64 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests } [Test] + public void TestMoveInVarRegion() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + SetUpScene(512, 512); + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); +// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); + + Vector3 startPos = new Vector3(128, 246, 30); + UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); + + ScenePresence npc = m_scene.GetScenePresence(npcId); + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + + // For now, we'll make the scene presence fly to simplify this test, but this needs to change. + npc.Flying = true; + + m_scene.Update(1); + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + + Vector3 targetPos = startPos + new Vector3(0, 20, 0); + m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false); + + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); + Assert.That( + npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); + + m_scene.Update(1); + + // We should really check the exact figure. + Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X)); + Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y)); + Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); + Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X)); + + for (int i = 0; i < 20; i++) + { + m_scene.Update(1); +// Console.WriteLine("pos: {0}", npc.AbsolutePosition); + } + + double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); + Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); + Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); + } + + [Test] public void TestSitAndStandWithSitTarget() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + SetUpScene(); + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); Vector3 startPos = new Vector3(128, 128, 30); @@ -321,9 +437,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); - Assert.That( - npc.AbsolutePosition, - Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); +// Assert.That( +// npc.AbsolutePosition, +// Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); m_npcMod.Stand(npc.UUID, m_scene); @@ -335,7 +451,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestSitAndStandWithNoSitTarget() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); + + SetUpScene(); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); @@ -353,13 +471,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); - // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the - // default avatar. - // Curiously, Vector3.ToString() will not display the last two places of the float. For example, - // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> + // We should really be using the NPC size but this would mean preserving the physics actor since it is + // removed on sit. Assert.That( npc.AbsolutePosition, - Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); + Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2))); m_npcMod.Stand(npc.UUID, m_scene); @@ -367,4 +483,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.ParentID, Is.EqualTo(0)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs index 12169ab..0927c4f 100644 --- a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using log4net; using Mono.Addins; using Nini.Config; @@ -48,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -93,28 +94,44 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments "Debug", this, "debug scene get", "debug scene get", "List current scene options.", - "If active is false then main scene update and maintenance loops are suspended.\n" - + "If animations is true then extra animations debug information is logged.\n" - + "If collisions is false then collisions with other objects are turned off.\n" - + "If pbackup is false then periodic scene backup is turned off.\n" - + "If physics is false then all physics objects are non-physical.\n" - + "If scripting is false then no scripting operations happen.\n" - + "If teleport is true then some extra teleport debug information is logged.\n" - + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", + "active - if false then main scene update and maintenance loops are suspended.\n" + + "animations - if true then extra animations debug information is logged.\n" + + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n" + + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n" + + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" + + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" + + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n" + + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n" + + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n" + + "collisions - if false then collisions with other objects are turned off.\n" + + "pbackup - if false then periodic scene backup is turned off.\n" + + "physics - if false then all physics objects are non-physical.\n" + + "scripting - if false then no scripting operations happen.\n" + + "teleport - if true then some extra teleport debug information is logged.\n" + + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n" + + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", HandleDebugSceneGetCommand); scene.AddCommand( "Debug", this, "debug scene set", - "debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false", + "debug scene set ", "Turn on scene debugging options.", - "If active is false then main scene update and maintenance loops are suspended.\n" - + "If animations is true then extra animations debug information is logged.\n" - + "If collisions is false then collisions with other objects are turned off.\n" - + "If pbackup is false then periodic scene backup is turned off.\n" - + "If physics is false then all physics objects are non-physical.\n" - + "If scripting is false then no scripting operations happen.\n" - + "If teleport is true then some extra teleport debug information is logged.\n" - + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", + "active - if false then main scene update and maintenance loops are suspended.\n" + + "animations - if true then extra animations debug information is logged.\n" + + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n" + + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n" + + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" + + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" + + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n" + + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n" + + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n" + + "collisions - if false then collisions with other objects are turned off.\n" + + "pbackup - if false then periodic scene backup is turned off.\n" + + "physics - if false then all physics objects are non-physical.\n" + + "scripting - if false then no scripting operations happen.\n" + + "teleport - if true then some extra teleport debug information is logged.\n" + + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n" + + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", HandleDebugSceneSetCommand); } @@ -138,10 +155,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.AddRow("active", m_scene.Active); cdl.AddRow("animations", m_scene.DebugAnimations); + cdl.AddRow("appear-refresh", m_scene.SendPeriodicAppearanceUpdates); + cdl.AddRow("child-repri", m_scene.ChildReprioritizationDistance); + cdl.AddRow("client-pos-upd", m_scene.RootPositionUpdateTolerance); + cdl.AddRow("client-rot-upd", m_scene.RootRotationUpdateTolerance); + cdl.AddRow("client-vel-upd", m_scene.RootVelocityUpdateTolerance); + cdl.AddRow("root-upd-per", m_scene.RootTerseUpdatePeriod); + cdl.AddRow("child-upd-per", m_scene.ChildTerseUpdatePeriod); cdl.AddRow("pbackup", m_scene.PeriodicBackup); cdl.AddRow("physics", m_scene.PhysicsEnabled); cdl.AddRow("scripting", m_scene.ScriptsEnabled); cdl.AddRow("teleport", m_scene.DebugTeleporting); + cdl.AddRow("update-on-timer", m_scene.UpdateOnTimer); cdl.AddRow("updates", m_scene.DebugUpdates); MainConsole.Instance.OutputFormat("Scene {0} options:", m_scene.Name); @@ -163,8 +188,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments } else { - MainConsole.Instance.Output( - "Usage: debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false"); + MainConsole.Instance.Output("Usage: debug scene set "); } } @@ -186,6 +210,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments m_scene.DebugAnimations = active; } + if (options.ContainsKey("appear-refresh")) + { + bool newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, options["appear-refresh"], out newValue)) + m_scene.SendPeriodicAppearanceUpdates = newValue; + } + + if (options.ContainsKey("child-repri")) + { + double newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleDouble(MainConsole.Instance, options["child-repri"], out newValue)) + m_scene.ChildReprioritizationDistance = newValue; + } + + if (options.ContainsKey("client-pos-upd")) + { + float newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-pos-upd"], out newValue)) + m_scene.RootPositionUpdateTolerance = newValue; + } + + if (options.ContainsKey("client-rot-upd")) + { + float newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-rot-upd"], out newValue)) + m_scene.RootRotationUpdateTolerance = newValue; + } + + if (options.ContainsKey("client-vel-upd")) + { + float newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-vel-upd"], out newValue)) + m_scene.RootVelocityUpdateTolerance = newValue; + } + + if (options.ContainsKey("root-upd-per")) + { + int newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["root-upd-per"], out newValue)) + m_scene.RootTerseUpdatePeriod = newValue; + } + + if (options.ContainsKey("child-upd-per")) + { + int newValue; + + // FIXME: This can only come from the console at the moment but might not always be true. + if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["child-upd-per"], out newValue)) + m_scene.ChildTerseUpdatePeriod = newValue; + } + if (options.ContainsKey("pbackup")) { bool active; @@ -221,6 +308,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments m_scene.DebugTeleporting = enableTeleportDebugging; } + if (options.ContainsKey("update-on-timer")) + { + bool enableUpdateOnTimer; + if (bool.TryParse(options["update-on-timer"], out enableUpdateOnTimer)) + { + m_scene.UpdateOnTimer = enableUpdateOnTimer; + m_scene.Active = false; + + while (m_scene.IsRunning) + Thread.Sleep(20); + + m_scene.Active = true; + } + } + if (options.ContainsKey("updates")) { bool enableUpdateDebugging; diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index 8144870..e4a3382 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs @@ -748,8 +748,8 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator position.X = s_tree.AbsolutePosition.X + (float)randX; position.Y = s_tree.AbsolutePosition.Y + (float)randY; - if (position.X <= ((int)Constants.RegionSize - 1) && position.X >= 0 && - position.Y <= ((int)Constants.RegionSize - 1) && position.Y >= 0 && + if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 && + position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 && Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) { UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs index 550b5d4..8720cc7 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView m_WorldViewModule = fmodule; } - public override byte[] Handle(string path, Stream requestData, + protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.ContentType = "image/jpeg"; -- cgit v1.1