diff options
author | UbitUmarov | 2019-10-18 15:02:32 +0100 |
---|---|---|
committer | UbitUmarov | 2019-10-18 15:02:32 +0100 |
commit | 9d698bcffb20ff7c1d0dc0029af63853f07fe85d (patch) | |
tree | 74580ca5b8a2a0425f8f7cca62f6bf12e697d759 /OpenSim | |
parent | Yengine: Also error on division by Zero (diff) | |
download | opensim-SC-9d698bcffb20ff7c1d0dc0029af63853f07fe85d.zip opensim-SC-9d698bcffb20ff7c1d0dc0029af63853f07fe85d.tar.gz opensim-SC-9d698bcffb20ff7c1d0dc0029af63853f07fe85d.tar.bz2 opensim-SC-9d698bcffb20ff7c1d0dc0029af63853f07fe85d.tar.xz |
Xengine: more on division by Zero
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 92 |
1 files changed, 70 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 949fe98..b04a32c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -2020,31 +2020,43 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
2020 | { | 2020 | { |
2021 | return new LSLInteger(i1.value / i2); | 2021 | return new LSLInteger(i1.value / i2); |
2022 | } | 2022 | } |
2023 | catch(DivideByZeroException) | 2023 | catch (DivideByZeroException) |
2024 | { | 2024 | { |
2025 | throw new ScriptException("Integer division by Zero"); | 2025 | throw new ScriptException("Integer division by Zero"); |
2026 | } | 2026 | } |
2027 | } | 2027 | } |
2028 | 2028 | ||
2029 | // static public LSLFloat operator +(LSLInteger i1, double f) | 2029 | static public LSLInteger operator %(LSLInteger i1, int i2) |
2030 | // { | 2030 | { |
2031 | // return new LSLFloat((double)i1.value + f); | 2031 | try |
2032 | // } | 2032 | { |
2033 | // | 2033 | return new LSLInteger(i1.value % i2); |
2034 | // static public LSLFloat operator -(LSLInteger i1, double f) | 2034 | } |
2035 | // { | 2035 | catch (DivideByZeroException) |
2036 | // return new LSLFloat((double)i1.value - f); | 2036 | { |
2037 | // } | 2037 | throw new ScriptException("Integer division by Zero"); |
2038 | // | 2038 | } |
2039 | // static public LSLFloat operator *(LSLInteger i1, double f) | 2039 | } |
2040 | // { | 2040 | |
2041 | // return new LSLFloat((double)i1.value * f); | 2041 | // static public LSLFloat operator +(LSLInteger i1, double f) |
2042 | // } | 2042 | // { |
2043 | // | 2043 | // return new LSLFloat((double)i1.value + f); |
2044 | // static public LSLFloat operator /(LSLInteger i1, double f) | 2044 | // } |
2045 | // { | 2045 | // |
2046 | // return new LSLFloat((double)i1.value / f); | 2046 | // static public LSLFloat operator -(LSLInteger i1, double f) |
2047 | // } | 2047 | // { |
2048 | // return new LSLFloat((double)i1.value - f); | ||
2049 | // } | ||
2050 | // | ||
2051 | // static public LSLFloat operator *(LSLInteger i1, double f) | ||
2052 | // { | ||
2053 | // return new LSLFloat((double)i1.value * f); | ||
2054 | // } | ||
2055 | // | ||
2056 | // static public LSLFloat operator /(LSLInteger i1, double f) | ||
2057 | // { | ||
2058 | // return new LSLFloat((double)i1.value / f); | ||
2059 | // } | ||
2048 | 2060 | ||
2049 | static public LSLInteger operator -(LSLInteger i) | 2061 | static public LSLInteger operator -(LSLInteger i) |
2050 | { | 2062 | { |
@@ -2084,10 +2096,30 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
2084 | return ret; | 2096 | return ret; |
2085 | } | 2097 | } |
2086 | 2098 | ||
2099 | static public LSLInteger operator /(LSLInteger i1, LSLInteger i2) | ||
2100 | { | ||
2101 | try | ||
2102 | { | ||
2103 | int ret = i1.value / i2.value; | ||
2104 | return ret; | ||
2105 | } | ||
2106 | catch (DivideByZeroException) | ||
2107 | { | ||
2108 | throw new ScriptException("Integer division by Zero"); | ||
2109 | } | ||
2110 | } | ||
2111 | |||
2087 | static public LSLInteger operator %(LSLInteger i1, LSLInteger i2) | 2112 | static public LSLInteger operator %(LSLInteger i1, LSLInteger i2) |
2088 | { | 2113 | { |
2089 | int ret = i1.value % i2.value; | 2114 | try |
2090 | return ret; | 2115 | { |
2116 | int ret = i1.value % i2.value; | ||
2117 | return ret; | ||
2118 | } | ||
2119 | catch (DivideByZeroException) | ||
2120 | { | ||
2121 | throw new ScriptException("Integer division by Zero"); | ||
2122 | } | ||
2091 | } | 2123 | } |
2092 | 2124 | ||
2093 | static public LSLInteger operator |(LSLInteger i1, LSLInteger i2) | 2125 | static public LSLInteger operator |(LSLInteger i1, LSLInteger i2) |
@@ -2302,6 +2334,14 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
2302 | return new LSLFloat(r); | 2334 | return new LSLFloat(r); |
2303 | } | 2335 | } |
2304 | 2336 | ||
2337 | static public LSLFloat operator %(LSLFloat f, int i) | ||
2338 | { | ||
2339 | double r = f.value % (double)i; | ||
2340 | if (IsBadNumber(r)) | ||
2341 | throw new ScriptException("Float division by zero"); | ||
2342 | return new LSLFloat(r); | ||
2343 | } | ||
2344 | |||
2305 | static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs) | 2345 | static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs) |
2306 | { | 2346 | { |
2307 | return new LSLFloat(lhs.value + rhs.value); | 2347 | return new LSLFloat(lhs.value + rhs.value); |
@@ -2325,6 +2365,14 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
2325 | return new LSLFloat(r); | 2365 | return new LSLFloat(r); |
2326 | } | 2366 | } |
2327 | 2367 | ||
2368 | static public LSLFloat operator %(LSLFloat lhs, LSLFloat rhs) | ||
2369 | { | ||
2370 | double r = lhs.value % rhs.value; | ||
2371 | if (IsBadNumber(r)) | ||
2372 | throw new ScriptException("Float division by zero"); | ||
2373 | return new LSLFloat(r); | ||
2374 | } | ||
2375 | |||
2328 | static public LSLFloat operator -(LSLFloat f) | 2376 | static public LSLFloat operator -(LSLFloat f) |
2329 | { | 2377 | { |
2330 | return new LSLFloat(-f.value); | 2378 | return new LSLFloat(-f.value); |