diff options
author | Charles Krinke | 2008-07-16 14:30:22 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-16 14:30:22 +0000 |
commit | 0106f967161b2fa0dbf131a56e9c5498d1b16270 (patch) | |
tree | 62e0cbad5193521f7a2549bb782207306ca9e92c /OpenSim/Region/ScriptEngine/Shared | |
parent | squashing warnings critters (diff) | |
download | opensim-SC_OLD-0106f967161b2fa0dbf131a56e9c5498d1b16270.zip opensim-SC_OLD-0106f967161b2fa0dbf131a56e9c5498d1b16270.tar.gz opensim-SC_OLD-0106f967161b2fa0dbf131a56e9c5498d1b16270.tar.bz2 opensim-SC_OLD-0106f967161b2fa0dbf131a56e9c5498d1b16270.tar.xz |
Mantis#1755. Thank you kindly, Matth for a patch that solves:
When using math operators +,-,*,/ in an LSL script with an LSLFloat
and an integer literal the wrong result is returned. This patch
adds operators to the LSLFloat type to handle this case.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 7ababb4..f71d584 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -1303,10 +1303,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1303 | { | 1303 | { |
1304 | return new LSLInteger(int.Parse(s)); | 1304 | return new LSLInteger(int.Parse(s)); |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | static public implicit operator LSLInteger(double d) | 1307 | static public implicit operator LSLInteger(uint u) |
1308 | { | 1308 | { |
1309 | return new LSLInteger(d); | 1309 | return new LSLInteger(u); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | static public bool operator ==(LSLInteger i1, LSLInteger i2) | 1312 | static public bool operator ==(LSLInteger i1, LSLInteger i2) |
@@ -1341,9 +1341,34 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1341 | return new LSLInteger(i1.value / i2); | 1341 | return new LSLInteger(i1.value / i2); |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | static public LSLFloat operator +(LSLInteger i1, double f) | ||
1345 | { | ||
1346 | return new LSLFloat((double)i1.value + f); | ||
1347 | } | ||
1348 | |||
1349 | static public LSLFloat operator -(LSLInteger i1, double f) | ||
1350 | { | ||
1351 | return new LSLFloat((double)i1.value - f); | ||
1352 | } | ||
1353 | |||
1354 | static public LSLFloat operator *(LSLInteger i1, double f) | ||
1355 | { | ||
1356 | return new LSLFloat((double)i1.value * f); | ||
1357 | } | ||
1358 | |||
1359 | static public LSLFloat operator /(LSLInteger i1, double f) | ||
1360 | { | ||
1361 | return new LSLFloat((double)i1.value / f); | ||
1362 | } | ||
1363 | |||
1364 | static public LSLInteger operator -(LSLInteger i) | ||
1365 | { | ||
1366 | return new LSLInteger(-i.value); | ||
1367 | } | ||
1368 | |||
1344 | static public LSLInteger operator &(LSLInteger i1, LSLInteger i2) | 1369 | static public LSLInteger operator &(LSLInteger i1, LSLInteger i2) |
1345 | { | 1370 | { |
1346 | int ret = i1.value & i2.value; | 1371 | int ret = i1.value & i2.value; |
1347 | return ret; | 1372 | return ret; |
1348 | } | 1373 | } |
1349 | 1374 | ||
@@ -1447,16 +1472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1447 | 1472 | ||
1448 | #region Operators | 1473 | #region Operators |
1449 | 1474 | ||
1450 | static public implicit operator int(LSLFloat f) | ||
1451 | { | ||
1452 | return (int)f.value; | ||
1453 | } | ||
1454 | |||
1455 | static public implicit operator uint(LSLFloat f) | ||
1456 | { | ||
1457 | return (uint) Math.Abs(f.value); | ||
1458 | } | ||
1459 | |||
1460 | static public implicit operator Boolean(LSLFloat f) | 1475 | static public implicit operator Boolean(LSLFloat f) |
1461 | { | 1476 | { |
1462 | if (f.value == 0.0) | 1477 | if (f.value == 0.0) |
@@ -1518,7 +1533,32 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1518 | f.value--; | 1533 | f.value--; |
1519 | return f; | 1534 | return f; |
1520 | } | 1535 | } |
1536 | |||
1537 | static public LSLFloat operator +(LSLFloat f, int i) | ||
1538 | { | ||
1539 | return new LSLFloat(f.value + (double)i); | ||
1540 | } | ||
1541 | |||
1542 | static public LSLFloat operator -(LSLFloat f, int i) | ||
1543 | { | ||
1544 | return new LSLFloat(f.value - (double)i); | ||
1545 | } | ||
1546 | |||
1547 | static public LSLFloat operator *(LSLFloat f, int i) | ||
1548 | { | ||
1549 | return new LSLFloat(f.value * (double)i); | ||
1550 | } | ||
1551 | |||
1552 | static public LSLFloat operator /(LSLFloat f, int i) | ||
1553 | { | ||
1554 | return new LSLFloat(f.value / (double)i); | ||
1555 | } | ||
1521 | 1556 | ||
1557 | static public LSLFloat operator -(LSLFloat f) | ||
1558 | { | ||
1559 | return new LSLFloat(-f.value); | ||
1560 | } | ||
1561 | |||
1522 | static public implicit operator System.Double(LSLFloat f) | 1562 | static public implicit operator System.Double(LSLFloat f) |
1523 | { | 1563 | { |
1524 | return f.value; | 1564 | return f.value; |