aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs55
1 files changed, 46 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index f981e89..6af4a54 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -245,9 +245,21 @@ namespace OpenSim.Region.ScriptEngine.Shared
245 245
246 public static Vector3 operator /(Vector3 v, float f) 246 public static Vector3 operator /(Vector3 v, float f)
247 { 247 {
248 v.x = v.x / f; 248 double r = v.x / f;
249 v.y = v.y / f; 249 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
250 v.z = v.z / f; 250 throw new ScriptException("Vector division by zero");
251 v.x = r;
252
253 r = v.y / f;
254 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
255 throw new ScriptException("Vector division by zero");
256 v.y = r;
257
258 r = v.z / f;
259 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
260 throw new ScriptException("Vector division by zero");
261 v.z = r;
262
251 return v; 263 return v;
252 } 264 }
253 265
@@ -267,9 +279,21 @@ namespace OpenSim.Region.ScriptEngine.Shared
267 279
268 public static Vector3 operator /(Vector3 v, double f) 280 public static Vector3 operator /(Vector3 v, double f)
269 { 281 {
270 v.x = v.x / f; 282 double r = v.x / f;
271 v.y = v.y / f; 283 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
272 v.z = v.z / f; 284 throw new ScriptException("Vector division by zero");
285 v.x = r;
286
287 r = v.y / f;
288 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
289 throw new ScriptException("Vector division by zero");
290 v.y = r;
291
292 r = v.z / f;
293 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
294 throw new ScriptException("Vector division by zero");
295 v.z = r;
296
273 return v; 297 return v;
274 } 298 }
275 299
@@ -1987,7 +2011,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
1987 2011
1988 static public LSLInteger operator /(LSLInteger i1, int i2) 2012 static public LSLInteger operator /(LSLInteger i1, int i2)
1989 { 2013 {
1990 return new LSLInteger(i1.value / i2); 2014 try
2015 {
2016 return new LSLInteger(i1.value / i2);
2017 }
2018 catch(DivideByZeroException)
2019 {
2020 throw new ScriptException("Integer division by Zero");
2021 }
1991 } 2022 }
1992 2023
1993// static public LSLFloat operator +(LSLInteger i1, double f) 2024// static public LSLFloat operator +(LSLInteger i1, double f)
@@ -2260,7 +2291,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
2260 2291
2261 static public LSLFloat operator /(LSLFloat f, int i) 2292 static public LSLFloat operator /(LSLFloat f, int i)
2262 { 2293 {
2263 return new LSLFloat(f.value / (double)i); 2294 double r = f.value / (double)i;
2295 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
2296 throw new ScriptException("Float division by zero");
2297 return new LSLFloat(r);
2264 } 2298 }
2265 2299
2266 static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs) 2300 static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs)
@@ -2280,7 +2314,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
2280 2314
2281 static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs) 2315 static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs)
2282 { 2316 {
2283 return new LSLFloat(lhs.value / rhs.value); 2317 double r = lhs.value / rhs.value;
2318 if (double.IsNaN(r) || double.IsNegativeInfinity(r) || double.IsPositiveInfinity(r))
2319 throw new ScriptException("Float division by zero");
2320 return new LSLFloat(r);
2284 } 2321 }
2285 2322
2286 static public LSLFloat operator -(LSLFloat f) 2323 static public LSLFloat operator -(LSLFloat f)