aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs87
1 files changed, 67 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
index 199216e..e0b7f5d 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
@@ -611,8 +611,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine
611 continue; 611 continue;
612 } 612 }
613 613
614 // Check for option enables. 614 // Check for option enables.
615 if((c == ';') && (lastToken is TokenName) && 615
616 if ((c == ';') && (lastToken is TokenName) &&
617 (strcasecmp(((TokenName)lastToken).val, "yoptions") == 0))
618 {
619 options.advFlowCtl = true;
620 options.tryCatch = true;
621
622 lastToken = lastToken.prevToken;
623 lastToken.nextToken = null;
624 continue;
625 }
626
627 else if ((c == ';') && (lastToken is TokenName) &&
616 (lastToken.prevToken is TokenName) && 628 (lastToken.prevToken is TokenName) &&
617 (strcasecmp(((TokenName)lastToken.prevToken).val, "yoption") == 0)) 629 (strcasecmp(((TokenName)lastToken.prevToken).val, "yoption") == 0))
618 { 630 {
@@ -2186,44 +2198,79 @@ namespace OpenSim.Region.ScriptEngine.Yengine
2186 } 2198 }
2187 public static object Div(object left, object right) 2199 public static object Div(object left, object right)
2188 { 2200 {
2189 if((left is int) && (right is int)) 2201 double r;
2202 try
2190 { 2203 {
2191 return (int)left / (int)right; 2204 if ((left is int) && (right is int))
2205 {
2206 return (int)left / (int)right;
2207 }
2208 if ((left is double) && (right is int))
2209 {
2210 r = (double)left / (int)right;
2211 if (double.IsNaN(r) || double.IsInfinity(r))
2212 throw new Exception("Division by Zero");
2213 return r;
2214 }
2192 } 2215 }
2193 if((left is int) && (right is double)) 2216 catch (DivideByZeroException)
2194 { 2217 {
2195 return (int)left / (double)right; 2218 throw new Exception("Division by Zero");
2196 } 2219 }
2197 if((left is double) && (right is int)) 2220
2221 if ((left is int) && (right is double))
2198 { 2222 {
2199 return (double)left / (int)right; 2223 r = (int)left / (double)right;
2200 } 2224 }
2201 if((left is double) && (right is double)) 2225 else if((left is double) && (right is double))
2202 { 2226 {
2203 return (double)left / (double)right; 2227 r= (double)left / (double)right;
2204 } 2228 }
2205 return null; 2229 else
2230 return null;
2231
2232 if (double.IsNaN(r) || double.IsInfinity(r))
2233 throw new Exception("Division by Zero");
2234 return r;
2206 } 2235 }
2207 public static object Mod(object left, object right) 2236 public static object Mod(object left, object right)
2208 { 2237 {
2209 if((left is int) && (right is int)) 2238 double r;
2239 try
2210 { 2240 {
2211 return (int)left % (int)right; 2241 if ((left is int) && (right is int))
2242 {
2243 return (int)left % (int)right;
2244 }
2245 if ((left is double) && (right is int))
2246 {
2247 r = (double)left % (int)right;
2248 if (double.IsNaN(r) || double.IsInfinity(r))
2249 throw new Exception("Division by Zero");
2250 return r;
2251 }
2212 } 2252 }
2213 if((left is int) && (right is double)) 2253 catch (DivideByZeroException)
2214 { 2254 {
2215 return (int)left % (double)right; 2255 throw new Exception("Division by Zero");
2216 } 2256 }
2217 if((left is double) && (right is int)) 2257
2258 if ((left is int) && (right is double))
2218 { 2259 {
2219 return (double)left % (int)right; 2260 r = (int)left % (double)right;
2220 } 2261 }
2221 if((left is double) && (right is double)) 2262 else if ((left is double) && (right is double))
2222 { 2263 {
2223 return (double)left % (double)right; 2264 r = (double)left % (double)right;
2224 } 2265 }
2225 return null; 2266 else
2267 return null;
2268
2269 if (double.IsNaN(r) || double.IsInfinity(r))
2270 throw new Exception("Division by Zero");
2271 return r;
2226 } 2272 }
2273
2227 public static object Mul(object left, object right) 2274 public static object Mul(object left, object right)
2228 { 2275 {
2229 if((left is int) && (right is int)) 2276 if((left is int) && (right is int))