From 6eaa9b4766d808a3817b7207e48cf65bcbdeff6c Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sun, 13 Jan 2008 16:40:33 +0000 Subject: Anti-crash fix: Allow int (numbers without dot) when changing Estate terrain settings. Also added exception handling if string->float conversion still should fail for some reason. --- OpenSim/Region/Environment/EstateManager.cs | 32 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 64b9d78..9700e6c 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -426,17 +426,29 @@ namespace OpenSim.Region.Environment } else { - float WaterHeight = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); - float TerrainRaiseLimit = - (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); - float TerrainLowerLimit = - (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); - bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter); - float SunHour = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); - - setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); + try + { + string tmp; + tmp = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float WaterHeight = (float)Convert.ToDecimal(tmp); + tmp = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp); + tmp = Helpers.FieldToUTF8String(packet.ParamList[2].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainLowerLimit = (float)Convert.ToDecimal(tmp); + bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter); + float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); + + setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); - sendRegionInfoPacketToAll(); + sendRegionInfoPacketToAll(); + } + catch (Exception ex) + { + MainLog.Instance.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString()); + } } } -- cgit v1.1