diff options
-rw-r--r-- | OpenSim/Framework/UndoStack.cs | 152 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 2 |
2 files changed, 1 insertions, 153 deletions
diff --git a/OpenSim/Framework/UndoStack.cs b/OpenSim/Framework/UndoStack.cs deleted file mode 100644 index 8f8849d..0000000 --- a/OpenSim/Framework/UndoStack.cs +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim.Framework | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Undo stack. Deletes entries beyond a certain capacity | ||
34 | /// </summary> | ||
35 | /// <typeparam name="T"></typeparam> | ||
36 | [Serializable] | ||
37 | public class UndoStack<T> | ||
38 | { | ||
39 | private int m_new = 1; | ||
40 | private int m_old = 0; | ||
41 | private T[] m_Undos; | ||
42 | |||
43 | public UndoStack(int capacity) | ||
44 | { | ||
45 | m_Undos = new T[capacity + 1]; | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Is the stack full? | ||
50 | /// </summary> | ||
51 | public bool IsFull | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | // If the old and new pointers are in the same place then all stack slots are occupied. | ||
56 | return m_new == m_old; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Capacity of the stack. | ||
62 | /// </summary> | ||
63 | public int Capacity | ||
64 | { | ||
65 | get { return m_Undos.Length - 1; } | ||
66 | } | ||
67 | |||
68 | /// <summary> | ||
69 | /// Return the number of undos on the stack. | ||
70 | /// </summary> | ||
71 | public int Count | ||
72 | { | ||
73 | get | ||
74 | { | ||
75 | int count = m_new - m_old - 1; | ||
76 | |||
77 | if (count < 0) | ||
78 | count += m_Undos.Length; | ||
79 | |||
80 | return count; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Push a new undo onto the stack. | ||
86 | /// </summary> | ||
87 | /// <param name="item"></param> | ||
88 | public void Push(T item) | ||
89 | { | ||
90 | if (IsFull) | ||
91 | { | ||
92 | m_old++; | ||
93 | |||
94 | if (m_old >= m_Undos.Length) | ||
95 | m_old -= m_Undos.Length; | ||
96 | } | ||
97 | |||
98 | if (++m_new >= m_Undos.Length) | ||
99 | m_new -= m_Undos.Length; | ||
100 | |||
101 | m_Undos[m_new] = item; | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Pop and item from the top of the undo stack. | ||
106 | /// </summary> | ||
107 | /// <returns></returns> | ||
108 | public T Pop() | ||
109 | { | ||
110 | if (Count > 0) | ||
111 | { | ||
112 | T deleted = m_Undos[m_new]; | ||
113 | m_Undos[m_new--] = default(T); | ||
114 | |||
115 | if (m_new < 0) | ||
116 | m_new += m_Undos.Length; | ||
117 | |||
118 | return deleted; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | throw new InvalidOperationException("Cannot pop from empty stack"); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// Peek at the undo on the top of the stack. | ||
128 | /// </summary> | ||
129 | /// <returns></returns> | ||
130 | public T Peek() | ||
131 | { | ||
132 | return m_Undos[m_new]; | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Clear the stack. | ||
137 | /// </summary> | ||
138 | public void Clear() | ||
139 | { | ||
140 | if (Count > 0) | ||
141 | { | ||
142 | for (int i = 0; i < m_Undos.Length; i++) | ||
143 | { | ||
144 | m_Undos[i] = default(T); | ||
145 | } | ||
146 | |||
147 | m_new = 1; | ||
148 | m_old = 0; | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 9c7b2fa..c832520 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
84 | private ITerrainChannel m_revert; | 84 | private ITerrainChannel m_revert; |
85 | private Scene m_scene; | 85 | private Scene m_scene; |
86 | private volatile bool m_tainted; | 86 | private volatile bool m_tainted; |
87 | private readonly UndoStack<LandUndoState> m_undo = new UndoStack<LandUndoState>(5); | 87 | private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); |
88 | 88 | ||
89 | #region ICommandableModule Members | 89 | #region ICommandableModule Members |
90 | 90 | ||