diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 8f34833..7844c75 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 ScriptException("MOD Runtime Error: " + msg); | 98 | throw new Exception("MOD Runtime Error: " + msg); |
99 | } | 99 | } |
100 | 100 | ||
101 | /// <summary> | 101 | // |
102 | /// Dumps an error message on the debug console. | 102 | //Dumps an error message on the debug console. |
103 | /// </summary> | 103 | // |
104 | /// <param name='message'></param> | 104 | |
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], fname); | 257 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); |
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, string fname) | 297 | protected object ConvertFromLSL(object lslparm, Type type) |
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) || type == typeof(float)) | 313 | if (type == typeof(int)) |
314 | return (int)(LSL_Integer)lslparm; | 314 | return (int)(LSL_Integer)lslparm; |
315 | } | 315 | } |
316 | 316 | ||
@@ -333,7 +333,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
333 | { | 333 | { |
334 | if (type == typeof(OpenMetaverse.Quaternion)) | 334 | if (type == typeof(OpenMetaverse.Quaternion)) |
335 | { | 335 | { |
336 | return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm); | 336 | LSL_Rotation rot = (LSL_Rotation)lslparm; |
337 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
337 | } | 338 | } |
338 | } | 339 | } |
339 | 340 | ||
@@ -342,7 +343,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
342 | { | 343 | { |
343 | if (type == typeof(OpenMetaverse.Vector3)) | 344 | if (type == typeof(OpenMetaverse.Vector3)) |
344 | { | 345 | { |
345 | return (OpenMetaverse.Vector3)((LSL_Vector)lslparm); | 346 | LSL_Vector vect = (LSL_Vector)lslparm; |
347 | return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
346 | } | 348 | } |
347 | } | 349 | } |
348 | 350 | ||
@@ -359,27 +361,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
359 | result[i] = (string)(LSL_String)plist[i]; | 361 | result[i] = (string)(LSL_String)plist[i]; |
360 | else if (plist[i] is LSL_Integer) | 362 | else if (plist[i] is LSL_Integer) |
361 | result[i] = (int)(LSL_Integer)plist[i]; | 363 | 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]; | ||
366 | else if (plist[i] is LSL_Float) | 364 | else if (plist[i] is LSL_Float) |
367 | result[i] = (float)(LSL_Float)plist[i]; | 365 | result[i] = (float)(LSL_Float)plist[i]; |
368 | else if (plist[i] is LSL_Key) | 366 | else if (plist[i] is LSL_Key) |
369 | result[i] = new UUID((LSL_Key)plist[i]); | 367 | result[i] = new UUID((LSL_Key)plist[i]); |
370 | else if (plist[i] is LSL_Rotation) | 368 | else if (plist[i] is LSL_Rotation) |
371 | result[i] = (Quaternion)((LSL_Rotation)plist[i]); | 369 | { |
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 | } | ||
372 | else if (plist[i] is LSL_Vector) | 373 | else if (plist[i] is LSL_Vector) |
373 | result[i] = (Vector3)((LSL_Vector)plist[i]); | 374 | { |
375 | LSL_Vector vect = (LSL_Vector)plist[i]; | ||
376 | result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
377 | } | ||
374 | else | 378 | else |
375 | MODError(String.Format("{0}: unknown LSL list element type", fname)); | 379 | MODError("unknown LSL list element type"); |
376 | } | 380 | } |
377 | 381 | ||
378 | return result; | 382 | return result; |
379 | } | 383 | } |
380 | } | 384 | } |
381 | 385 | ||
382 | MODError(String.Format("{1}: parameter type mismatch; expecting {0}",type.Name, fname)); | 386 | MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); |
383 | return null; | 387 | return null; |
384 | } | 388 | } |
385 | 389 | ||