aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-04-16 20:40:01 +0100
committerJustin Clark-Casey (justincc)2010-04-16 20:43:23 +0100
commit48f37339636f52392f698ae6036f970183ccae91 (patch)
tree8f001fe0e4c0ae5c0b0c3501576bd3d8dc710008 /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-48f37339636f52392f698ae6036f970183ccae91.zip
opensim-SC_OLD-48f37339636f52392f698ae6036f970183ccae91.tar.gz
opensim-SC_OLD-48f37339636f52392f698ae6036f970183ccae91.tar.bz2
opensim-SC_OLD-48f37339636f52392f698ae6036f970183ccae91.tar.xz
Fix http://opensimulator.org/mantis/view.php?id=4657 where OpenSim.Grid.UserServer.exe fails on startup if no previous config
probably appears to occur because mono 2.4.2.3 (and possibly later) erroneously returns a value of 0 for BufferWidth and BufferHeight in some circumstances
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Console/LocalConsole.cs63
-rw-r--r--OpenSim/Framework/Util.cs2
2 files changed, 48 insertions, 17 deletions
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs
index be936b6..a3036d0 100644
--- a/OpenSim/Framework/Console/LocalConsole.cs
+++ b/OpenSim/Framework/Console/LocalConsole.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Framework.Console
38{ 38{
39 /// <summary> 39 /// <summary>
40 /// A console that uses cursor control and color 40 /// A console that uses cursor control and color
41 /// </summary> 41 /// </summary>
42 public class LocalConsole : CommandConsole 42 public class LocalConsole : CommandConsole
43 { 43 {
44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -100,24 +100,40 @@ namespace OpenSim.Framework.Console
100 private int SetCursorTop(int top) 100 private int SetCursorTop(int top)
101 { 101 {
102 // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try 102 // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try
103 // to set a cursor row position with a currently invalid column, mono will throw an exception. 103 // to set a cursor row position with a currently invalid column, mono will throw an exception.
104 // Therefore, we need to make sure that the column position is valid first. 104 // Therefore, we need to make sure that the column position is valid first.
105 int left = System.Console.CursorLeft; 105 int left = System.Console.CursorLeft;
106 106
107 if (left < 0) 107 if (left < 0)
108 {
108 System.Console.CursorLeft = 0; 109 System.Console.CursorLeft = 0;
109 else if (left >= System.Console.BufferWidth) 110 }
110 System.Console.CursorLeft = System.Console.BufferWidth - 1; 111 else
112 {
113 int bw = System.Console.BufferWidth;
114
115 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
116 if (bw > 0 && left >= bw)
117 System.Console.CursorLeft = bw - 1;
118 }
111 119
112 if (top < 0) 120 if (top < 0)
121 {
113 top = 0; 122 top = 0;
114 if (top >= System.Console.BufferHeight) 123 }
115 top = System.Console.BufferHeight - 1; 124 else
125 {
126 int bh = System.Console.BufferHeight;
127
128 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
129 if (bh > 0 && top >= bh)
130 top = bh - 1;
131 }
116 132
117 System.Console.CursorTop = top; 133 System.Console.CursorTop = top;
118 134
119 return top; 135 return top;
120 } 136 }
121 137
122 /// <summary> 138 /// <summary>
123 /// Set the cursor column. 139 /// Set the cursor column.
@@ -129,23 +145,38 @@ namespace OpenSim.Framework.Console
129 /// </param> 145 /// </param>
130 /// <returns> 146 /// <returns>
131 /// The new cursor column. 147 /// The new cursor column.
132 /// </returns> 148 /// </returns>
133 private int SetCursorLeft(int left) 149 private int SetCursorLeft(int left)
134 { 150 {
135 // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try 151 // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try
136 // to set a cursor column position with a currently invalid row, mono will throw an exception. 152 // to set a cursor column position with a currently invalid row, mono will throw an exception.
137 // Therefore, we need to make sure that the row position is valid first. 153 // Therefore, we need to make sure that the row position is valid first.
138 int top = System.Console.CursorTop; 154 int top = System.Console.CursorTop;
139 155
140 if (top < 0) 156 if (top < 0)
157 {
141 System.Console.CursorTop = 0; 158 System.Console.CursorTop = 0;
142 else if (top >= System.Console.BufferHeight) 159 }
143 System.Console.CursorTop = System.Console.BufferHeight - 1; 160 else
161 {
162 int bh = System.Console.BufferHeight;
163 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
164 if (bh > 0 && top >= bh)
165 System.Console.CursorTop = bh - 1;
166 }
144 167
145 if (left < 0) 168 if (left < 0)
169 {
146 left = 0; 170 left = 0;
147 if (left >= System.Console.BufferWidth) 171 }
148 left = System.Console.BufferWidth - 1; 172 else
173 {
174 int bw = System.Console.BufferWidth;
175
176 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
177 if (bw > 0 && left >= bw)
178 left = bw - 1;
179 }
149 180
150 System.Console.CursorLeft = left; 181 System.Console.CursorLeft = left;
151 182
@@ -183,7 +214,7 @@ namespace OpenSim.Framework.Console
183 System.Console.Write("{0}", prompt); 214 System.Console.Write("{0}", prompt);
184 215
185 SetCursorTop(new_y); 216 SetCursorTop(new_y);
186 SetCursorLeft(new_x); 217 SetCursorLeft(new_x);
187 } 218 }
188 } 219 }
189 220
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 64f6118..802cb37 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1486,4 +1486,4 @@ namespace OpenSim.Framework
1486 } 1486 }
1487 1487
1488 } 1488 }
1489} 1489} \ No newline at end of file