From 2f5995f5c0a7720e28a8d88296dd1b8f07a9ac9a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 30 Jul 2011 00:58:17 +0100 Subject: [PATCH] Temporary code to change bad AvatarHeight values in the AvatarService to the default Ruth height. I was persuaded to do this because simulators on osgrid will persist in inserting bad values for an unknown length of time, even after the original simulator bug which was inserting bad values is out in an osgrid distro This code can be removed at some point in the future, though I think there is an argument for having services police these values in open grids. --- .../Services/AvatarService/AvatarService.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index 53ca7c868b..c4c7cadc20 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -109,7 +109,33 @@ namespace OpenSim.Services.AvatarService foreach (KeyValuePair kvp in avatar.Data) { av.Data["Name"] = kvp.Key; - av.Data["Value"] = kvp.Value; + + // justincc 20110730. Yes, this is a hack to get around the fact that a bug in OpenSim is causing + // various simulators on osgrid to inject bad values. Since these simulators might be around for a + // long time, we are going to manually police the value. + // + // It should be possible to remove this in half a year if we don't want to police values server side. + if (kvp.Key == "AvatarHeight") + { + float height; + if (!float.TryParse(kvp.Value, out height) || height < 0 || height > 10) + { + string rawHeight = kvp.Value.Replace(",", "."); + + if (!float.TryParse(rawHeight, out height) || height < 0 || height > 10) + height = 1.771488f; + + m_log.DebugFormat( + "[AVATAR SERVICE]: Rectifying height of avatar {0} from {1} to {2}", + principalID, kvp.Value, height); + } + + av.Data["Value"] = height.ToString(); + } + else + { + av.Data["Value"] = kvp.Value; + } if (!m_Database.Store(av)) {