diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/OptionalModules/World | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
9 files changed, 527 insertions, 113 deletions
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 | |||
76 | /// AutoBackupBusyCheck: True/False. Default: True. | 76 | /// AutoBackupBusyCheck: True/False. Default: True. |
77 | /// If True, we will only take an auto-backup if a set of conditions are met. | 77 | /// If True, we will only take an auto-backup if a set of conditions are met. |
78 | /// These conditions are heuristics to try and avoid taking a backup when the sim is busy. | 78 | /// These conditions are heuristics to try and avoid taking a backup when the sim is busy. |
79 | /// AutoBackupSkipAssets | ||
80 | /// 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 | ||
81 | /// AutoBackupKeepFilesForDays | ||
82 | /// 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 | ||
79 | /// AutoBackupScript: String. Default: not specified (disabled). | 83 | /// AutoBackupScript: String. Default: not specified (disabled). |
80 | /// File path to an executable script or binary to run when an automatic backup is taken. | 84 | /// File path to an executable script or binary to run when an automatic backup is taken. |
81 | /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary. | 85 | /// 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 | |||
111 | 115 | ||
112 | private delegate T DefaultGetter<T>(string settingName, T defaultValue); | 116 | private delegate T DefaultGetter<T>(string settingName, T defaultValue); |
113 | private bool m_enabled; | 117 | private bool m_enabled; |
118 | private ICommandConsole m_console; | ||
119 | private List<Scene> m_Scenes = new List<Scene> (); | ||
120 | |||
114 | 121 | ||
115 | /// <summary> | 122 | /// <summary> |
116 | /// Whether the shared module should be enabled at all. NOT the same as m_Enabled in AutoBackupModuleState! | 123 | /// 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 | |||
202 | /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded. | 209 | /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded. |
203 | /// </summary> | 210 | /// </summary> |
204 | /// <param name="scene"></param> | 211 | /// <param name="scene"></param> |
205 | void IRegionModuleBase.AddRegion(Scene scene) | 212 | void IRegionModuleBase.AddRegion (Scene scene) |
206 | { | 213 | { |
214 | if (!this.m_enabled) { | ||
215 | return; | ||
216 | } | ||
217 | lock (m_Scenes) { | ||
218 | m_Scenes.Add (scene); | ||
219 | } | ||
220 | m_console = MainConsole.Instance; | ||
221 | |||
222 | m_console.Commands.AddCommand ( | ||
223 | "AutoBackup", false, "dobackup", | ||
224 | "dobackup", | ||
225 | "do backup.", DoBackup); | ||
207 | } | 226 | } |
208 | 227 | ||
209 | /// <summary> | 228 | /// <summary> |
@@ -216,7 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
216 | { | 235 | { |
217 | return; | 236 | return; |
218 | } | 237 | } |
219 | 238 | m_Scenes.Remove (scene); | |
220 | if (this.m_states.ContainsKey(scene)) | 239 | if (this.m_states.ContainsKey(scene)) |
221 | { | 240 | { |
222 | AutoBackupModuleState abms = this.m_states[scene]; | 241 | AutoBackupModuleState abms = this.m_states[scene]; |
@@ -258,6 +277,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
258 | AutoBackupModuleState abms = this.ParseConfig(scene, false); | 277 | AutoBackupModuleState abms = this.ParseConfig(scene, false); |
259 | m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); | 278 | m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); |
260 | m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); | 279 | m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); |
280 | |||
281 | m_states.Add(scene, abms); | ||
261 | } | 282 | } |
262 | 283 | ||
263 | /// <summary> | 284 | /// <summary> |
@@ -269,6 +290,28 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
269 | 290 | ||
270 | #endregion | 291 | #endregion |
271 | 292 | ||
293 | private void DoBackup (string module, string[] args) | ||
294 | { | ||
295 | if (args.Length != 2) { | ||
296 | MainConsole.Instance.OutputFormat ("Usage: dobackup <regionname>"); | ||
297 | return; | ||
298 | } | ||
299 | bool found = false; | ||
300 | string name = args [1]; | ||
301 | lock (m_Scenes) { | ||
302 | foreach (Scene s in m_Scenes) { | ||
303 | string test = s.Name.ToString (); | ||
304 | if (test == name) { | ||
305 | found = true; | ||
306 | DoRegionBackup (s); | ||
307 | } | ||
308 | } | ||
309 | if (!found) { | ||
310 | MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name); | ||
311 | } | ||
312 | } | ||
313 | } | ||
314 | |||
272 | /// <summary> | 315 | /// <summary> |
273 | /// Set up internal state for a given scene. Fairly complex code. | 316 | /// Set up internal state for a given scene. Fairly complex code. |
274 | /// When this method returns, we've started auto-backup timers, put members in Dictionaries, and created a State object for this scene. | 317 | /// 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 | |||
334 | double interval = | 377 | double interval = |
335 | this.ResolveDouble("AutoBackupInterval", this.m_defaultState.IntervalMinutes, | 378 | this.ResolveDouble("AutoBackupInterval", this.m_defaultState.IntervalMinutes, |
336 | config, regionConfig) * 60000.0; | 379 | config, regionConfig) * 60000.0; |
337 | if (state == null && interval != this.m_defaultState.IntervalMinutes*60000.0) | 380 | if (state == null && interval != this.m_defaultState.IntervalMinutes * 60000.0) |
338 | { | 381 | { |
339 | state = new AutoBackupModuleState(); | 382 | state = new AutoBackupModuleState(); |
340 | } | 383 | } |
@@ -412,6 +455,32 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
412 | state.BusyCheck = tmpBusyCheck; | 455 | state.BusyCheck = tmpBusyCheck; |
413 | } | 456 | } |
414 | 457 | ||
458 | // Included Option To Skip Assets | ||
459 | bool tmpSkipAssets = ResolveBoolean("AutoBackupSkipAssets", | ||
460 | this.m_defaultState.SkipAssets, config, regionConfig); | ||
461 | if (state == null && tmpSkipAssets != this.m_defaultState.SkipAssets) | ||
462 | { | ||
463 | state = new AutoBackupModuleState(); | ||
464 | } | ||
465 | |||
466 | if (state != null) | ||
467 | { | ||
468 | state.SkipAssets = tmpSkipAssets; | ||
469 | } | ||
470 | |||
471 | // How long to keep backup files in days, 0 Disables this feature | ||
472 | int tmpKeepFilesForDays = ResolveInt("AutoBackupKeepFilesForDays", | ||
473 | this.m_defaultState.KeepFilesForDays, config, regionConfig); | ||
474 | if (state == null && tmpKeepFilesForDays != this.m_defaultState.KeepFilesForDays) | ||
475 | { | ||
476 | state = new AutoBackupModuleState(); | ||
477 | } | ||
478 | |||
479 | if (state != null) | ||
480 | { | ||
481 | state.KeepFilesForDays = tmpKeepFilesForDays; | ||
482 | } | ||
483 | |||
415 | // Set file naming algorithm | 484 | // Set file naming algorithm |
416 | string stmpNamingType = ResolveString("AutoBackupNaming", | 485 | string stmpNamingType = ResolveString("AutoBackupNaming", |
417 | this.m_defaultState.NamingType.ToString(), config, regionConfig); | 486 | this.m_defaultState.NamingType.ToString(), config, regionConfig); |
@@ -480,7 +549,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
480 | catch (Exception e) | 549 | catch (Exception e) |
481 | { | 550 | { |
482 | m_log.Warn( | 551 | m_log.Warn( |
483 | "BAD NEWS. You won't be able to save backups to directory " + | 552 | "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " + |
484 | state.BackupDir + | 553 | state.BackupDir + |
485 | " because it doesn't exist or there's a permissions issue with it. Here's the exception.", | 554 | " because it doesn't exist or there's a permissions issue with it. Here's the exception.", |
486 | e); | 555 | e); |
@@ -488,6 +557,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
488 | } | 557 | } |
489 | } | 558 | } |
490 | 559 | ||
560 | if(state == null) | ||
561 | return m_defaultState; | ||
562 | |||
491 | return state; | 563 | return state; |
492 | } | 564 | } |
493 | 565 | ||
@@ -594,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
594 | bool heuristicsPassed = false; | 666 | bool heuristicsPassed = false; |
595 | if (!this.m_timerMap.ContainsKey((Timer) sender)) | 667 | if (!this.m_timerMap.ContainsKey((Timer) sender)) |
596 | { | 668 | { |
597 | m_log.Debug("Code-up error: timerMap doesn't contain timer " + sender); | 669 | m_log.Debug("[AUTO BACKUP]: Code-up error: timerMap doesn't contain timer " + sender); |
598 | } | 670 | } |
599 | 671 | ||
600 | List<IScene> tmap = this.m_timerMap[(Timer) sender]; | 672 | List<IScene> tmap = this.m_timerMap[(Timer) sender]; |
@@ -630,6 +702,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
630 | } | 702 | } |
631 | this.DoRegionBackup(scene); | 703 | this.DoRegionBackup(scene); |
632 | } | 704 | } |
705 | |||
706 | // Remove Old Backups | ||
707 | this.RemoveOldFiles(state); | ||
633 | } | 708 | } |
634 | } | 709 | } |
635 | } | 710 | } |
@@ -640,7 +715,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
640 | /// <param name="scene"></param> | 715 | /// <param name="scene"></param> |
641 | private void DoRegionBackup(IScene scene) | 716 | private void DoRegionBackup(IScene scene) |
642 | { | 717 | { |
643 | if (scene.RegionStatus != RegionStatus.Up) | 718 | if (!scene.Ready) |
644 | { | 719 | { |
645 | // We won't backup a region that isn't operating normally. | 720 | // We won't backup a region that isn't operating normally. |
646 | m_log.Warn("[AUTO BACKUP]: Not backing up region " + scene.RegionInfo.RegionName + | 721 | m_log.Warn("[AUTO BACKUP]: Not backing up region " + scene.RegionInfo.RegionName + |
@@ -662,7 +737,41 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
662 | m_pendingSaves.Add(guid, scene); | 737 | m_pendingSaves.Add(guid, scene); |
663 | state.LiveRequests.Add(guid, savePath); | 738 | state.LiveRequests.Add(guid, savePath); |
664 | ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved); | 739 | ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved); |
665 | iram.ArchiveRegion(savePath, guid, null); | 740 | |
741 | m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName); | ||
742 | |||
743 | // Must pass options, even if dictionary is empty! | ||
744 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
745 | |||
746 | if (state.SkipAssets) | ||
747 | options["noassets"] = true; | ||
748 | |||
749 | iram.ArchiveRegion(savePath, guid, options); | ||
750 | } | ||
751 | |||
752 | // For the given state, remove backup files older than the states KeepFilesForDays property | ||
753 | private void RemoveOldFiles(AutoBackupModuleState state) | ||
754 | { | ||
755 | // 0 Means Disabled, Keep Files Indefinitely | ||
756 | if (state.KeepFilesForDays > 0) | ||
757 | { | ||
758 | string[] files = Directory.GetFiles(state.BackupDir, "*.oar"); | ||
759 | DateTime CuttOffDate = DateTime.Now.AddDays(0 - state.KeepFilesForDays); | ||
760 | |||
761 | foreach (string file in files) | ||
762 | { | ||
763 | try | ||
764 | { | ||
765 | FileInfo fi = new FileInfo(file); | ||
766 | if (fi.CreationTime < CuttOffDate) | ||
767 | fi.Delete(); | ||
768 | } | ||
769 | catch (Exception Ex) | ||
770 | { | ||
771 | m_log.Error("[AUTO BACKUP]: Error deleting old backup file '" + file + "': " + Ex.Message); | ||
772 | } | ||
773 | } | ||
774 | } | ||
666 | } | 775 | } |
667 | 776 | ||
668 | /// <summary> | 777 | /// <summary> |
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 | |||
45 | this.Enabled = false; | 45 | this.Enabled = false; |
46 | this.BackupDir = "."; | 46 | this.BackupDir = "."; |
47 | this.BusyCheck = true; | 47 | this.BusyCheck = true; |
48 | this.SkipAssets = false; | ||
48 | this.Timer = null; | 49 | this.Timer = null; |
49 | this.NamingType = NamingType.Time; | 50 | this.NamingType = NamingType.Time; |
50 | this.Script = null; | 51 | this.Script = null; |
52 | this.KeepFilesForDays = 0; | ||
51 | } | 53 | } |
52 | 54 | ||
53 | public Dictionary<Guid, string> LiveRequests | 55 | public Dictionary<Guid, string> LiveRequests |
@@ -91,6 +93,12 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
91 | set; | 93 | set; |
92 | } | 94 | } |
93 | 95 | ||
96 | public bool SkipAssets | ||
97 | { | ||
98 | get; | ||
99 | set; | ||
100 | } | ||
101 | |||
94 | public string Script | 102 | public string Script |
95 | { | 103 | { |
96 | get; | 104 | get; |
@@ -109,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
109 | set; | 117 | set; |
110 | } | 118 | } |
111 | 119 | ||
120 | public int KeepFilesForDays | ||
121 | { | ||
122 | get; | ||
123 | set; | ||
124 | } | ||
125 | |||
112 | public new string ToString() | 126 | public new string ToString() |
113 | { | 127 | { |
114 | string retval = ""; | 128 | 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 | |||
103 | 103 | ||
104 | #region IMoneyModule Members | 104 | #region IMoneyModule Members |
105 | 105 | ||
106 | #pragma warning disable 0067 | ||
106 | public event ObjectPaid OnObjectPaid; | 107 | public event ObjectPaid OnObjectPaid; |
108 | #pragma warning restore 0067 | ||
107 | 109 | ||
108 | public int UploadCharge | 110 | public int UploadCharge |
109 | { | 111 | { |
@@ -191,9 +193,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
191 | // Please do not refactor these to be just one method | 193 | // Please do not refactor these to be just one method |
192 | // Existing implementations need the distinction | 194 | // Existing implementations need the distinction |
193 | // | 195 | // |
194 | public void ApplyCharge(UUID agentID, int amount, string text) | 196 | public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData) |
195 | { | 197 | { |
196 | } | 198 | } |
199 | |||
200 | public void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type) | ||
201 | { | ||
202 | } | ||
203 | |||
197 | public void ApplyUploadCharge(UUID agentID, int amount, string text) | 204 | public void ApplyUploadCharge(UUID agentID, int amount, string text) |
198 | { | 205 | { |
199 | } | 206 | } |
@@ -322,7 +329,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
322 | client.SendAlertMessage(e.Message + " "); | 329 | client.SendAlertMessage(e.Message + " "); |
323 | } | 330 | } |
324 | 331 | ||
325 | client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds); | 332 | client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds, 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); |
326 | } | 333 | } |
327 | else | 334 | else |
328 | { | 335 | { |
@@ -385,12 +392,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
385 | { | 392 | { |
386 | if (sender != null) | 393 | if (sender != null) |
387 | { | 394 | { |
388 | sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID)); | 395 | sender.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(senderID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); |
389 | } | 396 | } |
390 | 397 | ||
391 | if (receiver != null) | 398 | if (receiver != null) |
392 | { | 399 | { |
393 | receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID)); | 400 | receiver.SendMoneyBalance(UUID.Random(), transactionresult, Utils.StringToBytes(description), GetFundsForAgentID(receiverID), 0, UUID.Zero, false, UUID.Zero, false, 0, String.Empty); |
394 | } | 401 | } |
395 | } | 402 | } |
396 | } | 403 | } |
@@ -555,7 +562,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
555 | /// <returns></returns> | 562 | /// <returns></returns> |
556 | private int GetFundsForAgentID(UUID AgentID) | 563 | private int GetFundsForAgentID(UUID AgentID) |
557 | { | 564 | { |
558 | int returnfunds = 75004; // Set it to the OpenSim version, plus the IG build number. Muahahaha; | 565 | int returnfunds = 0; |
559 | 566 | ||
560 | return returnfunds; | 567 | return returnfunds; |
561 | } | 568 | } |
@@ -688,19 +695,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
688 | /// Event called Economy Data Request handler. | 695 | /// Event called Economy Data Request handler. |
689 | /// </summary> | 696 | /// </summary> |
690 | /// <param name="agentId"></param> | 697 | /// <param name="agentId"></param> |
691 | public void EconomyDataRequestHandler(UUID agentId) | 698 | public void EconomyDataRequestHandler(IClientAPI user) |
692 | { | 699 | { |
693 | IClientAPI user = LocateClientObject(agentId); | 700 | Scene s = (Scene)user.Scene; |
694 | 701 | ||
695 | if (user != null) | 702 | user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, |
696 | { | 703 | PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, |
697 | Scene s = LocateSceneClientIn(user.AgentId); | 704 | PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, |
698 | 705 | TeleportMinPrice, TeleportPriceExponent); | |
699 | user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, | ||
700 | PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, | ||
701 | PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, | ||
702 | TeleportMinPrice, TeleportPriceExponent); | ||
703 | } | ||
704 | } | 706 | } |
705 | 707 | ||
706 | private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) | 708 | 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 | |||
44 | { | 44 | { |
45 | public bool SenseAsAgent { get; set; } | 45 | public bool SenseAsAgent { get; set; } |
46 | 46 | ||
47 | public delegate void ChatToNPC( | ||
48 | string message, byte type, Vector3 fromPos, string fromName, | ||
49 | UUID fromAgentID, UUID ownerID, byte source, byte audible); | ||
50 | |||
51 | /// <summary> | ||
52 | /// Fired when the NPC receives a chat message. | ||
53 | /// </summary> | ||
54 | public event ChatToNPC OnChatToNPC; | ||
55 | |||
56 | /// <summary> | ||
57 | /// Fired when the NPC receives an instant message. | ||
58 | /// </summary> | ||
59 | public event Action<GridInstantMessage> OnInstantMessageToNPC; | ||
60 | |||
47 | private readonly string m_firstname; | 61 | private readonly string m_firstname; |
48 | private readonly string m_lastname; | 62 | private readonly string m_lastname; |
49 | private readonly Vector3 m_startPos; | 63 | private readonly Vector3 m_startPos; |
50 | private readonly UUID m_uuid = UUID.Random(); | 64 | private readonly UUID m_uuid; |
51 | private readonly Scene m_scene; | 65 | private readonly Scene m_scene; |
52 | private readonly UUID m_ownerID; | 66 | private readonly UUID m_ownerID; |
53 | 67 | ||
@@ -57,6 +71,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
57 | m_firstname = firstname; | 71 | m_firstname = firstname; |
58 | m_lastname = lastname; | 72 | m_lastname = lastname; |
59 | m_startPos = position; | 73 | m_startPos = position; |
74 | m_uuid = UUID.Random(); | ||
75 | m_scene = scene; | ||
76 | m_ownerID = ownerID; | ||
77 | SenseAsAgent = senseAsAgent; | ||
78 | } | ||
79 | |||
80 | public NPCAvatar( | ||
81 | string firstname, string lastname, UUID agentID, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) | ||
82 | { | ||
83 | m_firstname = firstname; | ||
84 | m_lastname = lastname; | ||
85 | m_startPos = position; | ||
86 | m_uuid = agentID; | ||
60 | m_scene = scene; | 87 | m_scene = scene; |
61 | m_ownerID = ownerID; | 88 | m_ownerID = ownerID; |
62 | SenseAsAgent = senseAsAgent; | 89 | SenseAsAgent = senseAsAgent; |
@@ -258,6 +285,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
258 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 285 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
259 | public event UpdateAgent OnPreAgentUpdate; | 286 | public event UpdateAgent OnPreAgentUpdate; |
260 | public event UpdateAgent OnAgentUpdate; | 287 | public event UpdateAgent OnAgentUpdate; |
288 | public event UpdateAgent OnAgentCameraUpdate; | ||
261 | public event AgentRequestSit OnAgentRequestSit; | 289 | public event AgentRequestSit OnAgentRequestSit; |
262 | public event AgentSit OnAgentSit; | 290 | public event AgentSit OnAgentSit; |
263 | public event AvatarPickerRequest OnAvatarPickerRequest; | 291 | public event AvatarPickerRequest OnAvatarPickerRequest; |
@@ -391,6 +419,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
391 | public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; | 419 | public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; |
392 | public event EstateChangeInfo OnEstateChangeInfo; | 420 | public event EstateChangeInfo OnEstateChangeInfo; |
393 | public event EstateManageTelehub OnEstateManageTelehub; | 421 | public event EstateManageTelehub OnEstateManageTelehub; |
422 | public event CachedTextureRequest OnCachedTextureRequest; | ||
394 | public event ScriptReset OnScriptReset; | 423 | public event ScriptReset OnScriptReset; |
395 | public event GetScriptRunning OnGetScriptRunning; | 424 | public event GetScriptRunning OnGetScriptRunning; |
396 | public event SetScriptRunning OnSetScriptRunning; | 425 | public event SetScriptRunning OnSetScriptRunning; |
@@ -569,6 +598,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
569 | { | 598 | { |
570 | } | 599 | } |
571 | 600 | ||
601 | public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures) | ||
602 | { | ||
603 | |||
604 | } | ||
605 | |||
572 | public virtual void Kick(string message) | 606 | public virtual void Kick(string message) |
573 | { | 607 | { |
574 | } | 608 | } |
@@ -586,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
586 | 620 | ||
587 | } | 621 | } |
588 | 622 | ||
589 | public virtual void SendKillObject(ulong regionHandle, List<uint> localID) | 623 | public virtual void SendKillObject(List<uint> localID) |
590 | { | 624 | { |
591 | } | 625 | } |
592 | 626 | ||
@@ -607,25 +641,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
607 | string message, byte type, Vector3 fromPos, string fromName, | 641 | string message, byte type, Vector3 fromPos, string fromName, |
608 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | 642 | UUID fromAgentID, UUID ownerID, byte source, byte audible) |
609 | { | 643 | { |
610 | } | 644 | ChatToNPC ctn = OnChatToNPC; |
611 | 645 | ||
612 | public virtual void SendChatMessage( | 646 | if (ctn != null) |
613 | byte[] message, byte type, Vector3 fromPos, string fromName, | 647 | ctn(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); |
614 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | ||
615 | { | ||
616 | } | 648 | } |
617 | 649 | ||
618 | public void SendInstantMessage(GridInstantMessage im) | 650 | public void SendInstantMessage(GridInstantMessage im) |
619 | { | 651 | { |
620 | 652 | Action<GridInstantMessage> oimtn = OnInstantMessageToNPC; | |
653 | |||
654 | if (oimtn != null) | ||
655 | oimtn(im); | ||
621 | } | 656 | } |
622 | 657 | ||
623 | public void SendGenericMessage(string method, List<string> message) | 658 | public void SendGenericMessage(string method, UUID invoice, List<string> message) |
624 | { | 659 | { |
625 | 660 | ||
626 | } | 661 | } |
627 | 662 | ||
628 | public void SendGenericMessage(string method, List<byte[]> message) | 663 | public void SendGenericMessage(string method, UUID invoice, List<byte[]> message) |
629 | { | 664 | { |
630 | 665 | ||
631 | } | 666 | } |
@@ -688,7 +723,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
688 | { | 723 | { |
689 | } | 724 | } |
690 | 725 | ||
691 | public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance) | 726 | 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) |
692 | { | 727 | { |
693 | } | 728 | } |
694 | 729 | ||
@@ -860,11 +895,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
860 | { | 895 | { |
861 | } | 896 | } |
862 | 897 | ||
863 | public bool AddMoney(int debit) | ||
864 | { | ||
865 | return false; | ||
866 | } | ||
867 | |||
868 | public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) | 898 | public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) |
869 | { | 899 | { |
870 | } | 900 | } |
@@ -1227,12 +1257,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
1227 | { | 1257 | { |
1228 | } | 1258 | } |
1229 | 1259 | ||
1230 | public void StopFlying(ISceneEntity presence) | 1260 | public void SendAgentTerseUpdate(ISceneEntity presence) |
1231 | { | 1261 | { |
1232 | } | 1262 | } |
1233 | 1263 | ||
1234 | public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) | 1264 | public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) |
1235 | { | 1265 | { |
1236 | } | 1266 | } |
1267 | |||
1268 | public void SendPartPhysicsProprieties(ISceneEntity entity) | ||
1269 | { | ||
1270 | } | ||
1271 | |||
1237 | } | 1272 | } |
1238 | } | 1273 | } |
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 | |||
116 | return false; | 116 | return false; |
117 | 117 | ||
118 | // Delete existing npc attachments | 118 | // Delete existing npc attachments |
119 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); | 119 | if(scene.AttachmentsModule != null) |
120 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); | ||
120 | 121 | ||
121 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet | 122 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet |
122 | // since it doesn't transfer attachments | 123 | // since it doesn't transfer attachments |
@@ -125,7 +126,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
125 | npc.Appearance = npcAppearance; | 126 | npc.Appearance = npcAppearance; |
126 | 127 | ||
127 | // Rez needed npc attachments | 128 | // Rez needed npc attachments |
128 | scene.AttachmentsModule.RezAttachments(npc); | 129 | if (scene.AttachmentsModule != null) |
130 | scene.AttachmentsModule.RezAttachments(npc); | ||
129 | 131 | ||
130 | IAvatarFactoryModule module = | 132 | IAvatarFactoryModule module = |
131 | scene.RequestModuleInterface<IAvatarFactoryModule>(); | 133 | scene.RequestModuleInterface<IAvatarFactoryModule>(); |
@@ -138,15 +140,37 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
138 | Vector3 position, UUID owner, bool senseAsAgent, Scene scene, | 140 | Vector3 position, UUID owner, bool senseAsAgent, Scene scene, |
139 | AvatarAppearance appearance) | 141 | AvatarAppearance appearance) |
140 | { | 142 | { |
141 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, | 143 | return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance); |
142 | owner, senseAsAgent, scene); | 144 | } |
145 | |||
146 | public UUID CreateNPC(string firstname, string lastname, | ||
147 | Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, | ||
148 | AvatarAppearance appearance) | ||
149 | { | ||
150 | NPCAvatar npcAvatar = null; | ||
151 | |||
152 | try | ||
153 | { | ||
154 | if (agentID == UUID.Zero) | ||
155 | npcAvatar = new NPCAvatar(firstname, lastname, position, | ||
156 | owner, senseAsAgent, scene); | ||
157 | else | ||
158 | npcAvatar = new NPCAvatar(firstname, lastname, agentID, position, | ||
159 | owner, senseAsAgent, scene); | ||
160 | } | ||
161 | catch (Exception e) | ||
162 | { | ||
163 | m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString()); | ||
164 | return UUID.Zero; | ||
165 | } | ||
166 | |||
143 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, | 167 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, |
144 | int.MaxValue); | 168 | int.MaxValue); |
145 | 169 | ||
146 | m_log.DebugFormat( | 170 | m_log.DebugFormat( |
147 | "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", | 171 | "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", |
148 | firstname, lastname, npcAvatar.AgentId, owner, | 172 | firstname, lastname, npcAvatar.AgentId, owner, |
149 | senseAsAgent, position, scene.RegionInfo.RegionName); | 173 | senseAsAgent, position, scene.RegionInfo.RegionName); |
150 | 174 | ||
151 | AgentCircuitData acd = new AgentCircuitData(); | 175 | AgentCircuitData acd = new AgentCircuitData(); |
152 | acd.AgentID = npcAvatar.AgentId; | 176 | acd.AgentID = npcAvatar.AgentId; |
@@ -154,8 +178,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
154 | acd.lastname = lastname; | 178 | acd.lastname = lastname; |
155 | acd.ServiceURLs = new Dictionary<string, object>(); | 179 | acd.ServiceURLs = new Dictionary<string, object>(); |
156 | 180 | ||
157 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, | 181 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); |
158 | true); | ||
159 | acd.Appearance = npcAppearance; | 182 | acd.Appearance = npcAppearance; |
160 | 183 | ||
161 | /* | 184 | /* |
@@ -173,7 +196,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
173 | { | 196 | { |
174 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, | 197 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, |
175 | acd); | 198 | acd); |
176 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | 199 | scene.AddNewAgent(npcAvatar, PresenceType.Npc); |
177 | 200 | ||
178 | ScenePresence sp; | 201 | ScenePresence sp; |
179 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 202 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
@@ -186,16 +209,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
186 | 209 | ||
187 | sp.CompleteMovement(npcAvatar, false); | 210 | sp.CompleteMovement(npcAvatar, false); |
188 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 211 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
189 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", | 212 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); |
190 | npcAvatar.AgentId, sp.Name); | ||
191 | 213 | ||
192 | return npcAvatar.AgentId; | 214 | return npcAvatar.AgentId; |
193 | } | 215 | } |
194 | else | 216 | else |
195 | { | 217 | { |
196 | m_log.WarnFormat( | 218 | m_log.WarnFormat( |
197 | "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", | 219 | "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", |
198 | sp.Name, sp.UUID); | 220 | sp.Name, sp.UUID); |
221 | |||
199 | return UUID.Zero; | 222 | return UUID.Zero; |
200 | } | 223 | } |
201 | } | 224 | } |
@@ -211,12 +234,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
211 | ScenePresence sp; | 234 | ScenePresence sp; |
212 | if (scene.TryGetScenePresence(agentID, out sp)) | 235 | if (scene.TryGetScenePresence(agentID, out sp)) |
213 | { | 236 | { |
214 | /* | 237 | if (sp.IsSatOnObject || sp.SitGround) |
215 | m_log.DebugFormat( | 238 | return false; |
216 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 239 | |
217 | sp.Name, pos, scene.RegionInfo.RegionName, | 240 | // m_log.DebugFormat( |
218 | noFly, landAtTarget); | 241 | // "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
219 | */ | 242 | // sp.Name, pos, scene.RegionInfo.RegionName, |
243 | // noFly, landAtTarget); | ||
220 | 244 | ||
221 | sp.MoveToTarget(pos, noFly, landAtTarget); | 245 | sp.MoveToTarget(pos, noFly, landAtTarget); |
222 | sp.SetAlwaysRun = running; | 246 | sp.SetAlwaysRun = running; |
@@ -293,9 +317,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
293 | ScenePresence sp; | 317 | ScenePresence sp; |
294 | if (scene.TryGetScenePresence(agentID, out sp)) | 318 | if (scene.TryGetScenePresence(agentID, out sp)) |
295 | { | 319 | { |
296 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, | 320 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); |
297 | partID, Vector3.Zero); | ||
298 | //sp.HandleAgentSit(m_avatars[agentID], agentID); | ||
299 | 321 | ||
300 | return true; | 322 | return true; |
301 | } | 323 | } |
@@ -376,23 +398,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
376 | 398 | ||
377 | public bool DeleteNPC(UUID agentID, Scene scene) | 399 | public bool DeleteNPC(UUID agentID, Scene scene) |
378 | { | 400 | { |
401 | bool doRemove = false; | ||
402 | NPCAvatar av; | ||
379 | lock (m_avatars) | 403 | lock (m_avatars) |
380 | { | 404 | { |
381 | NPCAvatar av; | ||
382 | if (m_avatars.TryGetValue(agentID, out av)) | 405 | if (m_avatars.TryGetValue(agentID, out av)) |
383 | { | 406 | { |
384 | /* | 407 | /* |
385 | m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", | 408 | m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", |
386 | agentID, av.Name); | 409 | agentID, av.Name); |
387 | */ | 410 | */ |
388 | scene.RemoveClient(agentID, false); | 411 | doRemove = true; |
412 | } | ||
413 | } | ||
414 | |||
415 | if (doRemove) | ||
416 | { | ||
417 | scene.CloseAgent(agentID, false); | ||
418 | lock (m_avatars) | ||
419 | { | ||
389 | m_avatars.Remove(agentID); | 420 | m_avatars.Remove(agentID); |
390 | /* | ||
391 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", | ||
392 | agentID, av.Name); | ||
393 | */ | ||
394 | return true; | ||
395 | } | 421 | } |
422 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", | ||
423 | agentID, av.Name); | ||
424 | return true; | ||
396 | } | 425 | } |
397 | /* | 426 | /* |
398 | m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", | 427 | m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", |
@@ -416,13 +445,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
416 | /// <summary> | 445 | /// <summary> |
417 | /// Check if the caller has permission to manipulate the given NPC. | 446 | /// Check if the caller has permission to manipulate the given NPC. |
418 | /// </summary> | 447 | /// </summary> |
448 | /// <remarks> | ||
449 | /// A caller has permission if | ||
450 | /// * The caller UUID given is UUID.Zero. | ||
451 | /// * The avatar is unowned (owner is UUID.Zero). | ||
452 | /// * The avatar is owned and the owner and callerID match. | ||
453 | /// * The avatar is owned and the callerID matches its agentID. | ||
454 | /// </remarks> | ||
419 | /// <param name="av"></param> | 455 | /// <param name="av"></param> |
420 | /// <param name="callerID"></param> | 456 | /// <param name="callerID"></param> |
421 | /// <returns>true if they do, false if they don't.</returns> | 457 | /// <returns>true if they do, false if they don't.</returns> |
422 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | 458 | private bool CheckPermissions(NPCAvatar av, UUID callerID) |
423 | { | 459 | { |
424 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || | 460 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || |
425 | av.OwnerID == callerID; | 461 | av.OwnerID == callerID || av.AgentId == callerID; |
426 | } | 462 | } |
427 | } | 463 | } |
428 | } | 464 | } |
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; | |||
33 | using NUnit.Framework; | 33 | using NUnit.Framework; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | ||
37 | using OpenSim.Region.CoreModules.Avatar.Attachments; | 36 | using OpenSim.Region.CoreModules.Avatar.Attachments; |
38 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 37 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
39 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | 38 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
@@ -43,7 +42,6 @@ using OpenSim.Region.Framework.Interfaces; | |||
43 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Services.AvatarService; | 43 | using OpenSim.Services.AvatarService; |
45 | using OpenSim.Tests.Common; | 44 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | ||
47 | 45 | ||
48 | namespace OpenSim.Region.OptionalModules.World.NPC.Tests | 46 | namespace OpenSim.Region.OptionalModules.World.NPC.Tests |
49 | { | 47 | { |
@@ -71,11 +69,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
71 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 69 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
72 | } | 70 | } |
73 | 71 | ||
74 | [SetUp] | 72 | public void SetUpScene() |
75 | public void Init() | ||
76 | { | 73 | { |
77 | base.SetUp(); | 74 | SetUpScene(256, 256); |
75 | } | ||
78 | 76 | ||
77 | public void SetUpScene(uint sizeX, uint sizeY) | ||
78 | { | ||
79 | IConfigSource config = new IniConfigSource(); | 79 | IConfigSource config = new IniConfigSource(); |
80 | config.AddConfig("NPC"); | 80 | config.AddConfig("NPC"); |
81 | config.Configs["NPC"].Set("Enabled", "true"); | 81 | config.Configs["NPC"].Set("Enabled", "true"); |
@@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
87 | m_attMod = new AttachmentsModule(); | 87 | m_attMod = new AttachmentsModule(); |
88 | m_npcMod = new NPCModule(); | 88 | m_npcMod = new NPCModule(); |
89 | 89 | ||
90 | m_scene = new SceneHelpers().SetupScene(); | 90 | m_scene = new SceneHelpers().SetupScene("test scene", UUID.Random(), 1000, 1000, sizeX, sizeY, config); |
91 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); | 91 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); |
92 | } | 92 | } |
93 | 93 | ||
@@ -97,6 +97,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
97 | TestHelpers.InMethod(); | 97 | TestHelpers.InMethod(); |
98 | // log4net.Config.XmlConfigurator.Configure(); | 98 | // log4net.Config.XmlConfigurator.Configure(); |
99 | 99 | ||
100 | SetUpScene(); | ||
101 | |||
100 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 102 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
101 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 103 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
102 | 104 | ||
@@ -110,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
110 | // ScenePresence.SendInitialData() to reset our entire appearance. | 112 | // ScenePresence.SendInitialData() to reset our entire appearance. |
111 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); | 113 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); |
112 | 114 | ||
113 | m_afMod.SetAppearance(sp, originalTe, null); | 115 | m_afMod.SetAppearance(sp, originalTe, null, null); |
114 | 116 | ||
115 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); | 117 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); |
116 | 118 | ||
@@ -133,6 +135,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
133 | TestHelpers.InMethod(); | 135 | TestHelpers.InMethod(); |
134 | // log4net.Config.XmlConfigurator.Configure(); | 136 | // log4net.Config.XmlConfigurator.Configure(); |
135 | 137 | ||
138 | SetUpScene(); | ||
139 | |||
136 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 140 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
137 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 141 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
138 | 142 | ||
@@ -155,7 +159,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
155 | public void TestCreateWithAttachments() | 159 | public void TestCreateWithAttachments() |
156 | { | 160 | { |
157 | TestHelpers.InMethod(); | 161 | TestHelpers.InMethod(); |
158 | // log4net.Config.XmlConfigurator.Configure(); | 162 | // TestHelpers.EnableLogging(); |
163 | |||
164 | SetUpScene(); | ||
159 | 165 | ||
160 | UUID userId = TestHelpers.ParseTail(0x1); | 166 | UUID userId = TestHelpers.ParseTail(0x1); |
161 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | 167 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); |
@@ -191,11 +197,66 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
191 | } | 197 | } |
192 | 198 | ||
193 | [Test] | 199 | [Test] |
200 | public void TestCreateWithMultiAttachments() | ||
201 | { | ||
202 | TestHelpers.InMethod(); | ||
203 | // TestHelpers.EnableLogging(); | ||
204 | |||
205 | SetUpScene(); | ||
206 | // m_attMod.DebugLevel = 1; | ||
207 | |||
208 | UUID userId = TestHelpers.ParseTail(0x1); | ||
209 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | ||
210 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
211 | |||
212 | InventoryItemBase att1Item | ||
213 | = UserInventoryHelpers.CreateInventoryItem( | ||
214 | m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); | ||
215 | InventoryItemBase att2Item | ||
216 | = UserInventoryHelpers.CreateInventoryItem( | ||
217 | m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); | ||
218 | |||
219 | m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest); | ||
220 | m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80); | ||
221 | |||
222 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); | ||
223 | |||
224 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
225 | |||
226 | // Check scene presence status | ||
227 | Assert.That(npc.HasAttachments(), Is.True); | ||
228 | List<SceneObjectGroup> attachments = npc.GetAttachments(); | ||
229 | Assert.That(attachments.Count, Is.EqualTo(2)); | ||
230 | |||
231 | // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item | ||
232 | // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. | ||
233 | // Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
234 | |||
235 | TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID); | ||
236 | TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID); | ||
237 | |||
238 | // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least | ||
239 | // on Singularity 1.8.5. Otherwise, only one (the first ObjectUpdate sent) appears. | ||
240 | Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID); | ||
241 | } | ||
242 | |||
243 | private void TestAttachedObject(SceneObjectGroup attSo, AttachmentPoint attPoint, UUID ownerId) | ||
244 | { | ||
245 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)attPoint)); | ||
246 | Assert.That(attSo.IsAttachment); | ||
247 | Assert.That(attSo.UsesPhysics, Is.False); | ||
248 | Assert.That(attSo.IsTemporary, Is.False); | ||
249 | Assert.That(attSo.OwnerID, Is.EqualTo(ownerId)); | ||
250 | } | ||
251 | |||
252 | [Test] | ||
194 | public void TestLoadAppearance() | 253 | public void TestLoadAppearance() |
195 | { | 254 | { |
196 | TestHelpers.InMethod(); | 255 | TestHelpers.InMethod(); |
197 | // log4net.Config.XmlConfigurator.Configure(); | 256 | // log4net.Config.XmlConfigurator.Configure(); |
198 | 257 | ||
258 | SetUpScene(); | ||
259 | |||
199 | UUID userId = TestHelpers.ParseTail(0x1); | 260 | UUID userId = TestHelpers.ParseTail(0x1); |
200 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | 261 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); |
201 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | 262 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); |
@@ -237,7 +298,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
237 | public void TestMove() | 298 | public void TestMove() |
238 | { | 299 | { |
239 | TestHelpers.InMethod(); | 300 | TestHelpers.InMethod(); |
240 | // log4net.Config.XmlConfigurator.Configure(); | 301 | // TestHelpers.EnableLogging(); |
302 | |||
303 | SetUpScene(); | ||
241 | 304 | ||
242 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 305 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
243 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 306 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
@@ -303,11 +366,64 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
303 | } | 366 | } |
304 | 367 | ||
305 | [Test] | 368 | [Test] |
369 | public void TestMoveInVarRegion() | ||
370 | { | ||
371 | TestHelpers.InMethod(); | ||
372 | // TestHelpers.EnableLogging(); | ||
373 | |||
374 | SetUpScene(512, 512); | ||
375 | |||
376 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | ||
377 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | ||
378 | |||
379 | Vector3 startPos = new Vector3(128, 246, 30); | ||
380 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | ||
381 | |||
382 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
383 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
384 | |||
385 | // For now, we'll make the scene presence fly to simplify this test, but this needs to change. | ||
386 | npc.Flying = true; | ||
387 | |||
388 | m_scene.Update(1); | ||
389 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
390 | |||
391 | Vector3 targetPos = startPos + new Vector3(0, 20, 0); | ||
392 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false); | ||
393 | |||
394 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
395 | //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); | ||
396 | Assert.That( | ||
397 | npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); | ||
398 | |||
399 | m_scene.Update(1); | ||
400 | |||
401 | // We should really check the exact figure. | ||
402 | Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X)); | ||
403 | Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y)); | ||
404 | Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); | ||
405 | Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X)); | ||
406 | |||
407 | for (int i = 0; i < 20; i++) | ||
408 | { | ||
409 | m_scene.Update(1); | ||
410 | // Console.WriteLine("pos: {0}", npc.AbsolutePosition); | ||
411 | } | ||
412 | |||
413 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); | ||
414 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); | ||
415 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); | ||
416 | Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); | ||
417 | } | ||
418 | |||
419 | [Test] | ||
306 | public void TestSitAndStandWithSitTarget() | 420 | public void TestSitAndStandWithSitTarget() |
307 | { | 421 | { |
308 | TestHelpers.InMethod(); | 422 | TestHelpers.InMethod(); |
309 | // log4net.Config.XmlConfigurator.Configure(); | 423 | // log4net.Config.XmlConfigurator.Configure(); |
310 | 424 | ||
425 | SetUpScene(); | ||
426 | |||
311 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 427 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
312 | 428 | ||
313 | Vector3 startPos = new Vector3(128, 128, 30); | 429 | Vector3 startPos = new Vector3(128, 128, 30); |
@@ -321,9 +437,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
321 | 437 | ||
322 | Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); | 438 | Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); |
323 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); | 439 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); |
324 | Assert.That( | 440 | // Assert.That( |
325 | npc.AbsolutePosition, | 441 | // npc.AbsolutePosition, |
326 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | 442 | // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); |
327 | 443 | ||
328 | m_npcMod.Stand(npc.UUID, m_scene); | 444 | m_npcMod.Stand(npc.UUID, m_scene); |
329 | 445 | ||
@@ -335,7 +451,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
335 | public void TestSitAndStandWithNoSitTarget() | 451 | public void TestSitAndStandWithNoSitTarget() |
336 | { | 452 | { |
337 | TestHelpers.InMethod(); | 453 | TestHelpers.InMethod(); |
338 | // log4net.Config.XmlConfigurator.Configure(); | 454 | // TestHelpers.EnableLogging(); |
455 | |||
456 | SetUpScene(); | ||
339 | 457 | ||
340 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 458 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
341 | 459 | ||
@@ -353,13 +471,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
353 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | 471 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
354 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); | 472 | Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); |
355 | 473 | ||
356 | // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the | 474 | // We should really be using the NPC size but this would mean preserving the physics actor since it is |
357 | // default avatar. | 475 | // removed on sit. |
358 | // Curiously, Vector3.ToString() will not display the last two places of the float. For example, | ||
359 | // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> | ||
360 | Assert.That( | 476 | Assert.That( |
361 | npc.AbsolutePosition, | 477 | npc.AbsolutePosition, |
362 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); | 478 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2))); |
363 | 479 | ||
364 | m_npcMod.Stand(npc.UUID, m_scene); | 480 | m_npcMod.Stand(npc.UUID, m_scene); |
365 | 481 | ||
@@ -367,4 +483,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
367 | Assert.That(npc.ParentID, Is.EqualTo(0)); | 483 | Assert.That(npc.ParentID, Is.EqualTo(0)); |
368 | } | 484 | } |
369 | } | 485 | } |
370 | } | 486 | } \ 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; | |||
30 | using System.Linq; | 30 | using System.Linq; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Threading; | ||
33 | using log4net; | 34 | using log4net; |
34 | using Mono.Addins; | 35 | using Mono.Addins; |
35 | using Nini.Config; | 36 | using Nini.Config; |
@@ -48,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] | 49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] |
49 | public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule | 50 | public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule |
50 | { | 51 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 53 | ||
53 | private Scene m_scene; | 54 | private Scene m_scene; |
54 | 55 | ||
@@ -93,28 +94,44 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
93 | "Debug", this, "debug scene get", | 94 | "Debug", this, "debug scene get", |
94 | "debug scene get", | 95 | "debug scene get", |
95 | "List current scene options.", | 96 | "List current scene options.", |
96 | "If active is false then main scene update and maintenance loops are suspended.\n" | 97 | "active - if false then main scene update and maintenance loops are suspended.\n" |
97 | + "If animations is true then extra animations debug information is logged.\n" | 98 | + "animations - if true then extra animations debug information is logged.\n" |
98 | + "If collisions is false then collisions with other objects are turned off.\n" | 99 | + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n" |
99 | + "If pbackup is false then periodic scene backup is turned off.\n" | 100 | + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n" |
100 | + "If physics is false then all physics objects are non-physical.\n" | 101 | + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" |
101 | + "If scripting is false then no scripting operations happen.\n" | 102 | + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" |
102 | + "If teleport is true then some extra teleport debug information is logged.\n" | 103 | + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n" |
103 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", | 104 | + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n" |
105 | + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n" | ||
106 | + "collisions - if false then collisions with other objects are turned off.\n" | ||
107 | + "pbackup - if false then periodic scene backup is turned off.\n" | ||
108 | + "physics - if false then all physics objects are non-physical.\n" | ||
109 | + "scripting - if false then no scripting operations happen.\n" | ||
110 | + "teleport - if true then some extra teleport debug information is logged.\n" | ||
111 | + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n" | ||
112 | + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", | ||
104 | HandleDebugSceneGetCommand); | 113 | HandleDebugSceneGetCommand); |
105 | 114 | ||
106 | scene.AddCommand( | 115 | scene.AddCommand( |
107 | "Debug", this, "debug scene set", | 116 | "Debug", this, "debug scene set", |
108 | "debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false", | 117 | "debug scene set <param> <value>", |
109 | "Turn on scene debugging options.", | 118 | "Turn on scene debugging options.", |
110 | "If active is false then main scene update and maintenance loops are suspended.\n" | 119 | "active - if false then main scene update and maintenance loops are suspended.\n" |
111 | + "If animations is true then extra animations debug information is logged.\n" | 120 | + "animations - if true then extra animations debug information is logged.\n" |
112 | + "If collisions is false then collisions with other objects are turned off.\n" | 121 | + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n" |
113 | + "If pbackup is false then periodic scene backup is turned off.\n" | 122 | + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n" |
114 | + "If physics is false then all physics objects are non-physical.\n" | 123 | + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" |
115 | + "If scripting is false then no scripting operations happen.\n" | 124 | + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n" |
116 | + "If teleport is true then some extra teleport debug information is logged.\n" | 125 | + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n" |
117 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", | 126 | + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n" |
127 | + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n" | ||
128 | + "collisions - if false then collisions with other objects are turned off.\n" | ||
129 | + "pbackup - if false then periodic scene backup is turned off.\n" | ||
130 | + "physics - if false then all physics objects are non-physical.\n" | ||
131 | + "scripting - if false then no scripting operations happen.\n" | ||
132 | + "teleport - if true then some extra teleport debug information is logged.\n" | ||
133 | + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n" | ||
134 | + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", | ||
118 | HandleDebugSceneSetCommand); | 135 | HandleDebugSceneSetCommand); |
119 | } | 136 | } |
120 | 137 | ||
@@ -138,10 +155,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
138 | ConsoleDisplayList cdl = new ConsoleDisplayList(); | 155 | ConsoleDisplayList cdl = new ConsoleDisplayList(); |
139 | cdl.AddRow("active", m_scene.Active); | 156 | cdl.AddRow("active", m_scene.Active); |
140 | cdl.AddRow("animations", m_scene.DebugAnimations); | 157 | cdl.AddRow("animations", m_scene.DebugAnimations); |
158 | cdl.AddRow("appear-refresh", m_scene.SendPeriodicAppearanceUpdates); | ||
159 | cdl.AddRow("child-repri", m_scene.ChildReprioritizationDistance); | ||
160 | cdl.AddRow("client-pos-upd", m_scene.RootPositionUpdateTolerance); | ||
161 | cdl.AddRow("client-rot-upd", m_scene.RootRotationUpdateTolerance); | ||
162 | cdl.AddRow("client-vel-upd", m_scene.RootVelocityUpdateTolerance); | ||
163 | cdl.AddRow("root-upd-per", m_scene.RootTerseUpdatePeriod); | ||
164 | cdl.AddRow("child-upd-per", m_scene.ChildTerseUpdatePeriod); | ||
141 | cdl.AddRow("pbackup", m_scene.PeriodicBackup); | 165 | cdl.AddRow("pbackup", m_scene.PeriodicBackup); |
142 | cdl.AddRow("physics", m_scene.PhysicsEnabled); | 166 | cdl.AddRow("physics", m_scene.PhysicsEnabled); |
143 | cdl.AddRow("scripting", m_scene.ScriptsEnabled); | 167 | cdl.AddRow("scripting", m_scene.ScriptsEnabled); |
144 | cdl.AddRow("teleport", m_scene.DebugTeleporting); | 168 | cdl.AddRow("teleport", m_scene.DebugTeleporting); |
169 | cdl.AddRow("update-on-timer", m_scene.UpdateOnTimer); | ||
145 | cdl.AddRow("updates", m_scene.DebugUpdates); | 170 | cdl.AddRow("updates", m_scene.DebugUpdates); |
146 | 171 | ||
147 | MainConsole.Instance.OutputFormat("Scene {0} options:", m_scene.Name); | 172 | MainConsole.Instance.OutputFormat("Scene {0} options:", m_scene.Name); |
@@ -163,8 +188,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
163 | } | 188 | } |
164 | else | 189 | else |
165 | { | 190 | { |
166 | MainConsole.Instance.Output( | 191 | MainConsole.Instance.Output("Usage: debug scene set <param> <value>"); |
167 | "Usage: debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false"); | ||
168 | } | 192 | } |
169 | } | 193 | } |
170 | 194 | ||
@@ -186,6 +210,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
186 | m_scene.DebugAnimations = active; | 210 | m_scene.DebugAnimations = active; |
187 | } | 211 | } |
188 | 212 | ||
213 | if (options.ContainsKey("appear-refresh")) | ||
214 | { | ||
215 | bool newValue; | ||
216 | |||
217 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
218 | if (ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, options["appear-refresh"], out newValue)) | ||
219 | m_scene.SendPeriodicAppearanceUpdates = newValue; | ||
220 | } | ||
221 | |||
222 | if (options.ContainsKey("child-repri")) | ||
223 | { | ||
224 | double newValue; | ||
225 | |||
226 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
227 | if (ConsoleUtil.TryParseConsoleDouble(MainConsole.Instance, options["child-repri"], out newValue)) | ||
228 | m_scene.ChildReprioritizationDistance = newValue; | ||
229 | } | ||
230 | |||
231 | if (options.ContainsKey("client-pos-upd")) | ||
232 | { | ||
233 | float newValue; | ||
234 | |||
235 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
236 | if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-pos-upd"], out newValue)) | ||
237 | m_scene.RootPositionUpdateTolerance = newValue; | ||
238 | } | ||
239 | |||
240 | if (options.ContainsKey("client-rot-upd")) | ||
241 | { | ||
242 | float newValue; | ||
243 | |||
244 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
245 | if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-rot-upd"], out newValue)) | ||
246 | m_scene.RootRotationUpdateTolerance = newValue; | ||
247 | } | ||
248 | |||
249 | if (options.ContainsKey("client-vel-upd")) | ||
250 | { | ||
251 | float newValue; | ||
252 | |||
253 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
254 | if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-vel-upd"], out newValue)) | ||
255 | m_scene.RootVelocityUpdateTolerance = newValue; | ||
256 | } | ||
257 | |||
258 | if (options.ContainsKey("root-upd-per")) | ||
259 | { | ||
260 | int newValue; | ||
261 | |||
262 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
263 | if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["root-upd-per"], out newValue)) | ||
264 | m_scene.RootTerseUpdatePeriod = newValue; | ||
265 | } | ||
266 | |||
267 | if (options.ContainsKey("child-upd-per")) | ||
268 | { | ||
269 | int newValue; | ||
270 | |||
271 | // FIXME: This can only come from the console at the moment but might not always be true. | ||
272 | if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["child-upd-per"], out newValue)) | ||
273 | m_scene.ChildTerseUpdatePeriod = newValue; | ||
274 | } | ||
275 | |||
189 | if (options.ContainsKey("pbackup")) | 276 | if (options.ContainsKey("pbackup")) |
190 | { | 277 | { |
191 | bool active; | 278 | bool active; |
@@ -221,6 +308,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
221 | m_scene.DebugTeleporting = enableTeleportDebugging; | 308 | m_scene.DebugTeleporting = enableTeleportDebugging; |
222 | } | 309 | } |
223 | 310 | ||
311 | if (options.ContainsKey("update-on-timer")) | ||
312 | { | ||
313 | bool enableUpdateOnTimer; | ||
314 | if (bool.TryParse(options["update-on-timer"], out enableUpdateOnTimer)) | ||
315 | { | ||
316 | m_scene.UpdateOnTimer = enableUpdateOnTimer; | ||
317 | m_scene.Active = false; | ||
318 | |||
319 | while (m_scene.IsRunning) | ||
320 | Thread.Sleep(20); | ||
321 | |||
322 | m_scene.Active = true; | ||
323 | } | ||
324 | } | ||
325 | |||
224 | if (options.ContainsKey("updates")) | 326 | if (options.ContainsKey("updates")) |
225 | { | 327 | { |
226 | bool enableUpdateDebugging; | 328 | 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 | |||
748 | position.X = s_tree.AbsolutePosition.X + (float)randX; | 748 | position.X = s_tree.AbsolutePosition.X + (float)randX; |
749 | position.Y = s_tree.AbsolutePosition.Y + (float)randY; | 749 | position.Y = s_tree.AbsolutePosition.Y + (float)randY; |
750 | 750 | ||
751 | if (position.X <= ((int)Constants.RegionSize - 1) && position.X >= 0 && | 751 | if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 && |
752 | position.Y <= ((int)Constants.RegionSize - 1) && position.Y >= 0 && | 752 | position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 && |
753 | Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) | 753 | Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) |
754 | { | 754 | { |
755 | UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; | 755 | 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 | |||
55 | m_WorldViewModule = fmodule; | 55 | m_WorldViewModule = fmodule; |
56 | } | 56 | } |
57 | 57 | ||
58 | public override byte[] Handle(string path, Stream requestData, | 58 | protected override byte[] ProcessRequest(string path, Stream requestData, |
59 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 59 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
60 | { | 60 | { |
61 | httpResponse.ContentType = "image/jpeg"; | 61 | httpResponse.ContentType = "image/jpeg"; |