Fix some string to float casting nastiness. The "train script" now

works. Also makes llGetFreeMemory return the constant 16384.
LLGetFreeMemory is useless in SL, as it never goes up, only down.
So, the only thing it is used for, in practice, is to detect an imminent
stack/heap collision, a danger we don't have.
0.6.0-stable
Melanie Thielker 2008-09-13 16:16:08 +00:00
parent fdb24c46ac
commit dccdeb57bb
2 changed files with 14 additions and 3 deletions

View File

@ -4597,8 +4597,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Types.LSLInteger llGetFreeMemory() public LSL_Types.LSLInteger llGetFreeMemory()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
NotImplemented("llGetFreeMemory"); // NotImplemented("llGetFreeMemory");
return 0; // Make scripts desined for LSO happy
return 16384;
} }
public LSL_Types.LSLString llGetRegionName() public LSL_Types.LSLString llGetRegionName()

View File

@ -1689,7 +1689,17 @@ namespace OpenSim.Region.ScriptEngine.Shared
static public explicit operator LSLFloat(string s) static public explicit operator LSLFloat(string s)
{ {
return new LSLFloat(double.Parse(s)); Regex r = new Regex("^[ ]*-?[0-9]*\\.?[0-9]*[eE]?-?[0-9]*");
Match m = r.Match(s);
string v = m.Groups[0].Value;
while (v.Length > 0 && v.Substring(0, 1) == " ")
v = v.Substring(1);
if (v == String.Empty)
v = "0";
return new LSLFloat(double.Parse(v));
} }
static public implicit operator LSLFloat(double d) static public implicit operator LSLFloat(double d)