From 79e166e9aaf56b6798e27201962f6e109925c697 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 19 Jun 2017 05:22:38 +0100 Subject: revert EnvironmentTick back to orignal clock, since change may cause issues on some code paths. Clean a bit get mesh and get texture throttle --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 81 +++++++--------------- .../ClientStack/Linden/Caps/GetTextureModule.cs | 45 ++++++------ 2 files changed, 46 insertions(+), 80 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index a721454..ba917e39 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -221,7 +221,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceMeshEventArgs args; if (m_pollservices.TryGetValue(user, out args)) { - args.UpdateThrottle(imagethrottle, p); + args.UpdateThrottle(imagethrottle); } } @@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden base(null, uri, null, null, null, pId, int.MaxValue) { m_scene = scene; - m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); + m_throttler = new MeshCapsDataThrottler(100000); // x is request id, y is userid HasEvents = (x, y) => { lock (responses) { bool ret = m_throttler.hasEvents(x, responses); - m_throttler.ProcessTime(); return ret; } @@ -260,8 +259,8 @@ namespace OpenSim.Region.ClientStack.Linden } finally { - m_throttler.ProcessTime(); responses.Remove(x); + m_throttler.PassTime(); } } }; @@ -274,6 +273,7 @@ namespace OpenSim.Region.ClientStack.Linden reqinfo.request = y; m_queue.Enqueue(reqinfo); + m_throttler.PassTime(); }; // this should never happen except possible on shutdown @@ -335,12 +335,15 @@ namespace OpenSim.Region.ClientStack.Linden }; } - m_throttler.ProcessTime(); + m_throttler.PassTime(); } - internal void UpdateThrottle(int pimagethrottle, ScenePresence p) + internal void UpdateThrottle(int pthrottle) { - m_throttler.UpdateThrottle(pimagethrottle, p); + int tmp = 2 * pthrottle; + if(tmp < 10000) + tmp = 10000; + m_throttler.ThrottleBytes = tmp; } } @@ -394,25 +397,15 @@ namespace OpenSim.Region.ClientStack.Linden internal sealed class MeshCapsDataThrottler { + private double lastTimeElapsed = 0; + private double BytesSent = 0; - private volatile int currenttime = 0; - private volatile int lastTimeElapsed = 0; - private volatile int BytesSent = 0; - private int CapSetThrottle = 0; - private float CapThrottleDistributon = 0.30f; - private readonly Scene m_scene; - private ThrottleOutPacketType Throttle; - private readonly UUID User; - - public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser) + public MeshCapsDataThrottler(int pBytes) { + if(pBytes < 10000) + pBytes = 10000; ThrottleBytes = pBytes; - if(ThrottleBytes < 10000) - ThrottleBytes = 10000; - lastTimeElapsed = Util.EnvironmentTickCount(); - Throttle = ThrottleOutPacketType.Asset; - m_scene = pScene; - User = puser; + lastTimeElapsed = Util.GetTimeStampMS(); } public bool hasEvents(UUID key, Dictionary responses) @@ -442,46 +435,22 @@ namespace OpenSim.Region.ClientStack.Linden return haskey; } - public void ProcessTime() - { - PassTime(); - } - - private void PassTime() + public void PassTime() { - currenttime = Util.EnvironmentTickCount(); - int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); - if (timeElapsed >= 100) + double currenttime = Util.GetTimeStampMS(); + double timeElapsed = currenttime - lastTimeElapsed; + if(timeElapsed < 50.0) + return; + int add = (int)(ThrottleBytes * timeElapsed * 0.001); + if (add >= 1000) { lastTimeElapsed = currenttime; - BytesSent -= (ThrottleBytes * timeElapsed / 1000); + BytesSent -= add; if (BytesSent < 0) BytesSent = 0; } } - private void AlterThrottle(int setting, ScenePresence p) - { - p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); - } - - public int ThrottleBytes - { - get { return CapSetThrottle; } - set - { - if (value > 10000) - CapSetThrottle = value; - else - CapSetThrottle = 10000; - } - } - - internal void UpdateThrottle(int pimagethrottle, ScenePresence p) - { - // Client set throttle ! - CapSetThrottle = 2 * pimagethrottle; - ProcessTime(); - } + public int ThrottleBytes; } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index ce9798b..b01c7dc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden new Dictionary(); private Scene m_scene; - private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); + private CapsDataThrottler m_throttler = new CapsDataThrottler(100000); public PollServiceTextureEventArgs(UUID pId, Scene scene) : base(null, "", null, null, null, pId, int.MaxValue) { @@ -231,7 +231,6 @@ namespace OpenSim.Region.ClientStack.Linden lock (responses) { bool ret = m_throttler.hasEvents(x, responses); - m_throttler.ProcessTime(); return ret; } @@ -247,6 +246,7 @@ namespace OpenSim.Region.ClientStack.Linden finally { responses.Remove(x); + m_throttler.PassTime(); } } }; @@ -271,6 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden } } m_queue.Enqueue(reqinfo); + m_throttler.PassTime(); }; // this should never happen except possible on shutdown @@ -351,14 +352,15 @@ namespace OpenSim.Region.ClientStack.Linden }; } - m_throttler.ProcessTime(); + m_throttler.PassTime(); } internal void UpdateThrottle(int pimagethrottle) { - m_throttler.ThrottleBytes = 2 * pimagethrottle; - if(m_throttler.ThrottleBytes < 10000) - m_throttler.ThrottleBytes = 10000; + int tmp = 2 * pimagethrottle; + if(tmp < 10000) + tmp = 10000; + m_throttler.ThrottleBytes = tmp; } } @@ -426,16 +428,14 @@ namespace OpenSim.Region.ClientStack.Linden internal sealed class CapsDataThrottler { - - private volatile int currenttime = 0; - private volatile int lastTimeElapsed = 0; + private double lastTimeElapsed = 0; private volatile int BytesSent = 0; - public CapsDataThrottler(int pBytes, int max, int min) + public CapsDataThrottler(int pBytes) { + if(pBytes < 10000) + pBytes = 10000; ThrottleBytes = pBytes; - if(ThrottleBytes < 10000) - ThrottleBytes = 10000; - lastTimeElapsed = Util.EnvironmentTickCount(); + lastTimeElapsed = Util.GetTimeStampMS(); } public bool hasEvents(UUID key, Dictionary responses) { @@ -468,20 +468,17 @@ namespace OpenSim.Region.ClientStack.Linden return haskey; } - public void ProcessTime() - { - PassTime(); - } - - private void PassTime() + public void PassTime() { - currenttime = Util.EnvironmentTickCount(); - int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); - //processTimeBasedActions(responses); - if (timeElapsed >= 100) + double currenttime = Util.GetTimeStampMS(); + double timeElapsed = currenttime - lastTimeElapsed; + if(timeElapsed < 50.0) + return; + int add = (int)(ThrottleBytes * timeElapsed * 0.001); + if (add >= 1000) { lastTimeElapsed = currenttime; - BytesSent -= (ThrottleBytes * timeElapsed / 1000); + BytesSent -= add; if (BytesSent < 0) BytesSent = 0; } } -- cgit v1.1 From 651952e01eef5ad98e87fbe3909dd11f1d2d9db1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 03:31:07 +0100 Subject: changes to AutoBackModule. Time interval is now unique and only definable on OpenSim.ini. All enabled regions will be saved in sequence whne it expires. Interval is time since last region save end, so will not follow wall clock. This reduces the chance of overlapped saves. Console command renamed to dooarbackup to be more distint from db backup. Lost the region load checks, to put back later --- .../World/AutoBackup/AutoBackupModule.cs | 718 ++++++--------------- .../World/AutoBackup/AutoBackupModuleState.cs | 59 +- 2 files changed, 221 insertions(+), 556 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index 79b80f8..eab6705 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -59,23 +59,20 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// /// /// Config Settings Documentation. - /// Each configuration setting can be specified in two places: OpenSim.ini or Regions.ini. - /// If specified in Regions.ini, the settings should be within the region's section name. - /// If specified in OpenSim.ini, the settings should be within the [AutoBackupModule] section. - /// Region-specific settings take precedence. + /// Configuration setting can be specified in two places: OpenSim.ini and/or Regions.ini. /// - /// AutoBackupModuleEnabled: True/False. Default: False. If True, use the auto backup module. This setting does not support per-region basis. - /// All other settings under [AutoBackupModule] are ignored if AutoBackupModuleEnabled is false, even per-region settings! - /// AutoBackup: True/False. Default: False. If True, activate auto backup functionality. - /// This is the only required option for enabling auto-backup; the other options have sane defaults. - /// If False for a particular region, the auto-backup module becomes a no-op for the region, and all other AutoBackup* settings are ignored. - /// If False globally (the default), only regions that specifically override it in Regions.ini will get AutoBackup functionality. + /// OpenSim.ini only settings section [AutoBackupModule] + /// AutoBackupModuleEnabled: True/False. Default: False. If True, use the auto backup module. + /// if false module is disable and all rest is ignored /// AutoBackupInterval: Double, non-negative value. Default: 720 (12 hours). /// The number of minutes between each backup attempt. - /// If a negative or zero value is given, it is equivalent to setting AutoBackup = False. - /// 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. + /// + /// Next can be set on OpenSim.ini, as default, and or per region in Regions.ini + /// Region-specific settings take precedence. + /// + /// AutoBackup: True/False. Default: False. If True, activate auto backup functionality. + /// controls backup per region, with default optionaly set on OpenSim.ini + /// 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 @@ -93,36 +90,22 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// "Overwrite": Always save to file named "${AutoBackupDir}/RegionName.oar", even if we have to overwrite an existing file. /// AutoBackupDir: String. Default: "." (the current directory). /// A directory (absolute or relative) where backups should be saved. - /// AutoBackupDilationThreshold: float. Default: 0.5. Lower bound on time dilation required for BusyCheck heuristics to pass. - /// If the time dilation is below this value, don't take a backup right now. - /// AutoBackupAgentThreshold: int. Default: 10. Upper bound on # of agents in region required for BusyCheck heuristics to pass. - /// If the number of agents is greater than this value, don't take a backup right now - /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. - /// Also helps if you don't want AutoBackup at all. /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")] public class AutoBackupModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private readonly Dictionary m_pendingSaves = new Dictionary(1); private readonly AutoBackupModuleState m_defaultState = new AutoBackupModuleState(); private readonly Dictionary m_states = new Dictionary(1); - private readonly Dictionary> m_timerMap = - new Dictionary>(1); - private readonly Dictionary m_timers = new Dictionary(1); 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! - /// - private bool m_closed; + private Timer m_masterTimer; + private bool m_busy; private IConfigSource m_configSource; @@ -159,36 +142,34 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup void IRegionModuleBase.Initialise(IConfigSource source) { // Determine if we have been enabled at all in OpenSim.ini -- this is part and parcel of being an optional module - this.m_configSource = source; + m_configSource = source; IConfig moduleConfig = source.Configs["AutoBackupModule"]; if (moduleConfig == null) { - this.m_enabled = false; + m_enabled = false; return; } - else - { - this.m_enabled = moduleConfig.GetBoolean("AutoBackupModuleEnabled", false); - if (this.m_enabled) - { - m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled"); - } - else - { - return; - } - } - Timer defTimer = new Timer(43200000); - this.m_defaultState.Timer = defTimer; - this.m_timers.Add(43200000, defTimer); - defTimer.Elapsed += this.HandleElapsed; - defTimer.AutoReset = true; - defTimer.Start(); + m_enabled = moduleConfig.GetBoolean("AutoBackupModuleEnabled", false); + if(!m_enabled) + return; + + m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled"); + m_masterTimer = new Timer(43200000); + m_masterTimer.Elapsed += HandleElapsed; + m_masterTimer.AutoReset = false; + + ParseDefaultConfig(); + m_log.Debug("[AUTO BACKUP]: Default config:"); + m_log.Debug(m_defaultState.ToString()); - AutoBackupModuleState abms = this.ParseConfig(null, true); - m_log.Debug("[AUTO BACKUP]: Here is the default config:"); - m_log.Debug(abms.ToString()); + m_console = MainConsole.Instance; + + m_console.Commands.AddCommand ( + "AutoBackup", true, "dooarbackup", + "dooarbackup ", + "do single region backup into a oar. Identical to save oar but using AutoBackup settings for name etc", DoBackup); + m_busy = true; } /// @@ -196,13 +177,11 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// void IRegionModuleBase.Close() { - if (!this.m_enabled) - { + if (!m_enabled) return; - } // We don't want any timers firing while the sim's coming down; strange things may happen. - this.StopAllTimers(); + m_masterTimer.Dispose(); } /// @@ -211,18 +190,11 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// void IRegionModuleBase.AddRegion (Scene scene) { - if (!this.m_enabled) { + if (!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); + lock (m_Scenes) + m_Scenes.Add (scene); } /// @@ -231,28 +203,14 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// The scene (region) to stop performing AutoBackup on. void IRegionModuleBase.RemoveRegion(Scene scene) { - if (!this.m_enabled) - { + if (m_enabled) return; - } - m_Scenes.Remove (scene); - if (this.m_states.ContainsKey(scene)) - { - AutoBackupModuleState abms = this.m_states[scene]; - - // Remove this scene out of the timer map list - Timer timer = abms.Timer; - List list = this.m_timerMap[timer]; - list.Remove(scene); - // Shut down the timer if this was the last scene for the timer - if (list.Count == 0) - { - this.m_timerMap.Remove(timer); - this.m_timers.Remove(timer.Interval); - timer.Close(); - } - this.m_states.Remove(scene); + lock(m_Scenes) + { + if (m_states.ContainsKey(scene)) + m_states.Remove(scene); + m_Scenes.Remove(scene); } } @@ -263,22 +221,29 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// The scene to (possibly) perform AutoBackup on. void IRegionModuleBase.RegionLoaded(Scene scene) { - if (!this.m_enabled) - { + if (!m_enabled) return; - } // This really ought not to happen, but just in case, let's pretend it didn't... if (scene == null) - { return; - } - AutoBackupModuleState abms = this.ParseConfig(scene, false); - m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); - m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); + AutoBackupModuleState abms = ParseConfig(scene); + if(abms == null) + { + m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); + m_log.Debug("DEFAULT"); + abms = new AutoBackupModuleState(m_defaultState); + } + else + { + m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); + m_log.Debug(abms.ToString()); + } m_states.Add(scene, abms); + m_busy = false; + m_masterTimer.Start(); } /// @@ -286,280 +251,193 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// void ISharedRegionModule.PostInitialise() { + } #endregion private void DoBackup (string module, string[] args) { - if (args.Length != 2) { - MainConsole.Instance.OutputFormat ("Usage: dobackup "); + if (!m_enabled) + return; + + if(m_busy) + { + MainConsole.Instance.OutputFormat ("Already doing a backup, please try later"); + return; + } + + if (args.Length != 2) + { + MainConsole.Instance.OutputFormat ("Usage: dooarbackup "); return; } + + m_busy = true; + bool found = false; string name = args [1]; - lock (m_Scenes) { - foreach (Scene s in m_Scenes) { - string test = s.Name.ToString (); - if (test == name) { + Scene[] scenes; + lock (m_Scenes) + scenes = m_Scenes.ToArray(); + + if(scenes == null) + return; + + Scene s; + try + { + for(int i = 0; i < scenes.Length; i++) + { + s = scenes[i]; + if (s.Name == name) + { found = true; - DoRegionBackup (s); + m_masterTimer.Stop(); + DoRegionBackup(s); + break; } } - if (!found) { + } catch { } + + if (!found) MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name); - } - } + m_busy = false; } - /// - /// 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. - /// - /// The scene to look at. - /// Whether this call is intended to figure out what we consider the "default" config (applied to all regions unless overridden by per-region settings). - /// An AutoBackupModuleState contains most information you should need to know relevant to auto-backup, as applicable to a single region. - private AutoBackupModuleState ParseConfig(IScene scene, bool parseDefault) + private void ParseDefaultConfig() { - string sRegionName; - string sRegionLabel; -// string prepend; - AutoBackupModuleState state; + IConfig config = m_configSource.Configs["AutoBackupModule"]; + if (config == null) + return; - if (parseDefault) - { - sRegionName = null; - sRegionLabel = "DEFAULT"; -// prepend = ""; - state = this.m_defaultState; - } - else - { - sRegionName = scene.RegionInfo.RegionName; - sRegionLabel = sRegionName; -// prepend = sRegionName + "."; - state = null; - } + // Borrow an existing timer if one exists for the same interval; otherwise, make a new one. + double interval = config.GetDouble("AutoBackupInterval", 720); + interval *= 60000.0; + m_masterTimer.Interval = interval; - // Read the config settings and set variables. - IConfig regionConfig = (scene != null ? scene.Config.Configs[sRegionName] : null); - IConfig config = this.m_configSource.Configs["AutoBackupModule"]; - if (config == null) - { - // defaultState would be disabled too if the section doesn't exist. - state = this.m_defaultState; - return state; - } + m_defaultState.Enabled = config.GetBoolean("AutoBackup", m_defaultState.Enabled); - bool tmpEnabled = ResolveBoolean("AutoBackup", this.m_defaultState.Enabled, config, regionConfig); - if (state == null && tmpEnabled != this.m_defaultState.Enabled) - //Varies from default state - { - state = new AutoBackupModuleState(); - } + // Included Option To Skip Assets + m_defaultState.SkipAssets = config.GetBoolean("AutoBackupSkipAssets",m_defaultState.SkipAssets); - if (state != null) - { - state.Enabled = tmpEnabled; - } + // How long to keep backup files in days, 0 Disables this feature + m_defaultState.KeepFilesForDays = config.GetInt("AutoBackupKeepFilesForDays",m_defaultState.KeepFilesForDays); - // If you don't want AutoBackup, we stop. - if ((state == null && !this.m_defaultState.Enabled) || (state != null && !state.Enabled)) - { - return state; - } + // Set file naming algorithm + string stmpNamingType = config.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString()); + NamingType tmpNamingType; + if (stmpNamingType.Equals("Time", StringComparison.CurrentCultureIgnoreCase)) + tmpNamingType = NamingType.Time; + else if (stmpNamingType.Equals("Sequential", StringComparison.CurrentCultureIgnoreCase)) + tmpNamingType = NamingType.Sequential; + else if (stmpNamingType.Equals("Overwrite", StringComparison.CurrentCultureIgnoreCase)) + tmpNamingType = NamingType.Overwrite; else { - m_log.Info("[AUTO BACKUP]: Region " + sRegionLabel + " is AutoBackup ENABLED."); + m_log.Warn("Unknown naming type specified for Default"); + tmpNamingType = NamingType.Time; } + m_defaultState.NamingType = tmpNamingType; - // Borrow an existing timer if one exists for the same interval; otherwise, make a new one. - double interval = - this.ResolveDouble("AutoBackupInterval", this.m_defaultState.IntervalMinutes, - config, regionConfig) * 60000.0; - if (state == null && interval != this.m_defaultState.IntervalMinutes * 60000.0) - { - state = new AutoBackupModuleState(); - } + m_defaultState.Script = config.GetString("AutoBackupScript", m_defaultState.Script); - if (this.m_timers.ContainsKey(interval)) + string backupDir = config.GetString("AutoBackupDir", "."); + if (backupDir != ".") { - if (state != null) + try { - state.Timer = this.m_timers[interval]; + DirectoryInfo dirinfo = new DirectoryInfo(backupDir); + if (!dirinfo.Exists) + dirinfo.Create(); } - m_log.Debug("[AUTO BACKUP]: Reusing timer for " + interval + " msec for region " + - sRegionLabel); - } - else - { - // 0 or negative interval == do nothing. - if (interval <= 0.0 && state != null) + catch (Exception e) { - state.Enabled = false; - return state; - } - if (state == null) - { - state = new AutoBackupModuleState(); + m_log.Warn( + "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " + + backupDir + + " because it doesn't exist or there's a permissions issue with it. Here's the exception.", + e); } - Timer tim = new Timer(interval); - state.Timer = tim; - //Milliseconds -> minutes - this.m_timers.Add(interval, tim); - tim.Elapsed += this.HandleElapsed; - tim.AutoReset = true; - tim.Start(); } + m_defaultState.BackupDir = backupDir; + } - // Add the current region to the list of regions tied to this timer. - if (scene != null) - { - if (state != null) - { - if (this.m_timerMap.ContainsKey(state.Timer)) - { - this.m_timerMap[state.Timer].Add(scene); - } - else - { - List scns = new List(1); - scns.Add(scene); - this.m_timerMap.Add(state.Timer, scns); - } - } - else - { - if (this.m_timerMap.ContainsKey(this.m_defaultState.Timer)) - { - this.m_timerMap[this.m_defaultState.Timer].Add(scene); - } - else - { - List scns = new List(1); - scns.Add(scene); - this.m_timerMap.Add(this.m_defaultState.Timer, scns); - } - } - } + /// + /// 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. + /// + /// The scene to look at. + /// Whether this call is intended to figure out what we consider the "default" config (applied to all regions unless overridden by per-region settings). + /// An AutoBackupModuleState contains most information you should need to know relevant to auto-backup, as applicable to a single region. + private AutoBackupModuleState ParseConfig(IScene scene) + { + if(scene == null) + return null; - bool tmpBusyCheck = ResolveBoolean("AutoBackupBusyCheck", - this.m_defaultState.BusyCheck, config, regionConfig); - if (state == null && tmpBusyCheck != this.m_defaultState.BusyCheck) - { - state = new AutoBackupModuleState(); - } + string sRegionName; + string sRegionLabel; + AutoBackupModuleState state = null; - if (state != null) - { - state.BusyCheck = tmpBusyCheck; - } + sRegionName = scene.RegionInfo.RegionName; + sRegionLabel = sRegionName; - // 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(); - } + // Read the config settings and set variables. + IConfig regionConfig = scene.Config.Configs[sRegionName]; + if (regionConfig == null) + return null; - if (state != null) - { - state.SkipAssets = tmpSkipAssets; - } + state = new AutoBackupModuleState(); - // 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(); - } + state.Enabled = regionConfig.GetBoolean("AutoBackup", m_defaultState.Enabled); - if (state != null) - { - state.KeepFilesForDays = tmpKeepFilesForDays; - } + // Included Option To Skip Assets + state.SkipAssets = regionConfig.GetBoolean("AutoBackupSkipAssets", m_defaultState.SkipAssets); + + // How long to keep backup files in days, 0 Disables this feature + state.KeepFilesForDays = regionConfig.GetInt("AutoBackupKeepFilesForDays", m_defaultState.KeepFilesForDays); // Set file naming algorithm - string stmpNamingType = ResolveString("AutoBackupNaming", - this.m_defaultState.NamingType.ToString(), config, regionConfig); + string stmpNamingType = regionConfig.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString()); NamingType tmpNamingType; if (stmpNamingType.Equals("Time", StringComparison.CurrentCultureIgnoreCase)) - { tmpNamingType = NamingType.Time; - } else if (stmpNamingType.Equals("Sequential", StringComparison.CurrentCultureIgnoreCase)) - { tmpNamingType = NamingType.Sequential; - } else if (stmpNamingType.Equals("Overwrite", StringComparison.CurrentCultureIgnoreCase)) - { tmpNamingType = NamingType.Overwrite; - } else { m_log.Warn("Unknown naming type specified for region " + sRegionLabel + ": " + stmpNamingType); tmpNamingType = NamingType.Time; } + m_defaultState.NamingType = tmpNamingType; - if (state == null && tmpNamingType != this.m_defaultState.NamingType) - { - state = new AutoBackupModuleState(); - } - - if (state != null) - { - state.NamingType = tmpNamingType; - } + state.Script = regionConfig.GetString("AutoBackupScript", m_defaultState.Script); - string tmpScript = ResolveString("AutoBackupScript", - this.m_defaultState.Script, config, regionConfig); - if (state == null && tmpScript != this.m_defaultState.Script) + string tmpBackupDir = regionConfig.GetString("AutoBackupDir", "."); + // Let's give the user some convenience and auto-mkdir + if (tmpBackupDir != "." && tmpBackupDir != m_defaultState.BackupDir) { - state = new AutoBackupModuleState(); - } - - if (state != null) - { - state.Script = tmpScript; - } - - string tmpBackupDir = ResolveString("AutoBackupDir", ".", config, regionConfig); - if (state == null && tmpBackupDir != this.m_defaultState.BackupDir) - { - state = new AutoBackupModuleState(); - } - - if (state != null) - { - state.BackupDir = tmpBackupDir; - // Let's give the user some convenience and auto-mkdir - if (state.BackupDir != ".") + try { - try + DirectoryInfo dirinfo = new DirectoryInfo(state.BackupDir); + if (!dirinfo.Exists) { - DirectoryInfo dirinfo = new DirectoryInfo(state.BackupDir); - if (!dirinfo.Exists) - { - dirinfo.Create(); - } - } - catch (Exception e) - { - m_log.Warn( - "[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); + dirinfo.Create(); } } + catch (Exception e) + { + m_log.Warn( + "[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:", + e); + } } - - if(state == null) - return m_defaultState; - + state.BackupDir = tmpBackupDir; return state; } @@ -584,128 +462,27 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } /// - /// Helper function for ParseConfig. - /// - /// - /// - /// - /// - /// - private double ResolveDouble(string settingName, double defaultValue, IConfig global, IConfig local) - { - if (local != null) - { - return local.GetDouble(settingName, global.GetDouble(settingName, defaultValue)); - } - else - { - return global.GetDouble(settingName, defaultValue); - } - } - - /// - /// Helper function for ParseConfig. - /// - /// - /// - /// - /// - /// - private int ResolveInt(string settingName, int defaultValue, IConfig global, IConfig local) - { - if (local != null) - { - return local.GetInt(settingName, global.GetInt(settingName, defaultValue)); - } - else - { - return global.GetInt(settingName, defaultValue); - } - } - - /// - /// Helper function for ParseConfig. - /// - /// - /// - /// - /// - /// - private string ResolveString(string settingName, string defaultValue, IConfig global, IConfig local) - { - if (local != null) - { - return local.GetString(settingName, global.GetString(settingName, defaultValue)); - } - else - { - return global.GetString(settingName, defaultValue); - } - } - - /// /// Called when any auto-backup timer expires. This starts the code path for actually performing a backup. /// /// /// private void HandleElapsed(object sender, ElapsedEventArgs e) { - // TODO: heuristic thresholds are per-region, so we should probably run heuristics once per region - // XXX: Running heuristics once per region could add undue performance penalty for something that's supposed to - // check whether the region is too busy! Especially on sims with LOTS of regions. - // Alternative: make heuristics thresholds global to the module rather than per-region. Less flexible, - // but would allow us to be semantically correct while being easier on perf. - // Alternative 2: Run heuristics once per unique set of heuristics threshold parameters! Ay yi yi... - // Alternative 3: Don't support per-region heuristics at all; just accept them as a global only parameter. - // Since this is pretty experimental, I haven't decided which alternative makes the most sense. - if (this.m_closed) - { + if (!m_enabled || m_busy) return; - } - bool heuristicsRun = false; - bool heuristicsPassed = false; - if (!this.m_timerMap.ContainsKey((Timer) sender)) + + m_busy = true; + foreach (IScene scene in m_Scenes) { - m_log.Debug("[AUTO BACKUP]: Code-up error: timerMap doesn't contain timer " + sender); + if (!m_enabled) + return; + DoRegionBackup(scene); } - List tmap = this.m_timerMap[(Timer) sender]; - if (tmap != null && tmap.Count > 0) + if (m_enabled) { - foreach (IScene scene in tmap) - { - AutoBackupModuleState state = this.m_states[scene]; - bool heuristics = state.BusyCheck; - - // Fast path: heuristics are on; already ran em; and sim is fine; OR, no heuristics for the region. - if ((heuristics && heuristicsRun && heuristicsPassed) || !heuristics) - { - this.DoRegionBackup(scene); - // Heuristics are on; ran but we're too busy -- keep going. Maybe another region will have heuristics off! - } - else if (heuristicsRun) - { - m_log.Info("[AUTO BACKUP]: Heuristics: too busy to backup " + - scene.RegionInfo.RegionName + " right now."); - continue; - // Logical Deduction: heuristics are on but haven't been run - } - else - { - heuristicsPassed = this.RunHeuristics(scene); - heuristicsRun = true; - if (!heuristicsPassed) - { - m_log.Info("[AUTO BACKUP]: Heuristics: too busy to backup " + - scene.RegionInfo.RegionName + " right now."); - continue; - } - this.DoRegionBackup(scene); - } - - // Remove Old Backups - this.RemoveOldFiles(state); - } + m_masterTimer.Start(); + m_busy = false; } } @@ -723,8 +500,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup return; } - AutoBackupModuleState state = this.m_states[scene]; + m_busy = true; + + AutoBackupModuleState state; + if(!m_states.TryGetValue(scene, out state)) + return; + + if(state == null || !state.Enabled) + return; + IRegionArchiverModule iram = scene.RequestModuleInterface(); + if(iram == null) + return; + string savePath = BuildOarPath(scene.RegionInfo.RegionName, state.BackupDir, state.NamingType); @@ -733,11 +521,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed"); return; } - Guid guid = Guid.NewGuid(); - m_pendingSaves.Add(guid, scene); - state.LiveRequests.Add(guid, savePath); - ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved); + Guid guid = Guid.NewGuid(); m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName); // Must pass options, even if dictionary is empty! @@ -747,6 +532,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup options["noassets"] = true; iram.ArchiveRegion(savePath, guid, options); + ExecuteScript(state.Script, savePath); } // For the given state, remove backup files older than the states KeepFilesForDays property @@ -774,23 +560,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } } - /// - /// Called by the Event Manager when the OnOarFileSaved event is fired. - /// - /// - /// - void EventManager_OnOarFileSaved(Guid guid, string message) - { - // Ignore if the OAR save is being done by some other part of the system - if (m_pendingSaves.ContainsKey(guid)) - { - AutoBackupModuleState abms = m_states[(m_pendingSaves[guid])]; - ExecuteScript(abms.Script, abms.LiveRequests[guid]); - m_pendingSaves.Remove(guid); - abms.LiveRequests.Remove(guid); - } - } - /// This format may turn out to be too unwieldy to keep... /// Besides, that's what ctimes are for. But then how do I name each file uniquely without using a GUID? /// Sequential numbers, right? We support those, too! @@ -817,63 +586,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup return output; } - /// Return value of true ==> not too busy; false ==> too busy to backup an OAR right now, or error. - private bool RunHeuristics(IScene region) - { - try - { - return this.RunTimeDilationHeuristic(region) && this.RunAgentLimitHeuristic(region); - } - catch (Exception e) - { - m_log.Warn("[AUTO BACKUP]: Exception in RunHeuristics", e); - return false; - } - } - - /// - /// If the time dilation right at this instant is less than the threshold specified in AutoBackupDilationThreshold (default 0.5), - /// then we return false and trip the busy heuristic's "too busy" path (i.e. don't save an OAR). - /// AutoBackupDilationThreshold is a _LOWER BOUND_. Lower Time Dilation is bad, so if you go lower than our threshold, it's "too busy". - /// - /// - /// Returns true if we're not too busy; false means we've got worse time dilation than the threshold. - private bool RunTimeDilationHeuristic(IScene region) - { - string regionName = region.RegionInfo.RegionName; - return region.TimeDilation >= - this.m_configSource.Configs["AutoBackupModule"].GetFloat( - regionName + ".AutoBackupDilationThreshold", 0.5f); - } - - /// - /// If the root agent count right at this instant is less than the threshold specified in AutoBackupAgentThreshold (default 10), - /// then we return false and trip the busy heuristic's "too busy" path (i.e., don't save an OAR). - /// AutoBackupAgentThreshold is an _UPPER BOUND_. Higher Agent Count is bad, so if you go higher than our threshold, it's "too busy". - /// - /// - /// Returns true if we're not too busy; false means we've got more agents on the sim than the threshold. - private bool RunAgentLimitHeuristic(IScene region) - { - string regionName = region.RegionInfo.RegionName; - try - { - Scene scene = (Scene) region; - // TODO: Why isn't GetRootAgentCount() a method in the IScene interface? Seems generally useful... - return scene.GetRootAgentCount() <= - this.m_configSource.Configs["AutoBackupModule"].GetInt( - regionName + ".AutoBackupAgentThreshold", 10); - } - catch (InvalidCastException ice) - { - m_log.Debug( - "[AUTO BACKUP]: I NEED MAINTENANCE: IScene is not a Scene; can't get root agent count!", - ice); - return true; - // Non-obstructionist safest answer... - } - } - /// /// Run the script or executable specified by the "AutoBackupScript" config setting. /// Of course this is a security risk if you let anyone modify OpenSim.ini and they want to run some nasty bash script. @@ -920,18 +632,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } /// - /// Quickly stop all timers from firing. - /// - private void StopAllTimers() - { - foreach (Timer t in this.m_timerMap.Keys) - { - t.Close(); - } - this.m_closed = true; - } - - /// /// Determine the next unique filename by number, for "Sequential" AutoBackupNamingType. /// /// @@ -1033,5 +733,3 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } } } - - diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs index b90f0c4..be5f2ae 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs @@ -38,26 +38,24 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// public class AutoBackupModuleState { - private Dictionary m_liveRequests = null; - public AutoBackupModuleState() { - this.Enabled = false; - this.BackupDir = "."; - this.BusyCheck = true; - this.SkipAssets = false; - this.Timer = null; - this.NamingType = NamingType.Time; - this.Script = null; - this.KeepFilesForDays = 0; + Enabled = false; + BackupDir = "."; + SkipAssets = false; + NamingType = NamingType.Time; + Script = null; + KeepFilesForDays = 0; } - public Dictionary LiveRequests + public AutoBackupModuleState(AutoBackupModuleState copyFrom) { - get { - return this.m_liveRequests ?? - (this.m_liveRequests = new Dictionary(1)); - } + Enabled = copyFrom.Enabled; + BackupDir = copyFrom.BackupDir; + SkipAssets = copyFrom.SkipAssets; + NamingType = copyFrom.NamingType; + Script = copyFrom.Script; + KeepFilesForDays = copyFrom.KeepFilesForDays; } public bool Enabled @@ -66,33 +64,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup set; } - public System.Timers.Timer Timer - { - get; - set; - } - - public double IntervalMinutes - { - get - { - if (this.Timer == null) - { - return -1.0; - } - else - { - return this.Timer.Interval / 60000.0; - } - } - } - - public bool BusyCheck - { - get; - set; - } - public bool SkipAssets { get; @@ -126,10 +97,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup public new string ToString() { string retval = ""; - retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; - retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n"; - retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n"; retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n"; retval += "[AUTO BACKUP]: Script: " + Script + "\n"; @@ -137,4 +105,3 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } } } - -- cgit v1.1 From 36442c004f917442997df11d04bb473e8339d68b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 03:56:43 +0100 Subject: changes to AutoBackModule. Add option ALL to dooarbackup to save all regions in instance --- .../OptionalModules/World/AutoBackup/AutoBackupModule.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index eab6705..05321cd 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -167,8 +167,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup m_console.Commands.AddCommand ( "AutoBackup", true, "dooarbackup", - "dooarbackup ", - "do single region backup into a oar. Identical to save oar but using AutoBackup settings for name etc", DoBackup); + "dooarbackup | ALL", + "saves the single region to a oar or ALL regions in instance to oars, using same settings as AutoBackup. Note it restarts time interval", DoBackup); m_busy = true; } @@ -287,6 +287,18 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup Scene s; try { + if(name == "ALL") + { + m_masterTimer.Stop(); + for(int i = 0; i < scenes.Length; i++) + { + s = scenes[i]; + DoRegionBackup(s); + } + m_busy = false; + return; + } + for(int i = 0; i < scenes.Length; i++) { s = scenes[i]; -- cgit v1.1 From 70da90273297dba5f1c4253f0ea8796575b26ed3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 13:35:36 +0100 Subject: changes to AutoBackModule. Store folder and number of days expire is now also only defined in OpenSim.ini and so same for all regions. --- .../World/AutoBackup/AutoBackupModule.cs | 205 +++++++++------------ .../World/AutoBackup/AutoBackupModuleState.cs | 17 -- 2 files changed, 89 insertions(+), 133 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index 05321cd..a14d819 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -66,7 +66,10 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// if false module is disable and all rest is ignored /// AutoBackupInterval: Double, non-negative value. Default: 720 (12 hours). /// The number of minutes between each backup attempt. - /// + /// AutoBackupDir: String. Default: "." (the current directory). + /// A directory (absolute or relative) where backups should be saved. + /// AutoBackupKeepFilesForDays remove files older than this number of days. 0 disables + /// /// Next can be set on OpenSim.ini, as default, and or per region in Regions.ini /// Region-specific settings take precedence. /// @@ -86,10 +89,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// AutoBackupNaming: string. Default: Time. /// One of three strings (case insensitive): /// "Time": Current timestamp is appended to file name. An existing file will never be overwritten. - /// "Sequential": A number is appended to the file name. So if RegionName_x.oar exists, we'll save to RegionName_{x+1}.oar next. An existing file will never be overwritten. - /// "Overwrite": Always save to file named "${AutoBackupDir}/RegionName.oar", even if we have to overwrite an existing file. - /// AutoBackupDir: String. Default: "." (the current directory). - /// A directory (absolute or relative) where backups should be saved. + /// "Sequential": A number is appended to the file name. So if RegionName_x.oar exists, we'll save to RegionName_{x+1}.oar next. An existing file will never be overwritten. + /// "Overwrite": Always save to file named "${AutoBackupDir}/RegionName.oar", even if we have to overwrite an existing file. /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")] public class AutoBackupModule : ISharedRegionModule @@ -106,6 +107,10 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup private List m_Scenes = new List (); private Timer m_masterTimer; private bool m_busy; + private int m_KeepFilesForDays = -1; + private string m_backupDir; + private bool m_doneFirst; + private double m_baseInterval; private IConfigSource m_configSource; @@ -154,15 +159,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if(!m_enabled) return; - m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled"); - m_masterTimer = new Timer(43200000); - m_masterTimer.Elapsed += HandleElapsed; - m_masterTimer.AutoReset = false; + ParseDefaultConfig(moduleConfig); + if(!m_enabled) + return; - ParseDefaultConfig(); m_log.Debug("[AUTO BACKUP]: Default config:"); m_log.Debug(m_defaultState.ToString()); + m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled"); + m_masterTimer = new Timer(); + m_masterTimer.Interval = m_baseInterval; + m_masterTimer.Elapsed += HandleElapsed; + m_masterTimer.AutoReset = false; + m_console = MainConsole.Instance; m_console.Commands.AddCommand ( @@ -251,7 +260,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup /// void ISharedRegionModule.PostInitialise() { - } #endregion @@ -261,18 +269,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if (!m_enabled) return; - if(m_busy) + if (args.Length != 2) { - MainConsole.Instance.OutputFormat ("Already doing a backup, please try later"); + MainConsole.Instance.OutputFormat ("Usage: dooarbackup "); return; } - if (args.Length != 2) + if(m_busy) { - MainConsole.Instance.OutputFormat ("Usage: dooarbackup "); + MainConsole.Instance.OutputFormat ("Already doing a backup, please try later"); return; } + m_masterTimer.Stop(); m_busy = true; bool found = false; @@ -289,13 +298,13 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup { if(name == "ALL") { - m_masterTimer.Stop(); for(int i = 0; i < scenes.Length; i++) { s = scenes[i]; DoRegionBackup(s); + if (!m_enabled) + return; } - m_busy = false; return; } @@ -305,37 +314,56 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if (s.Name == name) { found = true; - m_masterTimer.Stop(); DoRegionBackup(s); break; } } - } catch { } - + } + catch { } + finally + { + if (m_enabled) + m_masterTimer.Start(); + m_busy = false; + } if (!found) MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name); - m_busy = false; } - private void ParseDefaultConfig() - { - IConfig config = m_configSource.Configs["AutoBackupModule"]; - if (config == null) - return; + private void ParseDefaultConfig(IConfig config) + { + + m_backupDir = "."; + string backupDir = config.GetString("AutoBackupDir", "."); + if (backupDir != ".") + { + try + { + DirectoryInfo dirinfo = new DirectoryInfo(backupDir); + if (!dirinfo.Exists) + dirinfo.Create(); + } + catch (Exception e) + { + m_enabled = false; + m_log.WarnFormat("[AUTO BACKUP]: Error accessing backup folder {0}. Module disabled. {1}", + backupDir, e); + return; + } + } + m_backupDir = backupDir; - // Borrow an existing timer if one exists for the same interval; otherwise, make a new one. double interval = config.GetDouble("AutoBackupInterval", 720); interval *= 60000.0; - m_masterTimer.Interval = interval; + m_baseInterval = interval; + + // How long to keep backup files in days, 0 Disables this feature + m_KeepFilesForDays = config.GetInt("AutoBackupKeepFilesForDays",m_KeepFilesForDays); m_defaultState.Enabled = config.GetBoolean("AutoBackup", m_defaultState.Enabled); - // Included Option To Skip Assets m_defaultState.SkipAssets = config.GetBoolean("AutoBackupSkipAssets",m_defaultState.SkipAssets); - // How long to keep backup files in days, 0 Disables this feature - m_defaultState.KeepFilesForDays = config.GetInt("AutoBackupKeepFilesForDays",m_defaultState.KeepFilesForDays); - // Set file naming algorithm string stmpNamingType = config.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString()); NamingType tmpNamingType; @@ -354,25 +382,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup m_defaultState.Script = config.GetString("AutoBackupScript", m_defaultState.Script); - string backupDir = config.GetString("AutoBackupDir", "."); - if (backupDir != ".") - { - try - { - DirectoryInfo dirinfo = new DirectoryInfo(backupDir); - if (!dirinfo.Exists) - dirinfo.Create(); - } - catch (Exception e) - { - m_log.Warn( - "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " + - backupDir + - " because it doesn't exist or there's a permissions issue with it. Here's the exception.", - e); - } - } - m_defaultState.BackupDir = backupDir; } /// @@ -388,11 +397,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup return null; string sRegionName; - string sRegionLabel; AutoBackupModuleState state = null; sRegionName = scene.RegionInfo.RegionName; - sRegionLabel = sRegionName; // Read the config settings and set variables. IConfig regionConfig = scene.Config.Configs[sRegionName]; @@ -406,9 +413,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup // Included Option To Skip Assets state.SkipAssets = regionConfig.GetBoolean("AutoBackupSkipAssets", m_defaultState.SkipAssets); - // How long to keep backup files in days, 0 Disables this feature - state.KeepFilesForDays = regionConfig.GetInt("AutoBackupKeepFilesForDays", m_defaultState.KeepFilesForDays); - // Set file naming algorithm string stmpNamingType = regionConfig.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString()); NamingType tmpNamingType; @@ -420,58 +424,16 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup tmpNamingType = NamingType.Overwrite; else { - m_log.Warn("Unknown naming type specified for region " + sRegionLabel + ": " + + m_log.Warn("Unknown naming type specified for region " + sRegionName + ": " + stmpNamingType); tmpNamingType = NamingType.Time; } m_defaultState.NamingType = tmpNamingType; state.Script = regionConfig.GetString("AutoBackupScript", m_defaultState.Script); - - string tmpBackupDir = regionConfig.GetString("AutoBackupDir", "."); - // Let's give the user some convenience and auto-mkdir - if (tmpBackupDir != "." && tmpBackupDir != m_defaultState.BackupDir) - { - try - { - DirectoryInfo dirinfo = new DirectoryInfo(state.BackupDir); - if (!dirinfo.Exists) - { - dirinfo.Create(); - } - } - catch (Exception e) - { - m_log.Warn( - "[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:", - e); - } - } - state.BackupDir = tmpBackupDir; return state; } - /// - /// Helper function for ParseConfig. - /// - /// - /// - /// - /// - /// - private bool ResolveBoolean(string settingName, bool defaultValue, IConfig global, IConfig local) - { - if(local != null) - { - return local.GetBoolean(settingName, global.GetBoolean(settingName, defaultValue)); - } - else - { - return global.GetBoolean(settingName, defaultValue); - } - } /// /// Called when any auto-backup timer expires. This starts the code path for actually performing a backup. @@ -484,6 +446,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup return; m_busy = true; + if(m_doneFirst && m_KeepFilesForDays > 0) + RemoveOldFiles(); + foreach (IScene scene in m_Scenes) { if (!m_enabled) @@ -496,6 +461,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup m_masterTimer.Start(); m_busy = false; } + + m_doneFirst = true; } /// @@ -526,7 +493,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup return; string savePath = BuildOarPath(scene.RegionInfo.RegionName, - state.BackupDir, + m_backupDir, state.NamingType); if (savePath == null) { @@ -548,26 +515,32 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup } // For the given state, remove backup files older than the states KeepFilesForDays property - private void RemoveOldFiles(AutoBackupModuleState state) + private void RemoveOldFiles() { - // 0 Means Disabled, Keep Files Indefinitely - if (state.KeepFilesForDays > 0) + string[] files; + try { - string[] files = Directory.GetFiles(state.BackupDir, "*.oar"); - DateTime CuttOffDate = DateTime.Now.AddDays(0 - state.KeepFilesForDays); + files = Directory.GetFiles(m_backupDir, "*.oar"); + } + catch (Exception Ex) + { + m_log.Error("[AUTO BACKUP]: Error reading backup folder " + m_backupDir + ": " + Ex.Message); + return; + } - foreach (string file in files) + DateTime CuttOffDate = DateTime.Now.AddDays(-m_KeepFilesForDays); + + foreach (string file in files) + { + try { - 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); - } + 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 be5f2ae..fb87677 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs @@ -41,21 +41,17 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup public AutoBackupModuleState() { Enabled = false; - BackupDir = "."; SkipAssets = false; NamingType = NamingType.Time; Script = null; - KeepFilesForDays = 0; } public AutoBackupModuleState(AutoBackupModuleState copyFrom) { Enabled = copyFrom.Enabled; - BackupDir = copyFrom.BackupDir; SkipAssets = copyFrom.SkipAssets; NamingType = copyFrom.NamingType; Script = copyFrom.Script; - KeepFilesForDays = copyFrom.KeepFilesForDays; } public bool Enabled @@ -76,30 +72,17 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup set; } - public string BackupDir - { - get; - set; - } - public NamingType NamingType { get; set; } - public int KeepFilesForDays - { - get; - set; - } - public new string ToString() { string retval = ""; retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; - retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n"; retval += "[AUTO BACKUP]: Script: " + Script + "\n"; return retval; } -- cgit v1.1 From 637d35631cd88258d5f3da44c2959985a047ae2d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 18:39:58 +0100 Subject: make oar/iar assets writer be done by caller thread like the rest of the oar/iar save. This may look more painfull but should reduce errors and threads fights. Fill lucky i just don't stop the entire simulation during this --- .../Archiver/InventoryArchiveWriteRequest.cs | 6 +- .../World/Archiver/ArchiveWriteRequest.cs | 7 +- .../CoreModules/World/Archiver/AssetsRequest.cs | 213 +++++---------------- 3 files changed, 50 insertions(+), 176 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index f002ad7..dde93db 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -423,14 +423,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetGatherer.GatheredUuids.Count); - AssetsRequest ar - = new AssetsRequest( + AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), m_assetGatherer.GatheredUuids, m_scene.AssetService, m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, options, ReceivedAllAssets); - - WorkManager.RunInThread(o => ar.Execute(), null, string.Format("AssetsRequest ({0})", m_scene.Name)); + ar.Execute(); } else { diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 8dabcee..5037219 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -195,14 +195,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Saving {0} assets", assetUuids.Count); // Asynchronously request all the assets required to perform this archive operation - AssetsRequest ar - = new AssetsRequest( + AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), assetUuids, m_rootScene.AssetService, m_rootScene.UserAccountService, m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets); - WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request"); - +// WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request"); + ar.Execute(); // CloseArchive() will be called from ReceivedAllAssets() } else diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index d380da8..f303498 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -62,24 +62,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver }; /// - /// Timeout threshold if we still need assets or missing asset notifications but have stopped receiving them - /// from the asset service - /// - protected const int TIMEOUT = 60 * 1000; - - /// - /// If a timeout does occur, limit the amount of UUID information put to the console. - /// - protected const int MAX_UUID_DISPLAY_ON_TIMEOUT = 3; - - protected System.Timers.Timer m_requestCallbackTimer; - - /// - /// State of this request - /// - private RequestState m_requestState = RequestState.Initial; - - /// /// uuids to request /// protected IDictionary m_uuids; @@ -104,6 +86,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// private int m_repliesRequired; + private System.Timers.Timer m_timeOutTimer; + private bool m_timeout; + /// /// Asset service used to request the assets /// @@ -129,186 +114,76 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scopeID = scope; m_options = options; m_repliesRequired = uuids.Count; - - // FIXME: This is a really poor way of handling the timeout since it will always leave the original requesting thread - // hanging. Need to restructure so an original request thread waits for a ManualResetEvent on asset received - // so we can properly abort that thread. Or request all assets synchronously, though that would be a more - // radical change - m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT); - m_requestCallbackTimer.AutoReset = false; - m_requestCallbackTimer.Elapsed += new ElapsedEventHandler(OnRequestCallbackTimeout); } protected internal void Execute() { - m_requestState = RequestState.Running; - + Culture.SetCurrentCulture(); m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} possible assets", m_repliesRequired); // We can stop here if there are no assets to fetch if (m_repliesRequired == 0) { - m_requestState = RequestState.Completed; PerformAssetsRequestCallback(false); return; } - m_requestCallbackTimer.Enabled = true; + m_timeOutTimer = new System.Timers.Timer(60000); + m_timeOutTimer .AutoReset = false; + m_timeOutTimer.Elapsed += OnTimeout; + m_timeout = false; foreach (KeyValuePair kvp in m_uuids) { -// m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); - -// m_assetService.Get(kvp.Key.ToString(), kvp.Value, PreAssetRequestCallback); - AssetBase asset = m_assetService.Get(kvp.Key.ToString()); - PreAssetRequestCallback(kvp.Key.ToString(), kvp.Value, asset); - } - } - - protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args) - { - bool timedOut = true; - - try - { - lock (this) + string thiskey = kvp.Key.ToString(); + try { - // Take care of the possibilty that this thread started but was paused just outside the lock before - // the final request came in (assuming that such a thing is possible) - if (m_requestState == RequestState.Completed) + m_timeOutTimer.Enabled = true; + AssetBase asset = m_assetService.Get(thiskey); + if(m_timeout) + break; + + m_timeOutTimer.Enabled = false; + + if(asset == null) { - timedOut = false; - return; + m_notFoundAssetUuids.Add(new UUID(thiskey)); + continue; } - m_requestState = RequestState.Aborted; - } - - // Calculate which uuids were not found. This is an expensive way of doing it, but this is a failure - // case anyway. - List uuids = new List(); - foreach (UUID uuid in m_uuids.Keys) - { - uuids.Add(uuid); - } - - foreach (UUID uuid in m_foundAssetUuids) - { - uuids.Remove(uuid); - } + sbyte assetType = kvp.Value; + if (asset != null && assetType == (sbyte)AssetType.Unknown) + { + m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", thiskey, SLUtil.AssetTypeFromCode(assetType)); + asset.Type = assetType; + } - foreach (UUID uuid in m_notFoundAssetUuids) - { - uuids.Remove(uuid); + m_foundAssetUuids.Add(asset.FullID); + m_assetsArchiver.WriteAsset(PostProcess(asset)); } - m_log.ErrorFormat( - "[ARCHIVER]: Asset service failed to return information about {0} requested assets", uuids.Count); - - int i = 0; - foreach (UUID uuid in uuids) + catch (Exception e) { - m_log.ErrorFormat("[ARCHIVER]: No information about asset {0} received", uuid); - - if (++i >= MAX_UUID_DISPLAY_ON_TIMEOUT) - break; + m_log.ErrorFormat("[ARCHIVER]: Execute failed with {0}", e); } - - if (uuids.Count > MAX_UUID_DISPLAY_ON_TIMEOUT) - m_log.ErrorFormat( - "[ARCHIVER]: (... {0} more not shown)", uuids.Count - MAX_UUID_DISPLAY_ON_TIMEOUT); - - m_log.Error("[ARCHIVER]: Archive save aborted. PLEASE DO NOT USE THIS ARCHIVE, IT WILL BE INCOMPLETE."); - } - catch (Exception e) - { - m_log.ErrorFormat("[ARCHIVER]: Timeout handler exception {0}{1}", e.Message, e.StackTrace); - } - finally - { - if (timedOut) - WorkManager.RunInThread(PerformAssetsRequestCallback, true, "Archive Assets Request Callback"); } - } - - protected void PreAssetRequestCallback(string fetchedAssetID, object assetType, AssetBase fetchedAsset) - { - // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer - if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) - { - m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType)); - fetchedAsset.Type = (sbyte)assetType; - } - - AssetRequestCallback(fetchedAssetID, this, fetchedAsset); - } - - /// - /// Called back by the asset cache when it has the asset - /// - /// - /// - public void AssetRequestCallback(string id, object sender, AssetBase asset) - { - Culture.SetCurrentCulture(); - - try - { - lock (this) - { - //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id); - - m_requestCallbackTimer.Stop(); - - if ((m_requestState == RequestState.Aborted) || (m_requestState == RequestState.Completed)) - { - m_log.WarnFormat( - "[ARCHIVER]: Received information about asset {0} while in state {1}. Ignoring.", - id, m_requestState); - - return; - } - if (asset != null) - { -// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); - m_foundAssetUuids.Add(asset.FullID); + m_timeOutTimer.Dispose(); - m_assetsArchiver.WriteAsset(PostProcess(asset)); - } - else - { -// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id); - m_notFoundAssetUuids.Add(new UUID(id)); - } - - if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired) - { - m_requestState = RequestState.Completed; - if(m_notFoundAssetUuids.Count == 0) - m_log.DebugFormat( - "[ARCHIVER]: Successfully added {0} assets", - m_foundAssetUuids.Count); - else - m_log.DebugFormat( - "[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)", + if(m_timeout) + m_log.DebugFormat("[ARCHIVER]: Aborted because AssetService request timeout. Successfully added {0} assets", m_foundAssetUuids.Count); + else if(m_notFoundAssetUuids.Count == 0) + m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count); + else + m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} assets not found)", m_foundAssetUuids.Count, m_notFoundAssetUuids.Count); - - // We want to stop using the asset cache thread asap - // as we now need to do the work of producing the rest of the archive - WorkManager.RunInThread(PerformAssetsRequestCallback, false, "Archive Assets Request Callback"); - } - else - { - m_requestCallbackTimer.Start(); - } - } - } - catch (Exception e) - { - m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e); - } + PerformAssetsRequestCallback(m_timeout); + } + + void OnTimeout(object source, ElapsedEventArgs args) + { + m_timeout = true; } /// @@ -316,6 +191,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// protected void PerformAssetsRequestCallback(object o) { + if(m_assetsRequestCallback == null) + return; Culture.SetCurrentCulture(); Boolean timedOut = (Boolean)o; -- cgit v1.1 From 1bfe4da3785ebed17735fdbda7638757bc83269e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 20:15:35 +0100 Subject: do not try to store on oars temporary or in transit objects ( they may be deleted during the save) --- .../CoreModules/World/Archiver/ArchiveWriteRequest.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 5037219..e6ea5d1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -193,22 +193,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (SaveAssets) { m_log.DebugFormat("[ARCHIVER]: Saving {0} assets", assetUuids.Count); - - // Asynchronously request all the assets required to perform this archive operation + AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), assetUuids, m_rootScene.AssetService, m_rootScene.UserAccountService, - m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets); - -// WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request"); + m_rootScene.RegionInfo.ScopeID, options, null); ar.Execute(); - // CloseArchive() will be called from ReceivedAllAssets() + assetUuids = null; } else { m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified"); - CloseArchive(string.Empty); +// CloseArchive(string.Empty); } + CloseArchive(string.Empty); } catch (Exception e) { @@ -236,7 +234,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { SceneObjectGroup sceneObject = (SceneObjectGroup)entity; - if (!sceneObject.IsDeleted && !sceneObject.IsAttachment) + if (!sceneObject.IsDeleted && !sceneObject.IsAttachment && !sceneObject.IsTemporary && !sceneObject.inTransit) { if (!CanUserArchiveObject(scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, FilterContent, permissionsModule)) { @@ -571,7 +569,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver foreach (SceneObjectGroup sceneObject in sceneObjects) { //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); - + if(sceneObject.IsDeleted || sceneObject.inTransit) + continue; string serializedObject = serializer.SerializeGroupToXml2(sceneObject, m_options); string objectPath = string.Format("{0}{1}", regionDir, ArchiveHelpers.CreateObjectPath(sceneObject)); m_archiveWriter.WriteFile(objectPath, serializedObject); -- cgit v1.1 From 11d38607811d1f2dca58bc3d99b4ad698d6b228a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 21 Jun 2017 21:38:12 +0100 Subject: avoid some broken object assets present in osgrid inventories due to past problems, etc --- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 2 ++ .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 6 ++++-- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index dde93db..2735b59 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -381,6 +381,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); Exception e = new InventoryArchiverException(errorMessage); m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e, 0, 0); + if(m_saveStream != null && m_saveStream.CanWrite) + m_saveStream.Close(); throw e; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index be59eb5..06aec7b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -218,7 +218,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // { try { - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService); + InventoryArchiveWriteRequest iarReq = new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream); + iarReq.Execute(options, UserAccountService); } catch (EntryPointNotFoundException e) { @@ -261,7 +262,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // { try { - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService); + InventoryArchiveWriteRequest iarReq = new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath); + iarReq.Execute(options, UserAccountService); } catch (EntryPointNotFoundException e) { diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 5a9a5a0..bac069b 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -142,6 +142,8 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat( // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); + if(sceneObject.IsDeleted) + return; SceneObjectPart[] parts = sceneObject.Parts; for (int i = 0; i < parts.Length; i++) @@ -489,6 +491,13 @@ namespace OpenSim.Region.Framework.Scenes /// private void RecordSceneObjectAssetUuids(AssetBase sceneObjectAsset) { + if(sceneObjectAsset.Data == null || sceneObjectAsset.Data.Length == 0) + { + m_log.WarnFormat("[UUIDgatherer] Error: object asset '{0}' id: {1} has no data", + sceneObjectAsset.Name,sceneObjectAsset.ID.ToString()); + return; + } + string xml = Utils.BytesToString(sceneObjectAsset.Data); CoalescedSceneObjects coa; -- cgit v1.1 From 66c8b7202bff02753060e093712b7053acaf8358 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Jun 2017 19:38:38 +0100 Subject: split some asset uuids gather i stages with dif possible errors, and dont let them be fatal --- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 77 +++++++++++++++---------- 1 file changed, 45 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index bac069b..3ba67eb 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -284,45 +284,58 @@ namespace OpenSim.Region.Framework.Scenes if (GatheredUuids.ContainsKey(assetUuid)) return; + AssetBase assetBase; try { - AssetBase assetBase = GetAsset(assetUuid); + assetBase = GetAsset(assetUuid); + } + catch (Exception e) + { + m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset id {0} : {1}", assetUuid, e.Message); + GatheredUuids.Remove(assetUuid); + return; + } - if (null != assetBase) - { - sbyte assetType = assetBase.Type; - GatheredUuids[assetUuid] = assetType; + if(assetBase == null) + { + m_log.ErrorFormat("[UUID GATHERER]: asset id {0} not found", assetUuid); + GatheredUuids.Remove(assetUuid); + return; + } - if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) - { - RecordWearableAssetUuids(assetBase); - } - else if ((sbyte)AssetType.Gesture == assetType) - { - RecordGestureAssetUuids(assetBase); - } - else if ((sbyte)AssetType.Notecard == assetType) - { - RecordTextEmbeddedAssetUuids(assetBase); - } - else if ((sbyte)AssetType.LSLText == assetType) - { - RecordTextEmbeddedAssetUuids(assetBase); - } - else if ((sbyte)OpenSimAssetType.Material == assetType) - { - RecordMaterialAssetUuids(assetBase); - } - else if ((sbyte)AssetType.Object == assetType) - { - RecordSceneObjectAssetUuids(assetBase); - } + sbyte assetType = assetBase.Type; + GatheredUuids[assetUuid] = assetType; + + try + { + if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) + { + RecordWearableAssetUuids(assetBase); + } + else if ((sbyte)AssetType.Gesture == assetType) + { + RecordGestureAssetUuids(assetBase); + } + else if ((sbyte)AssetType.Notecard == assetType) + { + RecordTextEmbeddedAssetUuids(assetBase); + } + else if ((sbyte)AssetType.LSLText == assetType) + { + RecordTextEmbeddedAssetUuids(assetBase); + } + else if ((sbyte)OpenSimAssetType.Material == assetType) + { + RecordMaterialAssetUuids(assetBase); + } + else if ((sbyte)AssetType.Object == assetType) + { + RecordSceneObjectAssetUuids(assetBase); } } - catch (Exception) + catch (Exception e) { - m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset id {0}", assetUuid); - throw; + m_log.ErrorFormat("[UUID GATHERER]: Failed to uuids for asset id {0} type {1}: {2}", assetUuid, assetType, e.Message); } } -- cgit v1.1 From aea49070c96b04d0f5e2496c14d32c1b1341b06f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Jun 2017 21:37:51 +0100 Subject: change uuidgather a bit more --- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 48 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3ba67eb..3a71c12 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The gathered uuids. public IDictionary GatheredUuids { get; private set; } + public HashSet FailedUUIDs { get; private set; } /// /// Gets the next UUID to inspect. @@ -111,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: Not efficient for searching, can improve. m_assetUuidsToInspect = new Queue(); + FailedUUIDs = new HashSet(); } /// @@ -120,6 +122,10 @@ namespace OpenSim.Region.Framework.Scenes /// UUID. public bool AddForInspection(UUID uuid) { + if(FailedUUIDs.Contains(uuid)) + return false; + if(GatheredUuids.ContainsKey(uuid)) + return false; if (m_assetUuidsToInspect.Contains(uuid)) return false; @@ -209,9 +215,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}", // tii.Name, tii.Type, part.Name, part.UUID); - - if (!GatheredUuids.ContainsKey(tii.AssetID)) - AddForInspection(tii.AssetID, (sbyte)tii.Type); + AddForInspection(tii.AssetID, (sbyte)tii.Type); } // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed @@ -280,9 +284,15 @@ namespace OpenSim.Region.Framework.Scenes /// The uuid of the asset for which to gather referenced assets private void GetAssetUuids(UUID assetUuid) { + if(FailedUUIDs.Contains(assetUuid)) + return; + // avoid infinite loops if (GatheredUuids.ContainsKey(assetUuid)) + { + FailedUUIDs.Add(assetUuid); return; + } AssetBase assetBase; try @@ -291,21 +301,28 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset id {0} : {1}", assetUuid, e.Message); - GatheredUuids.Remove(assetUuid); + m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset with id {0} : {1}", assetUuid, e.Message); + FailedUUIDs.Add(assetUuid); return; } if(assetBase == null) { - m_log.ErrorFormat("[UUID GATHERER]: asset id {0} not found", assetUuid); - GatheredUuids.Remove(assetUuid); + m_log.ErrorFormat("[UUID GATHERER]: asset with id {0} not found", assetUuid); + FailedUUIDs.Add(assetUuid); return; } sbyte assetType = assetBase.Type; - GatheredUuids[assetUuid] = assetType; + if(assetBase.Data == null || assetBase.Data.Length == 0) + { + m_log.ErrorFormat("[UUID GATHERER]: asset with id {0} type {1} has no data", assetUuid, assetType); + FailedUUIDs.Add(assetUuid); + return; + } + + GatheredUuids[assetUuid] = assetType; try { if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) @@ -335,13 +352,19 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[UUID GATHERER]: Failed to uuids for asset id {0} type {1}: {2}", assetUuid, assetType, e.Message); + m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset with id {0} type {1}: {2}", assetUuid, assetType, e.Message); + GatheredUuids.Remove(assetUuid); + FailedUUIDs.Add(assetUuid); } } private void AddForInspection(UUID assetUuid, sbyte assetType) { // Here, we want to collect uuids which require further asset fetches but mark the others as gathered + if(FailedUUIDs.Contains(assetUuid)) + return; + if(GatheredUuids.ContainsKey(assetUuid)) + return; try { if ((sbyte)AssetType.Bodypart == assetType @@ -504,13 +527,6 @@ namespace OpenSim.Region.Framework.Scenes /// private void RecordSceneObjectAssetUuids(AssetBase sceneObjectAsset) { - if(sceneObjectAsset.Data == null || sceneObjectAsset.Data.Length == 0) - { - m_log.WarnFormat("[UUIDgatherer] Error: object asset '{0}' id: {1} has no data", - sceneObjectAsset.Name,sceneObjectAsset.ID.ToString()); - return; - } - string xml = Utils.BytesToString(sceneObjectAsset.Data); CoalescedSceneObjects coa; -- cgit v1.1 From cbae148f6865e750bdbaeb4ba4eede56464d651e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Jun 2017 21:48:26 +0100 Subject: show the count of broken assets we now have from gather on iar/oar pre save information --- OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index e6ea5d1..ce296c7 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -262,6 +262,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat( "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", sceneObjects.Count, assetUuids.Count - prevAssets); + int errors = assetGatherer.FailedUUIDs.Count; + if(errors > 0) + m_log.DebugFormat("[ARCHIVER]: {0} assets have problems and will be ignored", errors); } if (numObjectsSkippedPermissions > 0) -- cgit v1.1 From 28caf1e08974a29c689837b99a4d21217aa54847 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Jun 2017 22:09:00 +0100 Subject: actually iar do it for iar --- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 3 +++ OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 2735b59..c218f5d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -424,6 +424,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetGatherer.GatheredUuids.Count); + int errors = m_assetGatherer.FailedUUIDs.Count; + if(errors > 0) + m_log.DebugFormat("[INVENTORY ARCHIVER]: aditional {0} assets have problems and will be ignored", errors); AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index ce296c7..761fece 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver sceneObjects.Count, assetUuids.Count - prevAssets); int errors = assetGatherer.FailedUUIDs.Count; if(errors > 0) - m_log.DebugFormat("[ARCHIVER]: {0} assets have problems and will be ignored", errors); + m_log.DebugFormat("[ARCHIVER]: aditional {0} assets have problems and will be ignored", errors); } if (numObjectsSkippedPermissions > 0) -- cgit v1.1 From 3c6790b061fe1dd6d7cf602a3eb082b5bd149012 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 23 Jun 2017 15:50:16 +0100 Subject: several changes to iar/oar assets error reports --- .../Inventory/Archiver/InventoryArchiveWriteRequest.cs | 10 ++++++---- .../CoreModules/World/Archiver/ArchiveWriteRequest.cs | 16 +++++++++------- .../CoreModules/World/Archiver/AssetsArchiver.cs | 2 +- .../Region/CoreModules/World/Archiver/AssetsRequest.cs | 18 ++++++++++-------- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 13 +++++++------ 5 files changed, 33 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index c218f5d..144cbbe 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -422,15 +422,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { m_assetGatherer.GatherAll(); - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetGatherer.GatheredUuids.Count); int errors = m_assetGatherer.FailedUUIDs.Count; + + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: The items to save reference {0} assets", m_assetGatherer.GatheredUuids.Count + errors); if(errors > 0) - m_log.DebugFormat("[INVENTORY ARCHIVER]: aditional {0} assets have problems and will be ignored", errors); + m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of this assets have problems and will be ignored", errors); AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), - m_assetGatherer.GatheredUuids, m_scene.AssetService, + m_assetGatherer.GatheredUuids, m_assetGatherer.FailedUUIDs.Count, + m_scene.AssetService, m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, options, ReceivedAllAssets); ar.Execute(); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 761fece..9500eb6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -181,11 +181,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Archive the regions Dictionary assetUuids = new Dictionary(); + HashSet failedIDs = new HashSet(); scenesGroup.ForEachScene(delegate(Scene scene) { string regionDir = MultiRegionFormat ? scenesGroup.GetRegionDir(scene.RegionInfo.RegionID) : ""; - ArchiveOneRegion(scene, regionDir, assetUuids); + ArchiveOneRegion(scene, regionDir, assetUuids, failedIDs); }); // Archive the assets @@ -196,6 +197,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), assetUuids, + failedIDs.Count, m_rootScene.AssetService, m_rootScene.UserAccountService, m_rootScene.RegionInfo.ScopeID, options, null); ar.Execute(); @@ -215,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } - private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids) + private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids, HashSet failedIDs) { m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name); @@ -251,7 +253,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (SaveAssets) { - UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids); + UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids, failedIDs); int prevAssets = assetUuids.Count; foreach (SceneObjectGroup sceneObject in sceneObjects) @@ -259,12 +261,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver assetGatherer.GatherAll(); - m_log.DebugFormat( - "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", - sceneObjects.Count, assetUuids.Count - prevAssets); int errors = assetGatherer.FailedUUIDs.Count; + m_log.DebugFormat( + "[ARCHIVER]: {0} region scene objects to save reference {1} assets", + sceneObjects.Count, assetUuids.Count - prevAssets + errors); if(errors > 0) - m_log.DebugFormat("[ARCHIVER]: aditional {0} assets have problems and will be ignored", errors); + m_log.DebugFormat("[ARCHIVER]: {0} of this assets have problems and will be ignored", errors); } if (numObjectsSkippedPermissions > 0) diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs index efacae3..3092fe0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// Post a message to the log every x assets as a progress bar /// - protected static int LOG_ASSET_LOAD_NOTIFICATION_INTERVAL = 50; + protected static int LOG_ASSET_LOAD_NOTIFICATION_INTERVAL = 100; /// /// Keep a count of the number of assets written so that we can provide status updates diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index f303498..903cb2d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// uuids to request /// protected IDictionary m_uuids; + private int m_previusErrorsCount; /// /// Callback used when all the assets requested have been received. @@ -102,12 +103,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected internal AssetsRequest( AssetsArchiver assetsArchiver, IDictionary uuids, + int previusErrorsCount, IAssetService assetService, IUserAccountService userService, UUID scope, Dictionary options, AssetsRequestCallback assetsRequestCallback) { m_assetsArchiver = assetsArchiver; m_uuids = uuids; + m_previusErrorsCount = previusErrorsCount; m_assetsRequestCallback = assetsRequestCallback; m_assetService = assetService; m_userAccountService = userService; @@ -119,8 +122,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected internal void Execute() { Culture.SetCurrentCulture(); - m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} possible assets", m_repliesRequired); - // We can stop here if there are no assets to fetch if (m_repliesRequired == 0) { @@ -169,19 +170,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver } m_timeOutTimer.Dispose(); + int totalerrors = m_notFoundAssetUuids.Count + m_previusErrorsCount; if(m_timeout) m_log.DebugFormat("[ARCHIVER]: Aborted because AssetService request timeout. Successfully added {0} assets", m_foundAssetUuids.Count); - else if(m_notFoundAssetUuids.Count == 0) + else if(totalerrors == 0) m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count); else - m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} assets not found)", - m_foundAssetUuids.Count, m_notFoundAssetUuids.Count); + m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} assets of total request where not found or are damaged", + m_foundAssetUuids.Count, totalerrors); PerformAssetsRequestCallback(m_timeout); } - void OnTimeout(object source, ElapsedEventArgs args) + private void OnTimeout(object source, ElapsedEventArgs args) { m_timeout = true; } @@ -189,7 +191,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// Perform the callback on the original requester of the assets /// - protected void PerformAssetsRequestCallback(object o) + private void PerformAssetsRequestCallback(object o) { if(m_assetsRequestCallback == null) return; @@ -208,7 +210,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } - protected AssetBase PostProcess(AssetBase asset) + private AssetBase PostProcess(AssetBase asset) { if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("home")) { diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3a71c12..548aa3a 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -93,7 +93,8 @@ namespace OpenSim.Region.Framework.Scenes /// /// Asset service. /// - public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary()) {} + public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary(), new HashSet ()) {} + public UuidGatherer(IAssetService assetService, IDictionary collector) : this(assetService, collector, new HashSet ()) {} /// /// Initializes a new instance of the class. @@ -105,14 +106,14 @@ namespace OpenSim.Region.Framework.Scenes /// Gathered UUIDs will be collected in this dictinaory. /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected. /// - public UuidGatherer(IAssetService assetService, IDictionary collector) + public UuidGatherer(IAssetService assetService, IDictionary collector, HashSet failedIDs) { m_assetService = assetService; GatheredUuids = collector; // FIXME: Not efficient for searching, can improve. m_assetUuidsToInspect = new Queue(); - FailedUUIDs = new HashSet(); + FailedUUIDs = failedIDs; } /// @@ -301,14 +302,14 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset with id {0} : {1}", assetUuid, e.Message); + m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset {0} : {1}", assetUuid, e.Message); FailedUUIDs.Add(assetUuid); return; } if(assetBase == null) { - m_log.ErrorFormat("[UUID GATHERER]: asset with id {0} not found", assetUuid); + m_log.ErrorFormat("[UUID GATHERER]: asset {0} not found", assetUuid); FailedUUIDs.Add(assetUuid); return; } @@ -317,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes if(assetBase.Data == null || assetBase.Data.Length == 0) { - m_log.ErrorFormat("[UUID GATHERER]: asset with id {0} type {1} has no data", assetUuid, assetType); + m_log.ErrorFormat("[UUID GATHERER]: asset {0}, type {1} has no data", assetUuid, assetType); FailedUUIDs.Add(assetUuid); return; } -- cgit v1.1 From 95595a8360f5d689dc1f680d53773866a9723f84 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 23 Jun 2017 17:23:28 +0100 Subject: coment out missing or damage assets messages in uuidgather that are not very usefull. In IAR save display information about items that contain references to broken assets. Note that as explained on mantis 8195 this can't will not detect all problems --- .../Archiver/InventoryArchiveWriteRequest.cs | 29 ++++++++++++++++++++-- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 25 +++++++++++-------- 2 files changed, 42 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 144cbbe..f89b904 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -218,10 +218,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Count inventory items (different to asset count) CountItems++; - + // Don't chase down link asset items as they actually point to their target item IDs rather than an asset if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) + { + int curErrorCntr = m_assetGatherer.ErrorCount; m_assetGatherer.AddForInspection(inventoryItem.AssetID); + m_assetGatherer.GatherAll(); + curErrorCntr = m_assetGatherer.ErrorCount - curErrorCntr; + if(curErrorCntr > 0) + { + string spath; + int indx = path.IndexOf("__"); + if(indx > 0) + spath = path.Substring(0,indx); + else + spath = path; + + if(curErrorCntr > 1) + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: item {0} '{1}', type {2}, in '{3}', contains at least {4} references to missing or damaged assets", + inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, curErrorCntr); + } + else if(curErrorCntr == 1) + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: item {0} '{1}', type {2}, in '{3}', contains at least 1 reference to a missing or damaged asset", + inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath); + } + } + } } /// @@ -427,7 +452,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: The items to save reference {0} assets", m_assetGatherer.GatheredUuids.Count + errors); if(errors > 0) - m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of this assets have problems and will be ignored", errors); + m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of these assets have problems and will be ignored", errors); AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 548aa3a..46ce2ce 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes /// The gathered uuids. public IDictionary GatheredUuids { get; private set; } public HashSet FailedUUIDs { get; private set; } - + public int ErrorCount { get; private set; } /// /// Gets the next UUID to inspect. /// @@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Scenes /// Asset service. /// /// - /// Gathered UUIDs will be collected in this dictinaory. + /// Gathered UUIDs will be collected in this dictionary. /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected. /// public UuidGatherer(IAssetService assetService, IDictionary collector, HashSet failedIDs) @@ -114,6 +114,7 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: Not efficient for searching, can improve. m_assetUuidsToInspect = new Queue(); FailedUUIDs = failedIDs; + ErrorCount = 0; } /// @@ -232,9 +233,6 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e); - m_log.DebugFormat( - "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)", - part.Shape.TextureEntry.Length); } } } @@ -286,14 +284,14 @@ namespace OpenSim.Region.Framework.Scenes private void GetAssetUuids(UUID assetUuid) { if(FailedUUIDs.Contains(assetUuid)) + { + ErrorCount++; return; + } // avoid infinite loops if (GatheredUuids.ContainsKey(assetUuid)) - { - FailedUUIDs.Add(assetUuid); return; - } AssetBase assetBase; try @@ -303,13 +301,15 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset {0} : {1}", assetUuid, e.Message); + ErrorCount++; FailedUUIDs.Add(assetUuid); return; } if(assetBase == null) { - m_log.ErrorFormat("[UUID GATHERER]: asset {0} not found", assetUuid); +// m_log.ErrorFormat("[UUID GATHERER]: asset {0} not found", assetUuid); + ErrorCount++; FailedUUIDs.Add(assetUuid); return; } @@ -318,7 +318,8 @@ namespace OpenSim.Region.Framework.Scenes if(assetBase.Data == null || assetBase.Data.Length == 0) { - m_log.ErrorFormat("[UUID GATHERER]: asset {0}, type {1} has no data", assetUuid, assetType); +// m_log.ErrorFormat("[UUID GATHERER]: asset {0}, type {1} has no data", assetUuid, assetType); + ErrorCount++; FailedUUIDs.Add(assetUuid); return; } @@ -355,6 +356,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset with id {0} type {1}: {2}", assetUuid, assetType, e.Message); GatheredUuids.Remove(assetUuid); + ErrorCount++; FailedUUIDs.Add(assetUuid); } } @@ -363,7 +365,10 @@ namespace OpenSim.Region.Framework.Scenes { // Here, we want to collect uuids which require further asset fetches but mark the others as gathered if(FailedUUIDs.Contains(assetUuid)) + { + ErrorCount++; return; + } if(GatheredUuids.ContainsKey(assetUuid)) return; try -- cgit v1.1 From 83e443bca168629045a054bf06e5c5e2302a27dc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 23 Jun 2017 17:48:59 +0100 Subject: do the same on OAR saves --- .../CoreModules/World/Archiver/ArchiveWriteRequest.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 9500eb6..d02db73 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -257,7 +257,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver int prevAssets = assetUuids.Count; foreach (SceneObjectGroup sceneObject in sceneObjects) + { + int curErrorCntr = assetGatherer.ErrorCount; assetGatherer.AddForInspection(sceneObject); + assetGatherer.GatherAll(); + curErrorCntr = assetGatherer.ErrorCount - curErrorCntr; + if(curErrorCntr > 1) + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: object {0} '{1}', at {2}, contains at least {3} references to missing or damaged assets", + sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), curErrorCntr); + } + else if(curErrorCntr == 1) + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: object {0} '{1}', at {2}, contains at least 1 reference to a missing or damaged asset", + sceneObject.UUID, sceneObject.Name, sceneObject.AbsolutePosition.ToString()); + } + } assetGatherer.GatherAll(); @@ -266,7 +281,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver "[ARCHIVER]: {0} region scene objects to save reference {1} assets", sceneObjects.Count, assetUuids.Count - prevAssets + errors); if(errors > 0) - m_log.DebugFormat("[ARCHIVER]: {0} of this assets have problems and will be ignored", errors); + m_log.DebugFormat("[ARCHIVER]: {0} of these assets have problems and will be ignored", errors); } if (numObjectsSkippedPermissions > 0) -- cgit v1.1 From 0a1f497dee60a8b6d02fe4565f251afd226b3a3a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 23 Jun 2017 19:55:23 +0100 Subject: code actually has no ideia if a id is a asset or not and does try to handle all as assets, it really can't report errors. Change messages to make more clear they are only warnings and may mean nothing at all --- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 8 ++++---- .../Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | 8 ++++---- OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | 10 +++++----- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index f89b904..d816ba4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -237,12 +237,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if(curErrorCntr > 1) { - m_log.WarnFormat("[INVENTORY ARCHIVER]: item {0} '{1}', type {2}, in '{3}', contains at least {4} references to missing or damaged assets", + m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references to possible missing or damaged assets )", inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, curErrorCntr); } else if(curErrorCntr == 1) { - m_log.WarnFormat("[INVENTORY ARCHIVER]: item {0} '{1}', type {2}, in '{3}', contains at least 1 reference to a missing or damaged asset", + m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains a reference to a possible missing or damaged asset)", inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath); } } @@ -450,9 +450,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver int errors = m_assetGatherer.FailedUUIDs.Count; m_log.DebugFormat( - "[INVENTORY ARCHIVER]: The items to save reference {0} assets", m_assetGatherer.GatheredUuids.Count + errors); + "[INVENTORY ARCHIVER]: The items to save reference {0} possible assets", m_assetGatherer.GatheredUuids.Count + errors); if(errors > 0) - m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of these assets have problems and will be ignored", errors); + m_log.DebugFormat("[INVENTORY ARCHIVER]: {0} of these have problems or are not assets and will be ignored", errors); AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index d02db73..0ed3399 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -264,12 +264,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver curErrorCntr = assetGatherer.ErrorCount - curErrorCntr; if(curErrorCntr > 1) { - m_log.WarnFormat("[INVENTORY ARCHIVER]: object {0} '{1}', at {2}, contains at least {3} references to missing or damaged assets", + m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains {3} references to possible missing or damaged assets", sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), curErrorCntr); } else if(curErrorCntr == 1) { - m_log.WarnFormat("[INVENTORY ARCHIVER]: object {0} '{1}', at {2}, contains at least 1 reference to a missing or damaged asset", + m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains a reference to a possible missing or damaged assets", sceneObject.UUID, sceneObject.Name, sceneObject.AbsolutePosition.ToString()); } } @@ -278,10 +278,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver int errors = assetGatherer.FailedUUIDs.Count; m_log.DebugFormat( - "[ARCHIVER]: {0} region scene objects to save reference {1} assets", + "[ARCHIVER]: {0} region scene objects to save reference {1} possible assets", sceneObjects.Count, assetUuids.Count - prevAssets + errors); if(errors > 0) - m_log.DebugFormat("[ARCHIVER]: {0} of these assets have problems and will be ignored", errors); + m_log.DebugFormat("[ARCHIVER]: {0} of these have problems or are not assets and will be ignored", errors); } if (numObjectsSkippedPermissions > 0) diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 903cb2d..751aaca 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// uuids to request /// protected IDictionary m_uuids; - private int m_previusErrorsCount; + private int m_previousErrorsCount; /// /// Callback used when all the assets requested have been received. @@ -103,14 +103,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected internal AssetsRequest( AssetsArchiver assetsArchiver, IDictionary uuids, - int previusErrorsCount, + int previousErrorsCount, IAssetService assetService, IUserAccountService userService, UUID scope, Dictionary options, AssetsRequestCallback assetsRequestCallback) { m_assetsArchiver = assetsArchiver; m_uuids = uuids; - m_previusErrorsCount = previusErrorsCount; + m_previousErrorsCount = previousErrorsCount; m_assetsRequestCallback = assetsRequestCallback; m_assetService = assetService; m_userAccountService = userService; @@ -170,14 +170,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver } m_timeOutTimer.Dispose(); - int totalerrors = m_notFoundAssetUuids.Count + m_previusErrorsCount; + int totalerrors = m_notFoundAssetUuids.Count + m_previousErrorsCount; if(m_timeout) m_log.DebugFormat("[ARCHIVER]: Aborted because AssetService request timeout. Successfully added {0} assets", m_foundAssetUuids.Count); else if(totalerrors == 0) m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count); else - m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} assets of total request where not found or are damaged", + m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested where not found, where damaged or where not assets", m_foundAssetUuids.Count, totalerrors); PerformAssetsRequestCallback(m_timeout); diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 46ce2ce..8ee7dbc 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -149,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes public void AddForInspection(SceneObjectGroup sceneObject) { // m_log.DebugFormat( - // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); + // "[UUID GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); if(sceneObject.IsDeleted) return; @@ -159,7 +159,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = parts[i]; // m_log.DebugFormat( - // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); + // "[UUID GATHERER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); try { -- cgit v1.1 From 191661b51d31254419e9b442ec12953772821ac3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 02:01:48 +0100 Subject: a few more changes to iar/oar assets save error/warning to show problems known to be asset errors --- .../Archiver/InventoryArchiveWriteRequest.cs | 18 +++++--- .../World/Archiver/ArchiveWriteRequest.cs | 24 ++++++---- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 52 ++++++++++++++++++---- 3 files changed, 70 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index d816ba4..ad46107 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -223,10 +223,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) { int curErrorCntr = m_assetGatherer.ErrorCount; + int possible = m_assetGatherer.possibleNotAssetCount; m_assetGatherer.AddForInspection(inventoryItem.AssetID); m_assetGatherer.GatherAll(); curErrorCntr = m_assetGatherer.ErrorCount - curErrorCntr; - if(curErrorCntr > 0) + possible = m_assetGatherer.possibleNotAssetCount - possible; + + if(curErrorCntr > 0 || possible > 0) { string spath; int indx = path.IndexOf("__"); @@ -235,15 +238,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else spath = path; - if(curErrorCntr > 1) + if(curErrorCntr > 0) { - m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references to possible missing or damaged assets )", + m_log.ErrorFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references to missing or damaged assets", inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, curErrorCntr); + if(possible > 0) + m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item also contains {0} references that may be to missing or damaged assets or not a problem", possible); } - else if(curErrorCntr == 1) - { - m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains a reference to a possible missing or damaged asset)", - inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath); + else if(possible > 0) + { + m_log.WarnFormat("[INVENTORY ARCHIVER Warning]: item {0} '{1}', type {2}, in '{3}', contains {4} references that may be to missing or damaged assets or not a problem", inventoryItem.ID, inventoryItem.Name, itemAssetType.ToString(), spath, possible); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 0ed3399..11c53d7 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -182,11 +182,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver Dictionary assetUuids = new Dictionary(); HashSet failedIDs = new HashSet(); + HashSet uncertainAssetsUUIDs = new HashSet(); scenesGroup.ForEachScene(delegate(Scene scene) { string regionDir = MultiRegionFormat ? scenesGroup.GetRegionDir(scene.RegionInfo.RegionID) : ""; - ArchiveOneRegion(scene, regionDir, assetUuids, failedIDs); + ArchiveOneRegion(scene, regionDir, assetUuids, failedIDs, uncertainAssetsUUIDs); }); // Archive the assets @@ -217,7 +218,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } - private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids, HashSet failedIDs) + private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids, + HashSet failedIDs, HashSet uncertainAssetsUUIDs) { m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name); @@ -253,24 +255,28 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (SaveAssets) { - UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids, failedIDs); + UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids, failedIDs, uncertainAssetsUUIDs); int prevAssets = assetUuids.Count; foreach (SceneObjectGroup sceneObject in sceneObjects) { int curErrorCntr = assetGatherer.ErrorCount; + int possible = assetGatherer.possibleNotAssetCount; assetGatherer.AddForInspection(sceneObject); assetGatherer.GatherAll(); curErrorCntr = assetGatherer.ErrorCount - curErrorCntr; - if(curErrorCntr > 1) + possible = assetGatherer.possibleNotAssetCount - possible; + if(curErrorCntr > 0) { - m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains {3} references to possible missing or damaged assets", + m_log.ErrorFormat("[ARCHIVER]: object {0} '{1}', at {2}, contains {3} references to missing or damaged assets", sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), curErrorCntr); + if(possible > 0) + m_log.WarnFormat("[ARCHIVER Warning]: object also contains {0} references that may be to missing or damaged assets or not a problem", possible); } - else if(curErrorCntr == 1) - { - m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains a reference to a possible missing or damaged assets", - sceneObject.UUID, sceneObject.Name, sceneObject.AbsolutePosition.ToString()); + else if(possible > 0) + { + m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains {3} references that may be to missing or damaged assets or not a problem", + sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), possible); } } diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 8ee7dbc..80d3f62 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -66,6 +66,8 @@ namespace OpenSim.Region.Framework.Scenes /// The gathered uuids. public IDictionary GatheredUuids { get; private set; } public HashSet FailedUUIDs { get; private set; } + public HashSet UncertainAssetsUUIDs { get; private set; } + public int possibleNotAssetCount { get; set; } public int ErrorCount { get; private set; } /// /// Gets the next UUID to inspect. @@ -93,8 +95,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Asset service. /// - public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary(), new HashSet ()) {} - public UuidGatherer(IAssetService assetService, IDictionary collector) : this(assetService, collector, new HashSet ()) {} + public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary(), + new HashSet (),new HashSet ()) {} + public UuidGatherer(IAssetService assetService, IDictionary collector) : this(assetService, collector, + new HashSet (), new HashSet ()) {} /// /// Initializes a new instance of the class. @@ -106,7 +110,7 @@ namespace OpenSim.Region.Framework.Scenes /// Gathered UUIDs will be collected in this dictionary. /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected. /// - public UuidGatherer(IAssetService assetService, IDictionary collector, HashSet failedIDs) + public UuidGatherer(IAssetService assetService, IDictionary collector, HashSet failedIDs, HashSet uncertainAssetsUUIDs) { m_assetService = assetService; GatheredUuids = collector; @@ -114,7 +118,9 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: Not efficient for searching, can improve. m_assetUuidsToInspect = new Queue(); FailedUUIDs = failedIDs; + UncertainAssetsUUIDs = uncertainAssetsUUIDs; ErrorCount = 0; + possibleNotAssetCount = 0; } /// @@ -124,8 +130,17 @@ namespace OpenSim.Region.Framework.Scenes /// UUID. public bool AddForInspection(UUID uuid) { + if(uuid == UUID.Zero) + return false; + if(FailedUUIDs.Contains(uuid)) - return false; + { + if(UncertainAssetsUUIDs.Contains(uuid)) + possibleNotAssetCount++; + else + ErrorCount++; + return false; + } if(GatheredUuids.ContainsKey(uuid)) return false; if (m_assetUuidsToInspect.Contains(uuid)) @@ -283,9 +298,15 @@ namespace OpenSim.Region.Framework.Scenes /// The uuid of the asset for which to gather referenced assets private void GetAssetUuids(UUID assetUuid) { + if(assetUuid == UUID.Zero) + return; + if(FailedUUIDs.Contains(assetUuid)) { - ErrorCount++; + if(UncertainAssetsUUIDs.Contains(assetUuid)) + possibleNotAssetCount++; + else + ErrorCount++; return; } @@ -309,11 +330,17 @@ namespace OpenSim.Region.Framework.Scenes if(assetBase == null) { // m_log.ErrorFormat("[UUID GATHERER]: asset {0} not found", assetUuid); - ErrorCount++; FailedUUIDs.Add(assetUuid); + if(UncertainAssetsUUIDs.Contains(assetUuid)) + possibleNotAssetCount++; + else + ErrorCount++; return; } + if(UncertainAssetsUUIDs.Contains(assetUuid)) + UncertainAssetsUUIDs.Remove(assetUuid); + sbyte assetType = assetBase.Type; if(assetBase.Data == null || assetBase.Data.Length == 0) @@ -363,10 +390,16 @@ namespace OpenSim.Region.Framework.Scenes private void AddForInspection(UUID assetUuid, sbyte assetType) { + if(assetUuid == UUID.Zero) + return; + // Here, we want to collect uuids which require further asset fetches but mark the others as gathered if(FailedUUIDs.Contains(assetUuid)) { - ErrorCount++; + if(UncertainAssetsUUIDs.Contains(assetUuid)) + possibleNotAssetCount++; + else + ErrorCount++; return; } if(GatheredUuids.ContainsKey(assetUuid)) @@ -502,8 +535,11 @@ namespace OpenSim.Region.Framework.Scenes foreach (Match uuidMatch in uuidMatches) { UUID uuid = new UUID(uuidMatch.Value); + if(uuid == UUID.Zero) + continue; // m_log.DebugFormat("[UUID GATHERER]: Recording {0} in text", uuid); - + if(!UncertainAssetsUUIDs.Contains(uuid)) + UncertainAssetsUUIDs.Add(uuid); AddForInspection(uuid); } } -- cgit v1.1 From c3dbf91152692734e46850036aae451d87eb9bae Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 03:21:23 +0100 Subject: osDrawFilledEllipse or string comand FillEllipse identical do Ellipse one --- .../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 11 +++++++++++ .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 +++++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 4 files changed, 26 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index f12286d..5d4d0f5 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -625,6 +625,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender startPoint.X += endPoint.X; startPoint.Y += endPoint.Y; } + else if (nextLine.StartsWith("FillEllipse")) + { + float x = 0; + float y = 0; + GetParams(partsDelimiter, ref nextLine, 11, ref x, ref y); + endPoint.X = (int)x; + endPoint.Y = (int)y; + graph.FillEllipse(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); + startPoint.X += endPoint.X; + startPoint.Y += endPoint.Y; + } else if (nextLine.StartsWith("FontSize")) { nextLine = nextLine.Remove(0, 8); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e51a078..37f8970 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1191,6 +1191,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return drawList; } + public string osDrawFilledEllipse(string drawList, int width, int height) + { + CheckThreatLevel(ThreatLevel.None, "osDrawFilledEllipse"); + + m_host.AddScriptLPS(1); + drawList += "FillEllipse " + width + "," + height + "; "; + return drawList; + } + public string osDrawRectangle(string drawList, int width, int height) { CheckThreatLevel(ThreatLevel.None, "osDrawRectangle"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index bd5d008..da3d6de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -222,6 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osDrawLine(string drawList, int endX, int endY); string osDrawText(string drawList, string text); string osDrawEllipse(string drawList, int width, int height); + string osDrawFilledEllipse(string drawList, int width, int height); string osDrawRectangle(string drawList, int width, int height); string osDrawFilledRectangle(string drawList, int width, int height); string osDrawPolygon(string drawList, LSL_List x, LSL_List y); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 9eac114..1451efc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -355,6 +355,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawEllipse(drawList, width, height); } + public string osDrawFilledEllipse(string drawList, int width, int height) + { + return m_OSSL_Functions.osDrawFilledEllipse(drawList, width, height); + } + public string osDrawRectangle(string drawList, int width, int height) { return m_OSSL_Functions.osDrawRectangle(drawList, width, height); -- cgit v1.1 From ae4266916cc3b75e1e897c9250b47390340eab72 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 04:23:13 +0100 Subject: add string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, int timer, int face) to easy only setting a prim face --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 ++++++++- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 37f8970..d782ee6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -736,6 +736,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer) { + return osSetDynamicTextureDataFace(dynamicID, contentType, data, extraParams, timer, -1); + } + + public string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, + int timer, int face) + { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData"); m_host.AddScriptLPS(1); @@ -750,7 +756,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer); + extraParams, timer, false, 3, 255, face); + return createdTexture.ToString(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index da3d6de..c12490c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -123,6 +123,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face); string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); + string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, int timer, int face); string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha); string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 1451efc..9bc3159 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -153,6 +153,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer); } + public string osSetDynamicTextureDataFace(string dynamicID, string contentType, string data, string extraParams, + int timer, int face) + { + return m_OSSL_Functions.osSetDynamicTextureDataFace(dynamicID, contentType, data, extraParams, timer, face); + } + public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha) { -- cgit v1.1 From 72db6f76b5dc373d3178fbf09d04d385d63bc52d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 05:22:02 +0100 Subject: remove a DynamicTexture leak, make it actually return the new texture ID to ossl, do delete previus texture from local cache if temporary,at least on same cases... but still very broken.. --- .../DynamicTexture/DynamicTextureModule.cs | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index c369d87..82596ca 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -135,16 +135,15 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture m_reuseableDynamicTextures.Store( GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID); } + updater.newTextureID = newTextureID; } - } - if (updater.UpdateTimer == 0) - { - lock (Updaters) + if (updater.UpdateTimer == 0) { - if (!Updaters.ContainsKey(updater.UpdaterID)) + lock (Updaters) { - Updaters.Remove(updater.UpdaterID); + if (Updaters.ContainsKey(updater.UpdaterID)) + Updaters.Remove(updater.UpdaterID); } } } @@ -213,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); - return updater.UpdaterID; + return updater.newTextureID; } return UUID.Zero; } @@ -314,7 +313,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.UpdatePart(part, (UUID)objReusableTextureUUID); } - return updater.UpdaterID; + return updater.newTextureID; } private string GenerateReusableTextureKey(string data, string extraParams) @@ -411,6 +410,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public int Face; public int Disp; public string Url; + public UUID newTextureID; public DynamicTextureUpdater() { @@ -445,7 +445,14 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture { try { - Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); + Primitive.TextureEntryFace texface = tmptex.GetFace((uint)Face); + if(texface == null) + tmptex.GetFace((uint)Face); + else + { + if(texface.TextureID != null && texface.TextureID != UUID.Zero) + oldID = texface.TextureID; + } texface.TextureID = textureID; tmptex.FaceTextures[Face] = texface; } -- cgit v1.1 From ed8fc359f3853bab07ec3f5d6fd533da8d3797be Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 06:11:10 +0100 Subject: change thread level of osSetDynamicTextureDataBlendFace to VeryHigh --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index d782ee6..7371fc5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -801,7 +801,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlendFace"); + CheckThreatLevel(ThreatLevel.VeryHigh , "osSetDynamicTextureDataBlendFace"); m_host.AddScriptLPS(1); if (dynamicID == String.Empty) -- cgit v1.1 From 8d1dd44edb187429b5a26ca56fc2d53766f710c7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 07:39:22 +0100 Subject: simplify vectorrender background draw --- .../Scripting/VectorRender/VectorRenderModule.cs | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 5d4d0f5..a3b53be 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -355,30 +355,22 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender lock (this) { if (alpha == 256) - bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb); - else - bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); - - graph = Graphics.FromImage(bitmap); - - // this is really just to save people filling the - // background color in their scripts, only do when fully opaque - if (alpha >= 255) { + bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb); + graph = Graphics.FromImage(bitmap); using (SolidBrush bgFillBrush = new SolidBrush(bgColor)) { graph.FillRectangle(bgFillBrush, 0, 0, width, height); } - } - - for (int w = 0; w < bitmap.Width; w++) + } + else { - if (alpha <= 255) + bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); + graph = Graphics.FromImage(bitmap); + Color newbg = Color.FromArgb(alpha,bgColor); + using (SolidBrush bgFillBrush = new SolidBrush(newbg)) { - for (int h = 0; h < bitmap.Height; h++) - { - bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h))); - } + graph.FillRectangle(bgFillBrush, 0, 0, width, height); } } -- cgit v1.1 From 1a8a77c41e4061b75ff97fcf89e39717550bfa25 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 09:24:56 +0100 Subject: revert the thread level change; remove unused dynamic texture timer from internal code; let blend alpha work if < 255; let blend work with the selected face; etc --- .../DynamicTexture/DynamicTextureModule.cs | 81 +++++++++++----------- .../VectorRender/Tests/VectorRenderModuleTests.cs | 48 +++++-------- .../Framework/Interfaces/IDynamicTextureManager.cs | 22 +++--- .../Shared/Api/Implementation/OSSL_Api.cs | 14 ++-- 4 files changed, 70 insertions(+), 95 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 82596ca..c0b7ab5 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -138,13 +138,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.newTextureID = newTextureID; } - if (updater.UpdateTimer == 0) + lock (Updaters) { - lock (Updaters) - { - if (Updaters.ContainsKey(updater.UpdaterID)) - Updaters.Remove(updater.UpdaterID); - } + if (Updaters.ContainsKey(updater.UpdaterID)) + Updaters.Remove(updater.UpdaterID); } } } @@ -171,21 +168,20 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, - string extraParams, int updateTimer) + string extraParams) { - return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255); + return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, false, 255); } public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, - string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) + string extraParams, bool SetBlending, byte AlphaValue) { - return AddDynamicTextureURL(simID, primID, contentType, url, - extraParams, updateTimer, SetBlending, - (int)(DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); + return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, SetBlending, + (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); } public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, - string extraParams, int updateTimer, bool SetBlending, + string extraParams, bool SetBlending, int disp, byte AlphaValue, int face) { if (RenderPlugins.ContainsKey(contentType)) @@ -195,7 +191,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.PrimID = primID; updater.ContentType = contentType; updater.Url = url; - updater.UpdateTimer = updateTimer; updater.UpdaterID = UUID.Random(); updater.Params = extraParams; updater.BlendWithOldTexture = SetBlending; @@ -218,20 +213,21 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, - string extraParams, int updateTimer) + string extraParams) { - return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255); + return AddDynamicTextureData(simID, primID, contentType, data, extraParams, false, + (DISP_TEMP|DISP_EXPIRE), 255, ALL_SIDES); } public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, - string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) + string extraParams, bool SetBlending, byte AlphaValue) { - return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, - (int) (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); + return AddDynamicTextureData(simID, primID, contentType, data, extraParams, SetBlending, + (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); } public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, - string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) + string extraParams, bool SetBlending, int disp, byte AlphaValue, int face) { if (!RenderPlugins.ContainsKey(contentType)) return UUID.Zero; @@ -257,7 +253,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.PrimID = primID; updater.ContentType = contentType; updater.BodyData = data; - updater.UpdateTimer = updateTimer; updater.UpdaterID = UUID.Random(); updater.Params = extraParams; updater.BlendWithOldTexture = SetBlending; @@ -403,10 +398,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public byte FrontAlpha = 255; public string Params; public UUID PrimID; - public bool SetNewFrontAlpha = false; public UUID SimUUID; public UUID UpdaterID; - public int UpdateTimer; public int Face; public int Disp; public string Url; @@ -414,7 +407,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public DynamicTextureUpdater() { - UpdateTimer = 0; BodyData = null; } @@ -440,19 +432,15 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture { oldID = tmptex.DefaultTexture.TextureID; tmptex.DefaultTexture.TextureID = textureID; + for(int i = 0; i < tmptex.FaceTextures.Length; i++) + tmptex.FaceTextures[i] = null; } else { try { - Primitive.TextureEntryFace texface = tmptex.GetFace((uint)Face); - if(texface == null) - tmptex.GetFace((uint)Face); - else - { - if(texface.TextureID != null && texface.TextureID != UUID.Zero) - oldID = texface.TextureID; - } + Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); + oldID = texface.TextureID; texface.TextureID = textureID; tmptex.FaceTextures[Face] = texface; } @@ -462,10 +450,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } } - // I'm pretty sure we always want to force this to true - // I'm pretty sure noone whats to set fullbright true if it wasn't true before. - // tmptex.DefaultTexture.Fullbright = true; - part.UpdateTextureEntry(tmptex.GetBytes()); } @@ -498,13 +482,26 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture if (BlendWithOldTexture) { - Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture; - if (defaultFace != null) + Primitive.TextureEntryFace curFace; + if(Face == ALL_SIDES) + curFace = part.Shape.Textures.DefaultTexture; + else + { + try + { + curFace = part.Shape.Textures.GetFace((uint)Face); + } + catch + { + curFace = null; + } + } + if (curFace != null) { - oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString()); + oldAsset = scene.AssetService.Get(curFace.TextureID.ToString()); if (oldAsset != null) - assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); + assetData = BlendTextures(data, oldAsset.Data, FrontAlpha); } } @@ -555,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture return asset.FullID; } - private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) + private byte[] BlendTextures(byte[] frontImage, byte[] backImage, byte newAlpha) { ManagedImage managedImage; Image image; @@ -575,7 +572,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture Bitmap image2 = new Bitmap(image); image.Dispose(); - if (setNewAlpha) + if (newAlpha < 255) SetAlpha(ref image1, newAlpha); using(Bitmap joint = MergeBitMaps(image1, image2)) diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs index ed255bf..325f7f9 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs @@ -77,8 +77,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;", - "", - 0); + ""); Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -98,8 +97,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -108,8 +106,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -129,8 +126,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -139,8 +135,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "alpha:250", - 0); + "alpha:250"); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -161,8 +156,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -171,8 +165,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -191,8 +184,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;", - "", - 0); + ""); Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -213,8 +205,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -223,8 +214,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -253,8 +243,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "1024", - 0); + "1024"); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -263,8 +252,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "1024", - 0); + "1024"); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -284,8 +272,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -294,8 +281,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "alpha:250", - 0); + "alpha:250"); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } @@ -316,8 +302,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -326,8 +311,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests so.UUID, m_vrm.GetContentType(), dtText, - "", - 0); + ""); Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); } diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs index 441076d..093ea9c 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs @@ -44,14 +44,13 @@ namespace OpenSim.Region.Framework.Interfaces /// void ReturnData(UUID id, IDynamicTexture texture); + UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams); UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, - int updateTimer); + bool SetBlending, byte AlphaValue); UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, - int updateTimer, bool SetBlending, byte AlphaValue); - UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, - int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face); - UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, - int updateTimer); + bool SetBlending, int disp, byte AlphaValue, int face); + + UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams); /// Apply a dynamically generated texture to all sides of the given prim. The texture is not persisted to the /// asset service. @@ -62,8 +61,6 @@ namespace OpenSim.Region.Framework.Interfaces /// based texture or "image" to create a texture from an image at a particular URL /// The data for the generator /// Parameters for the generator that don't form part of the main data. - /// If zero, the image is never updated after the first generation. If positive - /// the image is updated at the given interval. Not implemented for /// /// If true, the newly generated texture is blended with the appropriate existing ones on the prim /// @@ -76,7 +73,7 @@ namespace OpenSim.Region.Framework.Interfaces /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID /// UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, - int updateTimer, bool SetBlending, byte AlphaValue); + bool SetBlending, byte AlphaValue); /// /// Apply a dynamically generated texture to the given prim. @@ -87,8 +84,6 @@ namespace OpenSim.Region.Framework.Interfaces /// based texture or "image" to create a texture from an image at a particular URL /// The data for the generator /// Parameters for the generator that don't form part of the main data. - /// If zero, the image is never updated after the first generation. If positive - /// the image is updated at the given interval. Not implemented for /// /// If true, the newly generated texture is blended with the appropriate existing ones on the prim /// @@ -109,9 +104,8 @@ namespace OpenSim.Region.Framework.Interfaces /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID /// - UUID AddDynamicTextureData( - UUID simID, UUID primID, string contentType, string data, string extraParams, - int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face); + UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, + bool SetBlending, int disp, byte AlphaValue, int face); void GetDrawStringSize(string contentType, string text, string fontName, int fontSize, out double xSize, out double ySize); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7371fc5..3a0884f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -678,7 +678,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer); + extraParams); return createdTexture.ToString(); } else @@ -700,7 +700,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer, true, (byte) alpha); + extraParams, true, (byte) alpha); return createdTexture.ToString(); } else @@ -722,7 +722,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer, blend, disp, (byte) alpha, face); + extraParams, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } else @@ -756,7 +756,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, false, 3, 255, face); + extraParams, false, 3, 255, face); return createdTexture.ToString(); } @@ -786,7 +786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, true, (byte) alpha); + extraParams, true, (byte) alpha); return createdTexture.ToString(); } } @@ -801,7 +801,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - CheckThreatLevel(ThreatLevel.VeryHigh , "osSetDynamicTextureDataBlendFace"); + CheckThreatLevel(ThreatLevel.VeryLow , "osSetDynamicTextureDataBlendFace"); m_host.AddScriptLPS(1); if (dynamicID == String.Empty) @@ -815,7 +815,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, blend, disp, (byte) alpha, face); + extraParams, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } } -- cgit v1.1 From 5d776fca3a6c52f79f3fd33229492b26b03ca238 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 21:42:11 +0100 Subject: add dyn textures vectorrender comands ''ResetTransf;'', ''TransTransf x,y;'' and ''RotTransf x'' string only, no ossl helper api still --- .../Scripting/VectorRender/VectorRenderModule.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index a3b53be..fc4ccfe 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -511,8 +511,25 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender // m_log.DebugFormat("[VECTOR RENDER MODULE]: Processing line '{0}'", nextLine); + if (nextLine.StartsWith("ResetTransf")) + { + graph.ResetTransform(); + } + else if (nextLine.StartsWith("TransTransf")) + { + float x = 0; + float y = 0; + GetParams(partsDelimiter, ref nextLine, 11, ref x, ref y); + graph.TranslateTransform(x, y); + } + else if (nextLine.StartsWith("RotTransf")) + { + float x = 0; + GetParams(partsDelimiter, ref nextLine, 9, ref x); + graph.RotateTransform(x); + } //replace with switch, or even better, do some proper parsing - if (nextLine.StartsWith("MoveTo")) + else if (nextLine.StartsWith("MoveTo")) { float x = 0; float y = 0; @@ -793,6 +810,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } } + private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref float x) + { + line = line.Remove(0, startLength); + string[] parts = line.Split(partsDelimiter); + if (parts.Length > 0) + { + string xVal = parts[0].Trim(); + x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); + } + } + private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref float x, ref float y) { line = line.Remove(0, startLength); -- cgit v1.1 From cb8975e56729c6fd077a69df3a7fa06cba285f82 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Jun 2017 23:04:37 +0100 Subject: add string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y), string osDrawRotationTransform(string drawList, LSL_Float x) and string osDrawResetTransform(string drawList) helper functions for the new vector renderer comands. Removed ThreadLevel check of similar funtions that had it None, and actually only set strings --- .../Shared/Api/Implementation/OSSL_Api.cs | 58 ++++++++++++++++------ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 3 ++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 15 ++++++ 3 files changed, 60 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3a0884f..e93a7d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1153,9 +1153,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } //Texture draw functions + + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + CheckThreatLevel(); + + m_host.AddScriptLPS(1); + drawList += "TransTransf " + x + "," + y + ";"; + return drawList; + } + + public string osDrawRotationTransform(string drawList, LSL_Float x) + { + CheckThreatLevel(); + m_host.AddScriptLPS(1); + drawList += "RotTransf " + x + ";"; + return drawList; + } + + public string osDrawResetTransform(string drawList) + { + CheckThreatLevel(); + m_host.AddScriptLPS(1); + drawList += "ResetTransf;"; + return drawList; + } + public string osMovePen(string drawList, int x, int y) { - CheckThreatLevel(ThreatLevel.None, "osMovePen"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "MoveTo " + x + "," + y + ";"; @@ -1164,7 +1190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawLine(string drawList, int startX, int startY, int endX, int endY) { - CheckThreatLevel(ThreatLevel.None, "osDrawLine"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; @@ -1173,7 +1199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawLine(string drawList, int endX, int endY) { - CheckThreatLevel(ThreatLevel.None, "osDrawLine"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "LineTo " + endX + "," + endY + "; "; @@ -1191,7 +1217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawEllipse(string drawList, int width, int height) { - CheckThreatLevel(ThreatLevel.None, "osDrawEllipse"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "Ellipse " + width + "," + height + "; "; @@ -1200,7 +1226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawFilledEllipse(string drawList, int width, int height) { - CheckThreatLevel(ThreatLevel.None, "osDrawFilledEllipse"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "FillEllipse " + width + "," + height + "; "; @@ -1209,7 +1235,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawRectangle(string drawList, int width, int height) { - CheckThreatLevel(ThreatLevel.None, "osDrawRectangle"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "Rectangle " + width + "," + height + "; "; @@ -1218,7 +1244,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawFilledRectangle(string drawList, int width, int height) { - CheckThreatLevel(ThreatLevel.None, "osDrawFilledRectangle"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "FillRectangle " + width + "," + height + "; "; @@ -1227,7 +1253,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) { - CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon"); + CheckThreatLevel(); m_host.AddScriptLPS(1); @@ -1246,7 +1272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawPolygon(string drawList, LSL_List x, LSL_List y) { - CheckThreatLevel(ThreatLevel.None, "osDrawPolygon"); + CheckThreatLevel(); m_host.AddScriptLPS(1); @@ -1265,7 +1291,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetFontSize(string drawList, int fontSize) { - CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "FontSize "+ fontSize +"; "; @@ -1274,7 +1300,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetFontName(string drawList, string fontName) { - CheckThreatLevel(ThreatLevel.None, "osSetFontName"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "FontName "+ fontName +"; "; @@ -1283,7 +1309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetPenSize(string drawList, int penSize) { - CheckThreatLevel(ThreatLevel.None, "osSetPenSize"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "PenSize " + penSize + "; "; @@ -1292,7 +1318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetPenColor(string drawList, string color) { - CheckThreatLevel(ThreatLevel.None, "osSetPenColor"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "PenColor " + color + "; "; @@ -1302,7 +1328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Deprecated public string osSetPenColour(string drawList, string colour) { - CheckThreatLevel(ThreatLevel.None, "osSetPenColour"); + CheckThreatLevel(); OSSLDeprecated("osSetPenColour", "osSetPenColor"); m_host.AddScriptLPS(1); @@ -1312,7 +1338,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osSetPenCap(string drawList, string direction, string type) { - CheckThreatLevel(ThreatLevel.None, "osSetPenCap"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList += "PenCap " + direction + "," + type + "; "; @@ -1321,7 +1347,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawImage(string drawList, int width, int height, string imageUrl) { - CheckThreatLevel(ThreatLevel.None, "osDrawImage"); + CheckThreatLevel(); m_host.AddScriptLPS(1); drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index c12490c..19cfcc1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -228,6 +228,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osDrawFilledRectangle(string drawList, int width, int height); string osDrawPolygon(string drawList, LSL_List x, LSL_List y); string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y); + string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y); + string osDrawRotationTransform(string drawList, LSL_Float x); + string osDrawResetTransform(string drawList); string osSetFontName(string drawList, string fontName); string osSetFontSize(string drawList, int fontSize); string osSetPenSize(string drawList, int penSize); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 9bc3159..4b1f6d3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -386,6 +386,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y); } + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + return m_OSSL_Functions.osDrawTranslationTransform(drawList, x, y); + } + + public string osDrawRotationTransform(string drawList, LSL_Float x) + { + return m_OSSL_Functions.osDrawRotationTransform(drawList, x); + } + + public string osDrawResetTransform(string drawList) + { + return m_OSSL_Functions.osDrawResetTransform(drawList); + } + public string osSetFontSize(string drawList, int fontSize) { return m_OSSL_Functions.osSetFontSize(drawList, fontSize); -- cgit v1.1 From a9a44eaeb5abdbea63d6c7d0c81454fb5a093817 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 25 Jun 2017 02:17:02 +0100 Subject: add vectorrender string command ''ScaleTransf x,y;''. this allows scaling of objects to draw next. -1,1 will make text be drawn with x direction flipped (it is like the texture scale) --- .../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index fc4ccfe..8a26ab7 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -522,6 +522,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender GetParams(partsDelimiter, ref nextLine, 11, ref x, ref y); graph.TranslateTransform(x, y); } + else if (nextLine.StartsWith("ScaleTransf")) + { + float x = 0; + float y = 0; + GetParams(partsDelimiter, ref nextLine, 11, ref x, ref y); + graph.ScaleTransform(x, y); + } else if (nextLine.StartsWith("RotTransf")) { float x = 0; -- cgit v1.1 From 84abdf866a26401e48eff5b25a1ec7f7bf19dc3c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 25 Jun 2017 02:26:36 +0100 Subject: add respective ossl helper funtion osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) --- .../Shared/Api/Implementation/OSSL_Api.cs | 19 ++++++++++++++----- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 5 +++-- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 13 +++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e93a7d7..dee195a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1154,12 +1154,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Texture draw functions - public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + public string osDrawResetTransform(string drawList) { CheckThreatLevel(); - m_host.AddScriptLPS(1); - drawList += "TransTransf " + x + "," + y + ";"; + drawList += "ResetTransf;"; return drawList; } @@ -1171,11 +1170,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return drawList; } - public string osDrawResetTransform(string drawList) + public string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) { CheckThreatLevel(); + m_host.AddScriptLPS(1); - drawList += "ResetTransf;"; + drawList += "ScaleTransf " + x + "," + y + ";"; + return drawList; + } + + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + CheckThreatLevel(); + + m_host.AddScriptLPS(1); + drawList += "TransTransf " + x + "," + y + ";"; return drawList; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 19cfcc1..f7857da 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -228,9 +228,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osDrawFilledRectangle(string drawList, int width, int height); string osDrawPolygon(string drawList, LSL_List x, LSL_List y); string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y); - string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y); - string osDrawRotationTransform(string drawList, LSL_Float x); string osDrawResetTransform(string drawList); + string osDrawRotationTransform(string drawList, LSL_Float x); + string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y); + string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y); string osSetFontName(string drawList, string fontName); string osSetFontSize(string drawList, int fontSize); string osSetPenSize(string drawList, int penSize); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4b1f6d3..d6af32b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -386,9 +386,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y); } - public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + public string osDrawResetTransform(string drawList) { - return m_OSSL_Functions.osDrawTranslationTransform(drawList, x, y); + return m_OSSL_Functions.osDrawResetTransform(drawList); } public string osDrawRotationTransform(string drawList, LSL_Float x) @@ -396,9 +396,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawRotationTransform(drawList, x); } - public string osDrawResetTransform(string drawList) + public string osDrawScaleTransform(string drawList, LSL_Float x, LSL_Float y) { - return m_OSSL_Functions.osDrawResetTransform(drawList); + return m_OSSL_Functions.osDrawScaleTransform(drawList, x, y); + } + + public string osDrawTranslationTransform(string drawList, LSL_Float x, LSL_Float y) + { + return m_OSSL_Functions.osDrawTranslationTransform(drawList, x, y); } public string osSetFontSize(string drawList, int fontSize) -- cgit v1.1 From 3ce909528dd42cd2c92d8ac6590135bb1962aee4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 25 Jun 2017 15:42:36 +0100 Subject: change Backup calls overlap control code --- OpenSim/Region/Framework/Scenes/Scene.cs | 73 ++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ebef158..09b209e 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1942,7 +1942,6 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_backingup) { - m_backingup = true; WorkManager.RunInThreadPool(o => Backup(false), null, string.Format("BackupWorker ({0})", Name)); } } @@ -1971,38 +1970,58 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_returns) { - EventManager.TriggerOnBackup(SimulationDataService, forced); + if(m_backingup) + { + m_log.WarnFormat("[Scene] Backup of {0} already running. New call skipped", RegionInfo.RegionName); + return; + } - foreach (KeyValuePair ret in m_returns) + m_backingup = true; + try { - UUID transaction = UUID.Random(); - - GridInstantMessage msg = new GridInstantMessage(); - msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server - msg.toAgentID = new Guid(ret.Key.ToString()); - msg.imSessionID = new Guid(transaction.ToString()); - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); - msg.fromAgentName = "Server"; - msg.dialog = (byte)19; // Object msg - msg.fromGroup = false; - msg.offline = (byte)1; - msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; - msg.Position = Vector3.Zero; - msg.RegionID = RegionInfo.RegionID.Guid; - - // We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3. - msg.binaryBucket = Util.StringToBytes256("\0"); - if (ret.Value.count > 1) - msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); - else - msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); + EventManager.TriggerOnBackup(SimulationDataService, forced); + + if(m_returns.Count == 0) + return; IMessageTransferModule tr = RequestModuleInterface(); - if (tr != null) + if (tr == null) + return; + + uint unixtime = (uint)Util.UnixTimeSinceEpoch(); + uint estateid = RegionInfo.EstateSettings.ParentEstateID; + Guid regionguid = RegionInfo.RegionID.Guid; + + foreach (KeyValuePair ret in m_returns) + { + GridInstantMessage msg = new GridInstantMessage(); + msg.fromAgentID = Guid.Empty; // From server + msg.toAgentID = ret.Key.Guid; + msg.imSessionID = Guid.NewGuid(); + msg.timestamp = unixtime; + msg.fromAgentName = "Server"; + msg.dialog = 19; // Object msg + msg.fromGroup = false; + msg.offline = 1; + msg.ParentEstateID = estateid; + msg.Position = Vector3.Zero; + msg.RegionID = regionguid; + + // We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3. + msg.binaryBucket = new Byte[1] {0}; + if (ret.Value.count > 1) + msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); + else + msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); + tr.SendInstantMessage(msg, delegate(bool success) { }); + } + m_returns.Clear(); + } + finally + { + m_backingup = false; } - m_returns.Clear(); - m_backingup = false; } } -- cgit v1.1 From 041854234429800d6ca10c4987c5d99185552fd6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 00:18:46 +0100 Subject: some shortcuts on local osTeleport, reduce its time penalty, do it with script thread --- OpenSim/Region/Framework/Scenes/Scene.cs | 44 ++++++--- .../Shared/Api/Implementation/OSSL_Api.cs | 102 ++++++++++----------- 2 files changed, 79 insertions(+), 67 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 09b209e..5e8487d 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4824,16 +4824,34 @@ Label_GroupsDone: public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, Vector3 lookat, uint teleportFlags) { - GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName); + if (EntityTransferModule == null) + { + m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); + return; + } + + ScenePresence sp = GetScenePresence(remoteClient.AgentId); + if (sp == null || sp.IsDeleted || sp.IsInTransit) + return; - if (region == null) + ulong regionHandle = 0; + if(regionName == RegionInfo.RegionName) + regionHandle = RegionInfo.RegionHandle; + else + { + GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName); + if (region != null) + regionHandle = region.RegionHandle; + } + + if(regionHandle == 0) { // can't find the region: Tell viewer and abort remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); return; } - RequestTeleportLocation(remoteClient, region.RegionHandle, position, lookat, teleportFlags); + EntityTransferModule.Teleport(sp, regionHandle, position, lookat, teleportFlags); } /// @@ -4847,19 +4865,17 @@ Label_GroupsDone: public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { - ScenePresence sp = GetScenePresence(remoteClient.AgentId); - if (sp != null) + if (EntityTransferModule == null) { - if (EntityTransferModule != null) - { - EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); - } - else - { - m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); - sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator."); - } + m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); + return; } + + ScenePresence sp = GetScenePresence(remoteClient.AgentId); + if (sp == null || sp.IsDeleted || sp.IsInTransit) + return; + + EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); } public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index dee195a..5339fc3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -859,41 +859,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionName, position, lookat, false); + TeleportAgent(agent, regionName, position, lookat); } private void TeleportAgent(string agent, string regionName, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { m_host.AddScriptLPS(1); - UUID agentId = new UUID(); + if(String.IsNullOrWhiteSpace(regionName)) + return; + + UUID agentId; if (UUID.TryParse(agent, out agentId)) { ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null) - { - // For osTeleportAgent, agent must be over owners land to avoid abuse - // For osTeleportOwner, this restriction isn't necessary - - // commented out because its redundant and uneeded please remove eventually. - // if (relaxRestrictions || - // m_host.OwnerID - // == World.LandChannel.GetLandObject( - // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - // { - - // We will launch the teleport on a new thread so that when the script threads are terminated - // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. - Util.FireAndForget( - o => World.RequestTeleportLocation( - presence.ControllingClient, regionName, position, - lookat, (uint)TPFlags.ViaLocation), - null, "OSSL_Api.TeleportAgentByRegionCoords"); - - ScriptSleep(5000); - - // } + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; + if(regionName == World.RegionInfo.RegionName) + { + // should be faster than going to threadpool + World.RequestTeleportLocation(presence.ControllingClient, regionName, position, + lookat, (uint)TPFlags.ViaLocation); + ScriptSleep(500); + } + else + { + // We will launch the teleport on a new thread so that when the script threads are terminated + // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. + Util.FireAndForget( + o => World.RequestTeleportLocation( + presence.ControllingClient, regionName, position, + lookat, (uint)TPFlags.ViaLocation), + null, "OSSL_Api.TeleportAgentByRegionCoords"); + ScriptSleep(5000); } } } @@ -913,41 +912,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); m_host.AddScriptLPS(1); - UUID agentId = new UUID(); + UUID agentId; if (UUID.TryParse(agent, out agentId)) { ScenePresence presence = World.GetScenePresence(agentId); - if (presence != null) - { - // For osTeleportAgent, agent must be over owners land to avoid abuse - // For osTeleportOwner, this restriction isn't necessary - - // commented out because its redundant and uneeded please remove eventually. - // if (relaxRestrictions || - // m_host.OwnerID - // == World.LandChannel.GetLandObject( - // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - // { - - // We will launch the teleport on a new thread so that when the script threads are terminated - // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. - Util.FireAndForget( - o => World.RequestTeleportLocation( - presence.ControllingClient, regionHandle, - position, lookat, (uint)TPFlags.ViaLocation), - null, "OSSL_Api.TeleportAgentByRegionName"); - - ScriptSleep(5000); + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; - // } + Util.FireAndForget( + o => World.RequestTeleportLocation( + presence.ControllingClient, regionHandle, + position, lookat, (uint)TPFlags.ViaLocation), + null, "OSSL_Api.TeleportAgentByRegionName"); - } + ScriptSleep(5000); } } public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat); + m_host.AddScriptLPS(1); + + UUID agentId; + if (UUID.TryParse(agent, out agentId)) + { + ScenePresence presence = World.GetScenePresence(agentId); + if (presence == null || presence.IsDeleted || presence.IsInTransit) + return; + + World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, + lookat, (uint)TPFlags.ViaLocation); + ScriptSleep(500); + } } public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) @@ -955,12 +951,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Threat level None because this is what can already be done with the World Map in the viewer CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true); + TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); } public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - osTeleportOwner(World.RegionInfo.RegionName, position, lookat); + osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); } public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) -- cgit v1.1 From 0c5f412ed40663689aad2aadf9313e0dd782f4ac Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 02:49:20 +0100 Subject: put back restriction that on osTeleport the target must be on land owned by the script owner or this is a estate manager/owner, or target did gave script permission. --- .../Shared/Api/Implementation/OSSL_Api.cs | 93 ++++++++++++++++++---- 1 file changed, 78 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5339fc3..ce48e63 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -852,6 +852,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); } + private bool checkAllowAgentTPbyLandOwner(UUID agentId, Vector3 pos) + { + if (m_item.PermsGranter == agentId) + { + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) + return true; + } + + ILandObject land = World.LandChannel.GetLandObject(pos); + if(land == null) + return true; + + LandData landdata = land.LandData; + if(landdata == null) + return true; + + UUID hostOwner = m_host.OwnerID; + + if(landdata.OwnerID == hostOwner) + return true; + + if(World.RegionInfo.EstateSettings != null && World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(hostOwner)) + return true; + + if(!landdata.IsGroupOwned) + return false; + + UUID landGroup = landdata.GroupID; + if(landGroup == UUID.Zero) + return false; + + if(landGroup == m_host.GroupID) + return true; + + return false; + } + // Teleport functions public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { @@ -859,15 +896,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionName, position, lookat); + TeleportAgent(agent, regionName, position, lookat, true); } private void TeleportAgent(string agent, string regionName, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) { m_host.AddScriptLPS(1); - if(String.IsNullOrWhiteSpace(regionName)) - return; + if(String.IsNullOrEmpty(regionName)) + regionName = World.RegionInfo.RegionName; UUID agentId; if (UUID.TryParse(agent, out agentId)) @@ -876,6 +913,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null || presence.IsDeleted || presence.IsInTransit) return; + Vector3 pos = presence.AbsolutePosition; + if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + { + ScriptSleep(500); + return; + } + if(regionName == World.RegionInfo.RegionName) { // should be faster than going to threadpool @@ -903,15 +947,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionGridX, regionGridY, position, lookat, false); + TeleportAgent(agent, regionGridX, regionGridY, position, lookat, true); } private void TeleportAgent(string agent, int regionGridX, int regionGridY, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) { + m_host.AddScriptLPS(1); + ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); - m_host.AddScriptLPS(1); UUID agentId; if (UUID.TryParse(agent, out agentId)) { @@ -919,6 +964,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null || presence.IsDeleted || presence.IsInTransit) return; + Vector3 pos = presence.AbsolutePosition; + if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + { + ScriptSleep(500); + return; + } + Util.FireAndForget( o => World.RequestTeleportLocation( presence.ControllingClient, regionHandle, @@ -931,8 +983,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - m_host.AddScriptLPS(1); + TeleportAgent(agent, position, lookat, true); + } + private void TeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) + { + m_host.AddScriptLPS(1); UUID agentId; if (UUID.TryParse(agent, out agentId)) { @@ -940,6 +996,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null || presence.IsDeleted || presence.IsInTransit) return; + Vector3 pos = presence.AbsolutePosition; + if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + { + ScriptSleep(500); + return; + } + World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, lookat, (uint)TPFlags.ViaLocation); ScriptSleep(500); @@ -951,19 +1014,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Threat level None because this is what can already be done with the World Map in the viewer CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); - } - - public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) - { - osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); + TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, false); } public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat, true); + TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat, false); + } + + public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + { + TeleportAgent(m_host.OwnerID.ToString(), position, lookat, false); } /// -- cgit v1.1 From e075cf44614dde1b4fcf4c3f539b1d3eba049f5d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 09:08:23 +0100 Subject: fix bad english --- OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 751aaca..8fae1d5 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -177,7 +177,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver else if(totalerrors == 0) m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count); else - m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested where not found, where damaged or where not assets", + m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested were not found, were damaged or were not assets", m_foundAssetUuids.Count, totalerrors); PerformAssetsRequestCallback(m_timeout); -- cgit v1.1 From ef74efeaa7214e208739e1e71bcbc98426ec8764 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 09:18:31 +0100 Subject: and add a missing bracket :) --- OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 8fae1d5..91f4dc3 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -177,7 +177,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver else if(totalerrors == 0) m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count); else - m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested were not found, were damaged or were not assets", + m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested were not found, were damaged or were not assets)", m_foundAssetUuids.Count, totalerrors); PerformAssetsRequestCallback(m_timeout); -- cgit v1.1 From cbd0af3cab4c12aab0e149802d2b62aa35bd561b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 18:26:45 +0100 Subject: let osTeleport* always work on script prim owner --- .../Shared/Api/Implementation/OSSL_Api.cs | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ce48e63..d665f69 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -854,6 +854,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private bool checkAllowAgentTPbyLandOwner(UUID agentId, Vector3 pos) { + UUID hostOwner = m_host.OwnerID; + + if(hostOwner == agentId) + return true; + if (m_item.PermsGranter == agentId) { if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) @@ -868,8 +873,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(landdata == null) return true; - UUID hostOwner = m_host.OwnerID; - if(landdata.OwnerID == hostOwner) return true; @@ -896,11 +899,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionName, position, lookat, true); + TeleportAgent(agent, regionName, position, lookat); } private void TeleportAgent(string agent, string regionName, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { m_host.AddScriptLPS(1); if(String.IsNullOrEmpty(regionName)) @@ -914,7 +917,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; Vector3 pos = presence.AbsolutePosition; - if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) { ScriptSleep(500); return; @@ -947,11 +950,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); - TeleportAgent(agent, regionGridX, regionGridY, position, lookat, true); + TeleportAgent(agent, regionGridX, regionGridY, position, lookat); } private void TeleportAgent(string agent, int regionGridX, int regionGridY, - LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) + LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { m_host.AddScriptLPS(1); @@ -965,7 +968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; Vector3 pos = presence.AbsolutePosition; - if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) { ScriptSleep(500); return; @@ -983,11 +986,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - TeleportAgent(agent, position, lookat, true); - } - - private void TeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool isNotOwner) - { m_host.AddScriptLPS(1); UUID agentId; if (UUID.TryParse(agent, out agentId)) @@ -997,7 +995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; Vector3 pos = presence.AbsolutePosition; - if(isNotOwner && !checkAllowAgentTPbyLandOwner(agentId, pos)) + if(!checkAllowAgentTPbyLandOwner(agentId, pos)) { ScriptSleep(500); return; @@ -1014,19 +1012,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Threat level None because this is what can already be done with the World Map in the viewer CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, false); + TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); } public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); - TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat, false); + TeleportAgent(m_host.OwnerID.ToString(), regionGridX, regionGridY, position, lookat); } public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - TeleportAgent(m_host.OwnerID.ToString(), position, lookat, false); + osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); } /// -- cgit v1.1 From f660aa37ac7c8b935c2f317c2d4a1907c0ab9ed2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 19:40:20 +0100 Subject: add similar restrictions to osObjectTeleport :( --- .../Shared/Api/Implementation/OSSL_Api.cs | 43 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index d665f69..1a88529 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -876,7 +876,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(landdata.OwnerID == hostOwner) return true; - if(World.RegionInfo.EstateSettings != null && World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(hostOwner)) + EstateSettings es = World.RegionInfo.EstateSettings; + if(es != null && es.IsEstateManagerOrOwner(hostOwner)) return true; if(!landdata.IsGroupOwned) @@ -4756,6 +4757,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero ); } + private bool checkAllowObjectTPbyLandOwner(Vector3 pos) + { + ILandObject land = World.LandChannel.GetLandObject(pos); + if(land == null) + return true; + + LandData landdata = land.LandData; + if(landdata == null) + return true; + + UUID hostOwner = m_host.OwnerID; + if(landdata.OwnerID == hostOwner) + return true; + + EstateSettings es = World.RegionInfo.EstateSettings; + if(es != null && es.IsEstateManagerOrOwner(hostOwner)) + return true; + + if(!landdata.IsGroupOwned) + return false; + + UUID landGroup = landdata.GroupID; + if(landGroup == UUID.Zero) + return false; + + if(landGroup == m_host.GroupID) + return true; + + return false; + } + /// /// teleports a object (full linkset) /// @@ -4785,9 +4817,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } SceneObjectGroup sog = World.GetSceneObjectGroup(objUUID); - if(sog== null || sog.IsDeleted) + if(sog== null || sog.IsDeleted || sog.inTransit) return -1; + if(sog.OwnerID != m_host.OwnerID) + { + Vector3 pos = sog.AbsolutePosition; + if(!checkAllowObjectTPbyLandOwner(pos)) + return -1; + } + UUID myid = m_host.ParentGroup.UUID; return sog.TeleportObject(myid, targetPos, rotation, flags); -- cgit v1.1 From b59ce7c96889d72ddad6babb75cf7b68c885e26c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 20:28:16 +0100 Subject: also on the actual source file --- .../Shared/Api/Implementation/OSSL_Api.cs | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1a88529..823a4e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -517,13 +517,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetTerrainHeight(int x, int y) { - CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); + CheckThreatLevel(); return GetTerrainHeight(x, y); } public LSL_Float osTerrainGetHeight(int x, int y) { - CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); + CheckThreatLevel(); OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); return GetTerrainHeight(x, y); } @@ -1518,7 +1518,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public double osGetCurrentSunHour() { - CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour"); + CheckThreatLevel(); m_host.AddScriptLPS(1); @@ -1544,7 +1544,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public double osGetSunParam(string param) { - CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); + CheckThreatLevel(); return GetSunParam(param); } @@ -1743,7 +1743,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // is not allowed to contain any. // This really should be removed. // - CheckThreatLevel(ThreatLevel.None, "osList2Double"); + CheckThreatLevel(); m_host.AddScriptLPS(1); if (index < 0) @@ -2818,7 +2818,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osIsNpc(LSL_Key npc) { - CheckThreatLevel(ThreatLevel.None, "osIsNpc"); + CheckThreatLevel(); m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); @@ -3539,7 +3539,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetMapTexture() { - CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); +// CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); + CheckThreatLevel(); m_host.AddScriptLPS(1); return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); @@ -3597,7 +3598,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetRegionSize() { - CheckThreatLevel(ThreatLevel.None, "osGetRegionSize"); + CheckThreatLevel(); m_host.AddScriptLPS(1); Scene scene = m_ScriptEngine.World; @@ -3859,6 +3860,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Item description public LSL_String osGetInventoryDesc(string item) { + CheckThreatLevel(); m_host.AddScriptLPS(1); lock (m_host.TaskInventory) @@ -4239,7 +4241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// 1 if thing is a valid UUID, 0 otherwise public LSL_Integer osIsUUID(string thing) { - CheckThreatLevel(ThreatLevel.None, "osIsUUID"); + CheckThreatLevel(); m_host.AddScriptLPS(1); UUID test; @@ -4254,7 +4256,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMin(double a, double b) { - CheckThreatLevel(ThreatLevel.None, "osMin"); + CheckThreatLevel(); m_host.AddScriptLPS(1); return Math.Min(a, b); @@ -4268,7 +4270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Float osMax(double a, double b) { - CheckThreatLevel(ThreatLevel.None, "osMax"); + CheckThreatLevel(); m_host.AddScriptLPS(1); return Math.Max(a, b); -- cgit v1.1 From e53f4399812224939e4ebec6790a9addb38cca95 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 20:42:49 +0100 Subject: add osGetNPCList() --- .../Shared/Api/Implementation/OSSL_Api.cs | 19 +++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 25 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 823a4e5..fa7ee21 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3835,6 +3835,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return result; } + public LSL_List osGetNPCList() + { + CheckThreatLevel(ThreatLevel.None, "osGetNPCList"); + m_host.AddScriptLPS(1); + + LSL_List result = new LSL_List(); + World.ForEachRootScenePresence(delegate (ScenePresence avatar) + { + if (avatar != null && avatar.IsNPC) + { + result.Add(new LSL_String(avatar.UUID.ToString())); + result.Add(new LSL_Vector(avatar.AbsolutePosition)); + result.Add(new LSL_String(avatar.Name)); + } + }); + + return result; + } + /// /// Convert a unix time to a llGetTimestamp() like string /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f7857da..6e6a0be 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -395,6 +395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb); LSL_List osGetAvatarList(); + LSL_List osGetNPCList(); LSL_String osUnixTimeToTimestamp(long time); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index d6af32b..43113b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1041,6 +1041,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetAvatarList(); } + public LSL_List osGetNPCList() + { + return m_OSSL_Functions.osGetNPCList(); + } + public LSL_String osUnixTimeToTimestamp(long time) { return m_OSSL_Functions.osUnixTimeToTimestamp(time); -- cgit v1.1 From b319977a3f114442a0b8c93349f7d654745dc386 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 20:51:16 +0100 Subject: dont list deleted ones, that still don't know they are gone --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fa7ee21..ef511aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3843,7 +3843,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) { - if (avatar != null && avatar.IsNPC) + // npcs are not childagents but that is now. + if (avatar != null && avatar.IsNPC && !avatar.IsDeleted && !avatar.IsChildAgent) { result.Add(new LSL_String(avatar.UUID.ToString())); result.Add(new LSL_Vector(avatar.AbsolutePosition)); -- cgit v1.1 From 5242853d684e2fbe81a28401809a19e3d57e1e51 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 26 Jun 2017 20:55:44 +0100 Subject: dont list deleted ones, that still don't know they are gone --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ef511aa..f41f011 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3824,7 +3824,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) { - if (avatar != null && avatar.UUID != m_host.OwnerID) + if (avatar != null && !avatar.IsDeleted && avatar.UUID != m_host.OwnerID ) { result.Add(new LSL_String(avatar.UUID.ToString())); result.Add(new LSL_Vector(avatar.AbsolutePosition)); @@ -3844,7 +3844,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.ForEachRootScenePresence(delegate (ScenePresence avatar) { // npcs are not childagents but that is now. - if (avatar != null && avatar.IsNPC && !avatar.IsDeleted && !avatar.IsChildAgent) + if (avatar != null && avatar.IsNPC && !avatar.IsDeleted && !avatar.IsChildAgent && !avatar.IsInTransit) { result.Add(new LSL_String(avatar.UUID.ToString())); result.Add(new LSL_Vector(avatar.AbsolutePosition)); -- cgit v1.1 From 936aee412d67edc0e143ab13213c5ee1cb1c2a0e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 27 Jun 2017 01:41:06 +0100 Subject: remove osGetAgentIP() this was not a good idea to have :( --- .../Shared/Api/Implementation/OSSL_Api.cs | 26 +--------------------- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 - .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 +----- 3 files changed, 2 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f41f011..a1fd7cd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1080,31 +1080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api targetID, part.SitTargetPosition); } - - // Functions that get information from the agent itself. - // - // osGetAgentIP - this is used to determine the IP address of - //the client. This is needed to help configure other in world - //resources based on the IP address of the clients connected. - //I think High is a good risk level for this, as it is an - //information leak. - public string osGetAgentIP(string agent) - { - CheckThreatLevel(ThreatLevel.High, "osGetAgentIP"); - - UUID avatarID = (UUID)agent; - - m_host.AddScriptLPS(1); - if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) - { - ScenePresence target = (ScenePresence)World.Entities[avatarID]; - return target.ControllingClient.RemoteEndPoint.Address.ToString(); - } - - // fall through case, just return nothing - return ""; - } - + // Get a list of all the avatars/agents in the region public LSL_List osGetAgents() { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 6e6a0be..6be3c3f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -144,7 +144,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetParcelSIPAddress(string SIPAddress); // Avatar Info Commands - string osGetAgentIP(string agent); LSL_List osGetAgents(); // Teleport commands diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 43113b8..f5d2a3a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -277,12 +277,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportOwner(position, lookat); } - // Avatar info functions - public string osGetAgentIP(string agent) - { - return m_OSSL_Functions.osGetAgentIP(agent); - } - public LSL_List osGetAgents() { return m_OSSL_Functions.osGetAgents(); @@ -430,6 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osSetPenColor(drawList, color); } + // Deprecated public string osSetPenColour(string drawList, string colour) { -- cgit v1.1 From b0a0163253e14514289578d31e83ce0afe9b91a3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 28 Jun 2017 01:29:49 +0100 Subject: BUG FIX: change lludp hovertext utf-8 cut point. Thx djphil --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 5 ++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 01c1fb9..b3e68ec 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5753,7 +5753,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP //update.JointPivot = Vector3.Zero; //update.JointType = 0; update.Material = part.Material; - update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim /* if (data.ParentGroup.IsAttachment) { @@ -5832,8 +5831,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes; update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes; update.Scale = part.Shape.Scale; - update.Text = Util.StringToBytes256(part.Text); - update.MediaURL = Util.StringToBytes256(part.MediaUrl); + update.Text = Util.StringToBytes(part.Text, 255); + update.MediaURL = Util.StringToBytes(part.MediaUrl, 255); #region PrimFlags diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c2eac24..f9699b1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1103,8 +1103,8 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (m_text.Length > 255) - return m_text.Substring(0, 254); + if (m_text.Length > 256) // yes > 254 + return m_text.Substring(0, 256); return m_text; } set { m_text = value; } @@ -1379,7 +1379,8 @@ namespace OpenSim.Region.Framework.Scenes public UUID LastOwnerID { get { return _lastOwnerID; } - set { _lastOwnerID = value; } + set { + _lastOwnerID = value; } } public UUID RezzerID -- cgit v1.1 From e243dd05193a1edcb16f52b2514c41de70ff8006 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 28 Jun 2017 02:19:27 +0100 Subject: put back getAgentIP bug restricted, script owner must be a Administrator (god) --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 18 ++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 24 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a1fd7cd..b84065f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1097,6 +1097,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return result; } + public string osGetAgentIP(string agent) + { + CheckThreatLevel(); // user god is the restriction + if(!(World.Permissions.IsGod(m_host.OwnerID))) + return ""; + + UUID avatarID = (UUID)agent; + + m_host.AddScriptLPS(1); + if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) + { + ScenePresence target = (ScenePresence)World.Entities[avatarID]; + return target.ControllingClient.RemoteEndPoint.Address.ToString(); + } + + // fall through case, just return nothing + return ""; + } // Adam's super super custom animation functions public void osAvatarPlayAnimation(string avatar, string animation) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 6be3c3f..8f863af 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -145,6 +145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Avatar Info Commands LSL_List osGetAgents(); + string osGetAgentIP(string agent); // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index f5d2a3a..42e7bfb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -282,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetAgents(); } + public string osGetAgentIP(string agent) + { + return m_OSSL_Functions.osGetAgentIP(agent); + } + // Animation Functions public void osAvatarPlayAnimation(string avatar, string animation) -- cgit v1.1 From 6bac44e767819b6aa82d0ed503c5bcc7f72b9883 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 29 Jun 2017 00:42:35 +0100 Subject: bug fix --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index b3e68ec..53c185b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5526,6 +5526,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion #region Helper Methods + private void ClampVectorForUint(ref Vector3 v, float max) + { + float a,b; + + a = Math.Abs(v.X); + b = Math.Abs(v.Y); + if(b > a) + a = b; + b= Math.Abs(v.Z); + if(b > a) + a = b; + + if (a > max) + { + a = max / a; + v.X *= a; + v.Y *= a; + v.Z *= a; + } + } protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture) { @@ -5616,11 +5636,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP pos += 12; // Velocity + ClampVectorForUint(ref velocity, 128f); Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2; // Acceleration + ClampVectorForUint(ref acceleration, 64f); Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2; @@ -5632,6 +5654,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2; // Angular Velocity + ClampVectorForUint(ref angularVelocity, 64f); Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2; Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2; -- cgit v1.1 From 190874344b21a77037bc04114eb3347b944af55f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 29 Jun 2017 21:14:20 +0100 Subject: ScriptsHttpReq does not need a permanent thread --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 57dc556..f5b575b 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -379,9 +379,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest if (ThreadPool == null) { STPStartInfo startInfo = new STPStartInfo(); - startInfo.IdleTimeout = 20000; + startInfo.IdleTimeout = 2000; startInfo.MaxWorkerThreads = maxThreads; - startInfo.MinWorkerThreads = 1; + startInfo.MinWorkerThreads = 0; startInfo.ThreadPriority = ThreadPriority.BelowNormal; startInfo.StartSuspended = true; startInfo.ThreadPoolName = "ScriptsHttpReq"; -- cgit v1.1 From cb2607d4fa68e2c7721a0272e503bb07b4109524 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 29 Jun 2017 21:17:41 +0100 Subject: fix scripts xmlrpc threads names --- OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index f68c5f8..6028eef 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs @@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC public void Process() { _finished = false; - httpThread = WorkManager.StartThread(SendRequest, "HttpRequestThread", ThreadPriority.BelowNormal, true, false, null, int.MaxValue); + httpThread = WorkManager.StartThread(SendRequest, "XMLRPCreqThread", ThreadPriority.BelowNormal, true, false, null, int.MaxValue); } /* -- cgit v1.1 From 6b0a3e981cc06e7935960a5a806222a2aa2126d9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 30 Jun 2017 22:04:56 +0100 Subject: put osGetAgentIP() in threat control with level Severe so it can be disabled even for inworld administrators as needed on some grids. rearrage the osslEnable.ini file segregating the funtions only listed for information --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b84065f..1139579 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -452,7 +452,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) return( String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", @@ -1099,8 +1098,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetAgentIP(string agent) { - CheckThreatLevel(); // user god is the restriction - if(!(World.Permissions.IsGod(m_host.OwnerID))) + CheckThreatLevel(ThreatLevel.Severe, "osGetAgentIP"); + if(!(World.Permissions.IsGod(m_host.OwnerID))) // user god always needed return ""; UUID avatarID = (UUID)agent; @@ -1115,6 +1114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // fall through case, just return nothing return ""; } + // Adam's super super custom animation functions public void osAvatarPlayAnimation(string avatar, string animation) { @@ -1131,13 +1131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(!UUID.TryParse(avatar, out avatarID)) return; - if(!World.Entities.ContainsKey(avatarID)) - return; - - ScenePresence target = null; - if ((World.Entities[avatarID] is ScenePresence)) - target = (ScenePresence)World.Entities[avatarID]; - + ScenePresence target = World.GetScenePresence(avatarID); if (target == null) return; @@ -1417,7 +1411,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) { - CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize"); + CheckThreatLevel(); m_host.AddScriptLPS(1); LSL_Vector vec = new LSL_Vector(0,0,0); -- cgit v1.1 From 965d004fbe2f3753ea915bab00c5ab08a54648ca Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 30 Jun 2017 22:39:19 +0100 Subject: do calls to m_host.AddScriptLPS() on the right place on osslm this stat is of course still wrong LPS does not mean api function calls --- .../Shared/Api/Implementation/OSSL_Api.cs | 224 ++------------------- 1 file changed, 16 insertions(+), 208 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1139579..22d247d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -264,6 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // for safe funtions always active public void CheckThreatLevel() { + m_host.AddScriptLPS(1); if (!m_OSFunctionsEnabled) OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws } @@ -271,6 +272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Returns if the function is allowed. Throws a script exception if not allowed. public void CheckThreatLevel(ThreatLevel level, string function) { + m_host.AddScriptLPS(1); if (!m_OSFunctionsEnabled) OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws @@ -498,8 +500,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private LSL_Integer SetTerrainHeight(int x, int y, double val) { - m_host.AddScriptLPS(1); - if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) OSSLError("osSetTerrainHeight: Coordinate out of bounds"); @@ -529,7 +529,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private LSL_Float GetTerrainHeight(int x, int y) { - m_host.AddScriptLPS(1); if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0) OSSLError("osGetTerrainHeight: Coordinate out of bounds"); @@ -539,7 +538,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTerrainFlush() { CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush"); - m_host.AddScriptLPS(1); ITerrainModule terrainModule = World.RequestModuleInterface(); if (terrainModule != null) terrainModule.TaintTerrain(); @@ -556,7 +554,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); IRestartModule restartModule = World.RequestModuleInterface(); - m_host.AddScriptLPS(1); if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) { if (seconds < 15) @@ -579,7 +576,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); IRestartModule restartModule = World.RequestModuleInterface(); - m_host.AddScriptLPS(1); if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) { if (seconds < 15) @@ -630,8 +626,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice"); - m_host.AddScriptLPS(1); - IDialogModule dm = World.RequestModuleInterface(); if (dm != null) @@ -645,7 +639,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryHigh, "osSetRot"); - m_host.AddScriptLPS(1); if (World.Entities.ContainsKey(target)) { EntityBase entity; @@ -671,7 +664,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -693,7 +685,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -715,7 +706,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -743,7 +733,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -773,7 +762,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -802,7 +790,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow , "osSetDynamicTextureDataBlendFace"); - m_host.AddScriptLPS(1); if (dynamicID == String.Empty) { IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -830,8 +817,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand"); - m_host.AddScriptLPS(1); - // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { @@ -846,8 +831,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater"); - m_host.AddScriptLPS(1); - m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); } @@ -905,7 +888,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - m_host.AddScriptLPS(1); if(String.IsNullOrEmpty(regionName)) regionName = World.RegionInfo.RegionName; @@ -956,8 +938,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void TeleportAgent(string agent, int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - m_host.AddScriptLPS(1); - ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); UUID agentId; @@ -986,7 +966,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { - m_host.AddScriptLPS(1); UUID agentId; if (UUID.TryParse(agent, out agentId)) { @@ -1024,6 +1003,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { + CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); + osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); } @@ -1038,8 +1019,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); - m_host.AddScriptLPS(1); - ForceSit(avatar, m_host.UUID); } @@ -1053,8 +1032,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osForceOtherSit"); - m_host.AddScriptLPS(1); - UUID targetID = new UUID(target); ForceSit(avatar, targetID); @@ -1086,7 +1063,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // threat level is None as we could get this information with an // in-world script as well, just not as efficient CheckThreatLevel(ThreatLevel.None, "osGetAgents"); - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate(ScenePresence sp) @@ -1104,7 +1080,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID avatarID = (UUID)agent; - m_host.AddScriptLPS(1); if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) { ScenePresence target = (ScenePresence)World.Entities[avatarID]; @@ -1125,8 +1100,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void AvatarPlayAnimation(string avatar, string animation) { - m_host.AddScriptLPS(1); - UUID avatarID; if(!UUID.TryParse(avatar, out avatarID)) return; @@ -1167,8 +1140,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID avatarID = (UUID)avatar; - m_host.AddScriptLPS(1); - // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common // method (though see that doesn't do the is animation check, which is probably a bug) and have both // these functions call that common code. However, this does mean navigating the brain-dead requirement @@ -1203,7 +1174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawResetTransform(string drawList) { CheckThreatLevel(); - m_host.AddScriptLPS(1); + drawList += "ResetTransf;"; return drawList; } @@ -1211,7 +1182,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osDrawRotationTransform(string drawList, LSL_Float x) { CheckThreatLevel(); - m_host.AddScriptLPS(1); + drawList += "RotTransf " + x + ";"; return drawList; } @@ -1220,7 +1191,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "ScaleTransf " + x + "," + y + ";"; return drawList; } @@ -1229,7 +1199,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "TransTransf " + x + "," + y + ";"; return drawList; } @@ -1238,7 +1207,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "MoveTo " + x + "," + y + ";"; return drawList; } @@ -1247,7 +1215,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; "; return drawList; } @@ -1256,7 +1223,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "LineTo " + endX + "," + endY + "; "; return drawList; } @@ -1265,7 +1231,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.None, "osDrawText"); - m_host.AddScriptLPS(1); drawList += "Text " + text + "; "; return drawList; } @@ -1274,7 +1239,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "Ellipse " + width + "," + height + "; "; return drawList; } @@ -1283,7 +1247,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "FillEllipse " + width + "," + height + "; "; return drawList; } @@ -1292,7 +1255,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "Rectangle " + width + "," + height + "; "; return drawList; } @@ -1301,7 +1263,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "FillRectangle " + width + "," + height + "; "; return drawList; } @@ -1310,8 +1271,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); - if (x.Length != y.Length || x.Length < 3) { return ""; @@ -1329,8 +1288,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); - if (x.Length != y.Length || x.Length < 3) { return ""; @@ -1348,7 +1305,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "FontSize "+ fontSize +"; "; return drawList; } @@ -1357,7 +1313,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "FontName "+ fontName +"; "; return drawList; } @@ -1366,7 +1321,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "PenSize " + penSize + "; "; return drawList; } @@ -1375,7 +1329,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "PenColor " + color + "; "; return drawList; } @@ -1386,7 +1339,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(); OSSLDeprecated("osSetPenColour", "osSetPenColor"); - m_host.AddScriptLPS(1); drawList += "PenColour " + colour + "; "; return drawList; } @@ -1395,7 +1347,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList += "PenCap " + direction + "," + type + "; "; return drawList; } @@ -1404,7 +1355,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ; return drawList; } @@ -1412,7 +1362,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) { CheckThreatLevel(); - m_host.AddScriptLPS(1); LSL_Vector vec = new LSL_Vector(0,0,0); IDynamicTextureManager textureManager = World.RequestModuleInterface(); @@ -1435,7 +1384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // should be removed // CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); - m_host.AddScriptLPS(1); m_host.SetScriptEvents(m_item.ItemID, events); } @@ -1444,8 +1392,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); - m_host.AddScriptLPS(1); - World.EventManager.TriggerRequestChangeWaterHeight((float)height); } @@ -1459,8 +1405,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); - m_host.AddScriptLPS(1); - while (sunHour > 24.0) sunHour -= 24.0; @@ -1484,8 +1428,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); - m_host.AddScriptLPS(1); - while (sunHour > 24.0) sunHour -= 24.0; @@ -1508,8 +1450,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(); - m_host.AddScriptLPS(1); - // Must adjust for the fact that Region Sun Settings are still LL offset double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6; @@ -1538,8 +1478,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private double GetSunParam(string param) { - m_host.AddScriptLPS(1); - double value = 0.0; ISunModule module = World.RequestModuleInterface(); @@ -1566,8 +1504,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void SetSunParam(string param, double value) { - m_host.AddScriptLPS(1); - ISunModule module = World.RequestModuleInterface(); if (module != null) { @@ -1578,7 +1514,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osWindActiveModelPluginName() { CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); - m_host.AddScriptLPS(1); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1592,7 +1527,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetWindParam(string plugin, string param, LSL_Float value) { CheckThreatLevel(ThreatLevel.VeryLow, "osSetWindParam"); - m_host.AddScriptLPS(1); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1608,7 +1542,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetWindParam(string plugin, string param) { CheckThreatLevel(ThreatLevel.VeryLow, "osGetWindParam"); - m_host.AddScriptLPS(1); IWindModule module = World.RequestModuleInterface(); if (module != null) @@ -1623,7 +1556,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osParcelJoin(LSL_Vector pos1, LSL_Vector pos2) { CheckThreatLevel(ThreatLevel.High, "osParcelJoin"); - m_host.AddScriptLPS(1); int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x); int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y); @@ -1636,7 +1568,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osParcelSubdivide(LSL_Vector pos1, LSL_Vector pos2) { CheckThreatLevel(ThreatLevel.High, "osParcelSubdivide"); - m_host.AddScriptLPS(1); int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x); int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y); @@ -1663,8 +1594,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) { - m_host.AddScriptLPS(1); - // Get a reference to the land data and make sure the owner of the script // can modify it @@ -1733,7 +1662,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(); - m_host.AddScriptLPS(1); if (index < 0) { index = src.Length + index; @@ -1751,8 +1679,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); - m_host.AddScriptLPS(1); - ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (land.LandData.OwnerID != m_host.OwnerID) @@ -1767,8 +1693,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelSIPAddress"); - m_host.AddScriptLPS(1); - ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); if (land.LandData.OwnerID != m_host.OwnerID) @@ -1795,8 +1719,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName"); - m_host.AddScriptLPS(1); - int scriptEngineNameIndex = 0; if (!String.IsNullOrEmpty(m_ScriptEngine.ScriptEngineName)) @@ -1822,7 +1744,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osCheckODE() { CheckThreatLevel(); - m_host.AddScriptLPS(1); LSL_Integer ret = 0; // false if (m_ScriptEngine.World.PhysicsScene != null) @@ -1846,6 +1767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // about the physics engine, this function returns an empty string if // the user does not have permission to see it. This as opposed to // throwing an exception. + m_host.AddScriptLPS(1); string ret = String.Empty; if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType"))) @@ -1865,7 +1787,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetPhysicsEngineName() { CheckThreatLevel(); - m_host.AddScriptLPS(1); string ret = "NoEngine"; if (m_ScriptEngine.World.PhysicsScene != null) @@ -1886,7 +1807,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // kiddie) // CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion"); - m_host.AddScriptLPS(1); return m_ScriptEngine.World.GetSimulatorVersion(); } @@ -1932,8 +1852,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); - m_host.AddScriptLPS(1); - try { OSD decoded = OSDParser.DeserializeJson(JSON); @@ -1950,8 +1868,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.None, "osParseJSON"); - m_host.AddScriptLPS(1); - Object decoded = osParseJSONNew(JSON); if ( decoded is Hashtable ) { @@ -1982,7 +1898,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osMessageObject(LSL_Key objectUUID, string message) { CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); - m_host.AddScriptLPS(1); UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead. @@ -2023,7 +1938,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // if this is restricted to objects rezzed by this host level can be reduced CheckThreatLevel(ThreatLevel.Low, "osDie"); - m_host.AddScriptLPS(1); UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) @@ -2073,7 +1987,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osMakeNotecard(string notecardName, LSL_Types.list contents) { CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); - m_host.AddScriptLPS(1); StringBuilder notecardData = new StringBuilder(); @@ -2259,7 +2172,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetNotecardLine(string name, int line) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); - m_host.AddScriptLPS(1); UUID assetID = CacheNotecard(name); @@ -2287,7 +2199,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetNotecard(string name) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); - m_host.AddScriptLPS(1); string text = LoadNotecard(name); @@ -2317,7 +2228,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public int osGetNumberOfNotecardLines(string name) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); - m_host.AddScriptLPS(1); UUID assetID = CacheNotecard(name); @@ -2333,7 +2243,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osAvatarName2Key(string firstname, string lastname) { CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); - m_host.AddScriptLPS(1); IUserManagement userManager = World.RequestModuleInterface(); if (userManager == null) @@ -2385,7 +2294,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osKey2Name(string id) { CheckThreatLevel(ThreatLevel.Low, "osKey2Name"); - m_host.AddScriptLPS(1); UUID key = new UUID(); @@ -2495,7 +2403,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridNick() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); - m_host.AddScriptLPS(1); string nick = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2512,7 +2419,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridName() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); - m_host.AddScriptLPS(1); string name = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2529,7 +2435,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridLoginURI() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); - m_host.AddScriptLPS(1); string loginURI = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2546,7 +2451,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridHomeURI() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI"); - m_host.AddScriptLPS(1); IConfigSource config = m_ScriptEngine.ConfigSource; string HomeURI = Util.GetConfigVarFromSections(config, "HomeURI", @@ -2568,7 +2472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridGatekeeperURI() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); - m_host.AddScriptLPS(1); IConfigSource config = m_ScriptEngine.ConfigSource; string gatekeeperURI = Util.GetConfigVarFromSections(config, "GatekeeperURI", @@ -2587,7 +2490,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetGridCustom(string key) { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); - m_host.AddScriptLPS(1); string retval = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; @@ -2604,7 +2506,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osGetAvatarHomeURI(string uuid) { CheckThreatLevel(ThreatLevel.Low, "osGetAvatarHomeURI"); - m_host.AddScriptLPS(1); IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface(); string returnValue = ""; @@ -2637,7 +2538,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osFormatString(string str, LSL_List strings) { CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString"); - m_host.AddScriptLPS(1); return String.Format(str, strings.Data); } @@ -2645,7 +2545,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osMatchString(string src, string pattern, int start) { CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString"); - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); @@ -2687,7 +2586,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) { CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString"); - m_host.AddScriptLPS(1); // Normalize indices (if negative). // After normlaization they may still be @@ -2712,7 +2610,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osLoadedCreationDate() { CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate"); - m_host.AddScriptLPS(1); return World.RegionInfo.RegionSettings.LoadedCreationDate; } @@ -2720,7 +2617,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osLoadedCreationTime() { CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationTime"); - m_host.AddScriptLPS(1); return World.RegionInfo.RegionSettings.LoadedCreationTime; } @@ -2728,7 +2624,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string osLoadedCreationID() { CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationID"); - m_host.AddScriptLPS(1); return World.RegionInfo.RegionSettings.LoadedCreationID; } @@ -2749,7 +2644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); - m_host.AddScriptLPS(1); + InitLSL(); // One needs to cast m_LSL_Api because we're using functions not // on the ILSL_Api interface. @@ -2778,8 +2673,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osForceCreateLink"); - m_host.AddScriptLPS(1); - InitLSL(); ((LSL_Api)m_LSL_Api).CreateLink(target, parent); } @@ -2788,8 +2681,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakLink"); - m_host.AddScriptLPS(1); - InitLSL(); ((LSL_Api)m_LSL_Api).BreakLink(linknum); } @@ -2798,8 +2689,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryLow, "osForceBreakAllLinks"); - m_host.AddScriptLPS(1); - InitLSL(); ((LSL_Api)m_LSL_Api).BreakAllLinks(); } @@ -2807,7 +2696,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osIsNpc(LSL_Key npc) { CheckThreatLevel(); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2824,7 +2712,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - m_host.AddScriptLPS(1); // have to get the npc module also here to set the default Not Owned INPCModule module = World.RequestModuleInterface(); @@ -2839,7 +2726,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - m_host.AddScriptLPS(1); return NpcCreate( firstname, lastname, position, notecard, @@ -2982,7 +2868,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); @@ -3004,7 +2889,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcLoadAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); @@ -3036,7 +2920,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcGetOwner(LSL_Key npc) { CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3058,7 +2941,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osNpcGetPos(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3082,7 +2964,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3101,7 +2982,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3126,7 +3006,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation osNpcGetRot(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3150,7 +3029,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) { CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); - m_host.AddScriptLPS(1); INPCModule npcModule = World.RequestModuleInterface(); if (npcModule != null) @@ -3172,7 +3050,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopMoveToTarget(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3189,7 +3066,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetProfileAbout(LSL_Key npc, string about) { CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileAbout"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3208,7 +3084,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSetProfileImage(LSL_Key npc, string image) { CheckThreatLevel(ThreatLevel.Low, "osNpcSetProfileImage"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3242,7 +3117,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSay(LSL_Key npc, int channel, string message) { CheckThreatLevel(ThreatLevel.High, "osNpcSay"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3259,7 +3133,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcShout(LSL_Key npc, int channel, string message) { CheckThreatLevel(ThreatLevel.High, "osNpcShout"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3276,7 +3149,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcSit(LSL_Key npc, LSL_Key target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcSit"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3293,7 +3165,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStand(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcStand"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3310,7 +3181,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcRemove(LSL_Key npc) { CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); - m_host.AddScriptLPS(1); try { @@ -3331,7 +3201,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcPlayAnimation(LSL_Key npc, string animation) { CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3346,7 +3215,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcStopAnimation(LSL_Key npc, string animation) { CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3361,7 +3229,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcWhisper(LSL_Key npc, int channel, string message) { CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -3378,7 +3245,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num) { CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); - m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface(); int linkNum = link_num.value; @@ -3423,7 +3289,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osOwnerSaveAppearance(string notecard) { CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); - m_host.AddScriptLPS(1); return SaveAppearanceToNotecard(m_host.OwnerID, notecard); } @@ -3431,7 +3296,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) { CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); - m_host.AddScriptLPS(1); return SaveAppearanceToNotecard(avatarId, notecard); } @@ -3484,7 +3348,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osGetGender(LSL_Key rawAvatarId) { CheckThreatLevel(ThreatLevel.None, "osGetGender"); - m_host.AddScriptLPS(1); UUID avatarId; if (!UUID.TryParse(rawAvatarId, out avatarId)) @@ -3527,9 +3390,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public LSL_Key osGetMapTexture() { -// CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); CheckThreatLevel(); - m_host.AddScriptLPS(1); return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); } @@ -3542,7 +3403,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osGetRegionMapTexture(string regionName) { CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); - m_host.AddScriptLPS(1); Scene scene = m_ScriptEngine.World; UUID key = UUID.Zero; @@ -3573,7 +3433,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetRegionStats() { CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats"); - m_host.AddScriptLPS(1); + LSL_List ret = new LSL_List(); float[] stats = World.StatsReporter.LastReportedSimStats; @@ -3587,7 +3447,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector osGetRegionSize() { CheckThreatLevel(); - m_host.AddScriptLPS(1); Scene scene = m_ScriptEngine.World; RegionInfo reg = World.RegionInfo; @@ -3599,7 +3458,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public int osGetSimulatorMemory() { CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory"); - m_host.AddScriptLPS(1); + long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64; if (pws > Int32.MaxValue) @@ -3613,7 +3472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetSpeed(string UUID, LSL_Float SpeedModifier) { CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed"); - m_host.AddScriptLPS(1); + ScenePresence avatar = World.GetScenePresence(new UUID(UUID)); if (avatar != null) @@ -3623,7 +3482,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osKickAvatar(string FirstName, string SurName, string alert) { CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); - m_host.AddScriptLPS(1); World.ForEachRootScenePresence(delegate(ScenePresence sp) { @@ -3642,7 +3500,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetHealth(string avatar) { CheckThreatLevel(ThreatLevel.None, "osGetHealth"); - m_host.AddScriptLPS(1); LSL_Float health = new LSL_Float(-1); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); @@ -3654,7 +3511,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osCauseDamage(string avatar, double damage) { CheckThreatLevel(ThreatLevel.High, "osCauseDamage"); - m_host.AddScriptLPS(1); UUID avatarId = new UUID(avatar); Vector3 pos = m_host.GetWorldPosition(); @@ -3682,7 +3538,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osCauseHealing(string avatar, double healing) { CheckThreatLevel(ThreatLevel.High, "osCauseHealing"); - m_host.AddScriptLPS(1); UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); @@ -3702,7 +3557,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetHealth(string avatar, double health) { CheckThreatLevel(ThreatLevel.High, "osSetHealth"); - m_host.AddScriptLPS(1); UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); @@ -3721,7 +3575,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetHealRate(string avatar, double healrate) { CheckThreatLevel(ThreatLevel.High, "osSetHealRate"); - m_host.AddScriptLPS(1); UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); @@ -3733,7 +3586,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osGetHealRate(string avatar) { CheckThreatLevel(ThreatLevel.None, "osGetHealRate"); - m_host.AddScriptLPS(1); LSL_Float rate = new LSL_Float(0); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); @@ -3745,18 +3597,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules) { CheckThreatLevel(ThreatLevel.High, "osGetPrimitiveParams"); - m_host.AddScriptLPS(1); - InitLSL(); + InitLSL(); return m_LSL_Api.GetPrimitiveParamsEx(prim, rules); } public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) { CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams"); - m_host.AddScriptLPS(1); - InitLSL(); + InitLSL(); m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams"); } @@ -3765,8 +3615,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb) { - CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams"); - osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb); } @@ -3776,7 +3624,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb) { CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams"); - m_host.AddScriptLPS(1); SceneObjectPart obj = null; if (prim == UUID.Zero.ToString()) @@ -3807,7 +3654,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetAvatarList() { CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) @@ -3826,7 +3672,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetNPCList() { CheckThreatLevel(ThreatLevel.None, "osGetNPCList"); - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); World.ForEachRootScenePresence(delegate (ScenePresence avatar) @@ -3851,7 +3696,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osUnixTimeToTimestamp(long time) { CheckThreatLevel(ThreatLevel.VeryLow, "osUnixTimeToTimestamp"); - m_host.AddScriptLPS(1); long baseTicks = 621355968000000000; long tickResolution = 10000000; @@ -3869,7 +3713,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osGetInventoryDesc(string item) { CheckThreatLevel(); - m_host.AddScriptLPS(1); lock (m_host.TaskInventory) { @@ -3893,7 +3736,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osInviteToGroup(LSL_Key agentId) { CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup"); - m_host.AddScriptLPS(1); UUID agent = new UUID(agentId); @@ -3928,7 +3770,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osEjectFromGroup(LSL_Key agentId) { CheckThreatLevel(ThreatLevel.VeryLow, "osEjectFromGroup"); - m_host.AddScriptLPS(1); UUID agent = new UUID(agentId); @@ -3964,7 +3805,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); - m_host.AddScriptLPS(1); //Check to make sure that the script's owner is the estate manager/master //World.Permissions.GenericEstatePermission( if (World.Permissions.IsGod(m_host.OwnerID)) @@ -3994,7 +3834,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); - m_host.AddScriptLPS(1); //Check to make sure that the script's owner is the estate manager/master //World.Permissions.GenericEstatePermission( if (World.Permissions.IsGod(m_host.OwnerID)) @@ -4015,8 +3854,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); - m_host.AddScriptLPS(1); - InitLSL(); ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); } @@ -4025,8 +3862,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); - m_host.AddScriptLPS(1); - ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint); } @@ -4034,8 +3869,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osForceAttachToOtherAvatarFromInventory"); - m_host.AddScriptLPS(1); - UUID avatarId; if (!UUID.TryParse(rawAvatarId, out avatarId)) @@ -4095,8 +3928,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); - m_host.AddScriptLPS(1); - InitLSL(); ((LSL_Api)m_LSL_Api).DetachFromAvatar(); } @@ -4105,8 +3936,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments"); - m_host.AddScriptLPS(1); - UUID targetUUID; ScenePresence target; LSL_List resp = new LSL_List(); @@ -4140,7 +3969,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) { CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); - m_host.AddScriptLPS(1); UUID targetUUID; if(!UUID.TryParse(avatar.ToString(), out targetUUID)) @@ -4250,7 +4078,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osIsUUID(string thing) { CheckThreatLevel(); - m_host.AddScriptLPS(1); UUID test; return UUID.TryParse(thing, out test) ? 1 : 0; @@ -4265,7 +4092,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osMin(double a, double b) { CheckThreatLevel(); - m_host.AddScriptLPS(1); return Math.Min(a, b); } @@ -4279,7 +4105,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float osMax(double a, double b) { CheckThreatLevel(); - m_host.AddScriptLPS(1); return Math.Max(a, b); } @@ -4287,7 +4112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osGetRezzingObject() { CheckThreatLevel(ThreatLevel.None, "osGetRezzingObject"); - m_host.AddScriptLPS(1); + UUID rezID = m_host.ParentGroup.RezzerID; if(rezID == UUID.Zero || m_host.ParentGroup.Scene.GetScenePresence(rezID) != null) return new LSL_Key(UUID.Zero.ToString()); @@ -4312,7 +4137,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// boolean indicating whether an error was shouted. protected bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix) { - m_host.AddScriptLPS(1); bool fail = false; if (m_item.PermsGranter != m_host.OwnerID) { @@ -4363,7 +4187,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osDropAttachment() { CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment"); - m_host.AddScriptLPS(1); DropAttachment(true); } @@ -4371,7 +4194,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceDropAttachment() { CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment"); - m_host.AddScriptLPS(1); DropAttachment(false); } @@ -4379,7 +4201,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt"); - m_host.AddScriptLPS(1); DropAttachmentAt(true, pos, rot); } @@ -4387,7 +4208,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt"); - m_host.AddScriptLPS(1); DropAttachmentAt(false, pos, rot); } @@ -4395,7 +4215,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) { CheckThreatLevel(ThreatLevel.Low, "osListenRegex"); - m_host.AddScriptLPS(1); + UUID keyID; UUID.TryParse(ID, out keyID); @@ -4443,7 +4263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osRegexIsMatch(string input, string pattern) { CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch"); - m_host.AddScriptLPS(1); + try { return Regex.IsMatch(input, pattern) ? 1 : 0; @@ -4458,7 +4278,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osRequestURL(LSL_List options) { CheckThreatLevel(ThreatLevel.Moderate, "osRequestSecureURL"); - m_host.AddScriptLPS(1); Hashtable opts = new Hashtable(); for (int i = 0 ; i < options.Length ; i++) @@ -4476,7 +4295,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String osRequestSecureURL(LSL_List options) { CheckThreatLevel(ThreatLevel.Moderate, "osRequestSecureURL"); - m_host.AddScriptLPS(1); Hashtable opts = new Hashtable(); for (int i = 0 ; i < options.Length ; i++) @@ -4494,7 +4312,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osCollisionSound(string impact_sound, double impact_volume) { CheckThreatLevel(); - m_host.AddScriptLPS(1); if(impact_sound == "") { @@ -4527,7 +4344,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osVolumeDetect(int detect) { CheckThreatLevel(); - m_host.AddScriptLPS(1); if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment) return; @@ -4550,7 +4366,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List osGetInertiaData() { CheckThreatLevel(); - m_host.AddScriptLPS(1); LSL_List result = new LSL_List(); float TotalMass; @@ -4598,7 +4413,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) @@ -4637,7 +4451,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) @@ -4679,7 +4492,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) @@ -4719,7 +4531,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) @@ -4758,7 +4569,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osClearInertia() { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) @@ -4817,7 +4627,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osTeleportObject(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer flags) { CheckThreatLevel(ThreatLevel.Severe, "osTeleportObject"); - m_host.AddScriptLPS(1); UUID objUUID; if (!UUID.TryParse(objectUUID, out objUUID)) @@ -4846,7 +4655,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer osGetLinkNumber(LSL_String name) { CheckThreatLevel(); - m_host.AddScriptLPS(1); SceneObjectGroup sog = m_host.ParentGroup; if(sog== null || sog.IsDeleted) -- cgit v1.1 From edc7575f9ec3cd61aeec4ae9c3d65dc1235eb6ec Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 1 Jul 2017 01:43:58 +0100 Subject: a few changes to ubOde avatar collisions --- .../Region/PhysicsModules/ubOde/ODECharacter.cs | 65 ++++++++++++---------- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 12 +--- 2 files changed, 39 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index de7e879..b0f3f52 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -103,7 +103,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde public float walkDivisor = 1.3f; public float runDivisor = 0.8f; - private bool flying = false; + private bool m_flying = false; private bool m_iscolliding = false; private bool m_iscollidingGround = false; private bool m_iscollidingObj = false; @@ -298,10 +298,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde public override bool Flying { - get { return flying; } + get { return m_flying; } set { - flying = value; + m_flying = value; // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); } } @@ -900,10 +900,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde } public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact, - ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision) + ref bool feetcollision) { feetcollision = false; - useAltcontact = false; if (me == capsule) { @@ -943,12 +942,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } return true; } -/* - d.AABB aabb; - d.GeomGetAABB(other,out aabb); - float othertop = aabb.MaxZ - _position.Z; -*/ -// if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f) + if (offset.Z > 0 || contact.normal.Z > 0.35f) { if (offset.Z <= 0) @@ -965,27 +959,40 @@ namespace OpenSim.Region.PhysicsModule.ubOde return true; } - altContact = contact; - useAltcontact = true; + if(m_flying) + return true; offset.Z -= 0.2f; offset.Normalize(); - if (contact.depth > 0.1f) - contact.depth = 0.1f; + float tdp = contact.depth; + float t = contact.normal.Z * contact.normal.Z; + t = Math.Abs(t); + if(t > 1e-6) + { + tdp /= t; + tdp *= offset.Z * offset.Z; + } + else + tdp *= 10; + + if (tdp > 0.25f) + tdp = 0.25f; + + contact.depth = tdp; if (reverse) { - altContact.normal.X = offset.X; - altContact.normal.Y = offset.Y; - altContact.normal.Z = offset.Z; + contact.normal.X = offset.X; + contact.normal.Y = offset.Y; + contact.normal.Z = offset.Z; } else { - altContact.normal.X = -offset.X; - altContact.normal.Y = -offset.Y; - altContact.normal.Z = -offset.Z; + contact.normal.X = -offset.X; + contact.normal.Y = -offset.Y; + contact.normal.Z = -offset.Z; } feetcollision = true; @@ -1098,7 +1105,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde float ftmp; - if (flying) + if (m_flying) { ftmp = timeStep; posch.X += vel.X * ftmp; @@ -1122,7 +1129,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde vec.Z = depth * PID_P * 50; - if (!flying) + if (!m_flying) { vec.Z += -vel.Z * PID_D; if(n.Z < 0.4f) @@ -1259,7 +1266,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // movement relative to surface if moving on it // dont disturbe vertical movement, ie jumps - if (m_iscolliding && !flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f) + if (m_iscolliding && !m_flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f) { float p = ctz.X * m_collideNormal.X + ctz.Y * m_collideNormal.Y; ctz.X *= (float)Math.Sqrt(1 - m_collideNormal.X * m_collideNormal.X); @@ -1276,7 +1283,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { // if velocity is zero, use position control; otherwise, velocity control - if (tviszero && m_iscolliding && !flying) + if (tviszero && m_iscolliding && !m_flying) { // keep track of where we stopped. No more slippin' & slidin' if (!_zeroFlag) @@ -1313,7 +1320,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_iscolliding) { - if (!flying) + if (!m_flying) { // we are on a surface if (ctz.Z > 0f) @@ -1361,7 +1368,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else // ie not colliding { - if (flying || hoverPIDActive) //(!m_iscolliding && flying) + if (m_flying || hoverPIDActive) //(!m_iscolliding && flying) { // we're in mid air suspended vec.X += (ctz.X - vel.X) * (PID_D); @@ -1397,13 +1404,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde breakfactor = m_mass; vec.X -= breakfactor * vel.X; vec.Y -= breakfactor * vel.Y; - if (flying) + if (m_flying) vec.Z -= 0.5f * breakfactor * vel.Z; else vec.Z -= .16f* m_mass * vel.Z; } - if (flying || hoverPIDActive) + if (m_flying || hoverPIDActive) { vec.Z -= m_parent_scene.gravityz * m_mass; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 86d41ea..0837bfb 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -951,8 +951,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde SharedTmpcontact.surface.mu = mu; SharedTmpcontact.surface.bounce = bounce; - d.ContactGeom altContact = new d.ContactGeom(); - bool useAltcontact = false; bool noskip = true; if(dop1ava || dop2ava) @@ -961,11 +959,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde while (true) { noskip = true; - useAltcontact = false; if (dop1ava) { - if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) + if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref FeetCollision))) { if (p2.PhysicsActorType == (int)ActorTypes.Agent) { @@ -980,7 +977,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else if (dop2ava) { - if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) + if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref FeetCollision))) { if (p1.PhysicsActorType == (int)ActorTypes.Agent) { @@ -996,10 +993,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (noskip) { - if(useAltcontact) - Joint = CreateContacJoint(ref altContact,smoothMesh); - else - Joint = CreateContacJoint(ref curContact,smoothMesh); + Joint = CreateContacJoint(ref curContact,smoothMesh); if (Joint == IntPtr.Zero) break; -- cgit v1.1 From f3a920237b479149537f39d203c824571123d032 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 2 Jul 2017 01:34:06 +0100 Subject: oops i forgot the avatar knees bending on ramps... so go back.. --- .../Region/PhysicsModules/ubOde/ODECharacter.cs | 42 ++++++++++++---------- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 15 +++++--- 2 files changed, 33 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index b0f3f52..6016530 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -899,10 +899,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde y = tx * sin + y * cos; } - public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact, - ref bool feetcollision) - { + public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact, + ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision) + { feetcollision = false; + useAltcontact = false; if (me == capsule) { @@ -962,6 +963,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde if(m_flying) return true; + feetcollision = true; + if (h < boneOff) + { + m_collideNormal.X = contact.normal.X; + m_collideNormal.Y = contact.normal.Y; + m_collideNormal.Z = contact.normal.Z; + IsColliding = true; + } + + altContact = contact; + useAltcontact = true; + offset.Z -= 0.2f; offset.Normalize(); @@ -980,28 +993,19 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (tdp > 0.25f) tdp = 0.25f; - contact.depth = tdp; + altContact.depth = tdp; if (reverse) { - contact.normal.X = offset.X; - contact.normal.Y = offset.Y; - contact.normal.Z = offset.Z; + altContact.normal.X = offset.X; + altContact.normal.Y = offset.Y; + altContact.normal.Z = offset.Z; } else { - contact.normal.X = -offset.X; - contact.normal.Y = -offset.Y; - contact.normal.Z = -offset.Z; - } - - feetcollision = true; - if (h < boneOff) - { - m_collideNormal.X = contact.normal.X; - m_collideNormal.Y = contact.normal.Y; - m_collideNormal.Z = contact.normal.Z; - IsColliding = true; + altContact.normal.X = -offset.X; + altContact.normal.Y = -offset.Y; + altContact.normal.Z = -offset.Z; } return true; } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 0837bfb..844d02b 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -951,7 +951,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde SharedTmpcontact.surface.mu = mu; SharedTmpcontact.surface.bounce = bounce; - bool noskip = true; + d.ContactGeom altContact = new d.ContactGeom(); + bool useAltcontact; + bool noskip; if(dop1ava || dop2ava) smoothMesh = false; @@ -959,10 +961,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde while (true) { noskip = true; + useAltcontact = false; if (dop1ava) { - if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref FeetCollision))) + if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) { if (p2.PhysicsActorType == (int)ActorTypes.Agent) { @@ -977,7 +980,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else if (dop2ava) { - if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref FeetCollision))) + if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) { if (p1.PhysicsActorType == (int)ActorTypes.Agent) { @@ -993,8 +996,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (noskip) { - Joint = CreateContacJoint(ref curContact,smoothMesh); - + if(useAltcontact) + Joint = CreateContacJoint(ref altContact,smoothMesh); + else + Joint = CreateContacJoint(ref curContact,smoothMesh); if (Joint == IntPtr.Zero) break; -- cgit v1.1 From 39751891f49afb07d57fadd3002655b498698e31 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 3 Jul 2017 22:47:27 +0100 Subject: ubOde: dont do avatar step climb on small true spheres. lets play simple football --- OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 6016530..3c4675c 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -944,6 +944,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde return true; } + if (gtype == d.GeomClassID.SphereClass) + { + if(d.GeomSphereGetRadius(other) < 0.5) + return true; + } + if (offset.Z > 0 || contact.normal.Z > 0.35f) { if (offset.Z <= 0) @@ -980,12 +986,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde offset.Normalize(); float tdp = contact.depth; - float t = contact.normal.Z * contact.normal.Z; + float t = offset.X; t = Math.Abs(t); if(t > 1e-6) { tdp /= t; - tdp *= offset.Z * offset.Z; + tdp *= contact.normal.X; } else tdp *= 10; -- cgit v1.1 From 1dc56eb15f25748cc7d4df21a5dc2992332aa504 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 3 Jul 2017 23:38:55 +0100 Subject: ubOde: but only do that if sphere is physical.. --- OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 3c4675c..0e46471 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -944,7 +944,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde return true; } - if (gtype == d.GeomClassID.SphereClass) + if (gtype == d.GeomClassID.SphereClass && d.GeomGetBody(other) != IntPtr.Zero) { if(d.GeomSphereGetRadius(other) < 0.5) return true; -- cgit v1.1 From dfef16297b51fb81550745aeea05bd10cb1fc766 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Jul 2017 01:49:34 +0100 Subject: ubOde don't use old ode body sleep option, a few changes on sleep control, update ode.dll (windows, others needed) (keep older versions.. bc.. well bugs happen) --- OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs | 1 + OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 36 +++++++++++++++++----- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs index 2e6a7db..ce10065 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs @@ -345,6 +345,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) && !rootPrim.m_isSelected && !rootPrim.m_disabled) d.BodyEnable(rootPrim.Body); + break; case Vehicle.LINEAR_FRICTION_TIMESCALE: if (pValue < m_timestep) pValue = m_timestep; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 4bed0d2..005caee 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -1847,8 +1847,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde ApplyCollisionCatFlags(); _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); - } } resetCollisionAccounting(); @@ -2900,6 +2900,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero && !m_disabled) { _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); } } @@ -2933,6 +2934,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (!d.BodyIsEnabled(Body)) { _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); } } @@ -2947,6 +2949,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) { _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); } } @@ -3012,6 +3015,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) { _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); } } @@ -3070,6 +3074,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) { _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); } } @@ -3312,8 +3317,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_disabled) enableBodySoft(); else if (!d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); - + } } m_torque = newtorque; } @@ -3323,7 +3330,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde { m_force = force; if (!m_isSelected && !m_outbounds && Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); + } } private void changeAddForce(Vector3 theforce) @@ -3339,7 +3349,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_disabled) enableBodySoft(); else if (!d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); + } } } m_collisionscore = 0; @@ -3359,7 +3372,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_disabled) enableBodySoft(); else if (!d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); + } } } m_collisionscore = 0; @@ -3382,7 +3398,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_disabled) enableBodySoft(); else if (!d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); + } d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); } //resetCollisionAccounting(); @@ -3406,7 +3425,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_disabled) enableBodySoft(); else if (!d.BodyIsEnabled(Body)) + { + d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames); d.BodyEnable(Body); + } d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); } //resetCollisionAccounting(); @@ -3571,12 +3593,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde d.BodySetAngularVel(Body,0f,0f,0f); d.BodySetLinearVel(Body,0f,0f,0f); _zeroFlag = true; + d.BodySetAutoDisableSteps(Body, 1); d.BodyEnable(Body); m_bodydisablecontrol = -4; } if(m_bodydisablecontrol < 0) - m_bodydisablecontrol ++; + m_bodydisablecontrol++; d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator @@ -3741,13 +3764,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde public void UpdatePositionAndVelocity(int frame) { - if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero) + if (_parent == null && !m_isSelected && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero) { - bool bodyenabled = d.BodyIsEnabled(Body); - if(m_bodydisablecontrol < 0) return; + bool bodyenabled = d.BodyIsEnabled(Body); if (bodyenabled || !_zeroFlag) { bool lastZeroFlag = _zeroFlag; @@ -3891,7 +3913,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // disable interpolators _velocity = Vector3.Zero; m_acceleration = Vector3.Zero; - m_rotationalVelocity = Vector3.Zero; + m_rotationalVelocity = Vector3.Zero; } else { diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 844d02b..5758e0a 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -481,7 +481,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); - bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); +// bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); physics_logging = physicsconfig.GetBoolean("physics_logging", false); physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); -- cgit v1.1 From ead95e85c55e00abaac729109dfed47f10bc8c91 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Jul 2017 04:57:57 +0100 Subject: bug fix: dynamic testures set to ALL_SIDES, preserve other face data already present --- .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index c0b7ab5..090cb7d 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -428,12 +428,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // FIXME: Need to return the appropriate ID if only a single face is replaced. oldID = tmptex.DefaultTexture.TextureID; + // not using parts number of faces because that fails on old meshs if (Face == ALL_SIDES) { oldID = tmptex.DefaultTexture.TextureID; tmptex.DefaultTexture.TextureID = textureID; for(int i = 0; i < tmptex.FaceTextures.Length; i++) - tmptex.FaceTextures[i] = null; + { + if(tmptex.FaceTextures[i] != null) + tmptex.FaceTextures[i].TextureID = textureID; + } } else { -- cgit v1.1 From cc5d6f6b7bcf23b698d1d6a98b60d04bc5ecb036 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 9 Jul 2017 00:14:30 +0100 Subject: throttle collision sounds on a SOG. --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 24 ++++++++++++----- .../Region/Framework/Scenes/SceneObjectGroup.cs | 30 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index e76fef4..f87043e 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -116,16 +116,20 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { + if (part.CollisionSoundType < 0) + return; + if (collidersinfolist.Count == 0 || part == null) return; if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) return; - if (part.ParentGroup == null) + SceneObjectGroup sog = part.ParentGroup; + if (sog == null || sog.IsDeleted || sog.inTransit) return; - if (part.CollisionSoundType < 0) + if(sog.CollisionSoundThrootled(part.CollisionSoundType)) return; float volume = part.CollisionSoundVolume; @@ -189,15 +193,23 @@ namespace OpenSim.Region.Framework.Scenes continue; } - SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); + SceneObjectPart otherPart = sog.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) + SceneObjectGroup othersog = otherPart.ParentGroup; + if(othersog == null || othersog.IsDeleted || othersog.inTransit) + continue; + + int otherType = otherPart.CollisionSoundType; + if (otherType < 0 || otherPart.VolumeDetectActive) continue; if (!HaveSound) { - if (otherPart.CollisionSoundType == 1) + if(othersog.CollisionSoundThrootled(otherType)) + continue; + + if (otherType == 1) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; @@ -206,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (otherPart.CollisionSoundType == 2) + if (otherType == 2) { volume = otherPart.CollisionSoundVolume; if (volume == 0.0f) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fdfe8ae..bf915e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1259,6 +1259,8 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundSlavePrims = value; } } + private double m_lastCollisionSoundMS; + /// /// The UUID for the region this object is in. /// @@ -1336,7 +1338,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { - + m_lastCollisionSoundMS = Util.GetTimeStampMS() + 1000.0; } /// @@ -5528,7 +5530,33 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool CollisionSoundThrootled(int collisionSoundType) + { + double time = m_lastCollisionSoundMS; +// m_lastCollisionSoundMS = Util.GetTimeStampMS(); +// time = m_lastCollisionSoundMS - time; + double now = Util.GetTimeStampMS(); + time = now - time; + switch (collisionSoundType) + { + case 0: // default sounds + case 2: // default sounds with volume set by script + if(time < 300.0) + return true; + break; + case 1: // selected sound + if(time < 200.0) + return true; + break; + default: + break; + } + m_lastCollisionSoundMS = now; + return false; + } + #endregion } + } -- cgit v1.1 From 63e3fc21efa1089bf90ff2aa703128e8955d9aed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Jul 2017 13:48:28 +0100 Subject: fix the name of a funtion on last commit --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index f87043e..63aafcd 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes if (sog == null || sog.IsDeleted || sog.inTransit) return; - if(sog.CollisionSoundThrootled(part.CollisionSoundType)) + if(sog.CollisionSoundThrottled(part.CollisionSoundType)) return; float volume = part.CollisionSoundVolume; @@ -206,7 +206,7 @@ namespace OpenSim.Region.Framework.Scenes if (!HaveSound) { - if(othersog.CollisionSoundThrootled(otherType)) + if(othersog.CollisionSoundThrottled(otherType)) continue; if (otherType == 1) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bf915e0..c4b768b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -5530,7 +5530,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public bool CollisionSoundThrootled(int collisionSoundType) + public bool CollisionSoundThrottled(int collisionSoundType) { double time = m_lastCollisionSoundMS; // m_lastCollisionSoundMS = Util.GetTimeStampMS(); -- cgit v1.1 From 9dbcb4e5f687f576ec23794cdf85b41130fea0b0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Jul 2017 19:31:35 +0100 Subject: on entities updates throttles vectors needed to be compared as vectors, not just their norms --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 133 ++++++++++++++++++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 +-- 2 files changed, 116 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f9699b1..576a013 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -369,9 +369,9 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastPosition; protected Quaternion m_lastRotation; protected Vector3 m_lastVelocity; - protected Vector3 m_lastAcceleration; + protected Vector3 m_lastAcceleration; // acceleration is a derived var with high noise protected Vector3 m_lastAngularVelocity; - protected int m_lastUpdateSentTime; + protected double m_lastUpdateSentTime; protected float m_buoyancy = 0.0f; protected Vector3 m_force; protected Vector3 m_torque; @@ -2875,7 +2875,7 @@ namespace OpenSim.Region.Framework.Scenes public void PhysicsCollision(EventArgs e) { - if (ParentGroup.Scene == null || ParentGroup.IsDeleted) + if (ParentGroup.Scene == null || ParentGroup.IsDeleted || ParentGroup.inTransit) return; // this a thread from physics ( heartbeat ) @@ -3331,7 +3331,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; m_lastAngularVelocity = AngularVelocity; - m_lastUpdateSentTime = Environment.TickCount; + m_lastUpdateSentTime = Util.GetTimeStampMS(); ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { @@ -3350,7 +3350,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; m_lastAngularVelocity = AngularVelocity; - m_lastUpdateSentTime = Environment.TickCount; + m_lastUpdateSentTime = Util.GetTimeStampMS(); if (ParentGroup.IsAttachment) { @@ -3396,31 +3396,122 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); } + /// /// Tell all the prims which have had updates scheduled /// public void SendScheduledUpdates() { const float ROTATION_TOLERANCE = 0.01f; - const float VELOCITY_TOLERANCE = 0.001f; + const float VELOCITY_TOLERANCE = 0.1f; // terse update vel has low resolution const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary - const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. - + const double TIME_MS_TOLERANCE = 200f; //llSetPos has a 200ms delay. This should NOT be 3 seconds. + switch (UpdateFlag) { + // this is wrong we need to get back to this case UpdateRequired.TERSE: { ClearUpdateSchedule(); - // Throw away duplicate or insignificant updates - if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || - !Acceleration.Equals(m_lastAcceleration) || - !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || - !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || - !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) + + bool needupdate = true; + double now = Util.GetTimeStampMS(); + Vector3 curvel = Velocity; + Vector3 curacc = Acceleration; + Vector3 angvel = AngularVelocity; + + while(true) // just to avoid ugly goto { - SendTerseUpdateToAllClientsInternal(); + double elapsed = now - m_lastUpdateSentTime; + + // minimal rate also for the other things on terse updates + if (elapsed > TIME_MS_TOLERANCE) + break; + + if( Math.Abs(curacc.X - m_lastAcceleration.X) > VELOCITY_TOLERANCE || + Math.Abs(curacc.Y - m_lastAcceleration.Y) > VELOCITY_TOLERANCE || + Math.Abs(curacc.Z - m_lastAcceleration.Z) > VELOCITY_TOLERANCE) + break; + + // velocity change is also direction not only norm) + if( Math.Abs(curvel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || + Math.Abs(curvel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE || + Math.Abs(curvel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE) + break; + + float vx = Math.Abs(curvel.X); + if(vx > 128.0) + break; + float vy = Math.Abs(curvel.Y); + if(vy > 128.0) + break; + float vz = Math.Abs(curvel.Z); + if(vz > 128.0) + break; + + if ( + vx < VELOCITY_TOLERANCE && + vy < VELOCITY_TOLERANCE && + vz < VELOCITY_TOLERANCE + ) + { + if(!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + break; + + if (vx < 1e-4 && + vy < 1e-4 && + vz < 1e-4 && + ( + Math.Abs(m_lastVelocity.X) > 1e-4 || + Math.Abs(m_lastVelocity.Y) > 1e-4 || + Math.Abs(m_lastVelocity.Z) > 1e-4 + )) + break; + } + + if( Math.Abs(angvel.X - m_lastAngularVelocity.X) > VELOCITY_TOLERANCE || + Math.Abs(angvel.Y - m_lastAngularVelocity.Y) > VELOCITY_TOLERANCE || + Math.Abs(angvel.Z - m_lastAngularVelocity.Z) > VELOCITY_TOLERANCE) + break; + + // viewer interpolators have a limit of 128m/s + float ax = Math.Abs(angvel.X); + if(ax > 64.0) + break; + float ay = Math.Abs(angvel.Y); + if(ay > 64.0) + break; + float az = Math.Abs(angvel.Z); + if(az > 64.0) + break; + + if ( + ax < VELOCITY_TOLERANCE && + ay < VELOCITY_TOLERANCE && + az < VELOCITY_TOLERANCE && + !RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) + ) + break; + + needupdate = false; + break; + } + + if(needupdate) + { + + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = curvel; + m_lastAcceleration = curacc; + m_lastAngularVelocity = angvel; + m_lastUpdateSentTime = now; + + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) + { + SendTerseUpdateToClient(client); + }); } break; } @@ -3442,13 +3533,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter if (ParentGroup == null || ParentGroup.Scene == null) return; + ClearUpdateSchedule(); + // Update the "last" values m_lastPosition = OffsetPosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; m_lastAngularVelocity = AngularVelocity; - m_lastUpdateSentTime = Environment.TickCount; + m_lastUpdateSentTime = Util.GetTimeStampMS(); ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { @@ -3461,13 +3554,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter if (ParentGroup == null || ParentGroup.Scene == null) return; + ClearUpdateSchedule(); + // Update the "last" values m_lastPosition = OffsetPosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; m_lastAngularVelocity = AngularVelocity; - m_lastUpdateSentTime = Environment.TickCount; + m_lastUpdateSentTime = Util.GetTimeStampMS(); if (ParentGroup.IsAttachment) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7e3adb9..c1b62af 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3789,17 +3789,6 @@ namespace OpenSim.Region.Framework.Scenes // Send terse position update if not sitting and position, velocity, or rotation // has changed significantly from last sent update - if (!IsSatOnObject && ( - !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) - || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) - || !m_pos.ApproxEquals(m_lastPosition, POSITION_LARGETOLERANCE) - // if velocity is zero and it wasn't zero last time, send the update - || (Velocity == Vector3.Zero && m_lastVelocity != Vector3.Zero) - // if position has moved just a little and velocity is very low, send the update - || (!m_pos.ApproxEquals(m_lastPosition, POSITION_SMALLTOLERANCE) && Velocity.LengthSquared() < LOWVELOCITYSQ ) - ) ) - { -/* if (!IsSatOnObject) { // this does need to be more complex later @@ -3813,6 +3802,7 @@ namespace OpenSim.Region.Framework.Scenes Math.Abs(m_bodyRot.Y - m_lastRotation.Y) > ROTATION_TOLERANCE || Math.Abs(m_bodyRot.Z - m_lastRotation.Z) > ROTATION_TOLERANCE || + (vel == Vector3.Zero && m_lastVelocity != Vector3.Zero) || Math.Abs(dpos.X) > POSITION_LARGETOLERANCE || Math.Abs(dpos.Y) > POSITION_LARGETOLERANCE || Math.Abs(dpos.Z) > POSITION_LARGETOLERANCE || @@ -3823,9 +3813,8 @@ namespace OpenSim.Region.Framework.Scenes && vel.LengthSquared() < LOWVELOCITYSQ )) { -*/ SendTerseUpdateToAllClients(); -// } + } } CheckForSignificantMovement(); } -- cgit v1.1 From f8cdccc16729212e374cc001ab4f0be8e5960259 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Jul 2017 21:12:34 +0100 Subject: a few more changes on entities updates --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 30 ++++++++------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 43 +++++++--------------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 36 +++++++++++------- 3 files changed, 52 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 53c185b..954f21f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -6256,20 +6256,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - float vdelta = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); - if((vdelta > VDELTA)) - return true; - - vdelta = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); - if((vdelta > VDELTA)) - return true; - - vdelta = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); - if((vdelta > VDELTA)) - return true; - - vdelta = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); - if((vdelta > VDELTA)) + if(Math.Abs(x.CameraCenter.X - m_thisAgentUpdateArgs.CameraCenter.X) > VDELTA || + Math.Abs(x.CameraCenter.Y - m_thisAgentUpdateArgs.CameraCenter.Y) > VDELTA || + Math.Abs(x.CameraCenter.Z - m_thisAgentUpdateArgs.CameraCenter.Z) > VDELTA || + + Math.Abs(x.CameraAtAxis.X - m_thisAgentUpdateArgs.CameraAtAxis.X) > VDELTA || + Math.Abs(x.CameraAtAxis.Y - m_thisAgentUpdateArgs.CameraAtAxis.Y) > VDELTA || +// Math.Abs(x.CameraAtAxis.Z - m_thisAgentUpdateArgs.CameraAtAxis.Z) > VDELTA || + + Math.Abs(x.CameraLeftAxis.X - m_thisAgentUpdateArgs.CameraLeftAxis.X) > VDELTA || + Math.Abs(x.CameraLeftAxis.Y - m_thisAgentUpdateArgs.CameraLeftAxis.Y) > VDELTA || +// Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA || + + Math.Abs(x.CameraUpAxis.X - m_thisAgentUpdateArgs.CameraUpAxis.X) > VDELTA || + Math.Abs(x.CameraUpAxis.Y - m_thisAgentUpdateArgs.CameraUpAxis.Y) > VDELTA +// Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA || + ) return true; return false; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 576a013..2e16663 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3237,7 +3237,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Schedule a terse update for this prim. Terse updates only send position, - /// rotation, velocity and rotational velocity information. + /// rotation, velocity and rotational velocity information. WRONG!!!! /// public void ScheduleTerseUpdate() { @@ -3296,21 +3296,6 @@ namespace OpenSim.Region.Framework.Scenes sp.SendAttachmentUpdate(this, UpdateRequired.FULL); } } - -/* this does nothing -SendFullUpdateToClient(remoteClient, Position) ignores position parameter - if (IsRoot) - { - if (ParentGroup.IsAttachment) - { - SendFullUpdateToClient(remoteClient, AttachedPos); - } - else - { - SendFullUpdateToClient(remoteClient, AbsolutePosition); - } - } -*/ else { SendFullUpdateToClient(remoteClient); @@ -3396,24 +3381,26 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); } + + private const float ROTATION_TOLERANCE = 0.01f; + private const float VELOCITY_TOLERANCE = 0.1f; // terse update vel has low resolution + private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary + private const double TIME_MS_TOLERANCE = 200f; //llSetPos has a 200ms delay. This should NOT be 3 seconds. /// /// Tell all the prims which have had updates scheduled /// public void SendScheduledUpdates() - { - const float ROTATION_TOLERANCE = 0.01f; - const float VELOCITY_TOLERANCE = 0.1f; // terse update vel has low resolution - const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary - const double TIME_MS_TOLERANCE = 200f; //llSetPos has a 200ms delay. This should NOT be 3 seconds. - + { switch (UpdateFlag) { - // this is wrong we need to get back to this - case UpdateRequired.TERSE: - { + case UpdateRequired.NONE: ClearUpdateSchedule(); + break; + + case UpdateRequired.TERSE: + ClearUpdateSchedule(); bool needupdate = true; double now = Util.GetTimeStampMS(); Vector3 curvel = Velocity; @@ -3423,8 +3410,6 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter while(true) // just to avoid ugly goto { double elapsed = now - m_lastUpdateSentTime; - - // minimal rate also for the other things on terse updates if (elapsed > TIME_MS_TOLERANCE) break; @@ -3514,13 +3499,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter }); } break; - } + case UpdateRequired.FULL: - { ClearUpdateSchedule(); SendFullUpdateToAllClientsInternal(); break; - } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c1b62af..ba3aaae 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -279,8 +279,11 @@ namespace OpenSim.Region.Framework.Scenes private bool MouseDown = false; public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; + public Vector4 CollisionPlane = Vector4.UnitW; + public Vector4 m_lastCollisionPlane = Vector4.UnitW; + private byte m_lastState; private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; @@ -2818,16 +2821,13 @@ namespace OpenSim.Region.Framework.Scenes CameraAtAxis = agentData.CameraAtAxis; CameraLeftAxis = agentData.CameraLeftAxis; CameraUpAxis = agentData.CameraUpAxis; - Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); - CameraRotation = camRot; - - // The Agent's Draw distance setting - // When we get to the point of re-computing neighbors everytime this - // changes, then start using the agent's drawdistance rather than the - // region's draw distance. - DrawDistance = agentData.Far; + CameraAtAxis.Normalize(); + CameraLeftAxis.Normalize(); + CameraUpAxis.Normalize(); + Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); + CameraRotation = camRot; // Check if Client has camera in 'follow cam' or 'build' mode. // Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); @@ -3794,15 +3794,17 @@ namespace OpenSim.Region.Framework.Scenes // this does need to be more complex later Vector3 vel = Velocity; Vector3 dpos = m_pos - m_lastPosition; - if( Math.Abs(vel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || + if( State != m_lastState || + Math.Abs(vel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || Math.Abs(vel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE || Math.Abs(vel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE || Math.Abs(m_bodyRot.X - m_lastRotation.X) > ROTATION_TOLERANCE || Math.Abs(m_bodyRot.Y - m_lastRotation.Y) > ROTATION_TOLERANCE || Math.Abs(m_bodyRot.Z - m_lastRotation.Z) > ROTATION_TOLERANCE || - + (vel == Vector3.Zero && m_lastVelocity != Vector3.Zero) || + Math.Abs(dpos.X) > POSITION_LARGETOLERANCE || Math.Abs(dpos.Y) > POSITION_LARGETOLERANCE || Math.Abs(dpos.Z) > POSITION_LARGETOLERANCE || @@ -3811,7 +3813,12 @@ namespace OpenSim.Region.Framework.Scenes Math.Abs(dpos.Y) > POSITION_SMALLTOLERANCE || Math.Abs(dpos.Z) > POSITION_SMALLTOLERANCE) && vel.LengthSquared() < LOWVELOCITYSQ - )) + ) || + + Math.Abs(CollisionPlane.X - m_lastCollisionPlane.X) > POSITION_SMALLTOLERANCE || + Math.Abs(CollisionPlane.Y - m_lastCollisionPlane.Y) > POSITION_SMALLTOLERANCE || + Math.Abs(CollisionPlane.W - m_lastCollisionPlane.W) > POSITION_SMALLTOLERANCE + ) { SendTerseUpdateToAllClients(); } @@ -3910,11 +3917,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { - m_scene.ForEachScenePresence(SendTerseUpdateToAgent); - // Update the "last" values + m_lastState = State; m_lastPosition = m_pos; m_lastRotation = m_bodyRot; m_lastVelocity = Velocity; + m_lastCollisionPlane = CollisionPlane; + + m_scene.ForEachScenePresence(SendTerseUpdateToAgent); + // Update the "last" values TriggerScenePresenceUpdated(); } -- cgit v1.1 From 40b16f1705bd6361d7fd0cd2bc458ae9ea381bf1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Jul 2017 22:01:38 +0100 Subject: SimpleAngularDistance update prioritization scheme ameks no sense without ordered dequeue of the updates --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 954f21f..861b79e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -4137,6 +4137,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Vector3 mypos = Vector3.Zero; ScenePresence mysp = (ScenePresence)SceneAgent; + bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; // we should have a presence if(mysp == null) return; @@ -4151,8 +4152,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP while (maxUpdatesBytes > 0) { lock (m_entityUpdates.SyncRoot) - if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) - break; + { + if(orderedDequeue) + { + if (!m_entityUpdates.TryOrderedDequeue(out update, out timeinqueue)) + break; + } + else + { + if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) + break; + } + } PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags; @@ -4850,6 +4861,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // OpenSim.Framework.Lazy> propertyUpdates = // new OpenSim.Framework.Lazy>(); + bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; EntityUpdate iupdate; Int32 timeinqueue; // this is just debugging code & can be dropped later @@ -4857,8 +4869,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP while (maxUpdateBytes > 0) { lock (m_entityProps.SyncRoot) - if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue)) - break; + { + if(orderedDequeue) + { + if (!m_entityProps.TryOrderedDequeue(out iupdate, out timeinqueue)) + break; + } + else + { + if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue)) + break; + } + } ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate; if (update.SendFamilyProps) -- cgit v1.1 From 72bce8c4b41406e8f19e263be634f2434bc54765 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Jul 2017 02:33:48 +0100 Subject: do lsl object rez checks on script thread before wasting time possible creating a new poll thread --- .../Shared/Api/Implementation/LSL_Api.cs | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index af88e4f..f4b7aa3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3534,32 +3534,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void doObjectRez(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param, bool atRoot) { m_host.AddScriptLPS(1); + if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) + return; - Util.FireAndForget(x => - { - if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) - return; + float dist = (float)llVecDist(llGetPos(), pos); - float dist = (float)llVecDist(llGetPos(), pos); + if (dist > m_ScriptDistanceFactor * 10.0f) + return; - if (dist > m_ScriptDistanceFactor * 10.0f) - return; + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); + if (item == null) + { + Error("llRez(AtRoot/Object)", "Can't find object '" + inventory + "'"); + return; + } - if (item == null) - { - Error("llRez(AtRoot/Object)", "Can't find object '" + inventory + "'"); - return; - } + if (item.InvType != (int)InventoryType.Object) + { + Error("llRez(AtRoot/Object)", "Can't create requested object; object is missing from database"); + return; + } - if (item.InvType != (int)InventoryType.Object) - { - Error("llRez(AtRoot/Object)", "Can't create requested object; object is missing from database"); - return; - } + Util.FireAndForget(x => + { - List new_groups = World.RezObject(m_host, item, pos, rot, vel, param, atRoot); + Quaternion wrot = rot; + wrot.Normalize(); + List new_groups = World.RezObject(m_host, item, pos, wrot, vel, param, atRoot); // If either of these are null, then there was an unknown error. if (new_groups == null) -- cgit v1.1 From f5324833eeff9d99caf437fc47b920e616699de1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Jul 2017 02:47:37 +0100 Subject: remove wrong comment on lsl object rez. we can't add delays on async process --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f4b7aa3..c13e8b2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3598,9 +3598,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } - // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) - } - + } }, null, "LSL_Api.doObjectRez"); //ScriptSleep((int)((groupmass * velmag) / 10)); -- cgit v1.1 From c8a9b0321f1e3ea724d8230ea1106b8bfd682fc3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 12 Jul 2017 01:44:34 +0100 Subject: osSetParcelDetails: place hard restrictions on change owner,claimdate (both estate owner or manager) and group (same plus parcel owner that also needes to be a member of the new group); add PARCEL_DETAILS_SEE_AVATARS, PARCEL_DETAILS_ANY_AVATAR_SOUNDS and PARCEL_DETAILS_GROUP_SOUNDS --- .../Shared/Api/Implementation/OSSL_Api.cs | 115 ++++++++++++++++++--- .../Shared/Api/Runtime/LSL_Constants.cs | 4 +- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 3 +- 3 files changed, 103 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 22d247d..4bf8729 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1606,13 +1606,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false)) { - OSSLShoutError("You do not have permission to modify the parcel"); + OSSLShoutError("script owner does not have permission to modify the parcel"); return; } // Create a new land data object we can modify LandData newLand = startLandObject.LandData.Copy(); UUID uuid; + EstateSettings es = World.RegionInfo.EstateSettings; + + bool changed = false; // Process the rules, not sure what the impact would be of changing owner or group for (int idx = 0; idx < rules.Length;) @@ -1622,35 +1625,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { case ScriptBaseClass.PARCEL_DETAILS_NAME: - newLand.Name = arg; + if(newLand.Name != arg) + { + newLand.Name = arg; + changed = true; + } break; case ScriptBaseClass.PARCEL_DETAILS_DESC: - newLand.Description = arg; + if(newLand.Description != arg) + { + newLand.Description = arg; + changed = true; + } break; case ScriptBaseClass.PARCEL_DETAILS_OWNER: - CheckThreatLevel(ThreatLevel.VeryHigh, functionName); - if (UUID.TryParse(arg, out uuid)) - newLand.OwnerID = uuid; + if(es != null && !es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + OSSLError("script owner does not have permission to modify the parcel owner"); + } + else + { + if (UUID.TryParse(arg, out uuid)) + { + if(newLand.OwnerID != uuid) + { + changed = true; + newLand.OwnerID = uuid; + newLand.GroupID = UUID.Zero; + } + } + } break; case ScriptBaseClass.PARCEL_DETAILS_GROUP: - CheckThreatLevel(ThreatLevel.VeryHigh, functionName); - if (UUID.TryParse(arg, out uuid)) - newLand.GroupID = uuid; + if(m_host.OwnerID == newLand.OwnerID || es == null || es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + if (UUID.TryParse(arg, out uuid)) + { + if(newLand.GroupID != uuid) + { + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface(); + GroupMembershipData member = null; + if (groupsModule != null) + member = groupsModule.GetMembershipData(uuid, newLand.OwnerID); + if (member == null) + OSSLError(string.Format("land owner is not member of the new group for parcel")); + else + { + changed = true; + newLand.GroupID = uuid; + } + } + } + } + else + { + OSSLError("script owner does not have permission to modify the parcel group"); + } break; case ScriptBaseClass.PARCEL_DETAILS_CLAIMDATE: - CheckThreatLevel(ThreatLevel.VeryHigh, functionName); - newLand.ClaimDate = Convert.ToInt32(arg); - if (newLand.ClaimDate == 0) - newLand.ClaimDate = Util.UnixTimeSinceEpoch(); + if(es != null && !es.IsEstateManagerOrOwner(m_host.OwnerID)) + { + OSSLError("script owner does not have permission to modify the parcel CLAIM DATE"); + } + else + { + int date = Convert.ToInt32(arg); + if (date == 0) + date = Util.UnixTimeSinceEpoch(); + if(newLand.ClaimDate != date) + { + changed = true; + newLand.ClaimDate = date; + } + } break; - } - } - World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); + case ScriptBaseClass.PARCEL_DETAILS_SEE_AVATARS: + bool newavs = (Convert.ToInt32(arg) != 0); + if(newLand.SeeAVs != newavs) + { + changed = true; + newLand.SeeAVs = newavs; + } + break; + + case ScriptBaseClass.PARCEL_DETAILS_ANY_AVATAR_SOUNDS: + bool newavsounds = (Convert.ToInt32(arg) != 0); + if(newLand.AnyAVSounds != newavsounds) + { + changed = true; + newLand.AnyAVSounds = newavsounds; + } + break; + + case ScriptBaseClass.PARCEL_DETAILS_GROUP_SOUNDS: + bool newgrpsounds = (Convert.ToInt32(arg) != 0); + if(newLand.GroupAVSounds != newgrpsounds) + { + changed = true; + newLand.GroupAVSounds = newgrpsounds; + } + break; + } + } + if(changed) + World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); } public double osList2Double(LSL_Types.list src, int index) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index a277f6c..e4c1ca0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -697,7 +697,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PARCEL_DETAILS_GROUP = 3; public const int PARCEL_DETAILS_AREA = 4; public const int PARCEL_DETAILS_ID = 5; - public const int PARCEL_DETAILS_SEE_AVATARS = 6; // not implemented + public const int PARCEL_DETAILS_SEE_AVATARS = 6; + public const int PARCEL_DETAILS_ANY_AVATAR_SOUNDS = 7; + public const int PARCEL_DETAILS_GROUP_SOUNDS = 8; //osSetParcelDetails public const int PARCEL_DETAILS_CLAIMDATE = 10; diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 4d7a698..8780e49 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -39,7 +39,6 @@ using OMV_Quaternion = OpenMetaverse.Quaternion; namespace OpenSim.Region.ScriptEngine.Shared { - [Serializable] public partial class LSL_Types { // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain @@ -526,7 +525,7 @@ namespace OpenSim.Region.ScriptEngine.Shared } [Serializable] - public class list + public class list: MarshalByRefObject { private object[] m_data; -- cgit v1.1 From 3847f861e39a6792b7b6063289dabb9911580d71 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 12 Jul 2017 01:52:01 +0100 Subject: osSetParcelDetails: allow parcel group to be cleared also --- .../Shared/Api/Implementation/OSSL_Api.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 4bf8729..4aac9a0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1666,17 +1666,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if(newLand.GroupID != uuid) { - IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface(); - GroupMembershipData member = null; - if (groupsModule != null) - member = groupsModule.GetMembershipData(uuid, newLand.OwnerID); - if (member == null) - OSSLError(string.Format("land owner is not member of the new group for parcel")); - else + if(uuid == UUID.Zero) { changed = true; newLand.GroupID = uuid; } + else + { + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface(); + GroupMembershipData member = null; + if (groupsModule != null) + member = groupsModule.GetMembershipData(uuid, newLand.OwnerID); + if (member == null) + OSSLError(string.Format("land owner is not member of the new group for parcel")); + else + { + changed = true; + newLand.GroupID = uuid; + } + } } } } -- cgit v1.1 From a069ed09a82bfe07ef84a78202f502ed3b312134 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 12 Jul 2017 03:47:34 +0100 Subject: osSetParcelDetails: make seeAVs send updates. This is a temporary patch, this function does need to call a framework land function that deos issue proper updates about all fields to all cleints. ( sounds will not stop/start also for now) --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 4aac9a0..f274cd3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1616,6 +1616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api EstateSettings es = World.RegionInfo.EstateSettings; bool changed = false; + bool changedSeeAvs = false; // Process the rules, not sure what the impact would be of changing owner or group for (int idx = 0; idx < rules.Length;) @@ -1717,6 +1718,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(newLand.SeeAVs != newavs) { changed = true; + changedSeeAvs = true; newLand.SeeAVs = newavs; } break; @@ -1741,7 +1743,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } if(changed) + { World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); + + if(changedSeeAvs) + { + UUID parcelID= newLand.GlobalID; + World.ForEachScenePresence(delegate (ScenePresence avatar) + { + if (avatar != null && !avatar.IsDeleted && avatar.currentParcelUUID == parcelID ) + avatar.currentParcelUUID = parcelID; // force parcel flags review + }); + } + } + } public double osList2Double(LSL_Types.list src, int index) -- cgit v1.1 From aff9c345dddfa290222ceaf42b6c452a590a2276 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 12 Jul 2017 07:27:21 +0100 Subject: osSetParcelDetails: add more land update code --- .../Region/CoreModules/World/Land/LandChannel.cs | 8 +++++++ .../Shared/Api/Implementation/OSSL_Api.cs | 26 +++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs index b59e2af..5ff063b 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs @@ -176,6 +176,14 @@ namespace OpenSim.Region.CoreModules.World.Land } } + public void SendParcelsOverlay(IClientAPI client) + { + if (m_landManagementModule != null) + { + m_landManagementModule.SendParcelOverlay(client); + } + } + public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) { if (m_landManagementModule != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f274cd3..79367fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1617,6 +1617,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool changed = false; bool changedSeeAvs = false; + bool changedoverlay = false; + bool changedneedupdate = false; // Process the rules, not sure what the impact would be of changing owner or group for (int idx = 0; idx < rules.Length;) @@ -1719,6 +1721,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { changed = true; changedSeeAvs = true; + changedoverlay = true; + changedneedupdate = true; newLand.SeeAVs = newavs; } break; @@ -1744,19 +1748,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if(changed) { - World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); + World.LandChannel.UpdateLandObject(newLand.LocalID, newLand); - if(changedSeeAvs) + if(changedneedupdate) { UUID parcelID= newLand.GlobalID; - World.ForEachScenePresence(delegate (ScenePresence avatar) + World.ForEachRootScenePresence(delegate (ScenePresence avatar) { - if (avatar != null && !avatar.IsDeleted && avatar.currentParcelUUID == parcelID ) + if (avatar == null || avatar.IsDeleted || avatar.IsInTransit) + return; + + if(changedSeeAvs && avatar.currentParcelUUID == parcelID ) avatar.currentParcelUUID = parcelID; // force parcel flags review + + if(avatar.ControllingClient == null) + return; + + // this will be needed for some things like damage etc +// if(avatar.currentParcelUUID == parcelID) +// startLandObject.SendLandUpdateToClient(avatar.ControllingClient); + + if(changedoverlay && !avatar.IsNPC) + World.LandChannel.SendParcelsOverlay(avatar.ControllingClient); }); } } - } public double osList2Double(LSL_Types.list src, int index) -- cgit v1.1 From 457551d0699558520c9ce47e05fcace828a706e5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 12 Jul 2017 10:28:11 +0100 Subject: rename SOG.UpdatePrimFlags as just UpdateFlags since this is relative to the group never individual prims/parts and so confusing --- OpenSim/Region/Framework/Scenes/EventManager.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 131 +++++++++------------ 3 files changed, 59 insertions(+), 76 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 827f91e..f76f882 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -855,7 +855,7 @@ namespace OpenSim.Region.Framework.Scenes /// , /// , /// , - /// , + /// , /// /// public event ParcelPrimCountTainted OnParcelPrimCountTainted; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ae827f4..61a243d 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1649,7 +1649,7 @@ namespace OpenSim.Region.Framework.Scenes else // else turn it off vdtc = false; - group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, vdtc); + group.UpdateFlags(UsePhysics, SetTemporary, SetPhantom, vdtc); } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c4b768b..6f46a92 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2718,35 +2718,22 @@ namespace OpenSim.Region.Framework.Scenes RootPart.KeyframeMotion.Stop(); RootPart.KeyframeMotion = null; } - UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + UpdateFlags(usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } public void ScriptSetTemporaryStatus(bool makeTemporary) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect); + UpdateFlags(UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect); } public void ScriptSetPhantomStatus(bool makePhantom) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect); + UpdateFlags(UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect); } public void ScriptSetVolumeDetect(bool makeVolumeDetect) { - UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect); - - /* - ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore - - if (PhysActor != null) // Should always be the case now - { - PhysActor.SetVolumeDetect(param); - } - if (param != 0) - AddFlag(PrimFlags.Phantom); - - ScheduleFullUpdate(); - */ + UpdateFlags(UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect); } public void applyImpulse(Vector3 impulse) @@ -4031,84 +4018,80 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) + public void UpdateFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) { - HasGroupChanged = true; + if (m_scene == null || IsDeleted) + return; - SceneObjectPart selectionPart = GetPart(localID); + HasGroupChanged = true; - if (Scene != null) + if (SetTemporary) { - if (SetTemporary) - { - DetachFromBackup(); - // Remove from database and parcel prim count - // - m_scene.DeleteFromStorage(UUID); - } - else if (!Backup) - { - // Previously been temporary now switching back so make it - // available for persisting again - AttachToBackup(); - } - - m_scene.EventManager.TriggerParcelPrimCountTainted(); + DetachFromBackup(); + // Remove from database and parcel prim count + // + m_scene.DeleteFromStorage(UUID); } - - if (selectionPart != null) + else if (!Backup) { - SceneObjectPart[] parts = m_parts.GetArray(); + // Previously been temporary now switching back so make it + // available for persisting again + AttachToBackup(); + } - if (Scene != null && UsePhysics) - { - int maxprims = m_scene.m_linksetPhysCapacity; - bool checkShape = (maxprims > 0 && - parts.Length > maxprims); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; + SceneObjectPart[] parts = m_parts.GetArray(); - if(part.PhysicsShapeType == (byte)PhysicsShapeType.None) - continue; // assuming root type was checked elsewhere + if (UsePhysics) + { + int maxprims = m_scene.m_linksetPhysCapacity; + bool checkShape = (maxprims > 0 && + parts.Length > maxprims); - if (checkShape) - { - if (--maxprims < 0) - { - UsePhysics = false; - break; - } - } + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; - if (part.Scale.X > m_scene.m_maxPhys || - part.Scale.Y > m_scene.m_maxPhys || - part.Scale.Z > m_scene.m_maxPhys ) + if(part.PhysicsShapeType == (byte)PhysicsShapeType.None) + continue; // assuming root type was checked elsewhere + + if (checkShape) + { + if (--maxprims < 0) { - UsePhysics = false; // Reset physics + UsePhysics = false; break; } } - } - if (parts.Length > 1) - { - m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); - - for (int i = 0; i < parts.Length; i++) + if (part.Scale.X > m_scene.m_maxPhys || + part.Scale.Y > m_scene.m_maxPhys || + part.Scale.Z > m_scene.m_maxPhys ) { - - if (parts[i].UUID != m_rootPart.UUID) - parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); + UsePhysics = false; // Reset physics + break; } + } + } - if (m_rootPart.PhysActor != null) - m_rootPart.PhysActor.Building = false; + if (parts.Length > 1) + { + m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); + + for (int i = 0; i < parts.Length; i++) + { + + if (parts[i].UUID != m_rootPart.UUID) + parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); } - else - m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; } + else + m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); + + m_scene.EventManager.TriggerParcelPrimCountTainted(); } public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) -- cgit v1.1 From 51d32e3bed8a8d2ce8bd1e0ed3b9644eb4f97793 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Jul 2017 02:57:57 +0100 Subject: add more missing en-us culture on scene serializer writes --- .../CoalescedSceneObjectsSerializer.cs | 12 ++--- .../Scenes/Serialization/SceneObjectSerializer.cs | 51 +++++++++++----------- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs index 7f7977e..d151002 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs @@ -86,9 +86,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteStartElement("CoalescedObject"); - writer.WriteAttributeString("x", size.X.ToString()); - writer.WriteAttributeString("y", size.Y.ToString()); - writer.WriteAttributeString("z", size.Z.ToString()); + writer.WriteAttributeString("x", size.X.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("y", size.Y.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("z", size.Z.ToString(Utils.EnUsCulture)); // Embed the offsets into the group XML for (int i = 0; i < coaObjects.Count; i++) @@ -100,9 +100,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // i, obj.Name); writer.WriteStartElement("SceneObjectGroup"); - writer.WriteAttributeString("offsetx", offsets[i].X.ToString()); - writer.WriteAttributeString("offsety", offsets[i].Y.ToString()); - writer.WriteAttributeString("offsetz", offsets[i].Z.ToString()); + writer.WriteAttributeString("offsetx", offsets[i].X.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("offsety", offsets[i].Y.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("offsetz", offsets[i].Z.ToString(Utils.EnUsCulture)); SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, doScriptStates); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index b012a08..4ca4434 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -65,7 +65,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) { - try { + try + { return FromOriginalXmlFormat(reader); } catch (Exception e) @@ -1505,7 +1506,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); WriteFlags(writer, "Flags", sop.Flags.ToString(), options); WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); - writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); + writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString(Utils.EnUsCulture)); if (sop.MediaUrl != null) writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); WriteVector(writer, "AttachedPos", sop.AttachedPos); @@ -1525,7 +1526,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); - writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); + writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString(Utils.EnUsCulture)); WriteVector(writer, "Force", sop.Force); WriteVector(writer, "Torque", sop.Torque); @@ -1542,22 +1543,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower()); writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); if (sop.Density != 1000.0f) - writer.WriteElementString("Density", sop.Density.ToString().ToLower()); + writer.WriteElementString("Density", sop.Density.ToString(Utils.EnUsCulture)); if (sop.Friction != 0.6f) - writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); + writer.WriteElementString("Friction", sop.Friction.ToString(Utils.EnUsCulture)); if (sop.Restitution != 0.5f) - writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); + writer.WriteElementString("Bounce", sop.Restitution.ToString(Utils.EnUsCulture)); if (sop.GravityModifier != 1.0f) - writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); + writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString(Utils.EnUsCulture)); WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim { WriteUUID(writer, "SoundID", sop.Sound, options); - writer.WriteElementString("SoundGain", sop.SoundGain.ToString().ToLower()); + writer.WriteElementString("SoundGain", sop.SoundGain.ToString(Utils.EnUsCulture)); writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower()); - writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString().ToLower()); + writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString(Utils.EnUsCulture)); } writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower()); @@ -1731,22 +1732,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // Don't serialize SculptData. It's just a copy of the asset, which can be loaded separately using 'SculptTexture'. writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString()); - writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString()); - writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString()); - writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString()); - writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString()); - writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString()); - writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString()); - writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString()); - - writer.WriteElementString("LightColorR", shp.LightColorR.ToString()); - writer.WriteElementString("LightColorG", shp.LightColorG.ToString()); - writer.WriteElementString("LightColorB", shp.LightColorB.ToString()); - writer.WriteElementString("LightColorA", shp.LightColorA.ToString()); - writer.WriteElementString("LightRadius", shp.LightRadius.ToString()); - writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString()); - writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString()); - writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString()); + writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString(Utils.EnUsCulture)); + + writer.WriteElementString("LightColorR", shp.LightColorR.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightColorG", shp.LightColorG.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightColorB", shp.LightColorB.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightColorA", shp.LightColorA.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightRadius", shp.LightRadius.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString(Utils.EnUsCulture)); + writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString(Utils.EnUsCulture)); writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower()); writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower()); -- cgit v1.1 From 61e3fe42bd78b98ffffb3a0f1b8f8bf32583bb9f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Jul 2017 03:26:43 +0100 Subject: fix wrong test --- OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs index 045fd3c..4ce6a95 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs @@ -54,8 +54,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID ownerId = TestHelpers.ParseTail(0x1); SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(3, ownerId, "so1", 0x10); - so1.ScriptSetPhysicsStatus(true); m_scene.AddSceneObject(so1); + so1.ScriptSetPhysicsStatus(true); Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(3)); Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(3)); -- cgit v1.1 From bd249bdf5b175ee6d84588a777444f2b89d7df1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Jul 2017 04:14:33 +0100 Subject: replace the wrong libOMV user modifiable Utils.EnUSCulture by our own no User modifiable Culture.FormatProvider, and also for internal coerence. We do use the libomv on other code paths, so that must be fixed --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 16 ++--- .../CoalescedSceneObjectsSerializer.cs | 12 ++-- .../Scenes/Serialization/SceneObjectSerializer.cs | 70 +++++++++++----------- 3 files changed, 49 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 8d11331..351eda3 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -425,25 +425,25 @@ namespace OpenSim.Region.Framework.Scenes private void XWfloat(string name, float f) { - writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); + writer.WriteElementString(name, f.ToString(Culture.FormatProvider)); } private void XWVector(string name, Vector3 vec) { writer.WriteStartElement(name); - writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); + writer.WriteElementString("X", vec.X.ToString(Culture.FormatProvider)); + writer.WriteElementString("Y", vec.Y.ToString(Culture.FormatProvider)); + writer.WriteElementString("Z", vec.Z.ToString(Culture.FormatProvider)); writer.WriteEndElement(); } private void XWQuat(string name, Quaternion quat) { writer.WriteStartElement(name); - writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); - writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); + writer.WriteElementString("X", quat.X.ToString(Culture.FormatProvider)); + writer.WriteElementString("Y", quat.Y.ToString(Culture.FormatProvider)); + writer.WriteElementString("Z", quat.Z.ToString(Culture.FormatProvider)); + writer.WriteElementString("W", quat.W.ToString(Culture.FormatProvider)); writer.WriteEndElement(); } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs index d151002..41f3ef4 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs @@ -86,9 +86,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteStartElement("CoalescedObject"); - writer.WriteAttributeString("x", size.X.ToString(Utils.EnUsCulture)); - writer.WriteAttributeString("y", size.Y.ToString(Utils.EnUsCulture)); - writer.WriteAttributeString("z", size.Z.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("x", size.X.ToString(Culture.FormatProvider)); + writer.WriteAttributeString("y", size.Y.ToString(Culture.FormatProvider)); + writer.WriteAttributeString("z", size.Z.ToString(Culture.FormatProvider)); // Embed the offsets into the group XML for (int i = 0; i < coaObjects.Count; i++) @@ -100,9 +100,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // i, obj.Name); writer.WriteStartElement("SceneObjectGroup"); - writer.WriteAttributeString("offsetx", offsets[i].X.ToString(Utils.EnUsCulture)); - writer.WriteAttributeString("offsety", offsets[i].Y.ToString(Utils.EnUsCulture)); - writer.WriteAttributeString("offsetz", offsets[i].Z.ToString(Utils.EnUsCulture)); + writer.WriteAttributeString("offsetx", offsets[i].X.ToString(Culture.FormatProvider)); + writer.WriteAttributeString("offsety", offsets[i].Y.ToString(Culture.FormatProvider)); + writer.WriteAttributeString("offsetz", offsets[i].Z.ToString(Culture.FormatProvider)); SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, doScriptStates); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 4ca4434..3d867a4 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1460,10 +1460,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Description", sop.Description); writer.WriteStartElement("Color"); - writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); - writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); - writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); - writer.WriteElementString("A", sop.Color.A.ToString(Utils.EnUsCulture)); + writer.WriteElementString("R", sop.Color.R.ToString(Culture.FormatProvider)); + writer.WriteElementString("G", sop.Color.G.ToString(Culture.FormatProvider)); + writer.WriteElementString("B", sop.Color.B.ToString(Culture.FormatProvider)); + writer.WriteElementString("A", sop.Color.A.ToString(Culture.FormatProvider)); writer.WriteEndElement(); writer.WriteElementString("Text", sop.Text); @@ -1506,7 +1506,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); WriteFlags(writer, "Flags", sop.Flags.ToString(), options); WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); - writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString(Utils.EnUsCulture)); + writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString(Culture.FormatProvider)); if (sop.MediaUrl != null) writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); WriteVector(writer, "AttachedPos", sop.AttachedPos); @@ -1526,7 +1526,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); - writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString(Culture.FormatProvider)); WriteVector(writer, "Force", sop.Force); WriteVector(writer, "Torque", sop.Torque); @@ -1543,22 +1543,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower()); writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); if (sop.Density != 1000.0f) - writer.WriteElementString("Density", sop.Density.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Density", sop.Density.ToString(Culture.FormatProvider)); if (sop.Friction != 0.6f) - writer.WriteElementString("Friction", sop.Friction.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Friction", sop.Friction.ToString(Culture.FormatProvider)); if (sop.Restitution != 0.5f) - writer.WriteElementString("Bounce", sop.Restitution.ToString(Utils.EnUsCulture)); + writer.WriteElementString("Bounce", sop.Restitution.ToString(Culture.FormatProvider)); if (sop.GravityModifier != 1.0f) - writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString(Utils.EnUsCulture)); + writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString(Culture.FormatProvider)); WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim { WriteUUID(writer, "SoundID", sop.Sound, options); - writer.WriteElementString("SoundGain", sop.SoundGain.ToString(Utils.EnUsCulture)); + writer.WriteElementString("SoundGain", sop.SoundGain.ToString(Culture.FormatProvider)); writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower()); - writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString(Utils.EnUsCulture)); + writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString(Culture.FormatProvider)); } writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower()); @@ -1578,19 +1578,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization static void WriteVector(XmlTextWriter writer, string name, Vector3 vec) { writer.WriteStartElement(name); - writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); + writer.WriteElementString("X", vec.X.ToString(Culture.FormatProvider)); + writer.WriteElementString("Y", vec.Y.ToString(Culture.FormatProvider)); + writer.WriteElementString("Z", vec.Z.ToString(Culture.FormatProvider)); writer.WriteEndElement(); } static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat) { writer.WriteStartElement(name); - writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); - writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); - writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); + writer.WriteElementString("X", quat.X.ToString(Culture.FormatProvider)); + writer.WriteElementString("Y", quat.Y.ToString(Culture.FormatProvider)); + writer.WriteElementString("Z", quat.Z.ToString(Culture.FormatProvider)); + writer.WriteElementString("W", quat.W.ToString(Culture.FormatProvider)); writer.WriteEndElement(); } @@ -1732,22 +1732,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // Don't serialize SculptData. It's just a copy of the asset, which can be loaded separately using 'SculptTexture'. writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString()); - writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString(Utils.EnUsCulture)); - writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString(Utils.EnUsCulture)); - - writer.WriteElementString("LightColorR", shp.LightColorR.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightColorG", shp.LightColorG.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightColorB", shp.LightColorB.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightColorA", shp.LightColorA.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightRadius", shp.LightRadius.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString(Utils.EnUsCulture)); - writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString(Utils.EnUsCulture)); + writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString(Culture.FormatProvider)); + writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString(Culture.FormatProvider)); + + writer.WriteElementString("LightColorR", shp.LightColorR.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightColorG", shp.LightColorG.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightColorB", shp.LightColorB.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightColorA", shp.LightColorA.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightRadius", shp.LightRadius.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString(Culture.FormatProvider)); + writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString(Culture.FormatProvider)); writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower()); writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower()); -- cgit v1.1 From 8b16131206818329e973faec3a9861fca37f0073 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Jul 2017 20:21:18 +0100 Subject: add Util.GetTimeStamp() that returns the stamp in seconds; use it on ubOde; separed land collsions dispatch from the others... --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 104 +++++++++++++++------ OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 4 +- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 34 +++---- 3 files changed, 96 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2e16663..2384143 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -329,7 +329,8 @@ namespace OpenSim.Region.Framework.Scenes private byte[] m_TextureAnimation; private byte m_clickAction; private Color m_color = Color.Black; - private readonly List m_lastColliders = new List(); + private List m_lastColliders = new List(); + private bool m_lastLandCollide; private int m_linkNum; private int m_scriptAccessPin; @@ -2789,12 +2790,13 @@ namespace OpenSim.Region.Framework.Scenes { ColliderArgs colliderArgs = new ColliderArgs(); List colliding = new List(); + Scene parentScene = ParentGroup.Scene; foreach (uint localId in colliders) { if (localId == 0) continue; - SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); + SceneObjectPart obj = parentScene.GetSceneObjectPart(localId); if (obj != null) { if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) @@ -2802,7 +2804,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); + ScenePresence av = parentScene.GetScenePresence(localId); if (av != null && (!av.IsChildAgent)) { if (!dest.CollisionFilteredOut(av.UUID, av.Name)) @@ -2879,6 +2881,9 @@ namespace OpenSim.Region.Framework.Scenes return; // this a thread from physics ( heartbeat ) + bool thisHitLand = false; + bool startLand = false; + bool endedLand = false; CollisionEventUpdate a = (CollisionEventUpdate)e; Dictionary collissionswith = a.m_objCollisionList; @@ -2888,13 +2893,17 @@ namespace OpenSim.Region.Framework.Scenes if (collissionswith.Count == 0) { - if (m_lastColliders.Count == 0) + if (m_lastColliders.Count == 0 && !m_lastLandCollide) return; // nothing to do + endedLand = m_lastLandCollide; + m_lastLandCollide = false; + foreach (uint localID in m_lastColliders) { endedColliders.Add(localID); } + m_lastColliders.Clear(); } else @@ -2910,19 +2919,39 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint id in collissionswith.Keys) { - thisHitColliders.Add(id); - if (!m_lastColliders.Contains(id)) + if(id == 0) { - startedColliders.Add(id); - - curcontact = collissionswith[id]; - if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + thisHitLand = true; + if (!m_lastLandCollide) + { + startLand = true; + curcontact = collissionswith[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } + } + } + else + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) { - soundinfo = new CollisionForSoundInfo(); - soundinfo.colliderID = id; - soundinfo.position = curcontact.Position; - soundinfo.relativeVel = curcontact.RelativeSpeed; - soundinfolist.Add(soundinfo); + startedColliders.Add(id); + + curcontact = collissionswith[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } } } } @@ -2931,9 +2960,18 @@ namespace OpenSim.Region.Framework.Scenes { foreach (uint id in collissionswith.Keys) { - thisHitColliders.Add(id); - if (!m_lastColliders.Contains(id)) - startedColliders.Add(id); + if(id == 0) + { + thisHitLand = true; + if (!m_lastLandCollide) + startLand = true; + } + else + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + startedColliders.Add(id); + } } } @@ -2952,22 +2990,32 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint localID in endedColliders) m_lastColliders.Remove(localID); + if(m_lastLandCollide && !thisHitLand) + endedLand = true; + + m_lastLandCollide = thisHitLand; + // play sounds. if (soundinfolist.Count > 0) CollisionSounds.PartCollisionSound(this, soundinfolist); } + + EventManager eventmanager = ParentGroup.Scene.EventManager; - SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); + SendCollisionEvent(scriptEvents.collision_start, startedColliders, eventmanager.TriggerScriptCollidingStart); if (!VolumeDetectActive) - SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); - SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); + SendCollisionEvent(scriptEvents.collision , m_lastColliders , eventmanager.TriggerScriptColliding); + SendCollisionEvent(scriptEvents.collision_end , endedColliders , eventmanager.TriggerScriptCollidingEnd); - if (startedColliders.Contains(0)) - SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); - if (m_lastColliders.Contains(0)) - SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); - if (endedColliders.Contains(0)) - SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); + if (!VolumeDetectActive) + { + if (startLand) + SendLandCollisionEvent(scriptEvents.land_collision_start, eventmanager.TriggerScriptLandCollidingStart); + if (m_lastLandCollide) + SendLandCollisionEvent(scriptEvents.land_collision, eventmanager.TriggerScriptLandColliding); + if (endedLand) + SendLandCollisionEvent(scriptEvents.land_collision_end, eventmanager.TriggerScriptLandCollidingEnd); + } } // The Collision sounds code calls this @@ -2986,7 +3034,7 @@ namespace OpenSim.Region.Framework.Scenes volume = 0; int now = Util.EnvironmentTickCount(); - if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) + if(Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200) return; LastColSoundSentTime = now; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 005caee..44e722c 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -1240,7 +1240,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde SentEmptyCollisionsEvent = true; // _parent_scene.RemoveCollisionEventReporting(this); } - else if(Body == IntPtr.Zero || d.BodyIsEnabled(Body)) + else if(Body == IntPtr.Zero || (d.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 )) { SentEmptyCollisionsEvent = false; CollisionEventsThisFrame.Clear(); @@ -3595,7 +3595,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde _zeroFlag = true; d.BodySetAutoDisableSteps(Body, 1); d.BodyEnable(Body); - m_bodydisablecontrol = -4; + m_bodydisablecontrol = -3; } if(m_bodydisablecontrol < 0) diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 5758e0a..004ee7f 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -203,8 +203,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde private float metersInSpace = 25.6f; private float m_timeDilation = 1.0f; - private DateTime m_lastframe; - private DateTime m_lastMeshExpire; + private double m_lastframe; + private double m_lastMeshExpire; public float gravityx = 0f; public float gravityy = 0f; @@ -629,8 +629,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde staticPrimspaceOffRegion[i] = newspace; } - m_lastframe = DateTime.UtcNow; + m_lastframe = Util.GetTimeStamp(); m_lastMeshExpire = m_lastframe; + step_time = -1; } internal void waitForSpaceUnlock(IntPtr space) @@ -1625,6 +1626,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde } m_log.InfoFormat("[ubOde] {0} prim actors loaded",_prims.Count); } + m_lastframe = Util.GetTimeStamp() + 0.5; + step_time = -0.5f; } /// @@ -1638,13 +1641,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// public override float Simulate(float reqTimeStep) { - DateTime now = DateTime.UtcNow; - TimeSpan timedif = now - m_lastframe; - float timeStep = (float)timedif.TotalSeconds; + double now = Util.GetTimeStamp(); + double timeStep = now - m_lastframe; m_lastframe = now; // acumulate time so we can reduce error - step_time += timeStep; + step_time += (float)timeStep; if (step_time < HalfOdeStep) return 0; @@ -1853,14 +1855,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } - timedif = now - m_lastMeshExpire; - - if (timedif.Seconds > 10) - { - mesher.ExpireReleaseMeshs(); - m_lastMeshExpire = now; - } - // information block for in debug breakpoint only /* int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace); @@ -1940,7 +1934,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // if we lag too much skip frames m_timeDilation = 0.0f; step_time = 0; - m_lastframe = DateTime.UtcNow; // skip also the time lost + m_lastframe = Util.GetTimeStamp(); // skip also the time lost } else { @@ -1948,6 +1942,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_timeDilation > 1) m_timeDilation = 1; } + + if (m_timeDilation == 1 && now - m_lastMeshExpire > 30) + { + mesher.ExpireReleaseMeshs(); + m_lastMeshExpire = now; + } + + } return fps; -- cgit v1.1 From 4b7f79e2967e8e7ac7c70118b70a9b66cd16a2b1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 15 Jul 2017 04:06:34 +0100 Subject: fixes and changes on TreePopulatorModule. Please read OpenSimDefaults.ini [Trees] section. Does need more work, and some hardcode settings may not be the optimal still" --- .../World/TreePopulator/TreePopulatorModule.cs | 685 +++++++++++++-------- 1 file changed, 412 insertions(+), 273 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index da8c9a3..bdd875a 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs @@ -27,8 +27,13 @@ using System; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Timers; +using System.Threading; +using System.Xml; +using System.Xml.Serialization; + using OpenMetaverse; using log4net; using Mono.Addins; @@ -38,9 +43,7 @@ using OpenSim.Region.CoreModules.Framework.InterfaceCommander; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using System.Xml; -using System.Xml.Serialization; -using System.IO; +using Timer= System.Timers.Timer; namespace OpenSim.Region.OptionalModules.World.TreePopulator { @@ -48,7 +51,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator /// Version 2.02 - Still hacky /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TreePopulatorModule")] - public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule + public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly Commander m_commander = new Commander("tree"); @@ -82,20 +85,20 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator { Copse cp = (Copse)DeserializeObject(fileName); - this.m_name = cp.m_name; - this.m_frozen = cp.m_frozen; - this.m_tree_quantity = cp.m_tree_quantity; - this.m_treeline_high = cp.m_treeline_high; - this.m_treeline_low = cp.m_treeline_low; - this.m_range = cp.m_range; - this.m_tree_type = cp.m_tree_type; - this.m_seed_point = cp.m_seed_point; - this.m_initial_scale = cp.m_initial_scale; - this.m_maximum_scale = cp.m_maximum_scale; - this.m_initial_scale = cp.m_initial_scale; - this.m_rate = cp.m_rate; - this.m_planted = planted; - this.m_trees = new List(); + m_name = cp.m_name; + m_frozen = cp.m_frozen; + m_tree_quantity = cp.m_tree_quantity; + m_treeline_high = cp.m_treeline_high; + m_treeline_low = cp.m_treeline_low; + m_range = cp.m_range; + m_tree_type = cp.m_tree_type; + m_seed_point = cp.m_seed_point; + m_initial_scale = cp.m_initial_scale; + m_maximum_scale = cp.m_maximum_scale; + m_initial_scale = cp.m_initial_scale; + m_rate = cp.m_rate; + m_planted = planted; + m_trees = new List(); } public Copse(string copsedef) @@ -103,61 +106,63 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator char[] delimiterChars = {':', ';'}; string[] field = copsedef.Split(delimiterChars); - this.m_name = field[1].Trim(); - this.m_frozen = (copsedef[0] == 'F'); - this.m_tree_quantity = int.Parse(field[2]); - this.m_treeline_high = float.Parse(field[3], Culture.NumberFormatInfo); - this.m_treeline_low = float.Parse(field[4], Culture.NumberFormatInfo); - this.m_range = double.Parse(field[5], Culture.NumberFormatInfo); - this.m_tree_type = (Tree) Enum.Parse(typeof(Tree),field[6]); - this.m_seed_point = Vector3.Parse(field[7]); - this.m_initial_scale = Vector3.Parse(field[8]); - this.m_maximum_scale = Vector3.Parse(field[9]); - this.m_rate = Vector3.Parse(field[10]); - this.m_planted = true; - this.m_trees = new List(); + m_name = field[1].Trim(); + m_frozen = (copsedef[0] == 'F'); + m_tree_quantity = int.Parse(field[2]); + m_treeline_high = float.Parse(field[3], Culture.NumberFormatInfo); + m_treeline_low = float.Parse(field[4], Culture.NumberFormatInfo); + m_range = double.Parse(field[5], Culture.NumberFormatInfo); + m_tree_type = (Tree) Enum.Parse(typeof(Tree),field[6]); + m_seed_point = Vector3.Parse(field[7]); + m_initial_scale = Vector3.Parse(field[8]); + m_maximum_scale = Vector3.Parse(field[9]); + m_rate = Vector3.Parse(field[10]); + m_planted = true; + m_trees = new List(); } public Copse(string name, int quantity, float high, float low, double range, Vector3 point, Tree type, Vector3 scale, Vector3 max_scale, Vector3 rate, List trees) { - this.m_name = name; - this.m_frozen = false; - this.m_tree_quantity = quantity; - this.m_treeline_high = high; - this.m_treeline_low = low; - this.m_range = range; - this.m_tree_type = type; - this.m_seed_point = point; - this.m_initial_scale = scale; - this.m_maximum_scale = max_scale; - this.m_rate = rate; - this.m_planted = false; - this.m_trees = trees; + m_name = name; + m_frozen = false; + m_tree_quantity = quantity; + m_treeline_high = high; + m_treeline_low = low; + m_range = range; + m_tree_type = type; + m_seed_point = point; + m_initial_scale = scale; + m_maximum_scale = max_scale; + m_rate = rate; + m_planted = false; + m_trees = trees; } public override string ToString() { - string frozen = (this.m_frozen ? "F" : "A"); + string frozen = (m_frozen ? "F" : "A"); return string.Format("{0}TPM: {1}; {2}; {3:0.0}; {4:0.0}; {5:0.0}; {6}; {7:0.0}; {8:0.0}; {9:0.0}; {10:0.00};", frozen, - this.m_name, - this.m_tree_quantity, - this.m_treeline_high, - this.m_treeline_low, - this.m_range, - this.m_tree_type, - this.m_seed_point.ToString(), - this.m_initial_scale.ToString(), - this.m_maximum_scale.ToString(), - this.m_rate.ToString()); + m_name, + m_tree_quantity, + m_treeline_high, + m_treeline_low, + m_range, + m_tree_type, + m_seed_point.ToString(), + m_initial_scale.ToString(), + m_maximum_scale.ToString(), + m_rate.ToString()); } } - private List m_copse; - + private List m_copses = new List(); + private object mylock; private double m_update_ms = 1000.0; // msec between updates private bool m_active_trees = false; + private bool m_enabled = true; // original default + private bool m_allowGrow = true; // original default Timer CalculateTrees; @@ -174,51 +179,51 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator public void Initialise(IConfigSource config) { - - // ini file settings - try - { - m_active_trees = config.Configs["Trees"].GetBoolean("active_trees", m_active_trees); - } - catch (Exception) + IConfig moduleConfig = config.Configs["Trees"]; + if (moduleConfig != null) { - m_log.Debug("[TREES]: ini failure for active_trees - using default"); + m_enabled = moduleConfig.GetBoolean("enabled", m_enabled); + m_active_trees = moduleConfig.GetBoolean("active_trees", m_active_trees); + m_allowGrow = moduleConfig.GetBoolean("allowGrow", m_allowGrow); + m_update_ms = moduleConfig.GetDouble("update_rate", m_update_ms); } - try - { - m_update_ms = config.Configs["Trees"].GetDouble("update_rate", m_update_ms); - } - catch (Exception) - { - m_log.Debug("[TREES]: ini failure for update_rate - using default"); - } + if(!m_enabled) + return; + + m_copses = new List(); + mylock = new object(); InstallCommands(); - m_log.Debug("[TREES]: Initialised tree module"); + m_log.Debug("[TREES]: Initialised tree populator module"); } public void AddRegion(Scene scene) { + if(!m_enabled) + return; m_scene = scene; m_scene.RegisterModuleCommander(m_commander); m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; - + m_scene.EventManager.OnPrimsLoaded += EventManager_OnPrimsLoaded; } public void RemoveRegion(Scene scene) { - } + if(!m_enabled) + return; + if(m_active_trees && CalculateTrees != null) + { + CalculateTrees.Dispose(); + CalculateTrees = null; + } + m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; + m_scene.EventManager.OnPrimsLoaded -= EventManager_OnPrimsLoaded; + } public void RegionLoaded(Scene scene) { - ReloadCopse(); - if (m_copse.Count > 0) - m_log.Info("[TREES]: Copse load complete"); - - if (m_active_trees) - activeizeTreeze(true); } public void Close() @@ -240,6 +245,16 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator //-------------------------------------------------------------- + private void EventManager_OnPrimsLoaded(Scene s) + { + ReloadCopse(); + if (m_copses.Count > 0) + m_log.Info("[TREES]: Copses loaded" ); + + if (m_active_trees) + activeizeTreeze(true); + } + #region ICommandableModule Members private void HandleTreeActive(Object[] args) @@ -267,22 +282,51 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator string copsename = ((string)args[0]).Trim(); Boolean freezeState = (Boolean) args[1]; - foreach (Copse cp in m_copse) + foreach (Copse cp in m_copses) { - if (cp.m_name == copsename && (!cp.m_frozen && freezeState || cp.m_frozen && !freezeState)) + if (cp.m_name == copsename) + continue; + + if(!cp.m_frozen && freezeState || cp.m_frozen && !freezeState) { cp.m_frozen = freezeState; + List losttrees = new List(); foreach (UUID tree in cp.m_trees) { - SceneObjectPart sop = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; - sop.Name = (freezeState ? sop.Name.Replace("ATPM", "FTPM") : sop.Name.Replace("FTPM", "ATPM")); - sop.ParentGroup.HasGroupChanged = true; + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); + if(sog != null && !sog.IsDeleted) + { + SceneObjectPart sop = sog.RootPart; + string name = sop.Name; + if(freezeState) + { + if(name.StartsWith("FTPM")) + continue; + if(!name.StartsWith("ATPM")) + continue; + sop.Name = sop.Name.Replace("ATPM", "FTPM"); + } + else + { + if(name.StartsWith("ATPM")) + continue; + if(!name.StartsWith("FTPM")) + continue; + sop.Name = sop.Name.Replace("FTPM", "ATPM"); + } + sop.ParentGroup.HasGroupChanged = true; + sog.ScheduleGroupForFullUpdate(); + } + else + losttrees.Add(tree); } + foreach (UUID tree in losttrees) + cp.m_trees.Remove(tree); m_log.InfoFormat("[TREES]: Activity for copse {0} is frozen {1}", copsename, freezeState); return; } - else if (cp.m_name == copsename && (cp.m_frozen && freezeState || !cp.m_frozen && !freezeState)) + else { m_log.InfoFormat("[TREES]: Copse {0} is already in the requested freeze state", copsename); return; @@ -297,17 +341,21 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator m_log.InfoFormat("[TREES]: Loading copse definition...."); - copse = new Copse(((string)args[0]), false); - foreach (Copse cp in m_copse) + lock(mylock) { - if (cp.m_name == copse.m_name) + copse = new Copse(((string)args[0]), false); { - m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name); - return; + foreach (Copse cp in m_copses) + { + if (cp.m_name == copse.m_name) + { + m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name); + return; + } + } } + m_copses.Add(copse); } - - m_copse.Add(copse); m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString()); } @@ -318,20 +366,23 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator m_log.InfoFormat("[TREES]: New tree planting for copse {0}", copsename); UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; - foreach (Copse copse in m_copse) + lock(mylock) { - if (copse.m_name == copsename) + foreach (Copse copse in m_copses) { - if (!copse.m_planted) - { - // The first tree for a copse is created here - CreateTree(uuid, copse, copse.m_seed_point); - copse.m_planted = true; - return; - } - else + if (copse.m_name == copsename) { - m_log.InfoFormat("[TREES]: Copse {0} has already been planted", copsename); + if (!copse.m_planted) + { + // The first tree for a copse is created here + CreateTree(uuid, copse, copse.m_seed_point, true); + copse.m_planted = true; + return; + } + else + { + m_log.InfoFormat("[TREES]: Copse {0} has already been planted", copsename); + } } } } @@ -376,43 +427,46 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator string copsename = ((string)args[0]).Trim(); Copse copseIdentity = null; - foreach (Copse cp in m_copse) + lock(mylock) { - if (cp.m_name == copsename) + foreach (Copse cp in m_copses) { - copseIdentity = cp; + if (cp.m_name == copsename) + { + copseIdentity = cp; + } } - } - if (copseIdentity != null) - { - foreach (UUID tree in copseIdentity.m_trees) + if (copseIdentity != null) { - if (m_scene.Entities.ContainsKey(tree)) - { - SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; - // Delete tree and alert clients (not silent) - m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); - } - else + foreach (UUID tree in copseIdentity.m_trees) { - m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); + if (m_scene.Entities.ContainsKey(tree)) + { + SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; + // Delete tree and alert clients (not silent) + m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); + } + else + { + m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); + } } + copseIdentity.m_trees = null; + m_copses.Remove(copseIdentity); + m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename); + } + else + { + m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename); } - copseIdentity.m_trees = new List(); - m_copse.Remove(copseIdentity); - m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename); - } - else - { - m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename); } } private void HandleTreeStatistics(Object[] args) { m_log.InfoFormat("[TREES]: Activity State: {0}; Update Rate: {1}", m_active_trees, m_update_ms); - foreach (Copse cp in m_copse) + foreach (Copse cp in m_copses) { m_log.InfoFormat("[TREES]: Copse {0}; {1} trees; frozen {2}", cp.m_name, cp.m_trees.Count, cp.m_frozen); } @@ -442,7 +496,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator treeRateCommand.AddArgument("updateRate", "The required update rate (minimum 1000.0)", "Double"); Command treeReloadCommand = - new Command("reload", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeReload, "Reload copse definitions from the in-scene trees"); + new Command("reload", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeReload, "Reload copses from the in-scene trees"); Command treeRemoveCommand = new Command("remove", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeRemove, "Remove a copse definition and all its in-scene trees"); @@ -499,34 +553,17 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator treeShape.Scale = scale; treeShape.State = (byte)treeType; - return m_scene.AddNewPrim(uuid, groupID, position, rotation, treeShape); - } - - #endregion - - #region IEntityCreator Members - - protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.NewTree, PCode.Tree }; - public PCode[] CreationCapabilities { get { return creationCapabilities; } } - - public SceneObjectGroup CreateEntity( - UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) - { - if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0) - { - m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name); - return null; - } - - SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); - SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID); + SceneObjectGroup sog = new SceneObjectGroup(uuid, position, rotation, treeShape); + SceneObjectPart rootPart = sog.RootPart; rootPart.AddFlag(PrimFlags.Phantom); - sceneObject.SetGroup(groupID, null); - m_scene.AddNewSceneObject(sceneObject, true); - sceneObject.InvalidateEffectivePerms(); - return sceneObject; + sog.SetGroup(groupID, null); + m_scene.AddNewSceneObject(sog, true, false); + sog.IsSelected = false; + rootPart.IsSelected = false; + sog.InvalidateEffectivePerms(); + return sog; } #endregion @@ -569,26 +606,27 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator private void ReloadCopse() { - m_copse = new List(); + m_copses = new List(); - EntityBase[] objs = m_scene.GetEntities(); - foreach (EntityBase obj in objs) + List grps = m_scene.GetSceneObjectGroups(); + foreach (SceneObjectGroup grp in grps) { - if (obj is SceneObjectGroup) - { - SceneObjectGroup grp = (SceneObjectGroup)obj; + if(grp.RootPart.Shape.PCode != (byte)PCode.NewTree && grp.RootPart.Shape.PCode != (byte)PCode.Tree) + continue; - if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:")) + if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:")) + { + // Create a new copse definition or add uuid to an existing definition + try { - // Create a new copse definition or add uuid to an existing definition - try - { - Boolean copsefound = false; - Copse copse = new Copse(grp.Name); + Boolean copsefound = false; + Copse grpcopse = new Copse(grp.Name); - foreach (Copse cp in m_copse) + lock(mylock) + { + foreach (Copse cp in m_copses) { - if (cp.m_name == copse.m_name) + if (cp.m_name == grpcopse.m_name) { copsefound = true; cp.m_trees.Add(grp.UUID); @@ -598,15 +636,15 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator if (!copsefound) { - m_log.InfoFormat("[TREES]: Found copse {0}", grp.Name); - m_copse.Add(copse); - copse.m_trees.Add(grp.UUID); + m_log.InfoFormat("[TREES]: adding copse {0}", grpcopse.m_name); + grpcopse.m_trees.Add(grp.UUID); + m_copses.Add(grpcopse); } } - catch - { - m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name); - } + } + catch + { + m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name); } } } @@ -617,8 +655,10 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator { if (activeYN) { - CalculateTrees = new Timer(m_update_ms); + if(CalculateTrees == null) + CalculateTrees = new Timer(m_update_ms); CalculateTrees.Elapsed += CalculateTrees_Elapsed; + CalculateTrees.AutoReset = false; CalculateTrees.Start(); } else @@ -629,154 +669,253 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator private void growTrees() { - foreach (Copse copse in m_copse) + if(!m_allowGrow) + return; + + foreach (Copse copse in m_copses) { - if (!copse.m_frozen) + if (copse.m_frozen) + continue; + + if(copse.m_trees.Count == 0) + continue; + + float maxscale = copse.m_maximum_scale.Z; + float ratescale = 1.0f; + List losttrees = new List(); + foreach (UUID tree in copse.m_trees) { - foreach (UUID tree in copse.m_trees) - { - if (m_scene.Entities.ContainsKey(tree)) - { - SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); - if (s_tree.Scale.X < copse.m_maximum_scale.X && s_tree.Scale.Y < copse.m_maximum_scale.Y && s_tree.Scale.Z < copse.m_maximum_scale.Z) - { - s_tree.Scale += copse.m_rate; - s_tree.ParentGroup.HasGroupChanged = true; - s_tree.ScheduleFullUpdate(); - } - } - else + if (sog != null && !sog.IsDeleted) + { + SceneObjectPart s_tree = sog.RootPart; + if (s_tree.Scale.Z < maxscale) { - m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); + ratescale = (float)Util.RandomClass.NextDouble(); + if(ratescale < 0.2f) + ratescale = 0.2f; + s_tree.Scale += copse.m_rate * ratescale; + sog.HasGroupChanged = true; + s_tree.ScheduleFullUpdate(); } } + else + losttrees.Add(tree); } + + foreach (UUID tree in losttrees) + copse.m_trees.Remove(tree); } } private void seedTrees() { - foreach (Copse copse in m_copse) + foreach (Copse copse in m_copses) { - if (!copse.m_frozen) + if (copse.m_frozen) + continue; + + if(copse.m_trees.Count == 0) + return; + + bool low = copse.m_trees.Count < (int)(copse.m_tree_quantity * 0.8f); + + if (!low && Util.RandomClass.NextDouble() < 0.75) + return; + + int maxbirths = (int)(copse.m_tree_quantity) - copse.m_trees.Count; + if(maxbirths <= 1) + return; + + if(maxbirths > 20) + maxbirths = 20; + + float minscale = 0; + if(!low && m_allowGrow) + minscale = copse.m_maximum_scale.Z * 0.75f;; + + int i = 0; + UUID[] current = copse.m_trees.ToArray(); + while(--maxbirths > 0) { - foreach (UUID tree in copse.m_trees) + if(current.Length > 1) + i = Util.RandomClass.Next(current.Length -1); + + UUID tree = current[i]; + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); + + if (sog != null && !sog.IsDeleted) { - if (m_scene.Entities.ContainsKey(tree)) - { - SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; + SceneObjectPart s_tree = sog.RootPart; - if (copse.m_trees.Count < copse.m_tree_quantity) - { - // Tree has grown enough to seed if it has grown by at least 25% of seeded to full grown height - if (s_tree.Scale.Z > copse.m_initial_scale.Z + (copse.m_maximum_scale.Z - copse.m_initial_scale.Z) / 4.0) - { - if (Util.RandomClass.NextDouble() > 0.75) - { - SpawnChild(copse, s_tree); - } - } - } - } - else - { - m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); - } + // Tree has grown enough to seed if it has grown by at least 25% of seeded to full grown height + if (s_tree.Scale.Z > minscale) + SpawnChild(copse, s_tree, true); } - } + else if(copse.m_trees.Contains(tree)) + copse.m_trees.Remove(tree); + } } } private void killTrees() { - foreach (Copse copse in m_copse) + foreach (Copse copse in m_copses) { - if (!copse.m_frozen && copse.m_trees.Count >= copse.m_tree_quantity) - { - foreach (UUID tree in copse.m_trees) - { - double killLikelyhood = 0.0; + if (copse.m_frozen) + continue; - if (m_scene.Entities.ContainsKey(tree)) - { - SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; - double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + - Math.Pow(selectedTree.Scale.Y, 2) + - Math.Pow(selectedTree.Scale.Z, 2)); - - foreach (UUID picktree in copse.m_trees) - { - if (picktree != tree) - { - SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart; - - double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + - Math.Pow(pickedTree.Scale.Y, 2) + - Math.Pow(pickedTree.Scale.Z, 2)); + if (Util.RandomClass.NextDouble() < 0.25) + return; - double pickedTreeDistance = Vector3.Distance(pickedTree.AbsolutePosition, selectedTree.AbsolutePosition); + int maxbdeaths = copse.m_trees.Count - (int)(copse.m_tree_quantity * .98f) ; + if(maxbdeaths < 1) + return; - killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1; - } - } + float odds; + float scale = 1.0f / copse.m_maximum_scale.Z; - if (Util.RandomClass.NextDouble() < killLikelyhood) - { - // Delete tree and alert clients (not silent) - m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); - copse.m_trees.Remove(selectedTree.ParentGroup.UUID); - break; - } + int ntries = maxbdeaths * 4; + while(ntries-- > 0 ) + { + int next = 0; + if (copse.m_trees.Count > 1) + next = Util.RandomClass.Next(copse.m_trees.Count - 1); + UUID tree = copse.m_trees[next]; + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); + if (sog != null && !sog.IsDeleted) + { + if(m_allowGrow) + { + odds = sog.RootPart.Scale.Z * scale; + odds = odds * odds * odds; + odds *= (float)Util.RandomClass.NextDouble(); } else { - m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); + odds = (float)Util.RandomClass.NextDouble(); + odds = odds * odds * odds; } + + if(odds > 0.9f) + { + m_scene.DeleteSceneObject(sog, false); + if(maxbdeaths <= 0) + break; + } + } + else + { + copse.m_trees.Remove(tree); + if(copse.m_trees.Count - (int)(copse.m_tree_quantity * .98f) <= 0 ) + break; } } } } - private void SpawnChild(Copse copse, SceneObjectPart s_tree) + private void SpawnChild(Copse copse, SceneObjectPart s_tree, bool low) { Vector3 position = new Vector3(); - - double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); - double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); - + + float randX = copse.m_maximum_scale.X * 1.25f; + float randY = copse.m_maximum_scale.Y * 1.25f; + + float r = (float)Util.RandomClass.NextDouble(); + randX *= 2.0f * r - 1.0f; position.X = s_tree.AbsolutePosition.X + (float)randX; + + r = (float)Util.RandomClass.NextDouble(); + randY *= 2.0f * r - 1.0f; position.Y = s_tree.AbsolutePosition.Y + (float)randY; - 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; + if (position.X > (m_scene.RegionInfo.RegionSizeX - 1) || position.X <= 0 || + position.Y > (m_scene.RegionInfo.RegionSizeY - 1) || position.Y <= 0) + return; - CreateTree(uuid, copse, position); - } + randX = position.X - copse.m_seed_point.X; + randX *= randX; + randY = position.Y - copse.m_seed_point.Y; + randY *= randY; + randX += randY; + + if(randX > copse.m_range * copse.m_range) + return; + + UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; + CreateTree(uuid, copse, position, low); } - private void CreateTree(UUID uuid, Copse copse, Vector3 position) + private void CreateTree(UUID uuid, Copse copse, Vector3 position, bool randomScale) { - position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y]; - if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high) - { - SceneObjectGroup tree = AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false); + if (position.Z < copse.m_treeline_low || position.Z > copse.m_treeline_high) + return; - tree.Name = copse.ToString(); - copse.m_trees.Add(tree.UUID); - tree.SendGroupFullUpdate(); + Vector3 scale = copse.m_initial_scale; + if(randomScale) + { + try + { + float t; + float r = (float)Util.RandomClass.NextDouble(); + r *= (float)Util.RandomClass.NextDouble(); + r *= (float)Util.RandomClass.NextDouble(); + + t = copse.m_maximum_scale.X / copse.m_initial_scale.X; + if(t < 1.0) + t = 1 / t; + t = t * r + 1.0f; + scale.X *= t; + + t = copse.m_maximum_scale.Y / copse.m_initial_scale.Y; + if(t < 1.0) + t = 1 / t; + t = t * r + 1.0f; + scale.Y *= t; + + t = copse.m_maximum_scale.Z / copse.m_initial_scale.Z; + if(t < 1.0) + t = 1 / t; + t = t * r + 1.0f; + scale.Z *= t; + } + catch + { + scale = copse.m_initial_scale; + } } + + SceneObjectGroup tree = AddTree(uuid, UUID.Zero, scale, Quaternion.Identity, position, copse.m_tree_type, false); + tree.Name = copse.ToString(); + copse.m_trees.Add(tree.UUID); + tree.RootPart.ScheduleFullUpdate(); } private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) { - growTrees(); - seedTrees(); - killTrees(); + if(!m_scene.IsRunning) + return; + + if(Monitor.TryEnter(mylock)) + { + try + { + if(m_scene.LoginsEnabled ) + { + growTrees(); + seedTrees(); + killTrees(); + } + } + catch(Exception ex) + { + } + if(CalculateTrees != null) + CalculateTrees.Start(); + Monitor.Exit(mylock); + } } } } -- cgit v1.1 From ad46a29d9e2d409dcdafe311f4a9151bcb33d7b9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 15 Jul 2017 20:59:16 +0100 Subject: Ooopsss --- .../World/TreePopulator/TreePopulatorModule.cs | 91 +++++++++++----------- 1 file changed, 47 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index bdd875a..6e1f8bb 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs @@ -282,54 +282,57 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator string copsename = ((string)args[0]).Trim(); Boolean freezeState = (Boolean) args[1]; - foreach (Copse cp in m_copses) + lock(mylock) { - if (cp.m_name == copsename) - continue; - - if(!cp.m_frozen && freezeState || cp.m_frozen && !freezeState) + foreach (Copse cp in m_copses) { - cp.m_frozen = freezeState; - List losttrees = new List(); - foreach (UUID tree in cp.m_trees) + if (cp.m_name != copsename) + continue; + + if(!cp.m_frozen && freezeState || cp.m_frozen && !freezeState) { - SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); - if(sog != null && !sog.IsDeleted) + cp.m_frozen = freezeState; + List losttrees = new List(); + foreach (UUID tree in cp.m_trees) { - SceneObjectPart sop = sog.RootPart; - string name = sop.Name; - if(freezeState) + SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree); + if(sog != null && !sog.IsDeleted) { - if(name.StartsWith("FTPM")) - continue; - if(!name.StartsWith("ATPM")) - continue; - sop.Name = sop.Name.Replace("ATPM", "FTPM"); + SceneObjectPart sop = sog.RootPart; + string name = sop.Name; + if(freezeState) + { + if(name.StartsWith("FTPM")) + continue; + if(!name.StartsWith("ATPM")) + continue; + sop.Name = sop.Name.Replace("ATPM", "FTPM"); + } + else + { + if(name.StartsWith("ATPM")) + continue; + if(!name.StartsWith("FTPM")) + continue; + sop.Name = sop.Name.Replace("FTPM", "ATPM"); + } + sop.ParentGroup.HasGroupChanged = true; + sog.ScheduleGroupForFullUpdate(); } else - { - if(name.StartsWith("ATPM")) - continue; - if(!name.StartsWith("FTPM")) - continue; - sop.Name = sop.Name.Replace("FTPM", "ATPM"); - } - sop.ParentGroup.HasGroupChanged = true; - sog.ScheduleGroupForFullUpdate(); + losttrees.Add(tree); } - else - losttrees.Add(tree); - } - foreach (UUID tree in losttrees) - cp.m_trees.Remove(tree); + foreach (UUID tree in losttrees) + cp.m_trees.Remove(tree); - m_log.InfoFormat("[TREES]: Activity for copse {0} is frozen {1}", copsename, freezeState); - return; - } - else - { - m_log.InfoFormat("[TREES]: Copse {0} is already in the requested freeze state", copsename); - return; + m_log.InfoFormat("[TREES]: Activity for copse {0} is frozen {1}", copsename, freezeState); + return; + } + else + { + m_log.InfoFormat("[TREES]: Copse {0} is already in the requested freeze state", copsename); + return; + } } } m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename); @@ -382,6 +385,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator else { m_log.InfoFormat("[TREES]: Copse {0} has already been planted", copsename); + return; } } } @@ -465,10 +469,11 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator private void HandleTreeStatistics(Object[] args) { - m_log.InfoFormat("[TREES]: Activity State: {0}; Update Rate: {1}", m_active_trees, m_update_ms); + m_log.InfoFormat("[TREES]: region {0}:", m_scene.Name); + m_log.InfoFormat("[TREES]: Activity State: {0}; Update Rate: {1}", m_active_trees, m_update_ms); foreach (Copse cp in m_copses) { - m_log.InfoFormat("[TREES]: Copse {0}; {1} trees; frozen {2}", cp.m_name, cp.m_trees.Count, cp.m_frozen); + m_log.InfoFormat("[TREES]: Copse {0}; {1} trees; frozen {2}", cp.m_name, cp.m_trees.Count, cp.m_frozen); } } @@ -909,9 +914,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator killTrees(); } } - catch(Exception ex) - { - } + catch { } if(CalculateTrees != null) CalculateTrees.Start(); Monitor.Exit(mylock); -- cgit v1.1 From 101413ddd9e8a2a0d82f4e789ccd8f3bb1832666 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 00:48:04 +0100 Subject: make KFM use scheduled terse updates. This may increase some rubber band, but is needed, and should work better with recent changes on sop terseupdates control --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index d81d8a2..60f5791 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -483,8 +483,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -496,8 +496,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; m_skippedUpdates = 1000; - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } public void Suspend() @@ -644,8 +644,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); - +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -673,7 +673,8 @@ namespace OpenSim.Region.Framework.Scenes { m_group.RootPart.Velocity = Vector3.Zero; m_skippedUpdates = 1000; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } return; } @@ -797,7 +798,8 @@ namespace OpenSim.Region.Framework.Scenes m_lastPosUpdate = m_nextPosition; m_lastRotationUpdate = m_group.GroupRotation; m_skippedUpdates = 0; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } } @@ -842,8 +844,8 @@ namespace OpenSim.Region.Framework.Scenes { m_group.RootPart.Velocity = Vector3.Zero; m_skippedUpdates = 1000; - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } } @@ -855,8 +857,8 @@ namespace OpenSim.Region.Framework.Scenes { m_group.RootPart.Velocity = Vector3.Zero; m_skippedUpdates = 1000; - m_group.SendGroupRootTerseUpdate(); -// m_group.RootPart.ScheduleTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); if (m_running) { -- cgit v1.1 From 4ef64d4425479667c5f7a0b8239efe0215045235 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 01:10:27 +0100 Subject: trigger moving_end also KFM stop and pause --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 60f5791..110805c 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -486,6 +486,7 @@ namespace OpenSim.Region.Framework.Scenes // m_group.SendGroupRootTerseUpdate(); m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); + m_group.Scene.EventManager.TriggerMovingEndEvent(m_group.RootPart.LocalId); } public void Pause() @@ -498,6 +499,7 @@ namespace OpenSim.Region.Framework.Scenes m_skippedUpdates = 1000; // m_group.SendGroupRootTerseUpdate(); m_group.RootPart.ScheduleTerseUpdate(); + m_group.Scene.EventManager.TriggerMovingEndEvent(m_group.RootPart.LocalId); } public void Suspend() -- cgit v1.1 From cd15de628df3af968e3445a7cf22e741a23dc41f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 01:31:37 +0100 Subject: don't start moving KFM things on region start that where stopped on last shutdown --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 110805c..712ae01 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -326,8 +326,8 @@ namespace OpenSim.Region.Framework.Scenes newMotion.m_selected = true; } - newMotion.m_timerStopped = false; - newMotion.m_running = true; +// newMotion.m_timerStopped = false; +// newMotion.m_running = true; newMotion.m_isCrossing = false; newMotion.m_waitingCrossing = false; } -- cgit v1.1 From 04b97be71e6e33214491ee9f6fcf94d3978f45f7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 02:55:39 +0100 Subject: ode does not like null refs --- OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 44e722c..76ef88b 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -1043,7 +1043,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde d.BodySetLinearVel(Body, 0, 0, 0); // stop it d.BodySetAngularVel(Body, 0, 0, 0); } - d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + if(prim_geom != IntPtr.Zero) + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); disableBodySoft(); // stop collisions UnSubscribeEvents(); } -- cgit v1.1 From 9ae26fc5afc96c793186b79e80ac8f1a8a040d5b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 05:19:27 +0100 Subject: store kfm on inventory. this may still be a bit confusing on rez --- .../InventoryAccess/InventoryAccessModule.cs | 13 +++++++----- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 11 ++++++----- OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 3 +++ .../Scenes/Serialization/SceneObjectSerializer.cs | 23 ++++++++++++++++++++++ 5 files changed, 42 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 3f3245c..f1409bb 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess Dictionary originalPositions = new Dictionary(); Dictionary originalRotations = new Dictionary(); // this possible is not needed if keyframes are saved - Dictionary originalKeyframes = new Dictionary(); +// Dictionary originalKeyframes = new Dictionary(); foreach (SceneObjectGroup objectGroup in objlist) { @@ -423,8 +423,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess objectGroup.RootPart.SetForce(Vector3.Zero); objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false); - originalKeyframes[objectGroup.UUID] = objectGroup.RootPart.KeyframeMotion; - objectGroup.RootPart.KeyframeMotion = null; +// originalKeyframes[objectGroup.UUID] = objectGroup.RootPart.KeyframeMotion; +// objectGroup.RootPart.KeyframeMotion = null; Vector3 inventoryStoredPosition = objectGroup.AbsolutePosition; originalPositions[objectGroup.UUID] = inventoryStoredPosition; @@ -476,7 +476,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; objectGroup.RootPart.RotationOffset = originalRotations[objectGroup.UUID]; - objectGroup.RootPart.KeyframeMotion = originalKeyframes[objectGroup.UUID]; +// objectGroup.RootPart.KeyframeMotion = originalKeyframes[objectGroup.UUID]; if (objectGroup.RootPart.KeyframeMotion != null) objectGroup.RootPart.KeyframeMotion.Resume(); } @@ -989,11 +989,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // one full update during the attachment // process causes some clients to fail to display the // attachment properly. - m_Scene.AddNewSceneObject(group, true, false); if (!attachment) { group.AbsolutePosition = pos + veclist[i]; + m_Scene.AddNewSceneObject(group, true, false); // Fire on_rez group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); @@ -1001,6 +1001,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess group.ScheduleGroupForFullUpdate(); } + else + m_Scene.AddNewSceneObject(group, true, false); + // m_log.DebugFormat( // "[INVENTORY ACCESS MODULE]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 712ae01..c64a0f8 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -755,7 +755,8 @@ namespace OpenSim.Region.Framework.Scenes } else { - bool lastSteps = remainingSteps < 4; +// bool lastSteps = remainingSteps < 4; + Vector3 currentPosition = m_group.AbsolutePosition; Vector3 motionThisFrame = (Vector3)m_currentFrame.Position - currentPosition; motionThisFrame /= (float)remainingSteps; @@ -776,13 +777,13 @@ namespace OpenSim.Region.Framework.Scenes } m_group.AbsolutePosition = m_nextPosition; - if(lastSteps) - m_group.RootPart.Velocity = Vector3.Zero; - else +// if(lastSteps) +// m_group.RootPart.Velocity = Vector3.Zero; +// else m_group.RootPart.Velocity = m_currentVel; if(!update && ( - lastSteps || +// lastSteps || m_skippedUpdates * tickDuration > 0.5 || Math.Abs(m_nextPosition.X - currentPosition.X) > 5f || Math.Abs(m_nextPosition.Y - currentPosition.Y) > 5f || diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5e8487d..c06b3dd 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1651,10 +1651,11 @@ namespace OpenSim.Region.Framework.Scenes physicsMS2 = (float)(tmpMS2 - tmpMS); tmpMS = tmpMS2; +/* // Apply any pending avatar force input to the avatar's velocity if (Frame % m_update_entitymovement == 0) m_sceneGraph.UpdateScenePresenceMovement(); - +*/ if (Frame % (m_update_coarse_locations) == 0 && !m_sendingCoarseLocations) { m_sendingCoarseLocations = true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6f46a92..19449b1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -657,6 +657,9 @@ namespace OpenSim.Region.Framework.Scenes } } + if(!m_scene.IsRunning) + return sog; + if (root.KeyframeMotion != null) root.KeyframeMotion.StartCrossingCheck(); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3d867a4..cdf275b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -112,9 +112,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization while (reader.ReadToNextSibling("Part")); } + reader.ReadEndElement(); + + if (reader.Name == "KeyframeMotion" && reader.NodeType == XmlNodeType.Element) + { + + string innerkeytxt = reader.ReadElementContentAsString(); + sceneObject.RootPart.KeyframeMotion = + KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(innerkeytxt)); + } + else + sceneObject.RootPart.KeyframeMotion = null; + // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(reader); + sceneObject.InvalidateDeepEffectivePerms(); return sceneObject; } @@ -211,9 +224,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteEndElement(); // OtherParts + if (sceneObject.RootPart.KeyframeMotion != null) + { + Byte[] data = sceneObject.RootPart.KeyframeMotion.Serialize(); + + writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); + writer.WriteBase64(data, 0, data.Length); + writer.WriteEndElement(); + } + if (doScriptStates) sceneObject.SaveScriptedState(writer); + if (!noRootElement) writer.WriteEndElement(); // SceneObjectGroup -- cgit v1.1 From 2f9222bec315a6077e5c5156b5b1496a43e73320 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 05:52:01 +0100 Subject: test scenes do not set IsRunning --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 19449b1..6f46a92 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -657,9 +657,6 @@ namespace OpenSim.Region.Framework.Scenes } } - if(!m_scene.IsRunning) - return sog; - if (root.KeyframeMotion != null) root.KeyframeMotion.StartCrossingCheck(); -- cgit v1.1 From 59de8fbba037fbab6e7b49170229d90d77fbb1bf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 16 Jul 2017 06:10:24 +0100 Subject: fix placement of xml ReadEndElement() --- OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index cdf275b..82bbe6f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -110,9 +110,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } while (reader.ReadToNextSibling("Part")); - } - reader.ReadEndElement(); + } if (reader.Name == "KeyframeMotion" && reader.NodeType == XmlNodeType.Element) { -- cgit v1.1 From f921ad005f85fd05fa0a88df0268336f60e22d8d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Jul 2017 00:58:35 +0100 Subject: KFM: changes on update method implies other changes. Still not that good. Note: objects motion timing can't be done using timers. On windows at least, those can have jitter of tens of ms --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 38 +++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index c64a0f8..80ee510 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -295,6 +295,7 @@ namespace OpenSim.Region.Framework.Scenes lock (m_frames) { KeyframeTimer.Add(this); + m_lasttickMS = Util.GetTimeStampMS(); m_timerStopped = false; } } @@ -651,10 +652,11 @@ namespace OpenSim.Region.Framework.Scenes m_frames.Clear(); } - Vector3 m_lastPosUpdate; - Quaternion m_lastRotationUpdate; - Vector3 m_currentVel; - int m_skippedUpdates; + [NonSerialized()] Vector3 m_lastPosUpdate; + [NonSerialized()] Quaternion m_lastRotationUpdate; + [NonSerialized()] Vector3 m_currentVel; + [NonSerialized()] int m_skippedUpdates; + [NonSerialized()] double m_lasttickMS; private void DoOnTimer(double tickDuration) { @@ -699,6 +701,8 @@ namespace OpenSim.Region.Framework.Scenes return; } + double nowMS = Util.GetTimeStampMS(); + if (m_frames.Count == 0) { lock (m_frames) @@ -719,10 +723,16 @@ namespace OpenSim.Region.Framework.Scenes m_currentVel /= (m_currentFrame.TimeMS * 0.001f); m_currentFrame.TimeMS += (int)tickDuration; + m_lasttickMS = nowMS - 50f; update = true; } - m_currentFrame.TimeMS -= (int)tickDuration; + int elapsed = (int)(nowMS - m_lasttickMS); + if( elapsed > 3 * tickDuration) + elapsed = (int)tickDuration; + + m_currentFrame.TimeMS -= elapsed; + m_lasttickMS = nowMS; // Do the frame processing double remainingSteps = (double)m_currentFrame.TimeMS / tickDuration; @@ -770,10 +780,12 @@ namespace OpenSim.Region.Framework.Scenes Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); step.Normalize(); m_group.RootPart.RotationOffset = step; +/* if (Math.Abs(step.X - m_lastRotationUpdate.X) > 0.001f || Math.Abs(step.Y - m_lastRotationUpdate.Y) > 0.001f || Math.Abs(step.Z - m_lastRotationUpdate.Z) > 0.001f) update = true; +*/ } m_group.AbsolutePosition = m_nextPosition; @@ -781,7 +793,7 @@ namespace OpenSim.Region.Framework.Scenes // m_group.RootPart.Velocity = Vector3.Zero; // else m_group.RootPart.Velocity = m_currentVel; - +/* if(!update && ( // lastSteps || m_skippedUpdates * tickDuration > 0.5 || @@ -794,16 +806,16 @@ namespace OpenSim.Region.Framework.Scenes } else m_skippedUpdates++; - +*/ } - if(update) - { - m_lastPosUpdate = m_nextPosition; - m_lastRotationUpdate = m_group.GroupRotation; - m_skippedUpdates = 0; +// if(update) +// { +// m_lastPosUpdate = m_nextPosition; +// m_lastRotationUpdate = m_group.GroupRotation; +// m_skippedUpdates = 0; // m_group.SendGroupRootTerseUpdate(); m_group.RootPart.ScheduleTerseUpdate(); - } +// } } public Byte[] Serialize() -- cgit v1.1 From 4293b2cb3cb308b7fcce29ba5fba24d2c41c6ffa Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 18 Jul 2017 14:09:30 +0100 Subject: fix object updates throttle for scripts doing motion by direct change of position. Most this scripts are bad, making no use of viewers interpolators. Tanks lotek. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2384143..f0a3fab 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -810,7 +810,7 @@ namespace OpenSim.Region.Framework.Scenes { // If this is a linkset, we don't want the physics engine mucking up our group position here. PhysicsActor actor = PhysActor; - if (ParentID == 0) + if (_parentID == 0) { if (actor != null) m_groupPosition = actor.Position; @@ -839,7 +839,7 @@ namespace OpenSim.Region.Framework.Scenes try { // Root prim actually goes at Position - if (ParentID == 0) + if (_parentID == 0) { actor.Position = value; } @@ -881,7 +881,7 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.InvalidBoundsRadius(); PhysicsActor actor = PhysActor; - if (ParentID != 0 && actor != null) + if (_parentID != 0 && actor != null) { actor.Position = GetWorldPosition(); actor.Orientation = GetWorldRotation(); @@ -941,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor actor = PhysActor; // If this is a root of a linkset, the real rotation is what the physics engine thinks. // If not a root prim, the offset rotation is computed by SOG and is relative to the root. - if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) + if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) m_rotationOffset = actor.Orientation; return m_rotationOffset; @@ -958,7 +958,7 @@ namespace OpenSim.Region.Framework.Scenes try { // Root prim gets value directly - if (ParentID == 0) + if (_parentID == 0) { actor.Orientation = value; //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); @@ -1259,6 +1259,9 @@ namespace OpenSim.Region.Framework.Scenes { get { + if (_parentID == 0) + return GroupPosition; + return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); } } @@ -2424,7 +2427,7 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds += PhysicsOutOfBounds; - if (ParentID != 0 && ParentID != LocalId) + if (_parentID != 0 && _parentID != LocalId) { PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; @@ -3075,7 +3078,7 @@ namespace OpenSim.Region.Framework.Scenes //ParentGroup.RootPart.m_groupPosition = newpos; } /* - if (pa != null && ParentID != 0 && ParentGroup != null) + if (pa != null && _parentID != 0 && ParentGroup != null) { // Special case where a child object is requesting property updates. // This happens when linksets are modified to use flexible links rather than @@ -3359,7 +3362,7 @@ namespace OpenSim.Region.Framework.Scenes return; // Update the "last" values - m_lastPosition = OffsetPosition; + m_lastPosition = AbsolutePosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; @@ -3378,7 +3381,7 @@ namespace OpenSim.Region.Framework.Scenes return; // Update the "last" values - m_lastPosition = OffsetPosition; + m_lastPosition = AbsolutePosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; @@ -3488,7 +3491,7 @@ namespace OpenSim.Region.Framework.Scenes vz < VELOCITY_TOLERANCE ) { - if(!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + if(!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) break; if (vx < 1e-4 && @@ -3534,7 +3537,7 @@ namespace OpenSim.Region.Framework.Scenes { // Update the "last" values - m_lastPosition = OffsetPosition; + m_lastPosition = AbsolutePosition; m_lastRotation = RotationOffset; m_lastVelocity = curvel; m_lastAcceleration = curacc; @@ -3567,7 +3570,7 @@ namespace OpenSim.Region.Framework.Scenes ClearUpdateSchedule(); // Update the "last" values - m_lastPosition = OffsetPosition; + m_lastPosition = AbsolutePosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; @@ -3588,7 +3591,7 @@ namespace OpenSim.Region.Framework.Scenes ClearUpdateSchedule(); // Update the "last" values - m_lastPosition = OffsetPosition; + m_lastPosition = AbsolutePosition; m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; @@ -4910,7 +4913,7 @@ namespace OpenSim.Region.Framework.Scenes pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; pa.OnOutOfBounds += PhysicsOutOfBounds; - if (ParentID != 0 && ParentID != LocalId) + if (_parentID != 0 && _parentID != LocalId) { PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; -- cgit v1.1