From afa02aa104e0cfbedd0e1b6c1d7b60522a79a4e8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jul 2012 07:41:11 +0100 Subject: fix vehicle to XML string --- OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 45ca00c..e2ef77b 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -565,31 +565,37 @@ namespace OpenSim.Region.Framework.Scenes public string ToXml2() { - MemoryStream ms = new MemoryStream(); + MemoryStream ms = new MemoryStream(512); UTF8Encoding enc = new UTF8Encoding(); - XmlTextWriter writer = new XmlTextWriter(ms, null); - ToXml2(writer); - return enc.GetString(ms.ToArray()); + XmlTextWriter xwriter = new XmlTextWriter(ms, enc); + ToXml2(xwriter); + xwriter.Flush(); + string s = ms.GetStreamString(); + xwriter.Close(); + return s; } public static SOPVehicle FromXml2(string text) { if (text == String.Empty) return null; + UTF8Encoding enc = new UTF8Encoding(); MemoryStream ms = new MemoryStream(enc.GetBytes(text)); - XmlTextReader reader = new XmlTextReader(ms); + XmlTextReader xreader = new XmlTextReader(ms); SOPVehicle v = new SOPVehicle(); bool error; - v.FromXml2(reader, out error); + v.FromXml2(xreader, out error); + + xreader.Close(); + if (error) { v = null; return null; } - return v; } -- cgit v1.1