aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs59
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs27
3 files changed, 65 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e9d1d42..872c061 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -151,7 +151,8 @@ namespace OpenSim.Region.Framework.Scenes
151 // TODO: need to figure out how allow client agents but deny 151 // TODO: need to figure out how allow client agents but deny
152 // root agents when ACL denies access to root agent 152 // root agents when ACL denies access to root agent
153 public bool m_strictAccessControl = true; 153 public bool m_strictAccessControl = true;
154 public int MaxUndoCount = 5; 154
155 public int MaxUndoCount { get; set; }
155 156
156 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 157 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
157 public bool LoginLock = false; 158 public bool LoginLock = false;
@@ -931,6 +932,9 @@ namespace OpenSim.Region.Framework.Scenes
931 WestBorders.Add(westBorder); 932 WestBorders.Add(westBorder);
932 BordersLocked = false; 933 BordersLocked = false;
933 934
935 // TODO: At some point this should be made configurable.
936 MaxUndoCount = 5;
937
934 m_eventManager = new EventManager(); 938 m_eventManager = new EventManager();
935 939
936 m_permissions = new ScenePermissions(this); 940 m_permissions = new ScenePermissions(this);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 63eb387..9e78242 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -266,8 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
266 private string m_sitAnimation = "SIT"; 266 private string m_sitAnimation = "SIT";
267 private string m_text = String.Empty; 267 private string m_text = String.Empty;
268 private string m_touchName = String.Empty; 268 private string m_touchName = String.Empty;
269 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 269 private readonly List<UndoState> m_undo = new List<UndoState>(5);
270 private readonly Stack<UndoState> m_redo = new Stack<UndoState>(5); 270 private readonly List<UndoState> m_redo = new List<UndoState>(5);
271 271
272 private bool m_passTouches = false; 272 private bool m_passTouches = false;
273 private bool m_passCollisions = false; 273 private bool m_passCollisions = false;
@@ -3176,7 +3176,7 @@ namespace OpenSim.Region.Framework.Scenes
3176 { 3176 {
3177 if (m_undo.Count > 0) 3177 if (m_undo.Count > 0)
3178 { 3178 {
3179 UndoState last = m_undo.Peek(); 3179 UndoState last = m_undo[m_undo.Count - 1];
3180 if (last != null) 3180 if (last != null)
3181 { 3181 {
3182 // TODO: May need to fix for group comparison 3182 // TODO: May need to fix for group comparison
@@ -3199,7 +3199,10 @@ namespace OpenSim.Region.Framework.Scenes
3199 { 3199 {
3200 UndoState nUndo = new UndoState(this, forGroup); 3200 UndoState nUndo = new UndoState(this, forGroup);
3201 3201
3202 m_undo.Push(nUndo); 3202 m_undo.Add(nUndo);
3203
3204 if (m_undo.Count > ParentGroup.GetSceneMaxUndo())
3205 m_undo.RemoveAt(0);
3203 3206
3204 if (m_redo.Count > 0) 3207 if (m_redo.Count > 0)
3205 m_redo.Clear(); 3208 m_redo.Clear();
@@ -3245,21 +3248,24 @@ namespace OpenSim.Region.Framework.Scenes
3245 3248
3246 if (m_undo.Count > 0) 3249 if (m_undo.Count > 0)
3247 { 3250 {
3248 UndoState goback = m_undo.Pop(); 3251 UndoState goback = m_undo[m_undo.Count - 1];
3252 m_undo.RemoveAt(m_undo.Count - 1);
3249 3253
3250 if (goback != null) 3254 UndoState nUndo = null;
3255
3256 if (ParentGroup.GetSceneMaxUndo() > 0)
3251 { 3257 {
3252 UndoState nUndo = null; 3258 nUndo = new UndoState(this, goback.ForGroup);
3253 3259 }
3254 if (ParentGroup.GetSceneMaxUndo() > 0) 3260
3255 { 3261 goback.PlaybackState(this);
3256 nUndo = new UndoState(this, goback.ForGroup);
3257 }
3258 3262
3259 goback.PlaybackState(this); 3263 if (nUndo != null)
3264 {
3265 m_redo.Add(nUndo);
3260 3266
3261 if (nUndo != null) 3267 if (m_redo.Count > ParentGroup.GetSceneMaxUndo())
3262 m_redo.Push(nUndo); 3268 m_redo.RemoveAt(0);
3263 } 3269 }
3264 } 3270 }
3265 3271
@@ -3279,20 +3285,21 @@ namespace OpenSim.Region.Framework.Scenes
3279 3285
3280 if (m_redo.Count > 0) 3286 if (m_redo.Count > 0)
3281 { 3287 {
3282 UndoState gofwd = m_redo.Pop(); 3288 UndoState gofwd = m_redo[m_redo.Count - 1];
3283 3289 m_redo.RemoveAt(m_redo.Count - 1);
3284 if (gofwd != null) 3290
3291 if (ParentGroup.GetSceneMaxUndo() > 0)
3285 { 3292 {
3286 if (ParentGroup.GetSceneMaxUndo() > 0) 3293 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3287 { 3294
3288 UndoState nUndo = new UndoState(this, gofwd.ForGroup); 3295 m_undo.Add(nUndo);
3289 3296
3290 m_undo.Push(nUndo); 3297 if (m_undo.Count > ParentGroup.GetSceneMaxUndo())
3291 } 3298 m_undo.RemoveAt(0);
3292
3293 gofwd.PlayfwdState(this);
3294 } 3299 }
3295 3300
3301 gofwd.PlayfwdState(this);
3302
3296// m_log.DebugFormat( 3303// m_log.DebugFormat(
3297// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", 3304// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
3298// Name, LocalId, m_redo.Count); 3305// Name, LocalId, m_redo.Count);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
index 1e317c6..c93562d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
@@ -76,6 +76,33 @@ namespace OpenSim.Region.Framework.Scenes.Tests
76 } 76 }
77 77
78 [Test] 78 [Test]
79 public void TestUndoLimit()
80 {
81 TestHelpers.InMethod();
82
83 Vector3 firstSize = new Vector3(2, 3, 4);
84 Vector3 secondSize = new Vector3(5, 6, 7);
85 Vector3 thirdSize = new Vector3(8, 9, 10);
86 Vector3 fourthSize = new Vector3(11, 12, 13);
87
88 Scene scene = new SceneHelpers().SetupScene();
89 scene.MaxUndoCount = 2;
90 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
91
92 g1.GroupResize(firstSize);
93 g1.GroupResize(secondSize);
94 g1.GroupResize(thirdSize);
95 g1.GroupResize(fourthSize);
96
97 g1.RootPart.Undo();
98 g1.RootPart.Undo();
99 g1.RootPart.Undo();
100
101 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
102 Assert.That(g1.GroupScale, Is.EqualTo(secondSize));
103 }
104
105 [Test]
79 public void TestUndoBeyondAvailable() 106 public void TestUndoBeyondAvailable()
80 { 107 {
81 TestHelpers.InMethod(); 108 TestHelpers.InMethod();