diff options
author | teravus | 2012-11-15 09:46:41 -0500 |
---|---|---|
committer | teravus | 2012-11-15 09:46:41 -0500 |
commit | dfac269032300872c4d0dc507f4f9062d102b0f4 (patch) | |
tree | d60fca83f54417c349c33b46de6ac65748ff762f /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |
parent | * Fixes mesh loading issues in last commit. (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-dfac269032300872c4d0dc507f4f9062d102b0f4.zip opensim-SC-dfac269032300872c4d0dc507f4f9062d102b0f4.tar.gz opensim-SC-dfac269032300872c4d0dc507f4f9062d102b0f4.tar.bz2 opensim-SC-dfac269032300872c4d0dc507f4f9062d102b0f4.tar.xz |
Merge master into teravuswork
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 7844c75..8f34833 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
95 | 95 | ||
96 | internal void MODError(string msg) | 96 | internal void MODError(string msg) |
97 | { | 97 | { |
98 | throw new Exception("MOD Runtime Error: " + msg); | 98 | throw new ScriptException("MOD Runtime Error: " + msg); |
99 | } | 99 | } |
100 | 100 | ||
101 | // | 101 | /// <summary> |
102 | //Dumps an error message on the debug console. | 102 | /// Dumps an error message on the debug console. |
103 | // | 103 | /// </summary> |
104 | 104 | /// <param name='message'></param> | |
105 | internal void MODShoutError(string message) | 105 | internal void MODShoutError(string message) |
106 | { | 106 | { |
107 | if (message.Length > 1023) | 107 | if (message.Length > 1023) |
@@ -254,7 +254,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
254 | 254 | ||
255 | object[] convertedParms = new object[parms.Length]; | 255 | object[] convertedParms = new object[parms.Length]; |
256 | for (int i = 0; i < parms.Length; i++) | 256 | for (int i = 0; i < parms.Length; i++) |
257 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); | 257 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i], fname); |
258 | 258 | ||
259 | // now call the function, the contract with the function is that it will always return | 259 | // now call the function, the contract with the function is that it will always return |
260 | // non-null but don't trust it completely | 260 | // non-null but don't trust it completely |
@@ -294,7 +294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
294 | 294 | ||
295 | /// <summary> | 295 | /// <summary> |
296 | /// </summary> | 296 | /// </summary> |
297 | protected object ConvertFromLSL(object lslparm, Type type) | 297 | protected object ConvertFromLSL(object lslparm, Type type, string fname) |
298 | { | 298 | { |
299 | // ---------- String ---------- | 299 | // ---------- String ---------- |
300 | if (lslparm is LSL_String) | 300 | if (lslparm is LSL_String) |
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
310 | // ---------- Integer ---------- | 310 | // ---------- Integer ---------- |
311 | else if (lslparm is LSL_Integer) | 311 | else if (lslparm is LSL_Integer) |
312 | { | 312 | { |
313 | if (type == typeof(int)) | 313 | if (type == typeof(int) || type == typeof(float)) |
314 | return (int)(LSL_Integer)lslparm; | 314 | return (int)(LSL_Integer)lslparm; |
315 | } | 315 | } |
316 | 316 | ||
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
333 | { | 333 | { |
334 | if (type == typeof(OpenMetaverse.Quaternion)) | 334 | if (type == typeof(OpenMetaverse.Quaternion)) |
335 | { | 335 | { |
336 | LSL_Rotation rot = (LSL_Rotation)lslparm; | 336 | return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm); |
337 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
338 | } | 337 | } |
339 | } | 338 | } |
340 | 339 | ||
@@ -343,8 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
343 | { | 342 | { |
344 | if (type == typeof(OpenMetaverse.Vector3)) | 343 | if (type == typeof(OpenMetaverse.Vector3)) |
345 | { | 344 | { |
346 | LSL_Vector vect = (LSL_Vector)lslparm; | 345 | return (OpenMetaverse.Vector3)((LSL_Vector)lslparm); |
347 | return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
348 | } | 346 | } |
349 | } | 347 | } |
350 | 348 | ||
@@ -361,29 +359,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
361 | result[i] = (string)(LSL_String)plist[i]; | 359 | result[i] = (string)(LSL_String)plist[i]; |
362 | else if (plist[i] is LSL_Integer) | 360 | else if (plist[i] is LSL_Integer) |
363 | result[i] = (int)(LSL_Integer)plist[i]; | 361 | result[i] = (int)(LSL_Integer)plist[i]; |
362 | // The int check exists because of the many plain old int script constants in ScriptBase which | ||
363 | // are not LSL_Integers. | ||
364 | else if (plist[i] is int) | ||
365 | result[i] = plist[i]; | ||
364 | else if (plist[i] is LSL_Float) | 366 | else if (plist[i] is LSL_Float) |
365 | result[i] = (float)(LSL_Float)plist[i]; | 367 | result[i] = (float)(LSL_Float)plist[i]; |
366 | else if (plist[i] is LSL_Key) | 368 | else if (plist[i] is LSL_Key) |
367 | result[i] = new UUID((LSL_Key)plist[i]); | 369 | result[i] = new UUID((LSL_Key)plist[i]); |
368 | else if (plist[i] is LSL_Rotation) | 370 | else if (plist[i] is LSL_Rotation) |
369 | { | 371 | result[i] = (Quaternion)((LSL_Rotation)plist[i]); |
370 | LSL_Rotation rot = (LSL_Rotation)plist[i]; | ||
371 | result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
372 | } | ||
373 | else if (plist[i] is LSL_Vector) | 372 | else if (plist[i] is LSL_Vector) |
374 | { | 373 | result[i] = (Vector3)((LSL_Vector)plist[i]); |
375 | LSL_Vector vect = (LSL_Vector)plist[i]; | ||
376 | result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
377 | } | ||
378 | else | 374 | else |
379 | MODError("unknown LSL list element type"); | 375 | MODError(String.Format("{0}: unknown LSL list element type", fname)); |
380 | } | 376 | } |
381 | 377 | ||
382 | return result; | 378 | return result; |
383 | } | 379 | } |
384 | } | 380 | } |
385 | 381 | ||
386 | MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); | 382 | MODError(String.Format("{1}: parameter type mismatch; expecting {0}",type.Name, fname)); |
387 | return null; | 383 | return null; |
388 | } | 384 | } |
389 | 385 | ||