From 31c636f1e48db2a42950e2ec0e8c7eba2c16616c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 26 Sep 2012 23:25:50 +0100 Subject: refactor: Change control structures in SOP.StoreUndoState() to reduce nesting. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 88 +++++++++++----------- 1 file changed, 43 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 018e4fc..8710c3e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3170,64 +3170,62 @@ namespace OpenSim.Region.Framework.Scenes public void StoreUndoState(bool forGroup) { - if (!Undoing) + if (Undoing) { - if (!IgnoreUndoUpdate) +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); + return; + } + + if (IgnoreUndoUpdate) + { +// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); + return; + } + + if (ParentGroup == null) + return; + + lock (m_undo) + { + if (m_undo.Count > 0) { - if (ParentGroup != null) + UndoState last = m_undo[m_undo.Count - 1]; + if (last != null) { - lock (m_undo) + // TODO: May need to fix for group comparison + if (last.Compare(this)) { - if (m_undo.Count > 0) - { - UndoState last = m_undo[m_undo.Count - 1]; - if (last != null) - { - // TODO: May need to fix for group comparison - if (last.Compare(this)) - { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", - // Name, LocalId, m_undo.Count); - - return; - } - } - } - +// m_log.DebugFormat( +// "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", +// Name, LocalId, m_undo.Count); + + return; + } + } + } + // m_log.DebugFormat( // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", // Name, LocalId, forGroup, m_undo.Count); - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, forGroup); - - m_undo.Add(nUndo); - if (m_undo.Count > ParentGroup.GetSceneMaxUndo()) - m_undo.RemoveAt(0); - - if (m_redo.Count > 0) - m_redo.Clear(); - + if (ParentGroup.GetSceneMaxUndo() > 0) + { + UndoState nUndo = new UndoState(this, forGroup); + + m_undo.Add(nUndo); + + if (m_undo.Count > ParentGroup.GetSceneMaxUndo()) + m_undo.RemoveAt(0); + + if (m_redo.Count > 0) + m_redo.Clear(); + // m_log.DebugFormat( // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", // Name, LocalId, forGroup, m_undo.Count); - } - } - } } -// else -// { -// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); -// } } -// else -// { -// m_log.DebugFormat( -// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); -// } } /// -- cgit v1.1